mobile_order_flow.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: async function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'mobile_order_flow/index' + location.search,
  8. add_url: 'mobile_order_flow/add',
  9. edit_url: 'mobile_order_flow/edit',
  10. del_url: 'mobile_order_flow/del',
  11. multi_url: 'mobile_order_flow/multi',
  12. import_url: 'mobile_order_flow/import',
  13. table: 'mobile_order',
  14. show_open_data_url: 'mobile_order_flow/show_open_data',
  15. }
  16. });
  17. var table = $("#table");
  18. table.on('post-common-search.bs.table', function (event, table) {
  19. var form = $("form", table.$commonsearch);
  20. $("input[name='s_id']", form).addClass("selectpage").data("source", "auth/admin/index2").data("primaryKey", "id").data("params",{"custom[proxy]":"0","custom[sub]":"1"}).data("field", "nickname").data("orderBy", "id asc");
  21. Form.events.cxselect(form);
  22. Form.events.selectpage(form);
  23. });
  24. let status = await $.getJSON('mobile_order_flow/status')
  25. let statusColor={};
  26. let colors=['label-daifukuan','label-info','label-danger','label-warning','label-primary','label-success','label-default','label-danger','label-info','label-warning','label-primary','label-success','label-default','label-danger','label-info','label-warning','label-primary','label-success','label-default','label-danger','label-info','label-warning','label-primary','label-success','label-default','label-danger','label-info','label-warning','label-primary','label-success'];
  27. Object.keys(status).forEach((item,idx)=>{
  28. statusColor[item]=colors[idx];
  29. });
  30. statusColor[50]='label-default';
  31. let payType = await $.getJSON('mobile_order/pay_type')
  32. table.on('load-success.bs.table', function (_, data) {
  33. let e=data.extend;
  34. });
  35. $(document).on('click','.btn-sub-remark',function (){
  36. let id=$(this).data('id')
  37. let url=table.data('url-sub-remark')+`/id/${id}`
  38. Fast.api.open(url,'备注')
  39. })
  40. $(document).on('click','.btn-click-show-open',function (){
  41. if(!$(this).data('open')){
  42. parent.layer.msg('该用户未上传开卡资料')
  43. return
  44. }
  45. Fast.api.open($.fn.bootstrapTable.defaults.extend.show_open_data_url+'/id/'+$(this).data('id'),'查看资料',{
  46. shade:.3,
  47. shadeClose:false,
  48. })
  49. })
  50. let columns=[
  51. //{checkbox: true},
  52. {field: 'id', title: __('ID'),operate:false,},
  53. {field: 'order_no', title: __('订单号'),visible:false,operate: 'like'},
  54. {field: 'pay_no', title: __('支付单号'),visible: false,operate: '='},
  55. {field: 'mobile.name', title: __('商品信息'),visible:false,operate: 'like'},
  56. {field: 'mobile.product_no', title: __('产品编码'),visible:false,operate: '='},
  57. {field: 's_id', title: __('来源渠道'),formatter(_, order) {
  58. let a=[]
  59. a.push(`<div>${order.s_id}</div>`);
  60. a.push(`<div>${order.s_name}</div>`);
  61. return a.join('')
  62. }},
  63. {field: 'pay_type', title: __('支付方式'),searchList: payType,visible: false},
  64. {field: 'pay_mid_wechat', title: __('微信商户号'),visible: false,operate: 'LIKE'},
  65. {field: 'pay_mid_alipay', title: __('支付宝商户号'),visible: false,operate: 'LIKE'},
  66. {field: 'pay_mid_dy', title: __('抖音商户号'),visible: false,operate: 'LIKE'},
  67. {field: 'pay_mid_ks', title: __('快手商户号'),visible: false,operate: 'LIKE'},
  68. {field: 'name', title: __('收货人'),visible: false,operate: 'LIKE'},
  69. {field: 'phone', title: __('收货人手机'),visible: false,operate: 'LIKE'},
  70. {field: 'id_no', title: __('收货人身份证'),visible: false,operate: "like"},
  71. {field: 'order_no', title: __('订单信息'),operate: false,formatter(_,order){
  72. let a=[], product_no = '', product_brand = brands[order.brand];
  73. if(order.info.mobile.product_no && order.info.mobile.product_no != undefined){
  74. product_no = order.info.mobile.product_no;
  75. }
  76. if(order.info.mobile.logo){
  77. a.push(`<div><img src="${order.info.mobile.logo}" style="width: 50px;height: 50px;object-fit: cover;" alt="${order.name}"></div>`)
  78. }
  79. a.push(`<div>订单号:<b>${order.order_no}</b></div>`)
  80. if(order.pay_no){
  81. a.push(`<div>支付单号:<b>${order.pay_no}</b></div>`)
  82. }
  83. if(product_brand == undefined){
  84. product_brand = order.brand;
  85. }
  86. a.push(`<div>产品编码:<b>${product_no}</b></div>`)
  87. a.push(`<div>商品信息:<b>${order.info.mobile.name}</b></div>`)
  88. a.push(`<div>运营商:${product_brand}</div>`)
  89. a.push(`<div>商品名称:${order.info.mobile.name}</div>`)
  90. a.push(`<div>套餐:${order.info?order.info.mobile.summary:''}</div>`)
  91. return `<div class="break-words" style="width: inherit;">${a.join('')}</div>`
  92. },width:300,align:'left',valign:'top'},
  93. {
  94. field:'amount',
  95. title:'支付信息',
  96. operate: false,
  97. align:'left',
  98. valign: 'top',
  99. width: 125,
  100. formatter(_, order) {
  101. let a=[]
  102. a.push(`<div><b>支付金额:${order.amount}</b></div>`)
  103. a.push(`<div>支付方式:${payType[order.pay_type]}</div>`)
  104. return a.join('')
  105. }
  106. },
  107. {field: 'order_no', title: __('收货人'),operate: false,formatter(_,order){
  108. let a=[]
  109. a.push(`<div>收货人:${order.name}</div>`)
  110. a.push(`<div>手机号:${order.phone}<span style="color: red;">(${order.phone_order_flow_count})</span></div>`)
  111. a.push(`<div>地址:${order.address}</div>`)
  112. a.push(`<div>备注:${order.remark}</div>`)
  113. a.push(`<div>快递名称:${order.trans_name||''}</div>`)
  114. a.push(`<div>快递单号:${order.trans_no||''}</div>`)
  115. a.push(`<a class="btn btn-link btn-click-show-open" style="color: #00a2ff;" data-id="${order.id}" data-open="${order.open_idcard_face_img}">查看资料</a>`)
  116. // if(order.open_idcard_face_img){
  117. // a.push(`<img src="${order.open_idcard_face_img}" style="width: 50px;height: 50px;object-fit: cover;" alt="${order.name}">`)
  118. // }
  119. // if(order.open_idcard_back_img){
  120. // a.push(`<img src="${order.open_idcard_back_img}" style="width: 50px;height: 50px;object-fit: cover;" alt="${order.name}">`)
  121. // }
  122. // if(order.open_face_img){
  123. // a.push(`<img src="${order.open_face_img}" style="width: 50px;height: 50px;object-fit: cover;" alt="${order.name}">`)
  124. // }
  125. return `<div style="width: 200px;" class="break-words">${a.join('')}</div>`
  126. },width:200,align:'left',valign:'top'},
  127. {field: 'order_no', title: __('生产信息'),operate: false,formatter(_,order){
  128. let a=[], product_no = '';
  129. a.push(`<div>生产号码:${order.gantanhao_data_notify?order.gantanhao_data_notify.plan_mobile_produced:''}</div>`)
  130. return `<div class="break-words" style="width: inherit;">${a.join('')}</div>`
  131. },width:140,align:'left',valign:'top'},
  132. {field: 'status', title: __('Status'),formatter(a,order){
  133. if(a===30) {
  134. return `<span class="label label-primary">${status[order.status_bak]||''}-${status[a]}</span>`;
  135. }
  136. return `<span class="label ${statusColor[a]}">${status[a]}</span>`
  137. },searchList:status},
  138. {field: 'gantanhao_status', title: __('运营商结果'),formatter(a,order){
  139. var str = '';
  140. if(order.gantanhao_data_notify && order.status == '110' && order.gantanhao_data_notify.reason != undefined){
  141. str = `<div style="width: 200px;" class="break-words">${order.gantanhao_data_notify.reason}</div>`;
  142. }
  143. if(order.gantanhao_data_notify && order.gantanhao_data_notify.is_activated == 1){
  144. str += `<div style="width: 200px;" class="break-words">已激活</div>`;
  145. }
  146. return str;
  147. },searchable:false},
  148. {field: 'anchor.name', title:__('主播名称') ,searchList(){return Template('anchor-search',{});},width:100,formatter:Table.api.formatter.width},
  149. {field: 'sub_anchor.mobile_anchor.name', title: __(adminInfo.is_sub?'主播名称':'分站主播'),searchList(){return Template('anchor-sub-search',{});},width:100,formatter:Table.api.formatter.width},
  150. {field: 'sub_log', title: __(adminInfo.is_manager?'分站备注':'备注'),formatter(_,order){
  151. let a=[]
  152. order.sub_remark.forEach(item=>{
  153. a.push(`<div><span style="color: #0000ff;">${item.create_time_format}</span> <span style="color: #00caff">${item.admin?item.admin.nickname:'-'}</span> ${item.content}</div>`)
  154. })
  155. if(table.data('auth-url-sub-remark')) {
  156. a.push(`<a class="btn btn-info btn-xs btn-sub-remark" data-id="${order.id}">备注</a>`)
  157. }
  158. return `<div style="text-align: left;font-size: 10px;width: 200px;" class="break-words">${a.join('')}</div>`
  159. },operate:false,valign:'top',align:'left',width:200},
  160. {field: 'operation_log', title: __('客服记录'),formatter(_,order){
  161. let a=[]
  162. order.operation.forEach(item=>{
  163. a.push(`<div><span style="color: #0000ff;">${item.create_time_format}</span> <span style="color: #00caff">${item.admin?item.admin.nickname:'-'}-${item.admin?item.admin.job:'-'}</span> ${item.content}</div>`)
  164. })
  165. return `<div style="text-align: left;font-size: 10px;width: 200px;white-space: break-spaces;">${a.join('')}</div>`
  166. },operate:false,align:'left',valign:'top',width: 200},
  167. {field: 'admin.admin_id', title: __('操作员'),formatter(_,order){
  168. let a=[]
  169. order.admin.forEach(item=>{
  170. a.push(`<div>${item.admin.nickname}</div>`)
  171. })
  172. return `<div style="text-align: left;font-size: 10px;width: 100px;">${a.join('')}</div>`
  173. },operate:"=",searchList: admins,align:'left',valign:'top',width: 100},
  174. {field: 'create_time', title: __('创建时间'),formatter: Table.api.formatter.datetime,addClass:'datetimerange',operate: 'range'},
  175. {field: 'update_time', title: __('更新时间'),formatter: Table.api.formatter.datetime,addClass:'datetimerange',operate: 'range'},
  176. {field: 'trans_no', title: __('快递单号'),visible: false},
  177. {
  178. field: 'operate',
  179. title: __('Operate'),
  180. table: table,
  181. events: Table.api.events.buttons,
  182. formatter: Table.api.formatter.buttons,
  183. buttons:[
  184. {
  185. name: 'detail',
  186. text: __('设置主播'),
  187. title: __('设置主播'),
  188. classname: 'btn btn-xs btn-info btn-dialog period',
  189. url: table.data('url-set_anchor'),
  190. callback: function (data) {
  191. },
  192. visible: function (row) {
  193. return $('#table').data('auth-set_anchor');
  194. }
  195. },
  196. {
  197. name: 'detail',
  198. text: __('添加备注'),
  199. title: __('添加备注'),
  200. classname: 'btn btn-xs btn-info btn-dialog',
  201. url: 'mobile_order_flow/add_operation?a=1',
  202. callback: function (data) {
  203. },
  204. visible: function (row) {
  205. return $('#table').data('add_operation');
  206. }
  207. },
  208. {
  209. name: 'detail',
  210. text: __('编辑'),
  211. title: __('编辑'),
  212. classname: 'btn btn-xs btn-info btn-dialog',
  213. url: 'mobile_order_flow/edit?a=1',
  214. callback: function (data) {
  215. },
  216. visible: function (row) {
  217. return $('#table').data('operate-edit');
  218. }
  219. },
  220. {
  221. name: 'detail',
  222. text: __('发货'),
  223. title: __('发货'),
  224. classname: 'btn btn-xs btn-info btn-dialog period',
  225. url: 'mobile_order_flow/send?a=1',
  226. callback: function (data) {
  227. },
  228. visible: function (row) {
  229. return $('#table').data('mobile_order_send') && row.status>0;
  230. }
  231. },
  232. {
  233. name: '重新提交',
  234. text: __('重新提交'),
  235. title: __('重新提交'),
  236. classname: 'btn btn-xs btn-info btn-ajax',
  237. url: 'mobile_order_flow/resubmit?a=1',
  238. refresh: true,
  239. callback: function (data) {
  240. },
  241. visible: function (row) {
  242. return row.status==10;
  243. }
  244. },
  245. {
  246. name:'detail',
  247. title:'查看物流',
  248. text: __('查看物流'),
  249. classname: 'btn btn-xs btn-danger btn-dialog',
  250. url: 'mobile_order/see_logistics?a=1',
  251. visible:(row)=>{
  252. return $('#table').data('see_logistics') && row.trans_id>0 && row.trans_no
  253. }
  254. },
  255. {
  256. name: 'detail',
  257. text: __('抖音结算'),
  258. title: __('抖音结算'),
  259. classname: 'btn btn-xs btn-success btn-ajax',
  260. url: 'mobile_order/dy_settle',
  261. confirm:'确认结算吗?',
  262. callback: function (data) {
  263. },
  264. visible: function (row) {
  265. return $('#table').data('auth-dy_settle') && row.pay_type===4 && row.pay_time>0 && row.payment && row.payment.settle_status===0;
  266. },
  267. disable(row){
  268. }
  269. },
  270. {
  271. name: 'detail',
  272. text: __('退款'),
  273. title: __('退款'),
  274. classname: 'btn btn-xs btn-danger btn-dialog period',
  275. url: 'mobile_order/refund?a=1',
  276. callback: function (data) {
  277. },
  278. visible: function (row) {
  279. return $('#table').data('mobile_order_refund') && row.status>0 && row.status==10 && row.amount>0;
  280. }
  281. },
  282. ]
  283. }
  284. ]
  285. if(adminInfo.is_sub){
  286. Table.api.removeColumn('operation_log',columns)
  287. Table.api.removeColumn('anchor.name',columns)
  288. Table.api.removeColumn('sub',columns)
  289. Table.api.removeColumn('admin.admin_id',columns)
  290. Table.api.removeColumn('s_id',columns)
  291. }
  292. // 初始化表格
  293. table.bootstrapTable({
  294. url: $.fn.bootstrapTable.defaults.extend.index_url,
  295. pk: 'id',
  296. sortName: 'id',
  297. searchFormVisible:true,
  298. search:false,
  299. fixedColumns:true,
  300. fixedRightNumber:1,
  301. columns: [
  302. columns
  303. ],
  304. onLoadSuccess(a){
  305. $('.btn-export').attr('href',a.link).show();
  306. let arr1 = [];let status_all=0;
  307. a.status_list.forEach(function(item, index) {
  308. $(".nav li .nav_id_"+item.status).text(item.total);
  309. arr1.push(item.status);
  310. status_all = status_all+item.total;
  311. });
  312. // 全部
  313. $(".nav li .nav_id_all").text(status_all);
  314. // 无数据的置0
  315. let arr2 = [0,10,15,20,23,25,30,50,90,110];
  316. let diff=arr2.filter(item=>arr1.indexOf(item)==-1);
  317. diff.forEach(function (i,k){
  318. $(".nav li .nav_id_"+i).text(0);
  319. });
  320. /*table.find('thead').css('position','fixed').css('background','white').css('top','365px')
  321. table.css('margin-top',41)
  322. table.find('tbody>tr:first-child>td').each((a,b)=>{
  323. table.find('thead tr th').eq(a).css('width',b.offsetWidth).css('max-width',b.offsetWidth)
  324. table.find('thead tr th .th-inner').eq(a).css('width',b.offsetWidth)
  325. })*/
  326. }
  327. });
  328. // 为表格绑定事件
  329. Table.api.bindevent(table);
  330. /*let innerHeight=window.innerHeight
  331. $('.fixed-table-container').css('height',`${innerHeight-420}px`)
  332. window.addEventListener('resize',function (){
  333. let innerHeight=window.innerHeight
  334. $('.fixed-table-container').css('height',`${innerHeight-420}px`)
  335. })*/
  336. },
  337. edit: function () {
  338. Controller.api.bindevent();
  339. $(document).on('input propertychange','#c-trans_no',function (){
  340. let no=$(this).val()
  341. if(!no){
  342. return
  343. }
  344. Form.api.guessLogistics(no,'#c-trans_id')
  345. })
  346. },
  347. add_operation(){
  348. Controller.api.bindevent();
  349. },
  350. sub_remark(){
  351. Controller.api.bindevent();
  352. $('#c-no').focus()
  353. },
  354. send(){
  355. Controller.api.bindevent();
  356. $(document).on('input propertychange','#c-trans_no',function (){
  357. let no=$(this).val()
  358. if(!no){
  359. return
  360. }
  361. Form.api.guessLogistics(no,'#c-trans_id')
  362. })
  363. },
  364. api: {
  365. bindevent: function () {
  366. Form.api.bindevent($("form[role=form]"));
  367. }
  368. }
  369. };
  370. return Controller;
  371. });