orders.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. ]
  92. ]
  93. });
  94. // 为表格绑定事件
  95. Table.api.bindevent(table);
  96. },
  97. add: function () {
  98. Controller.api.bindevent();
  99. },
  100. send: function () {
  101. Controller.api.bindevent();
  102. },
  103. tax: function () {
  104. Controller.api.bindevent();
  105. },
  106. api: {
  107. bindevent: function () {
  108. Form.api.bindevent($("form[role=form]"));
  109. }
  110. },
  111. detail: function () {
  112. // 初始化表格参数配置
  113. Table.api.init({
  114. extend: {
  115. index_url: location.pathname + location.search,
  116. }
  117. });
  118. var table = $("#table");
  119. // 初始化表格
  120. table.bootstrapTable({
  121. url: $.fn.bootstrapTable.defaults.extend.index_url,
  122. pk: 'id',
  123. sortName: 'id',
  124. commonSearch:false,
  125. search:false,
  126. pagination:false,
  127. columns: [
  128. [
  129. {field: 'id', title: __('Id')},
  130. {field: 'logo', title: __('商品图片'),formatter: Table.api.formatter.image,events:Table.api.events.image,operate: false},
  131. {field: 'goods_name', title: __('商品名称'),operate: false},
  132. {field: 'sku_name', title: __('商品规格'),operate: false},
  133. {field: 'amount_total', title: __('Amount_total'), operate:'BETWEEN'},
  134. {field: 'amount_pay', title: __('Amount_pay'), operate:'BETWEEN'},
  135. {field: 'amount_install', title: __('Amount_install'), operate:'BETWEEN'},
  136. {field: 'num', title: __('购买数量'),operate: 'between'},
  137. {field: 'num_install', title: __('安装数量'),operate: 'between'},
  138. ]
  139. ],
  140. onLoadSuccess(){
  141. setTimeout(()=>{
  142. $('.btn-detail').data('area',["500px","900px"])
  143. },200)
  144. }
  145. });
  146. // 为表格绑定事件
  147. Table.api.bindevent(table);
  148. },
  149. };
  150. return Controller;
  151. });