produceorder.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form','clipboard'],
  2. function ($, undefined, Backend, Table, Form,clipboard) {
  3. var Controller = {
  4. index: async function () {
  5. // 初始化表格参数配置
  6. Table.api.init({
  7. extend: {
  8. index_url: 'Produceorder/index' + location.search,
  9. add_url: 'Produceorder/add',
  10. edit_url: 'Produceorder/edit',
  11. del_url: 'Produceorder/del',
  12. multi_url: 'Produceorder/multi',
  13. import_url: 'Produceorder/import',
  14. show_open_data_url: 'Produceorder/show_open_data',
  15. detail_url: 'Produceorder/detail', // 详情
  16. table: 'Produceorder',
  17. multi_edit_url: 'produceorder/multi_edit',
  18. }
  19. });
  20. var table = $("#table");
  21. $('.btn-multi-edit').click(function (){
  22. let ids=[]
  23. $('#table').bootstrapTable('getSelections').forEach(item=>{
  24. ids.push(item.id)
  25. })
  26. if(!ids.length){
  27. layer.alert('请选择')
  28. return
  29. }
  30. Fast.api.open(`${$.fn.bootstrapTable.defaults.extend.multi_edit_url}/ids/${ids.join(',')}`,'批量编辑')
  31. })
  32. table.on('post-common-search.bs.table', function (event, table) {
  33. var form = $("form", table.$commonsearch);
  34. $("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");
  35. Form.events.cxselect(form);
  36. Form.events.selectpage(form);
  37. });
  38. let is_proxy = Config.is_proxy;
  39. let is_proxy_operate = false;
  40. let is_proxy_operate_eq = false;
  41. if(is_proxy==0){
  42. is_proxy_operate = 'LIKE';
  43. is_proxy_operate_eq = '=';
  44. }
  45. let tableData=[]
  46. let url_clip=new clipboard('.btn-copy-obj',{
  47. text:function (a){
  48. let idx=$(a).data('row-index'),
  49. row=tableData[idx]
  50. return `${location.origin}/h5/#/?id=${row.id}`
  51. }
  52. })
  53. url_clip.on('success',function (){
  54. parent.layer.msg('复制成功')
  55. })
  56. let clip=new clipboard('.btn-pay_link',{
  57. text(a){
  58. let link=$(a).data('link')
  59. return link
  60. }
  61. })
  62. clip.on('success',function (){
  63. parent.layer.msg('复制成功')
  64. })
  65. //订单信息复制
  66. let order_clip=new clipboard('.btn-order_link',{
  67. text(a){
  68. // let link=$(a).data('link').replace(/<[^>]*>/g, '')
  69. let link=$(a).data('link');
  70. // console.log(JSON.stringify(link));
  71. return link + ''
  72. }
  73. })
  74. console.log(order_clip,'22222222')
  75. order_clip.on('success',function (){
  76. console.log(order_clip);
  77. parent.layer.msg('复制成功')
  78. })
  79. let status = await $.getJSON('Produceorder/status');
  80. let statusColor={};
  81. 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'];
  82. Object.keys(status).forEach((item,idx)=>{
  83. statusColor[item]=colors[idx];
  84. });
  85. statusColor[50]='label-default';
  86. let payType = await $.getJSON('Produceorder/pay_type');
  87. let mobileRules = await $.getJSON('mobile/mobile_rules');
  88. table.on('load-success.bs.table', function (_, data) {
  89. let e=data.extend;
  90. $('#orderAmount').html(`收入:${e.total},支付宝:${e.alipay},微信:${e.wechat},抖音:${e.dy},快手:${e.ks},成本:${e.di},利润:${e.profit},退款:${e.refund}`)
  91. });
  92. $(document).on('click','.btn-click-show-open',function (){
  93. if($(this).data('open')!==1){
  94. parent.layer.msg('该用户未上传开卡资料')
  95. return
  96. }
  97. Fast.api.open($.fn.bootstrapTable.defaults.extend.show_open_data_url+'/id/'+$(this).data('id'),'查看资料',{
  98. shade:.3,
  99. shadeClose:false,
  100. })
  101. })
  102. $(document).on('click','.btn-sub-remark',function (){
  103. let id=$(this).data('id')
  104. let url="produceorder/sub_remark"+`/id/${id}`
  105. Fast.api.open(url,'备注')
  106. })
  107. let columns=[
  108. {checkbox: true},
  109. // {field: 'id', title: __('ID'),operate:false,},
  110. {field: 'order_no', title: __('订单号'),visible:false,operate: 'like'},
  111. {field: 'out_order_no', title: __('外部订单号'),visible:false,operate: 'like'},
  112. // {field: 'logistics_numbers', title: __('支付单号'),visible: false,operate: '='},
  113. // {field: 'pay_type', title: __('支付方式'),searchList: payType,visible: false, operate: is_proxy_operate},
  114. {field: 'produce_id', title: __('商品名称'),visible: false,operate: 'LIKE', addClass: 'selectpage', extend: "data-source='produce/index' data-field='name'"},
  115. {field: 'is_arrearage', title: __('是否欠费'), searchList: {"1":__('是'),"0":__('否')},visible: false},
  116. {field: 'produce_activation', title: __('是否激活'), searchList: {"1":__('是'),"0":__('否')},visible: false},
  117. {field: 'produce_is_recharge', title: __('是否首充'), searchList: {"1":__('是'),"0":__('否')},visible: false},
  118. {field: 'flag', title: __('旗帜'), searchList: {"#FF0000":'红色',"#FFFF00":'黄色',"#00FF33":'绿色',"#0033FF":'蓝色',"#9900FF":'紫色',"#00CCFF":'青色'},visible: false},
  119. {field: 'supplier', title: __('分销商'),visible: false,operate: 'LIKE'},
  120. {field: 'no', title: __('生产号码'),visible: false,operate: 'LIKE'},
  121. {field: 'phone', title: __('收货人手机'),visible: false,operate: 'LIKE'},
  122. {field: 'name', title: __('收货人'),visible: false,operate: 'LIKE'},
  123. {field: 'id_no', title: __('收货人身份证'),visible: false,operate: "like"},
  124. {field: 'is_auto', title: __('是否是自动订单'),visible: false},
  125. {field: 'no', title: __('订单来源'),visible: false,operate: 'LIKE'},
  126. {field: 'no', title: __('外部订单号'),visible: false,operate: 'LIKE'},
  127. {field: 'no', title: __('商品编码'),visible: false,operate: 'LIKE'},
  128. {field: 'create_time', title: __('订单生成时间'),visible: false,operate: 'LIKE'},
  129. // {field: 'no', title: __('订单更新时间'),visible: false,operate: 'LIKE'},
  130. {field: 'order_no', title: __('订单信息'),operate: false,formatter(_,order){
  131. let a=[]
  132. a.push(`<div>订单号:<b class="btn-order_link" data-link="${order.order_no}">${order.order_no}</b><span style='color: ${order.flag};font-size: 24px; '>&#127987;</span></div>`)
  133. a.push(`<div>外部订单号:<b class="btn-order_link" data-link="${order.out_order_no}">${order.out_order_no}</b></div>`)
  134. a.push(`<div>商品编码:<b class="btn-order_link" data-link="${order.produce ? order.produce.local_code : ''}">${order.produce ? order.produce.local_code : ''}</b></div>`)
  135. a.push(`<div>供应商:<b class="btn-order_link" data-link="${order.supplier}">${order.supplier}</b></div>`)
  136. // if(order.pay_no){
  137. // a.push(`<div>支付单号:<b class="btn-order_link" data-link="${order.pay_no}">${order.pay_no}</b></div>`)
  138. // }
  139. // a.push(`<div class="btn-order_link" data-link="${order.no}"><b>商品信息:${order.no}</b></div>`)
  140. // a.push(`<div>归属地:${order.info.mobile.province}/${order.info.mobile.city}</div>`)
  141. // if(adminInfo.is_manager){
  142. // a.push(`<div>供应商:${order.proxy?order.proxy.nickname:''}</div>`)
  143. // }
  144. // a.push(`<div>运营商:${order.info?order.info.mobile.network:''}</div>`)
  145. // a.push(`<div>卡品牌:${order.brand}</div>`)
  146. // if(showAmountDi && is_proxy==0) {
  147. // a.push(`<div class="btn-order_link" data-link="${order}">底价:${order.amount_di}</div>`)
  148. // }
  149. // a.push(`<div class="btn-order_link" data-link="${order.amount_charge}">预存:${order.amount_charge}</div>`)
  150. // if(is_proxy == 0 ) {
  151. // a.push(`<div class="btn-order_link" data-link="${order.info.mobile.is_activity?order.info.mobile.amount_kill:order.info.mobile.amount_base}"><b>售价:${order.info.mobile.is_activity?order.info.mobile.amount_kill:order.info.mobile.amount_base}</b></div>`)
  152. // a.push(`<div class="btn-order_link" data-link="${order.amount}">订单价格:${order.amount}</div>`)
  153. // }
  154. // a.push(`<div class='btn-order_link' data-link="${order.info.info.describe}">套餐:${order.info?order.info.info.describe:''}</div>`)
  155. // a.push(`<div>备注:${order.info?order.info.mobile.remark:''}</div>`)
  156. // a.push(`<a class="btn btn-success btn-sm btn-order_link" data-link="${a.join('')}">点击复制</a>`)
  157. return `<div style="max-width: 250px;word-wrap: break-word;word-break: break-all;white-space: normal;text-align: left;">${a.join('')}</div>`
  158. },width:'20%',valign:'top',align:'left'},
  159. {field: 'order_no', title: __('收货人'),operate: false,formatter(_,order){
  160. let a=[]
  161. a.push(`<div class="btn-order_link" data-link="${order.name}">收货人:${order.name}</div>`)
  162. a.push(`<div class="btn-order_link" data-link="${order.phone}">手机号:${order.phone}<span style="color: red;">(${order.phone_order_count})</span></div>`)
  163. a.push(`<div class="btn-order_link" data-link="${order.address}">地址:${order.address}</div>`)
  164. if(is_proxy == 0 ) {
  165. // a.push(`<div>支付方式:${payType[order.pay_type]}</div>`)
  166. // a.push(`<div>微信商户号:<span style="color: #00b578;">${order.pay_mid_wechat}</span></div>`)
  167. // a.push(`<div>支付宝商户号:<span style="color: #0d6aad;">${order.pay_mid_alipay}</span></div>`)
  168. // a.push(`<div>抖音商户号:<span style="color: #0d6aad;">${order.pay_mid_dy}</span></div>`)
  169. // a.push(`<div>快手商户号:<span style="color: #0d6aad;">${order.pay_mid_ks}</span></div>`)
  170. }
  171. a.push(`<div>备注:${order.remark}</div>`)
  172. // a.push(`<div>快递名称:${order.trans_name}</div>`)
  173. // a.push(`<div>快递单号:${order.trans_no}</div>`)
  174. a.push(`<a class="btn btn-link btn-click-show-open" style="color: #00a2ff;" data-id="${order.id}" data-open="${order.open_uploaded}">查看资料</a>`)
  175. return `<div style="max-width: 200px;text-align: left;" class="break-words">${a.join('')}</div>`
  176. },width:'20%',valign:'top',align:'left'},
  177. {field: 'create_time', title: __('订单状态'),operate: false,formatter(_,order){
  178. let a=[]
  179. a.push(`<div class="btn-order_link" data-link="${order.name}">订单状态:</div>`)
  180. a.push(`<div class="btn-order_link" data-link="${order.phone}">激活状态:</div>`)
  181. a.push(`<div class="btn-order_link" data-link="${order.address}">是否首充:</div>`)
  182. a.push(`<div>首充金额:</div>`)
  183. a.push(`<div>创建时间:${order.create_time}</div>`)
  184. a.push(`<div>更新时间:${order.update_time}</div>`)
  185. // a.push(`<a class="btn btn-link btn-click-show-open" style="color: #00a2ff;" data-id="${order.id}" data-open="${order.open_uploaded}">查看资料</a>`)
  186. return `<div style="max-width: 200px;text-align: left;" class="break-words">${a.join('')}</div>`
  187. },width:'15%',valign:'top',align:'left'},
  188. {field: 'create_time', title: __('生产信息'),operate: false,formatter(_,order){
  189. let a=[]
  190. a.push(`<div class="btn-order_link" data-link="${order.name}">生产号码:</div>`)
  191. a.push(`<div class="btn-order_link" data-link="${order.phone}">订单来源:</div>`)
  192. a.push(`<div class="btn-order_link" data-link="${order.address}">物流名称:</div>`)
  193. a.push(`<div>物流单号:</div>`)
  194. a.push(`<div>物流状态:</div>`)
  195. // a.push(`<a class="btn btn-link btn-click-show-open" style="color: #00a2ff;" data-id="${order.id}" data-open="${order.open_uploaded}">查看资料</a>`)
  196. return `<div style="max-width: 200px;text-align: left;" class="break-words">${a.join('')}</div>`
  197. },width:'15%',valign:'top',align:'left'},
  198. {field: 'remark', title: '备注',operate: 'false', formatter(_,order) {
  199. let a=[]
  200. a.push(`<div>${order.remark}</div>`)
  201. a.push(`<a class="btn btn-info btn-xs btn-sub-remark" data-id="${order.id}">备注</a>`)
  202. return `<div style="text-align: left;font-size: 10px;max-width: 200px;" class="break-words">${a.join('')}</div>`
  203. },width:'10%'},
  204. // {field: 'failure_reason', title: '失败原因',operate: 'false',width:'10%'},
  205. {field: 'failure_reason', title: __('失败原因'), operate: false,align:'left', class: 'autocontent', formatter: Table.api.formatter.content},
  206. // {field: 'title', title: __('Title'), operate: 'LIKE',align:'left', class: 'autocontent', formatter: Table.api.formatter.content},
  207. // {field: 'remark', title: '失败原因&备注',formatter: Table.api.formatter.datetime,addClass:'datetimerange',operate: 'range'},
  208. {field: 'trans_no', title: __('Trans_no'),visible: false,operate: "like"},
  209. {
  210. field: 'operate',
  211. title: __('Operate'),
  212. table: table,
  213. width: '5%',
  214. events: Table.api.events.buttons,
  215. formatter: Table.api.formatter.buttons,
  216. buttons:[
  217. {
  218. name: 'detail',
  219. text: '订单详情',
  220. title: '订单详情',
  221. classname: 'btn btn-xs btn-info btn-dialog',
  222. url: 'Produceorder/detail',
  223. extend:'data-area=\'["40%","90%"]\' data-toggle=\'tooltip\'',
  224. // icon:'fa fa-pencil',
  225. callback: function (data) {
  226. Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  227. // $('.btn-refresh').trigger('click')
  228. },
  229. visible: function (row) {
  230. //返回true时按钮显示,返回false隐藏
  231. return true;
  232. }
  233. },
  234. {
  235. name: 'edie',
  236. text: __('修改订单'),
  237. title: __('修改订单'),
  238. classname: 'btn btn-xs btn-info btn-dialog period',
  239. url: 'Produceorder/edit?a=1',
  240. callback: function (data) {
  241. },
  242. visible: function (row) {
  243. if(row['is_cancel'] == '0'){
  244. return true;
  245. }
  246. return false;
  247. }
  248. },
  249. // {
  250. // name:'detail',
  251. // title:'查看物流',
  252. // text: __('查看物流'),
  253. // classname: 'btn btn-xs btn-danger btn-dialog',
  254. // url: 'Produceorder/see_logistics?a=1',
  255. // visible:(row)=>{
  256. // return $('#table').data('see_logistics') && row.trans_id>0 && row.trans_no
  257. // }
  258. // },
  259. {
  260. name: 'copy',
  261. title: __('上传资料链接'),
  262. text: __('上传资料链接'),
  263. classname: 'btn btn-xs btn-info btn-copy-obj',
  264. click: function (data,row) {
  265. },
  266. visible: function (row) {
  267. if(row['is_cancel'] == '0'){
  268. return true;
  269. }
  270. return false;
  271. }
  272. },
  273. {
  274. name: 'resubmit',
  275. title: __('再次提交'),
  276. text: __('再次提交'),
  277. classname: 'btn btn-xs btn-success btn-magic btn-ajax',
  278. confirm: '确认再次提交吗?',
  279. url: 'produceorder/resubmit',
  280. success: function (data, ret) {
  281. Layer.alert('操作成功');
  282. //如果需要阻止成功提示,则必须使用return false;
  283. //return false;
  284. },
  285. error: function (data, ret) {
  286. console.log(data, ret);
  287. Layer.alert(ret.msg);
  288. return false;
  289. },
  290. visible: function (row) {
  291. if(row['is_cancel'] == '0'){
  292. return true;
  293. }
  294. return false;
  295. }
  296. },
  297. {
  298. name: 'cancel',
  299. title: __('取消订单'),
  300. text: __('取消订单'),
  301. classname: 'btn btn-xs btn-success btn-magic btn-ajax',
  302. confirm: '确定要取消订单吗?',
  303. url: 'produceorder/cancel',
  304. success: function (data, ret) {
  305. Layer.alert('取消成功');
  306. table.bootstrapTable('refresh');
  307. //如果需要阻止成功提示,则必须使用return false;
  308. //return false;
  309. },
  310. error: function (data, ret) {
  311. console.log(data, ret);
  312. Layer.alert(ret.msg);
  313. return false;
  314. },
  315. visible: function (row) {
  316. if(row['is_cancel'] == '0'){
  317. return true;
  318. }
  319. return false;
  320. }
  321. },
  322. ]
  323. }
  324. ]
  325. if(!adminInfo.is_manager){
  326. Table.api.removeColumn('operation_log',columns)
  327. Table.api.removeColumn('anchor.name',columns)
  328. Table.api.removeColumn('s_id',columns)
  329. Table.api.removeColumn('admin.admin_id',columns)
  330. }
  331. // 初始化表格
  332. table.bootstrapTable({
  333. url: $.fn.bootstrapTable.defaults.extend.index_url,
  334. pk: 'id',
  335. sortName: 'id',
  336. search:false,
  337. searchFormVisible:true,
  338. columns: [
  339. columns
  340. ],
  341. fixedColumns:true,
  342. fixedRightNumber:1,
  343. onLoadSuccess(a){
  344. tableData=a.rows
  345. $('.btn-export').attr('href',a.link).show()
  346. // 角标
  347. let arr1 = [];let status_all=0;
  348. a.status_list.forEach(function(item, index) {
  349. $(".nav li .nav_id_"+item.status).text(item.total);
  350. arr1.push(item.status);
  351. status_all = status_all+item.total;
  352. });
  353. // 全部
  354. $(".nav li .nav_id_all").text(status_all);
  355. // 无数据的置0
  356. let arr2 = [0,10,15,17,20,25,30,50,60,70,80,90];
  357. let diff=arr2.filter(item=>arr1.indexOf(item)==-1);
  358. diff.forEach(function (i,k){
  359. $(".nav li .nav_id_"+i).text(0);
  360. });
  361. $(".nav li .nav_id_10").text(a.status_10_count);
  362. /*table.find('thead').css('position','fixed').css('background','white').css('top','370px')
  363. table.css('margin-top',41)
  364. table.find('tbody>tr:first-child>td').each((a,b)=>{
  365. table.find('thead tr th').eq(a).css('width',b.offsetWidth).css('max-width',b.offsetWidth)
  366. })*/
  367. }
  368. });
  369. // 为表格绑定事件
  370. Table.api.bindevent(table);
  371. /* let innerHeight=window.innerHeight
  372. $('.fixed-table-container').css('height',`${innerHeight-420}px`)
  373. window.addEventListener('resize',function (){
  374. let innerHeight=window.innerHeight
  375. $('.fixed-table-container').css('height',`${innerHeight-420}px`)
  376. })*/
  377. },
  378. add: function () {
  379. Controller.api.bindevent();
  380. },
  381. multi_edit: function () {
  382. Controller.api.bindevent();
  383. },
  384. edit: function () {
  385. Controller.api.bindevent();
  386. $(document).on('input propertychange','#c-trans_no',function (){
  387. let no=$(this).val()
  388. if(!no){
  389. return
  390. }
  391. Form.api.guessLogistics(no,'#c-trans_id')
  392. })
  393. },
  394. add_operation(){
  395. Controller.api.bindevent();
  396. $('#c-no').focus()
  397. },
  398. sub_remark(){
  399. Controller.api.bindevent();
  400. $('#c-no').focus()
  401. },
  402. set_anchor(){
  403. Controller.api.bindevent();
  404. },
  405. refund(){
  406. Controller.api.bindevent();
  407. },
  408. mobile_up(){
  409. Controller.api.bindevent()
  410. if(!row){
  411. Fast.api.close({say:'此号码已被删除,无法上架'})
  412. }else if(row.status===0){
  413. //Fast.api.close({say:'此号码已是上架状态'})
  414. }
  415. },
  416. send(){
  417. Controller.api.bindevent();
  418. $(document).on('input propertychange','#c-trans_no',function (){
  419. let no=$(this).val()
  420. if(!no){
  421. return
  422. }
  423. Form.api.guessLogistics(no,'#c-trans_id')
  424. })
  425. },
  426. show_open_data(){
  427. Controller.api.bindevent()
  428. },
  429. api: {
  430. bindevent: function () {
  431. Form.api.bindevent($("form[role=form]"));
  432. }
  433. },
  434. refund_log(){
  435. Table.api.init();
  436. var table = $("#table");
  437. let columns=[
  438. //{field:'id',title:'ID',operate:false},
  439. {field:'od.mobile_id',title:'商品ID',operate:'='},
  440. {field:'od.s_id',title:'代理商ID',operate:'='},
  441. {field:'od.order_no',title:'订单号',operate:'='},
  442. {field:'od.no',title:'手机号',operate:'like'},
  443. {field:'pass',title:'审核状态',searchList:{1:'通过',0:'驳回'},formatter: Table.api.formatter.label},
  444. {field:'reason',title:'备注',formatter: Table.api.formatter.content,width:200},
  445. {field:'od.amount',title:'订单金额',operate:'between'},
  446. {field:'amount_backend',title:'退款金额',operate:'between'},
  447. {field:'create_time',title:'创建时间',operate:'range',addClass:'datetimerange',formatter:Table.api.formatter.datetime},
  448. {field:'admin.nickname',title:' 操作员',operate:'like'},
  449. ];
  450. if(!admin.is_manager){
  451. Table.api.removeColumn('od.s_id',columns)
  452. }
  453. table.bootstrapTable({
  454. url: 'Produceorder/refund_log',
  455. pk: 'id',
  456. sortName: 'id',
  457. search:false,
  458. searchFormVisible:true,
  459. columns: columns,
  460. onLoadSuccess(a){
  461. }
  462. });
  463. Table.api.bindevent(table);
  464. }
  465. };
  466. return Controller;
  467. });