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.
 
 
 
 
 
 

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