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.
 
 
 
 
 
 

259 lines
15 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. // 初始化表格
  76. table.bootstrapTable({
  77. url: $.fn.bootstrapTable.defaults.extend.index_url,
  78. pk: 'id',
  79. sortName: 'id',
  80. columns: [
  81. [
  82. {checkbox: true},
  83. {field: 'id', title: __('Id'),visible:false},
  84. {field: 'user_id', title: __('User_id')},
  85. {field: 'user.username', title: __('User name')},
  86. {field: 'out_trade_no', title: __('Out_trade_no')},
  87. {field: 'order_price', title: __('Order_price'), operate:'BETWEEN'},
  88. {field: 'discount_price', title: __('Discount_price'), operate:'BETWEEN'},
  89. {field: 'delivery_price', title: __('Delivery_price'), operate:'BETWEEN'},
  90. {field: 'total_price', title: __('Total_price'), operate:'BETWEEN'},
  91. {field: 'status', title: __('Status'), searchList: {"-1":__('Refund'),"0":__('Cancel'),"1":__('Normal')}, formatter: Table.api.formatter.status},
  92. {field: 'pay_type', title: __('Pay_type'), searchList: {"1":__('Online'),"2":__('Offline'),"3":__('wxPay'),"4":__('aliPay')}, formatter: Table.api.formatter.normal},
  93. {field: 'ip', title: __('Ip'), visible:false},
  94. {field: 'have_paid_status', title: __('Have_paid'), searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
  95. {field: 'have_delivered_status', title: __('Have_delivered'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
  96. {field: 'have_received_status', title: __('Have_received'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
  97. {field: 'have_commented_status', title: __('Have_commented'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
  98. {field: 'refund_status', title: __('Refund status'),searchList: {"0":__('None'),"1":__('Apply'),"2":__('Waiting for shipment'),"3":__('Pass'),"4":__('Refuse')}, formatter: Table.api.formatter.status},
  99. {field: 'have_paid', title: __('Pay time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  100. {field: 'have_delivered', title: __('Delivered time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  101. {field: 'have_received', title: __('Received time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  102. {field: 'have_commented', title: __('Commented time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  103. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  104. {field: 'remark', title: __('Remark'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符'},
  105. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  106. {
  107. field: 'operate',
  108. title: __('Operate'),
  109. table: table,
  110. events: Table.api.events.operate,
  111. formatter: Table.api.formatter.operate,
  112. buttons:[
  113. {
  114. name: 'refund',
  115. text: __('Refund'),
  116. classname: 'btn btn-xs btn-info btn-refund',
  117. extend: 'data-toggle="tooltip"',
  118. icon: 'fa fa-handshake-o'
  119. },
  120. {
  121. name: 'delivere',
  122. text: __('Delivere'),
  123. classname: 'btn btn-xs btn-info btn-delivere',
  124. extend: 'data-toggle="tooltip"',
  125. icon: 'fa fa-plane'
  126. },
  127. {
  128. name: 'product',
  129. text: __('Product'),
  130. classname: 'btn btn-xs btn-info btn-product',
  131. extend: 'data-toggle="tooltip"',
  132. icon: 'fa fa-star-half'
  133. },
  134. {
  135. name: 'edit',
  136. icon: 'fa fa-pencil',
  137. text: __('Edit'),
  138. extend: 'data-toggle="tooltip"',
  139. classname: 'btn btn-xs btn-success btn-editone',
  140. url: $.fn.bootstrapTable.defaults.extend.edit_url
  141. }
  142. ]
  143. }
  144. ]
  145. ]
  146. });
  147. // 为表格绑定事件
  148. Table.api.bindevent(table);
  149. },
  150. recyclebin: function () {
  151. // 初始化表格参数配置
  152. Table.api.init({
  153. extend: {
  154. 'dragsort_url': ''
  155. }
  156. });
  157. var table = $("#table");
  158. // 初始化表格
  159. table.bootstrapTable({
  160. url: 'unishop/order/recyclebin' + location.search,
  161. pk: 'id',
  162. sortName: 'id',
  163. columns: [
  164. [
  165. {checkbox: true},
  166. {field: 'id', title: __('Id'),visible:false},
  167. {field: 'user_id', title: __('User_id')},
  168. {field: 'user.username', title: __('User name')},
  169. {field: 'out_trade_no', title: __('Out_trade_no')},
  170. {field: 'order_price', title: __('Order_price'), operate:'BETWEEN'},
  171. {field: 'discount_price', title: __('Discount_price'), operate:'BETWEEN'},
  172. {field: 'delivery_price', title: __('Delivery_price'), operate:'BETWEEN'},
  173. {field: 'total_price', title: __('Total_price'), operate:'BETWEEN'},
  174. {field: 'pay_type', title: __('Pay_type'), searchList: {"1":__('Online'),"2":__('Offline'),"3":__('wxPay'),"4":__('aliPay')}, formatter: Table.api.formatter.normal},
  175. {field: 'ip', title: __('Ip'), visible:false},
  176. {field: 'status', title: __('Status'), searchList: {"-1":__('Refund'),"0":__('Cancel'),"1":__('Normal')}, formatter: Table.api.formatter.status},
  177. {field: 'have_paid_status', title: __('Have_paid'), searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
  178. {field: 'have_delivered_status', title: __('Have_delivered'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
  179. {field: 'have_received_status', title: __('Have_received'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
  180. {field: 'have_commented_status', title: __('Have_commented'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
  181. {field: 'refund_status', title: __('Refund status'),searchList: {"0":__('None'),"1":__('Apply'),"2":__('Waiting for shipment'),"3":__('Pass'),"4":__('Refuse')}, formatter: Table.api.formatter.status},
  182. {field: 'have_paid', title: __('Pay time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  183. {field: 'have_delivered', title: __('Delivered time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  184. {field: 'have_received', title: __('Received time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  185. {field: 'have_commented', title: __('Commented time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  186. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  187. {field: 'remark', title: __('Remark'), operate: 'LIKE %...%', placeholder: '模糊搜索,*表示任意字符'},
  188. {
  189. field: 'deletetime',
  190. title: __('Deletetime'),
  191. operate: 'RANGE',
  192. addclass: 'datetimerange',
  193. formatter: Table.api.formatter.datetime
  194. },
  195. {
  196. field: 'operate',
  197. width: '130px',
  198. title: __('Operate'),
  199. table: table,
  200. events: Table.api.events.operate,
  201. buttons: [
  202. {
  203. name: 'Restore',
  204. text: __('Restore'),
  205. classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
  206. icon: 'fa fa-rotate-left',
  207. url: 'unishop/order/restore',
  208. refresh: true
  209. },
  210. {
  211. name: 'Destroy',
  212. text: __('Destroy'),
  213. classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
  214. icon: 'fa fa-times',
  215. url: 'unishop/order/destroy',
  216. refresh: true
  217. }
  218. ],
  219. formatter: Table.api.formatter.operate
  220. }
  221. ]
  222. ]
  223. });
  224. // 为表格绑定事件
  225. Table.api.bindevent(table);
  226. },
  227. add: function () {
  228. Controller.api.bindevent();
  229. },
  230. edit: function () {
  231. Controller.api.bindevent();
  232. },
  233. delivery: function(){
  234. Controller.api.bindevent();
  235. },
  236. product: function(){
  237. Controller.api.bindevent();
  238. },
  239. refund: function(){
  240. Controller.api.bindevent();
  241. },
  242. api: {
  243. bindevent: function () {
  244. Form.api.bindevent($("form[role=form]"));
  245. }
  246. }
  247. };
  248. return Controller;
  249. });