delivery.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'trade/delivery/index' + location.search,
  8. add_url: 'trade/delivery/add',
  9. edit_url: 'trade/delivery/edit',
  10. del_url: 'trade/delivery/del',
  11. multi_url: 'trade/delivery/multi',
  12. import_url: 'trade/delivery/import',
  13. table: 'delivery_order',
  14. }
  15. });
  16. var sidebarNUmber = Config.sidebar_number.all;
  17. var table = $("#table");
  18. table.on('load-success.bs.table',function(e){
  19. var tabdom = $('.panel-heading ul[data-field] li.active a[data-toggle="tab"]');
  20. $(tabdom.find('small')).text('');
  21. var tabvalue = tabdom.data('value');
  22. switch (tabvalue) {
  23. case '':
  24. table.bootstrapTable('showColumn', 'out_trade_no');
  25. table.bootstrapTable('showColumn', 'delivery_order_no');
  26. table.bootstrapTable('showColumn', 'prize_id');
  27. table.bootstrapTable('showColumn', 'goods_name');
  28. table.bootstrapTable('showColumn', 'goods_image');
  29. table.bootstrapTable('showColumn', 'nickname');
  30. table.bootstrapTable('showColumn', 'avatar');
  31. table.bootstrapTable('showColumn', 'username');
  32. table.bootstrapTable('showColumn', 'mobile');
  33. table.bootstrapTable('showColumn', 'address');
  34. table.bootstrapTable('showColumn', 'status');
  35. table.bootstrapTable('showColumn', 'post_name');
  36. table.bootstrapTable('showColumn', 'delivery_number');
  37. table.bootstrapTable('showColumn', 'create_time');
  38. table.bootstrapTable('showColumn', 'delivery_time');
  39. table.bootstrapTable('showColumn', 'receive_time');
  40. table.bootstrapTable('showColumn', 'delivery');
  41. // table.bootstrapTable('hideColumn', 'out_trade_no');
  42. // table.bootstrapTable('hideColumn', 'delivery_order_no');
  43. // table.bootstrapTable('hideColumn', 'prize_id');
  44. // table.bootstrapTable('hideColumn', 'goods_name');
  45. // table.bootstrapTable('hideColumn', 'goods_image');
  46. table.bootstrapTable('hideColumn', 'nickname');
  47. table.bootstrapTable('hideColumn', 'avatar');
  48. // table.bootstrapTable('hideColumn', 'username');
  49. // table.bootstrapTable('hideColumn', 'mobile');
  50. // table.bootstrapTable('hideColumn', 'address');
  51. // table.bootstrapTable('hideColumn', 'status');
  52. table.bootstrapTable('hideColumn', 'post_name');
  53. table.bootstrapTable('hideColumn', 'delivery_number');
  54. table.bootstrapTable('hideColumn', 'create_time');
  55. table.bootstrapTable('hideColumn', 'delivery_time');
  56. table.bootstrapTable('hideColumn', 'receive_time');
  57. table.bootstrapTable('hideColumn', 'delivery');
  58. break;
  59. case 'undelivered': // 待发货
  60. table.bootstrapTable('showColumn', 'out_trade_no');
  61. table.bootstrapTable('showColumn', 'delivery_order_no');
  62. table.bootstrapTable('showColumn', 'prize_id');
  63. table.bootstrapTable('showColumn', 'goods_name');
  64. table.bootstrapTable('showColumn', 'goods_image');
  65. table.bootstrapTable('showColumn', 'nickname');
  66. table.bootstrapTable('showColumn', 'avatar');
  67. table.bootstrapTable('showColumn', 'username');
  68. table.bootstrapTable('showColumn', 'mobile');
  69. table.bootstrapTable('showColumn', 'address');
  70. table.bootstrapTable('showColumn', 'status');
  71. table.bootstrapTable('showColumn', 'post_name');
  72. table.bootstrapTable('showColumn', 'delivery_number');
  73. table.bootstrapTable('showColumn', 'create_time');
  74. table.bootstrapTable('showColumn', 'delivery_time');
  75. table.bootstrapTable('showColumn', 'receive_time');
  76. table.bootstrapTable('showColumn', 'delivery');
  77. // table.bootstrapTable('hideColumn', 'out_trade_no');
  78. table.bootstrapTable('hideColumn', 'delivery_order_no');
  79. // table.bootstrapTable('hideColumn', 'prize_id');
  80. // table.bootstrapTable('hideColumn', 'goods_name');
  81. // table.bootstrapTable('hideColumn', 'goods_image');
  82. // table.bootstrapTable('hideColumn', 'nickname');
  83. // table.bootstrapTable('hideColumn', 'avatar');
  84. // table.bootstrapTable('hideColumn', 'username');
  85. // table.bootstrapTable('hideColumn', 'mobile');
  86. // table.bootstrapTable('hideColumn', 'address');
  87. // table.bootstrapTable('hideColumn', 'status');
  88. table.bootstrapTable('hideColumn', 'post_name');
  89. table.bootstrapTable('hideColumn', 'delivery_number');
  90. // table.bootstrapTable('hideColumn', 'create_time');
  91. table.bootstrapTable('hideColumn', 'delivery_time');
  92. table.bootstrapTable('hideColumn', 'receive_time');
  93. // table.bootstrapTable('hideColumn', 'delivery');
  94. sidebarNUmber -= Config.sidebar_number.undelivered;
  95. break;
  96. case 'unreceived':
  97. table.bootstrapTable('showColumn', 'out_trade_no');
  98. table.bootstrapTable('showColumn', 'delivery_order_no');
  99. table.bootstrapTable('showColumn', 'prize_id');
  100. table.bootstrapTable('showColumn', 'goods_name');
  101. table.bootstrapTable('showColumn', 'goods_image');
  102. table.bootstrapTable('showColumn', 'nickname');
  103. table.bootstrapTable('showColumn', 'avatar');
  104. table.bootstrapTable('showColumn', 'username');
  105. table.bootstrapTable('showColumn', 'mobile');
  106. table.bootstrapTable('showColumn', 'address');
  107. table.bootstrapTable('showColumn', 'status');
  108. table.bootstrapTable('showColumn', 'post_name');
  109. table.bootstrapTable('showColumn', 'delivery_number');
  110. table.bootstrapTable('showColumn', 'create_time');
  111. table.bootstrapTable('showColumn', 'delivery_time');
  112. table.bootstrapTable('showColumn', 'receive_time');
  113. table.bootstrapTable('showColumn', 'delivery');
  114. // table.bootstrapTable('hideColumn', 'out_trade_no');
  115. // table.bootstrapTable('hideColumn', 'delivery_order_no');
  116. // table.bootstrapTable('hideColumn', 'prize_id');
  117. // table.bootstrapTable('hideColumn', 'goods_name');
  118. // table.bootstrapTable('hideColumn', 'goods_image');
  119. // table.bootstrapTable('hideColumn', 'nickname');
  120. // table.bootstrapTable('hideColumn', 'avatar');
  121. // table.bootstrapTable('hideColumn', 'username');
  122. // table.bootstrapTable('hideColumn', 'mobile');
  123. table.bootstrapTable('hideColumn', 'address');
  124. // table.bootstrapTable('hideColumn', 'status');
  125. // table.bootstrapTable('hideColumn', 'post_name');
  126. // table.bootstrapTable('hideColumn', 'delivery_number');
  127. table.bootstrapTable('hideColumn', 'create_time');
  128. // table.bootstrapTable('hideColumn', 'delivery_time');
  129. table.bootstrapTable('hideColumn', 'receive_time');
  130. table.bootstrapTable('hideColumn', 'delivery');
  131. sidebarNUmber -= Config.sidebar_number.unreceived;
  132. break;
  133. case 'finished':
  134. table.bootstrapTable('showColumn', 'out_trade_no');
  135. table.bootstrapTable('showColumn', 'delivery_order_no');
  136. table.bootstrapTable('showColumn', 'prize_id');
  137. table.bootstrapTable('showColumn', 'goods_name');
  138. table.bootstrapTable('showColumn', 'goods_image');
  139. table.bootstrapTable('showColumn', 'nickname');
  140. table.bootstrapTable('showColumn', 'avatar');
  141. table.bootstrapTable('showColumn', 'username');
  142. table.bootstrapTable('showColumn', 'mobile');
  143. table.bootstrapTable('showColumn', 'address');
  144. table.bootstrapTable('showColumn', 'status');
  145. table.bootstrapTable('showColumn', 'post_name');
  146. table.bootstrapTable('showColumn', 'delivery_number');
  147. table.bootstrapTable('showColumn', 'create_time');
  148. table.bootstrapTable('showColumn', 'delivery_time');
  149. table.bootstrapTable('showColumn', 'receive_time');
  150. table.bootstrapTable('showColumn', 'delivery');
  151. // table.bootstrapTable('hideColumn', 'out_trade_no');
  152. // table.bootstrapTable('hideColumn', 'delivery_order_no');
  153. // table.bootstrapTable('hideColumn', 'prize_id');
  154. // table.bootstrapTable('hideColumn', 'goods_name');
  155. // table.bootstrapTable('hideColumn', 'goods_image');
  156. // table.bootstrapTable('hideColumn', 'nickname');
  157. // table.bootstrapTable('hideColumn', 'avatar');
  158. // table.bootstrapTable('hideColumn', 'username');
  159. // table.bootstrapTable('hideColumn', 'mobile');
  160. table.bootstrapTable('hideColumn', 'address');
  161. // table.bootstrapTable('hideColumn', 'status');
  162. table.bootstrapTable('hideColumn', 'post_name');
  163. table.bootstrapTable('hideColumn', 'delivery_number');
  164. table.bootstrapTable('hideColumn', 'create_time');
  165. table.bootstrapTable('hideColumn', 'delivery_time');
  166. // table.bootstrapTable('hideColumn', 'receive_time');
  167. table.bootstrapTable('hideColumn', 'delivery');
  168. sidebarNUmber -= Config.sidebar_number.finished;
  169. break;
  170. }
  171. Backend.api.sidebar({
  172. 'trade/delivery': [sidebarNUmber,'yellow'],
  173. });
  174. });
  175. // 初始化表格
  176. table.bootstrapTable({
  177. url: $.fn.bootstrapTable.defaults.extend.index_url,
  178. pk: 'id',
  179. sortName: 'delivery.id',
  180. columns: [
  181. [
  182. {checkbox: true},
  183. {field: 'out_trade_no', title: __('Out_trade_no'), operate: 'LIKE'},
  184. {field: 'delivery_order_no', title: __('Delivery_order_no'), operate: 'LIKE'},
  185. {field: 'prize_id', title: __('Prize_id')},
  186. {field: 'goods_name', title: __('Goods_name'), operate: 'LIKE'},
  187. {field: 'goods_image', title: __('Goods_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  188. {field: 'user.nickname', title: __('Nickname'), operate: 'LIKE', visible: false},
  189. {field: 'nickname', title: __('Nickname'), operate: false},
  190. {field: 'avatar', title: __('Avatar'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  191. {field: 'user.username', title: __('Username'), operate: 'LIKE', visible: false},
  192. {field: 'username', title: __('Username'), operate: false},
  193. {field: 'user.mobile', title: __('Mobile'), visible: false, operate: 'LIKE'},
  194. {field: 'mobile', title: __('Mobile'), operate: false},
  195. {field: 'address', title: __('Address'), operate: 'LIKE'},
  196. {field: 'delivery.status', title: __('Status'), searchList: {"undelivered":__('Status undelivered'),"unreceived":__('Status unreceived'),"finished":__('Status finished')}, formatter: Table.api.formatter.status, visible: false},
  197. {field: 'status', title: __('Status'), searchList: {"undelivered":__('Status undelivered'),"unreceived":__('Status unreceived'),"finished":__('Status finished')}, formatter: Table.api.formatter.status,operate: false},
  198. {field: 'post_name', title: __('Post_name'), operate: 'LIKE'},
  199. {field: 'delivery_number', title: __('Delivery_number'), operate: 'LIKE'},
  200. {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  201. {field: 'delivery_time', title: __('Delivery_time'), operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  202. {field: 'receive_time', title: __('Receive_time'), operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  203. {
  204. field: 'delivery',
  205. title: __('发货'),
  206. table: table,
  207. events: Table.api.events.operate,
  208. buttons: [
  209. {
  210. name: 'send',
  211. text: __('发货'),
  212. classname: 'btn btn-xs btn-info btn-dialog',
  213. icon: 'fa fa-truck fa-fw',
  214. url: 'trade/delivery/edit?ids={id}',
  215. extend: "data-area='[\"60%\",\"90%\"]'"
  216. }
  217. ],
  218. operate: false,
  219. formatter: Table.api.formatter.buttons
  220. },
  221. ]
  222. ],
  223. searchFormVisible: true,
  224. search:false,
  225. showToggle: false,
  226. showColumns: false
  227. });
  228. // 为表格绑定事件
  229. Table.api.bindevent(table);
  230. },
  231. add: function () {
  232. Controller.api.bindevent();
  233. },
  234. edit: function () {
  235. Controller.api.bindevent();
  236. },
  237. api: {
  238. bindevent: function () {
  239. Form.api.bindevent($("form[role=form]"));
  240. }
  241. }
  242. };
  243. return Controller;
  244. });