orders.js 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'orders/index' + location.search,
  8. add_url: 'orders/add',
  9. edit_url: 'orders/edit',
  10. del_url: 'orders/del',
  11. multi_url: 'orders/multi',
  12. import_url: 'orders/import',
  13. table: 'orders',
  14. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. sortName: 'id',
  22. searchFormVisible:true,
  23. search:false,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. {field: 'order_no', title: __('Order_no')},
  29. {field: 'status', title: __('Status'),formatter: Table.api.formatter.label,searchList:status},
  30. {field: 'user.nickname', title: __('下单用户')},
  31. {field: 'amount_total', title: __('Amount_total'), operate:'BETWEEN'},
  32. {field: 'amount_pay', title: __('Amount_pay'), operate:'BETWEEN'},
  33. /* {field: 'amount_install', title: __('Amount_install'), operate:'BETWEEN'},
  34. {field: 'num', title: __('Num'),operate: 'between'},
  35. {field: 'num_install', title: __('Num_install'),operate: 'between'},*/
  36. {field: 'create_time', title: __('Create_time'),addClass:'datetimerange',formatter: Table.api.formatter.datetime,operate: 'range'},
  37. //{field: 'update_time', title: __('Update_time'),addClass:'datetimerange',formatter: Table.api.formatter.datetime,operate: 'range'},
  38. {field: 'pay_type', title: __('Pay_type'),formatter: Table.api.formatter.label,searchList:payTypes},
  39. {field: 'pay_time', title: __('支付时间'),addClass:'datetimerange',formatter: Table.api.formatter.datetime,operate: 'range'},
  40. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,buttons:[
  41. {
  42. name: 'edit',
  43. text: __('发货'),
  44. title: __('发货'),
  45. classname: 'btn btn-xs btn-info btn-dialog',
  46. icon: 'fa',
  47. url: 'orders/send',
  48. callback: function (data) {
  49. //Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  50. $('.btn-refresh').trigger('click')
  51. },
  52. visible: function (row) {
  53. //返回true时按钮显示,返回false隐藏
  54. return row.status===5 && table.data('operate-send');
  55. }
  56. },
  57. {
  58. name: 'edit',
  59. text: __('订单详情'),
  60. title: __('订单详情'),
  61. classname: 'btn btn-xs btn-info btn-detail btn-dialog',
  62. icon: 'fa fa-outdent',
  63. url: 'orders/detail',
  64. extend:'data-area=\'["1200px","100%"]\'',
  65. callback: function (data) {
  66. //Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  67. $('.btn-refresh').trigger('click')
  68. },
  69. visible: function (row) {
  70. //返回true时按钮显示,返回false隐藏
  71. return table.data('operate-detail');
  72. }
  73. },
  74. {
  75. name: 'edit',
  76. text: __('上传发票'),
  77. title: __('上传发票'),
  78. classname: 'btn btn-xs btn-warning btn-dialog',
  79. icon: 'fa',
  80. url: 'orders/tax',
  81. callback: function (data) {
  82. //Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  83. $('.btn-refresh').trigger('click')
  84. },
  85. visible: function (row) {
  86. //返回true时按钮显示,返回false隐藏
  87. return !row.tax_link && row.tax && table.data('operate-tax');
  88. }
  89. },
  90. {
  91. name: 'edit',
  92. text: __('查看物流'),
  93. title: __('查看物流'),
  94. classname: 'btn btn-xs btn-warning btn-dialog',
  95. icon: 'fa',
  96. url: 'orders/logistics',
  97. callback: function (data) {
  98. //Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  99. $('.btn-refresh').trigger('click')
  100. },
  101. extend: `data-area='["800px","80%"]'`,
  102. visible: function (row) {
  103. //返回true时按钮显示,返回false隐藏
  104. return table.data('operate-logistics') && row.logistics && row.logistics.trans_no;
  105. }
  106. },
  107. ]}
  108. ]
  109. ]
  110. });
  111. // 为表格绑定事件
  112. Table.api.bindevent(table);
  113. },
  114. add: function () {
  115. Controller.api.bindevent();
  116. },
  117. send: function () {
  118. Controller.api.bindevent();
  119. },
  120. tax: function () {
  121. Controller.api.bindevent();
  122. },
  123. api: {
  124. bindevent: function () {
  125. Form.api.bindevent($("form[role=form]"));
  126. }
  127. },
  128. detail: function () {
  129. // 初始化表格参数配置
  130. Table.api.init({
  131. extend: {
  132. index_url: location.pathname + location.search,
  133. }
  134. });
  135. var table = $("#table");
  136. // 初始化表格
  137. table.bootstrapTable({
  138. url: $.fn.bootstrapTable.defaults.extend.index_url,
  139. pk: 'id',
  140. sortName: 'id',
  141. commonSearch:false,
  142. search:false,
  143. pagination:false,
  144. columns: [
  145. [
  146. {field: 'id', title: __('Id')},
  147. {field: 'logo', title: __('商品图片'),formatter: Table.api.formatter.image,events:Table.api.events.image,operate: false},
  148. {field: 'goods_name', title: __('商品名称'),operate: false},
  149. {field: 'sku_name', title: __('商品规格'),operate: false},
  150. {field: 'amount_total', title: __('Amount_total'), operate:'BETWEEN'},
  151. {field: 'amount_pay', title: __('Amount_pay'), operate:'BETWEEN'},
  152. {field: 'amount_install', title: __('Amount_install'), operate:'BETWEEN'},
  153. {field: 'num', title: __('购买数量'),operate: 'between'},
  154. {field: 'num_install', title: __('安装数量'),operate: 'between'},
  155. ]
  156. ],
  157. onLoadSuccess(){
  158. setTimeout(()=>{
  159. $('.btn-detail').data('area',["500px","900px"])
  160. },200)
  161. }
  162. });
  163. // 为表格绑定事件
  164. Table.api.bindevent(table);
  165. },
  166. };
  167. return Controller;
  168. });