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.
 
 
 
 
 
 

338 lines
19 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. carry_url: 'unishop/order/carry',
  28. del_url: 'unishop/order/del',
  29. multi_url: 'unishop/order/multi',
  30. delivere_url: 'unishop/order/delivery',
  31. product_url: 'unishop/order/product',
  32. refund_url: 'unishop/order/refund',
  33. table: 'unishop_order',
  34. }
  35. });
  36. // 合并操作方法
  37. Table.api.events.operate = $.extend(Table.api.events.operate,
  38. {
  39. 'click .btn-delivere': function (e, value, row, index) {
  40. e.stopPropagation();
  41. e.preventDefault();
  42. var table = $(this).closest('table');
  43. var options = table.bootstrapTable('getOptions');
  44. var ids = row[options.pk];
  45. row = $.extend({}, row ? row : {}, {ids: ids});
  46. var url = options.extend.delivere_url;
  47. Fast.api.open(Table.api.replaceurl(url, row, table), __('Delivere'), $(this).data() || {});
  48. }
  49. },
  50. {
  51. 'click .btn-product': function (e, value, row, index) {
  52. e.stopPropagation();
  53. e.preventDefault();
  54. var table = $(this).closest('table');
  55. var options = table.bootstrapTable('getOptions');
  56. var ids = row[options.pk];
  57. row = $.extend({}, row ? row : {}, {ids: ids});
  58. var url = options.extend.product_url;
  59. Fast.api.open(Table.api.replaceurl(url, row, table), __('Product'), $(this).data() || {});
  60. }
  61. },
  62. {
  63. 'click .btn-refund': function (e, value, row, index) {
  64. e.stopPropagation();
  65. e.preventDefault();
  66. var table = $(this).closest('table');
  67. var options = table.bootstrapTable('getOptions');
  68. var ids = row[options.pk];
  69. row = $.extend({}, row ? row : {}, {ids: ids});
  70. var url = options.extend.refund_url;
  71. Fast.api.open(Table.api.replaceurl(url, row, table), __('Refund'), $(this).data() || {});
  72. }
  73. }
  74. );
  75. var table = $("#table");
  76. // 初始化表格
  77. table.bootstrapTable({
  78. pageSize: 20,
  79. pageList: [20, 50, 100],
  80. url: $.fn.bootstrapTable.defaults.extend.index_url,
  81. pk: 'id',
  82. sortName: 'id',
  83. showExport: false,
  84. commonSearch: true,
  85. search: false,
  86. showToggle: false,
  87. columns: [
  88. [
  89. {checkbox: true},
  90. // {field: 'id', title: __('Id'),visible:false},
  91. // {field: 'user_id', title: __('User_id')},
  92. {field: 'user.username', title: __('工号'),operate: 'LIKE'},
  93. {field: 'user.nickname', title: __('名字'),visible:false,operate: 'LIKE'},
  94. {field: 'out_trade_no', title: __('Out_trade_no'),operate:false},
  95. {field: 'order_price', title: __('Order_price'), operate:false},
  96. {field: 'is_carry', title: __('是否提货'), operate:false},
  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:false},
  100. {field: 'status', title: __('Status'),operate:false, searchList: {"-1":__('Refund'),"0":__('Cancel'),"1":__('Normal')}, formatter: Table.api.formatter.status},
  101. {field: 'refund_fee', title: __('退款金额'), operate:false},
  102. {field: 'pay_type', title: __('Pay_type'),operate:false, searchList: {"1":__('Online'),"2":__('Offline'),"3":__('wxPay'),"4":__('aliPay')}, formatter: Table.api.formatter.normal},
  103. // {field: 'ip', title: __('Ip'), visible:false},
  104. // {field: 'have_paid_status', title: __('Have_paid'), searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
  105. // {field: 'have_delivered_status', title: __('Have_delivered'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
  106. // {field: 'have_received_status', title: __('Have_received'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
  107. // {field: 'have_commented_status', title: __('Have_commented'),searchList: {"0":__('No'),"1":__('Yes')}, formatter: Table.api.formatter.statusCustom},
  108. // {field: 'refund_status', title: __('Refund status'),searchList: {"0":__('None'),"1":__('Apply'),"2":__('Waiting for shipment'),"3":__('Pass'),"4":__('Refuse')}, formatter: Table.api.formatter.status},
  109. // {field: 'have_paid', title: __('Pay time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  110. // {field: 'have_delivered', title: __('Delivered time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  111. // {field: 'have_received', title: __('Received time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  112. // {field: 'have_commented', title: __('Commented time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  113. {field: 'createtime', title: __('Createtime'),operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  114. {field: 'remark', title: __('Remark'),operate:false},
  115. {field: 'updatetime', title: __('Updatetime'),operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  116. {
  117. field: 'operate',
  118. title: __('Operate'),
  119. table: table,
  120. events: Table.api.events.operate,
  121. formatter: Table.api.formatter.operate,
  122. buttons:[
  123. // {
  124. // name: 'refund',
  125. // text: __('Refund'),
  126. // classname: 'btn btn-xs btn-info',
  127. // extend: 'data-toggle="tooltip"',
  128. // icon: 'fa fa-handshake-o',
  129. // url:function(row){
  130. // return "/admin.php/unishop/order/refundShow?id="+row.id+"&refund_fee="+row.total_price;
  131. // },
  132. // confirm:"是否确认退款"
  133. // },
  134. {
  135. name: 'click',
  136. text: __('Refund'),
  137. classname: 'btn btn-xs btn-info btn-click',
  138. icon: 'fa fa-leaf',
  139. // dropdown: '更多',//如果包含dropdown,将会以下拉列表的形式展示
  140. click: function (data,rowElement) {
  141. Layer.prompt({title: '请输入退款金额', formType: 2}, function(text){
  142. Fast.api.ajax({
  143. url:"/admin.php/unishop/order/doRefund?id="+rowElement.id+"&refund_fee="+text
  144. }, function (data, ret) {
  145. Layer.closeAll();
  146. Layer.alert(ret.msg);
  147. table.bootstrapTable('refresh');
  148. }, function (data, ret) {
  149. Layer.closeAll();
  150. Layer.alert(ret.msg);
  151. table.bootstrapTable('refresh');
  152. });
  153. });
  154. },
  155. },
  156. // {
  157. // name: 'delivere',
  158. // text: __('Delivere'),
  159. // classname: 'btn btn-xs btn-info btn-delivere',
  160. // extend: 'data-toggle="tooltip"',
  161. // icon: 'fa fa-plane'
  162. // },
  163. {
  164. name: 'product',
  165. text: __('Product'),
  166. classname: 'btn btn-xs btn-info btn-product',
  167. extend: 'data-toggle="tooltip"',
  168. icon: 'fa fa-star-half'
  169. },
  170. {
  171. name: 'edit',
  172. icon: 'fa fa-pencil',
  173. text: __('Edit'),
  174. extend: 'data-toggle="tooltip"',
  175. classname: 'btn btn-xs btn-success btn-editone',
  176. url: $.fn.bootstrapTable.defaults.extend.edit_url
  177. }
  178. ]
  179. }
  180. ]
  181. ]
  182. });
  183. // 为表格绑定事件
  184. Table.api.bindevent(table);
  185. $(document).on("click", ".btn-export", function () {
  186. window.location.href="order/export";
  187. });
  188. $(document).on("click", ".btn-finish", function () {
  189. Layer.confirm(
  190. __('确定要完成所有订单?'),
  191. {icon: 3, title: __('Warning'), offset: 0, shadeClose: true},
  192. function (index) {
  193. Fast.api.ajax({
  194. url:"unishop/order/finish",
  195. loading:false
  196. }, function(data, ret){
  197. //成功回调
  198. Layer.close(index);
  199. // layer.msg('操作成功!');
  200. });
  201. }
  202. );
  203. });
  204. $(document).on("click", ".btn-carry", function () {
  205. var ids = Table.api.selectedids(table);
  206. Layer.confirm(
  207. __('确定要提货吗?'),
  208. {icon: 3, title: __('Warning'), offset: 0, shadeClose: true},
  209. function (index) {
  210. Fast.api.ajax({
  211. url:"unishop/order/carry",
  212. loading:false,
  213. data:{"ids":ids}
  214. }, function(data, ret){
  215. //成功回调
  216. Layer.close(index);
  217. // layer.msg('操作成功!');
  218. });
  219. }
  220. );
  221. });
  222. },
  223. recyclebin: function () {
  224. // 初始化表格参数配置
  225. Table.api.init({
  226. extend: {
  227. 'dragsort_url': ''
  228. }
  229. });
  230. var table = $("#table");
  231. // 初始化表格
  232. table.bootstrapTable({
  233. url: 'unishop/order/recyclebin' + location.search,
  234. pk: 'id',
  235. sortName: 'id',
  236. pageSize: 20,
  237. pageList: [20, 50, 100],
  238. columns: [
  239. [
  240. {checkbox: true},
  241. {field: 'id', title: __('Id'),visible:false},
  242. {field: 'user_id', title: __('User_id')},
  243. {field: 'user.username', title: __('User name')},
  244. {field: 'out_trade_no', title: __('Out_trade_no'),operate:false},
  245. {field: 'order_price', title: __('Order_price'), operate:false},
  246. {field: 'discount_price', title: __('Discount_price'), operate:false},
  247. {field: 'delivery_price', title: __('Delivery_price'), operate:false},
  248. {field: 'total_price', title: __('Total_price'),operate:false},
  249. {field: 'pay_type', title: __('Pay_type'), searchList: {"1":__('Online'),"2":__('Offline'),"3":__('wxPay'),"4":__('aliPay')},operate:false, formatter: Table.api.formatter.normal},
  250. {field: 'ip', title: __('Ip'), visible:false},
  251. {field: 'status', title: __('Status'), searchList: {"-1":__('Refund'),"0":__('Cancel'),"1":__('Normal')},operate:false, formatter: Table.api.formatter.status},
  252. {field: 'have_paid_status', title: __('Have_paid'), searchList: {"0":__('No'),"1":__('Yes')},operate:false, formatter: Table.api.formatter.statusCustom},
  253. {field: 'have_delivered_status', title: __('Have_delivered'),searchList: {"0":__('No'),"1":__('Yes')},operate:false, formatter: Table.api.formatter.statusCustom},
  254. {field: 'have_received_status', title: __('Have_received'),searchList: {"0":__('No'),"1":__('Yes')},operate:false, formatter: Table.api.formatter.statusCustom},
  255. {field: 'have_commented_status', title: __('Have_commented'),searchList: {"0":__('No'),"1":__('Yes')},operate:false, formatter: Table.api.formatter.statusCustom},
  256. {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},
  257. {field: 'have_paid', title: __('Pay time'), operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  258. {field: 'have_delivered', title: __('Delivered time'), operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  259. {field: 'have_received', title: __('Received time'), operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  260. {field: 'have_commented', title: __('Commented time'),operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime,visible:false},
  261. {field: 'createtime', title: __('Createtime'), operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  262. {field: 'remark', title: __('Remark'), operate:false, placeholder: '模糊搜索,*表示任意字符'},
  263. {
  264. field: 'deletetime',
  265. title: __('Deletetime'),
  266. operate: 'RANGE',
  267. addclass: 'datetimerange',
  268. formatter: Table.api.formatter.datetime
  269. },
  270. {
  271. field: 'operate',
  272. width: '130px',
  273. title: __('Operate'),
  274. table: table,
  275. events: Table.api.events.operate,
  276. buttons: [
  277. {
  278. name: 'Restore',
  279. text: __('Restore'),
  280. classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
  281. icon: 'fa fa-rotate-left',
  282. url: 'unishop/order/restore',
  283. refresh: true
  284. },
  285. {
  286. name: 'Destroy',
  287. text: __('Destroy'),
  288. classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
  289. icon: 'fa fa-times',
  290. url: 'unishop/order/destroy',
  291. refresh: true
  292. }
  293. ],
  294. formatter: Table.api.formatter.operate
  295. }
  296. ]
  297. ]
  298. });
  299. // 为表格绑定事件
  300. Table.api.bindevent(table);
  301. },
  302. add: function () {
  303. Controller.api.bindevent();
  304. },
  305. edit: function () {
  306. Controller.api.bindevent();
  307. },
  308. carry: function () {
  309. console(1);
  310. Controller.api.bindevent();
  311. },
  312. delivery: function(){
  313. Controller.api.bindevent();
  314. },
  315. product: function(){
  316. Controller.api.bindevent();
  317. },
  318. refund: function(){
  319. Controller.api.bindevent();
  320. },
  321. api: {
  322. bindevent: function () {
  323. Form.api.bindevent($("form[role=form]"));
  324. }
  325. }
  326. };
  327. return Controller;
  328. });