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.

order.js 17 KiB

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