tp6框架的销售统计系统

lists.html 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. {layout name="layout" /}
  2. <nav class="breadcrumb">
  3. <span><a href="/">首页</a></span>
  4. <span>&gt;</span>
  5. <span><a href="/order/index">销售订单</a></span>
  6. <span>&gt;</span>
  7. <span>{$year!=0?$year:"全部"} 年度</span>
  8. </nav>
  9. <div class="content">
  10. <div class="row" style="margin: 10px 0;">
  11. <div class="col-md-2 col-xs-3 text-center">
  12. <a href="/order/save/{$year}/0" class="btn btn-success radius">新增</a>
  13. </div>
  14. <div class="col-md-8">
  15. <form action="/order/lists/{$year}" method="get">
  16. {notempty name="year"}
  17. <label for="month" class="form-label col-md-2 text-right mt-5">
  18. 请选择月份 :
  19. </label>
  20. <div class="formControls col-md-2" style="width: 100px;">
  21. <select class="form-control input-sm" name="month" id="month">
  22. {for start="0" end="13"}
  23. {eq name="i" value="0"}
  24. <option value="{$i}" {eq name="month" value="0" }selected{/eq}>全年</option>
  25. {else/}
  26. <option value="{$i}" {eq name="month" value="$i" }selected{/eq}>{$i}月</option>
  27. {/eq}
  28. {/for}
  29. </select>
  30. </div>
  31. {/notempty}
  32. <div class="col-md-4">
  33. <input type="text" class="form-control" name="key" id="key" value="{$key}" placeholder="请输入公司名称">
  34. </div>
  35. <div class="col-md-3" style="text-align:left;">
  36. <div class="btn-group ">
  37. <button type="submit" class="btn btn-success">搜索</button>
  38. </div>
  39. <div class="btn-group ">
  40. <a href="/order/lists/{$year}" class="btn btn-danger ml-10">清除</a>
  41. </div>
  42. </div>
  43. </form>
  44. </div>
  45. </div>
  46. <div class="col-md-12" style="min-width: 1200px;">
  47. <table class="table table-hover table-bordered table-condensed">
  48. <thead>
  49. <tr class="text-center bg-info">
  50. <td>统计</td>
  51. <td colspan="11" class="text-left">
  52. 总销售金额 : ¥{$total_contract_money} | 总到款金额: ¥{$total_payment}
  53. </td>
  54. <td colspan="3">
  55. <span>每页行数:</span>
  56. <select name="limit" id="limit" onchange="changLimit()">
  57. {for start="10" end="101" step="10"}
  58. <option value="{$i}" {eq name="limit" value="$i" }selected{/eq}>{$i}</option>
  59. {/for}
  60. </select>
  61. </td>
  62. </tr>
  63. <tr>
  64. <th>序号</th>
  65. <th>月份</th>
  66. <th style="width: 250px;">购货单位</th>
  67. <th style="min-width: 160px;">合同号</th>
  68. <th>合同总金额</th>
  69. <th>签订时间</th>
  70. <th>运费</th>
  71. <th>代理费</th>
  72. <th>销售员</th>
  73. <th>到款金额</th>
  74. <th>未到款</th>
  75. <!-- <th>末期余额</th> -->
  76. <th style="min-width: 40px;">提成</th>
  77. <th>操作</th>
  78. </tr>
  79. </thead>
  80. <tbody>
  81. {foreach $list as $value}
  82. <tr class="text-center {eq name='value.status' value='-1'}bg-danger{/eq}">
  83. <td>{$value.no}</td>
  84. <td>{$value.month}</td>
  85. <td class="text-left">{$value.company_name}</td>
  86. <td class="text-left"><a href="/order_item/{$value.id}">{$value.contract_no}</a></td>
  87. <td>{$value.contract_money|format_money}</td>
  88. <td>{$value.contract_time}</td>
  89. <td>{$value.fare|format_money}</td>
  90. <td>{$value.agency|format_money}</td>
  91. <td>{$value.seller_name}</td>
  92. <td>{$value.payment|format_money}</td>
  93. <td>{$value.contract_money-$value.payment|format_money}</td>
  94. <!-- <td>--</td> -->
  95. <td class="td-status">
  96. {eq name="value.is_commission" value="0"}
  97. <a href="javascript:void(0);" title="计提" data-value='{$value.is_commission}'
  98. onclick="commission('{$value.id}', this)"><span
  99. class="label label-default radius">否</span></a>
  100. {else/}
  101. <a href="javascript:void(0);" title="取消" data-value='{$value.is_commission}'
  102. onclick="commission('{$value.id}', this)"><span
  103. class="label label-success radius">是</span></a>
  104. {/eq}
  105. </td>
  106. <td class="td-manager">
  107. <a href="/order_item/{$value.id}">明细</a>
  108. <a href="/order/save/{$year}/{$value.id}" onclick="edit()">修改</a>
  109. {eq name='value.status' value='-1'}
  110. <a href="javascript:void(0);" data-value='-1' onclick="status('{$value.id}', this)">恢复</a>
  111. {else/}
  112. <a href="javascript:void(0);" data-value='0' onclick="status('{$value.id}', this)">取消</a>
  113. {/eq}
  114. <a href="javascript:void(0);" onclick="del('{$value.id}', this)">删除</a>
  115. </td>
  116. </tr>
  117. {/foreach}
  118. </tbody>
  119. </table>
  120. </div>
  121. <div class="pagelist">
  122. {$page|raw}
  123. </div>
  124. </div>
  125. <div class="modal" tabindex="-1" role="dialog" data-backdrop="false" id="myModal" aria-labelledby="myModalLabel"
  126. style="right: 10%;">
  127. <div class="modal-dialog" role="document">
  128. <div class="modal-content">
  129. <div class="modal-header">
  130. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
  131. aria-hidden="true">&times;</span></button>
  132. <h4 class="modal-title">计提</h4>
  133. </div>
  134. <div class="modal-body">
  135. <form role="form" id="form-commission">
  136. <input type="hidden" name="id" id="id" value="0">
  137. <input type="hidden" name="order_id" id="order_id" value="">
  138. <div class="row">
  139. <div class="col-md-4">
  140. <div class="form-group">
  141. <label for="name">序号</label>
  142. <input type="text" class="form-control" name="no" id="no" placeholder="序号">
  143. </div>
  144. </div>
  145. <div class="col-md-4">
  146. <div class="form-group">
  147. <label for="name">合同号</label>
  148. <input type="text" class="form-control" name="contract_no" id="contract_no"
  149. placeholder="合同号">
  150. </div>
  151. </div>
  152. <div class="col-md-4">
  153. <div class="form-group">
  154. <label for="name">购货单位</label>
  155. <input type="text" class="form-control" name="company_name" id="company_name"
  156. placeholder="公司名称">
  157. <input type="hidden" name="company_id" id="company_id" value="">
  158. </div>
  159. </div>
  160. </div>
  161. <div class="row">
  162. <div class="col-md-4">
  163. <div class="form-group">
  164. <label for="name">一般提成金额</label>
  165. <input type="number" class="form-control" name="general_money" id="general_money"
  166. placeholder="一般提成金额">
  167. </div>
  168. </div>
  169. <div class="col-md-4">
  170. <div class="form-group">
  171. <label for="name">特别提成金额</label>
  172. <input type="number" class="form-control" name="special_money" id="special_money"
  173. placeholder="特别提成金额">
  174. </div>
  175. </div>
  176. <div class="col-md-3">
  177. <div class="form-group">
  178. <label for="name">提成日期</label>
  179. <input type="date" class="form-control" name="time" id="time" value=""
  180. placeholder="提成日期">
  181. </div>
  182. </div>
  183. </div>
  184. <div class="row">
  185. <div class="col-md-4">
  186. <div class="form-group">
  187. <label for="name">销售员</label>
  188. <input type="text" class="form-control" name="seller_name" id="seller_name"
  189. placeholder="销售员">
  190. <input type="hidden" name="seller_id" id="seller_id" value="">
  191. <input type="hidden" name="department_id" id="department_id" value="">
  192. <input type="hidden" name="department_name" id="department_name" value="">
  193. </div>
  194. </div>
  195. <div class="col-md-8">
  196. <div class="form-group">
  197. <label for="name">备注</label>
  198. <textarea class="form-control" name="remark" id="remark" rows="3"></textarea>
  199. </div>
  200. </div>
  201. </div>
  202. </form>
  203. </div>
  204. <div class="modal-footer">
  205. <button type="button" class="btn btn-default" onclick="closeModel()">Close</button>
  206. <button type="button" class="btn btn-success" onclick="doSave()">Save</button>
  207. </div>
  208. </div><!-- /.modal-content -->
  209. </div><!-- /.modal-dialog -->
  210. </div><!-- /.modal -->
  211. <script>
  212. function del(id, obj) {
  213. $.ajax({
  214. url: "/order/delete",
  215. type: "POST",
  216. data: {
  217. "id": id
  218. },
  219. dataType: 'json',
  220. success: function (data) {
  221. if (data.code == 2) {
  222. $(obj).parents("tr").remove();
  223. } else {
  224. alert(data.msg);
  225. }
  226. return false;
  227. }
  228. });
  229. }
  230. function status(id, obj) {
  231. var status = $(obj).data('value');
  232. if (status == 0) {
  233. cancel(id, obj);
  234. } else {
  235. restore(id, obj);
  236. }
  237. }
  238. function cancel(id, obj) {
  239. $.ajax({
  240. url: "/order/cancel",
  241. type: "POST",
  242. data: {
  243. "id": id,
  244. },
  245. dataType: 'json',
  246. success: function (data) {
  247. if (data.code == 2) {
  248. $(obj).parents("tr").addClass('bg-danger');
  249. $(obj).data('value', -1)
  250. $(obj).text('恢复');
  251. } else {
  252. alert(data.msg);
  253. }
  254. return false;
  255. }
  256. });
  257. }
  258. function restore(id, obj) {
  259. $.ajax({
  260. url: "/order/restore",
  261. type: "POST",
  262. data: {
  263. "id": id
  264. },
  265. dataType: 'json',
  266. success: function (data) {
  267. if (data.code == 2) {
  268. $(obj).parents("tr").removeClass();
  269. $(obj).parents("tr").addClass('text-center');
  270. $(obj).data('value', 0);
  271. $(obj).text('取消');
  272. } else {
  273. alert(data.msg);
  274. }
  275. return false;
  276. }
  277. });
  278. }
  279. function commission(id, obj) {
  280. var is_commission = $(obj).data('value');
  281. if (is_commission == 0) {
  282. saveCommission(id, obj);
  283. } else {
  284. deleteCommission(is_commission, obj);
  285. }
  286. }
  287. function saveCommission(order_id, obj) {
  288. // console.log(id);
  289. $.get('/commission/infobyorderid', {
  290. 'id': order_id,
  291. }, function (res) {
  292. // console.log(order_id);
  293. if (res.code == 2) {
  294. var data = res.data;
  295. $("#id").val(0);
  296. $("#order_id").val(order_id);
  297. $("#no").val(data.no);
  298. $("#contract_no").val(data.contract_no);
  299. $("#company_id").val(data.company_id);
  300. $("#company_name").val(data.company_name);
  301. $("#seller_id").val(data.seller_id);
  302. $("#seller_name").val(data.seller_name);
  303. $("#department_id").val(data.department_id);
  304. $("#department_name").val(data.department_name);
  305. $("#general_money").val(Number(data.general_money));
  306. $("#special_money").val(Number(data.special_money));
  307. $('#myModal').modal('show');
  308. }
  309. }, 'json');
  310. }
  311. function closeModel() {
  312. $("#form-commission")[0].reset();
  313. $('#myModal').modal('hide');
  314. }
  315. function doSave() {
  316. var jttime = $("#time").val();
  317. if (!jttime) {
  318. alert("请选择计提日期");
  319. return false;
  320. }
  321. var data = $("#form-commission").serializeArray();
  322. $.post('/commission/save', data, function (res) {
  323. if (res.code == 2) {
  324. alert('保存成功');
  325. $("#form-commission")[0].reset();
  326. $('#myModal').modal('hide');
  327. window.location.reload();
  328. } else {
  329. alert(res.msg);
  330. }
  331. return false;
  332. }, 'json');
  333. return false;
  334. }
  335. function deleteCommission(commission_id, obj) {
  336. if (confirm('确定删除此计提数据?')) {
  337. $.post('/commission/delete', {'id': commission_id}, function (res) {
  338. if (res.code == 2) {
  339. alert("删除成功");
  340. $(obj).attr('title', '计提');
  341. $(obj).data('value', 0);
  342. $(obj).children('span').text('否');
  343. $(obj).children('span').removeClass('label-success');
  344. $(obj).children('span').addClass('label-default');
  345. } else {
  346. alert('删除失败!');
  347. }
  348. return false;
  349. }, 'json');
  350. }
  351. return false;
  352. }
  353. </script>