You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

274 lines
17 KiB

  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. // 合并格式化方法
  3. Table.api.formatter = $.extend(Table.api.formatter,
  4. {
  5. statusCustom : function (value, row, index) {
  6. let number = value == 0 ? 0 : 1;
  7. let display = value == 0 ? '否' : '是';
  8. let color = value == 0 ? 'primary' : 'success';
  9. var html = '<span class="text-' + color + '"><i class="fa fa-circle"></i> ' + display + '</span>';
  10. if (value != 0){
  11. html = '<a href="javascript:;" class="searchit" data-operate="=" data-field="' + this.field + '" data-value="' + number + '" data-toggle="tooltip" title="' + __('Time: %s', Moment(parseInt(value) * 1000).format('YYYY-MM-DD HH:mm:ss')) + '" >' + html + '</a>';
  12. } else {
  13. html = '<a href="javascript:;" class="searchit" data-operate="=" data-field="' + this.field + '" data-value="' + number + '" data-toggle="tooltip" title="' + __('Click to search %s', display) + '" >' + html + '</a>';
  14. }
  15. return html;
  16. }
  17. }
  18. );
  19. var Controller = {
  20. index: function () {
  21. // 初始化表格参数配置
  22. Table.api.init({
  23. extend: {
  24. index_url: 'unishop/order/index' + location.search,
  25. add_url: 'unishop/order/add',
  26. edit_url: 'unishop/order/edit',
  27. del_url: 'unishop/order/del',
  28. multi_url: 'unishop/order/multi',
  29. delivere_url: 'unishop/order/delivery',
  30. product_url: 'unishop/order/product',
  31. refund_url: 'unishop/order/refund',
  32. table: 'unishop_order',
  33. }
  34. });
  35. // 合并操作方法
  36. Table.api.events.operate = $.extend(Table.api.events.operate,
  37. {
  38. 'click .btn-delivere': function (e, value, row, index) {
  39. e.stopPropagation();
  40. e.preventDefault();
  41. var table = $(this).closest('table');
  42. var options = table.bootstrapTable('getOptions');
  43. var ids = row[options.pk];
  44. row = $.extend({}, row ? row : {}, {ids: ids});
  45. var url = options.extend.delivere_url;
  46. Fast.api.open(Table.api.replaceurl(url, row, table), __('Delivere'), $(this).data() || {});
  47. }
  48. },
  49. {
  50. 'click .btn-product': function (e, value, row, index) {
  51. e.stopPropagation();
  52. e.preventDefault();
  53. var table = $(this).closest('table');
  54. var options = table.bootstrapTable('getOptions');
  55. var ids = row[options.pk];
  56. row = $.extend({}, row ? row : {}, {ids: ids});
  57. var url = options.extend.product_url;
  58. Fast.api.open(Table.api.replaceurl(url, row, table), __('Product'), $(this).data() || {});
  59. }
  60. },
  61. {
  62. 'click .btn-refund': function (e, value, row, index) {
  63. e.stopPropagation();
  64. e.preventDefault();
  65. var table = $(this).closest('table');
  66. var options = table.bootstrapTable('getOptions');
  67. var ids = row[options.pk];
  68. row = $.extend({}, row ? row : {}, {ids: ids});
  69. var url = options.extend.refund_url;
  70. Fast.api.open(Table.api.replaceurl(url, row, table), __('Refund'), $(this).data() || {});
  71. }
  72. }
  73. );
  74. var table = $("#table");
  75. $(document).on("click", ".btn-export", function () {
  76. window.location.href="order/export";
  77. });
  78. // 初始化表格
  79. table.bootstrapTable({
  80. url: $.fn.bootstrapTable.defaults.extend.index_url,
  81. pk: 'id',
  82. sortName: 'id',
  83. columns: [
  84. [ {checkbox: true},
  85. {field: 'id', title: __('Id'),visible:false},
  86. {field: 'name', title: __('姓名'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符'},
  87. {field: 'mobile', title: __('手机号'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符'},
  88. {field: 'email', title: __('邮箱'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符'},
  89. {field: 'address', title: __('地址'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符'},
  90. {field: 'title', title: __('商品')},
  91. {field: 'spec', title: __('规格')},
  92. {field: 'number', title: __('购买数量')},
  93. // {field: 'user_id', title: __('User_id')},
  94. // {field: 'user.username', title: __('User name')},
  95. {field: 'out_trade_no', title: __('Out_trade_no')},
  96. {field: 'order_price', title: __('Order_price'), operate:'BETWEEN'},
  97. // {field: 'discount_price', title: __('Discount_price'), operate:'BETWEEN'},
  98. // {field: 'delivery_price', title: __('Delivery_price'), operate:'BETWEEN'},
  99. // {field: 'total_price', title: __('Total_price'), operate:'BETWEEN'},
  100. // {field: 'pay_type', title: __('Pay_type'), searchList: {"1":__('Online'),"2":__('Offline'),"3":__('wxPay'),"4":__('aliPay')}, formatter: Table.api.formatter.normal},
  101. {field: 'ip', title: __('Ip'), visible:false},
  102. {field: 'status', title: __('Status'), searchList: {"-1":__('Refund'),"0":__('Cancel'),"1":__('Normal')}, formatter: Table.api.formatter.status},
  103. // {field: 'have_paid_status', title: __('Have_paid'), searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
  104. // {field: 'have_delivered_status', title: __('Have_delivered'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
  105. // {field: 'have_received_status', title: __('Have_received'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
  106. // {field: 'have_commented_status', title: __('Have_commented'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
  107. // {field: 'refund_status', title: __('Refund status'),searchList: {"0":__('None'),"1":__('Apply'),"2":__('Waiting for shipment'),"3":__('Pass'),"4":__('Refuse')}, formatter: Table.api.formatter.status},
  108. // {field: 'have_paid', title: __('Pay time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  109. // {field: 'have_delivered', title: __('Delivered time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  110. // {field: 'have_received', title: __('Received time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  111. // {field: 'have_commented', title: __('Commented time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  112. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  113. {field: 'remark', title: __('Remark'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符'},
  114. {
  115. field: 'operate',
  116. title: __('Operate'),
  117. table: table,
  118. events: Table.api.events.operate,
  119. formatter: Table.api.formatter.operate,
  120. buttons:[
  121. // {
  122. // name: 'refund',
  123. // text: __('Refund'),
  124. // classname: 'btn btn-xs btn-info btn-refund',
  125. // extend: 'data-toggle="tooltip"',
  126. // icon: 'fa fa-handshake-o'
  127. // },
  128. // {
  129. // name: 'delivere',
  130. // text: __('Delivere'),
  131. // classname: 'btn btn-xs btn-info btn-delivere',
  132. // extend: 'data-toggle="tooltip"',
  133. // icon: 'fa fa-plane'
  134. // },
  135. // {
  136. // name: 'product',
  137. // text: __('Product'),
  138. // classname: 'btn btn-xs btn-info btn-product',
  139. // extend: 'data-toggle="tooltip"',
  140. // icon: 'fa fa-star-half'
  141. // },
  142. // {
  143. // name: 'edit',
  144. // icon: 'fa fa-pencil',
  145. // text: __('Edit'),
  146. // extend: 'data-toggle="tooltip"',
  147. // classname: 'btn btn-xs btn-success btn-editone',
  148. // url: $.fn.bootstrapTable.defaults.extend.edit_url
  149. // }
  150. ]
  151. }
  152. ]
  153. ]
  154. });
  155. // 为表格绑定事件
  156. Table.api.bindevent(table);
  157. },
  158. recyclebin: function () {
  159. // 初始化表格参数配置
  160. Table.api.init({
  161. extend: {
  162. 'dragsort_url': ''
  163. }
  164. });
  165. var table = $("#table");
  166. // 初始化表格
  167. table.bootstrapTable({
  168. url: 'unishop/order/recyclebin' + location.search,
  169. pk: 'id',
  170. sortName: 'id',
  171. columns: [
  172. [
  173. {checkbox: true},
  174. {field: 'id', title: __('Id'),visible:false},
  175. {field: 'name', title: __('姓名'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符'},
  176. {field: 'mobile', title: __('手机号'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符'},
  177. {field: 'email', title: __('邮箱'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符'},
  178. {field: 'address', title: __('地址'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符'},
  179. {field: 'product_name', title: __('商品')},
  180. {field: 'spec', title: __('规格')},
  181. // {field: 'user_id', title: __('User_id')},
  182. // {field: 'user.username', title: __('User name')},
  183. {field: 'out_trade_no', title: __('Out_trade_no')},
  184. {field: 'order_price', title: __('Order_price'), operate:'BETWEEN'},
  185. // {field: 'discount_price', title: __('Discount_price'), operate:'BETWEEN'},
  186. // {field: 'delivery_price', title: __('Delivery_price'), operate:'BETWEEN'},
  187. {field: 'total_price', title: __('Total_price'), operate:'BETWEEN'},
  188. // {field: 'pay_type', title: __('Pay_type'), searchList: {"1":__('Online'),"2":__('Offline'),"3":__('wxPay'),"4":__('aliPay')}, formatter: Table.api.formatter.normal},
  189. {field: 'ip', title: __('Ip'), visible:false},
  190. {field: 'status', title: __('Status'), searchList: {"-1":__('Refund'),"0":__('Cancel'),"1":__('Normal')}, formatter: Table.api.formatter.status},
  191. // {field: 'have_paid_status', title: __('Have_paid'), searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
  192. // {field: 'have_delivered_status', title: __('Have_delivered'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
  193. // {field: 'have_received_status', title: __('Have_received'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
  194. // {field: 'have_commented_status', title: __('Have_commented'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
  195. // {field: 'refund_status', title: __('Refund status'),searchList: {"0":__('None'),"1":__('Apply'),"2":__('Waiting for shipment'),"3":__('Pass'),"4":__('Refuse')}, formatter: Table.api.formatter.status},
  196. // {field: 'have_paid', title: __('Pay time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  197. // {field: 'have_delivered', title: __('Delivered time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  198. // {field: 'have_received', title: __('Received time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  199. // {field: 'have_commented', title: __('Commented time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  200. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  201. {field: 'remark', title: __('Remark'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符'},
  202. {
  203. field: 'deletetime',
  204. title: __('Deletetime'),
  205. operate: 'RANGE',
  206. addclass: 'datetimerange',
  207. formatter: Table.api.formatter.datetime
  208. },
  209. {
  210. field: 'operate',
  211. width: '130px',
  212. title: __('Operate'),
  213. table: table,
  214. events: Table.api.events.operate,
  215. buttons: [
  216. // {
  217. // name: 'Restore',
  218. // text: __('Restore'),
  219. // classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
  220. // icon: 'fa fa-rotate-left',
  221. // url: 'unishop/order/restore',
  222. // refresh: true
  223. // },
  224. // {
  225. // name: 'Destroy',
  226. // text: __('Destroy'),
  227. // classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
  228. // icon: 'fa fa-times',
  229. // url: 'unishop/order/destroy',
  230. // refresh: true
  231. // }
  232. ],
  233. formatter: Table.api.formatter.operate
  234. }
  235. ]
  236. ]
  237. });
  238. // 为表格绑定事件
  239. Table.api.bindevent(table);
  240. },
  241. add: function () {
  242. Controller.api.bindevent();
  243. },
  244. edit: function () {
  245. Controller.api.bindevent();
  246. },
  247. delivery: function(){
  248. Controller.api.bindevent();
  249. },
  250. product: function(){
  251. Controller.api.bindevent();
  252. },
  253. refund: function(){
  254. Controller.api.bindevent();
  255. },
  256. api: {
  257. bindevent: function () {
  258. Form.api.bindevent($("form[role=form]"));
  259. }
  260. }
  261. };
  262. return Controller;
  263. });