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.
 
 
 
 
 
 

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