produceorder.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  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. table: 'Produceorder',
  16. }
  17. });
  18. var table = $("#table");
  19. table.on('post-common-search.bs.table', function (event, table) {
  20. var form = $("form", table.$commonsearch);
  21. $("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");
  22. Form.events.cxselect(form);
  23. Form.events.selectpage(form);
  24. });
  25. let is_proxy = Config.is_proxy;
  26. let is_proxy_operate = false;
  27. let is_proxy_operate_eq = false;
  28. if(is_proxy==0){
  29. is_proxy_operate = 'LIKE';
  30. is_proxy_operate_eq = '=';
  31. }
  32. let clip=new clipboard('.btn-pay_link',{
  33. text(a){
  34. let link=$(a).data('link')
  35. return link
  36. }
  37. })
  38. clip.on('success',function (){
  39. parent.layer.msg('复制成功')
  40. })
  41. //订单信息复制
  42. let order_clip=new clipboard('.btn-order_link',{
  43. text(a){
  44. // let link=$(a).data('link').replace(/<[^>]*>/g, '')
  45. let link=$(a).data('link');
  46. // console.log(JSON.stringify(link));
  47. return link + ''
  48. }
  49. })
  50. console.log(order_clip,'22222222')
  51. order_clip.on('success',function (){
  52. console.log(order_clip);
  53. parent.layer.msg('复制成功')
  54. })
  55. let status = await $.getJSON('Produceorder/status');
  56. let statusColor={};
  57. 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'];
  58. Object.keys(status).forEach((item,idx)=>{
  59. statusColor[item]=colors[idx];
  60. });
  61. statusColor[50]='label-default';
  62. let payType = await $.getJSON('Produceorder/pay_type');
  63. let mobileRules = await $.getJSON('mobile/mobile_rules');
  64. table.on('load-success.bs.table', function (_, data) {
  65. let e=data.extend;
  66. $('#orderAmount').html(`收入:${e.total},支付宝:${e.alipay},微信:${e.wechat},抖音:${e.dy},快手:${e.ks},成本:${e.di},利润:${e.profit},退款:${e.refund}`)
  67. });
  68. $(document).on('click','.btn-click-show-open',function (){
  69. if($(this).data('open')!==1){
  70. parent.layer.msg('该用户未上传开卡资料')
  71. return
  72. }
  73. Fast.api.open($.fn.bootstrapTable.defaults.extend.show_open_data_url+'/id/'+$(this).data('id'),'查看资料',{
  74. shade:.3,
  75. shadeClose:false,
  76. })
  77. })
  78. $(document).on('click','.btn-sub-remark',function (){
  79. let id=$(this).data('id')
  80. let url=table.data('url-sub-remark')+`/id/${id}`
  81. Fast.api.open(url,'备注')
  82. })
  83. let columns=[
  84. //{checkbox: true},
  85. {field: 'id', title: __('ID'),operate:false,},
  86. {field: 'order_no', title: __('订单号'),visible:false,operate: 'like'},
  87. {field: 'pay_no', title: __('支付单号'),visible: false,operate: '='},
  88. {field: 'pay_type', title: __('支付方式'),searchList: payType,visible: false, operate: is_proxy_operate},
  89. {field: 'no', title: __('手机号'),visible: false,operate: 'LIKE'},
  90. {field: 'phone', title: __('收货人手机'),visible: false,operate: 'LIKE'},
  91. {field: 'name', title: __('收货人'),visible: false,operate: 'LIKE'},
  92. {field: 'id_no', title: __('收货人身份证'),visible: false,operate: "like"},
  93. {field: 'pay_mid_wechat', title: __('微信商户号'),visible: false, operate: is_proxy_operate},
  94. {field: 'pay_mid_alipay', title: __('支付宝商户号'),visible: false,operate: is_proxy_operate},
  95. {field: 'pay_mid_dy', title: __('抖音商户号'),visible: false,operate: is_proxy_operate},
  96. {field: 'pay_mid_ks', title: __('快手商户号'),visible: false,operate: is_proxy_operate},
  97. {field: 'order_no', title: __('订单信息'),operate: false,formatter(_,order){
  98. let a=[]
  99. a.push(`<div>订单号:<b class="btn-order_link" data-link="${order.order_no}">${order.order_no}</b></div>`)
  100. if(order.pay_no){
  101. a.push(`<div>支付单号:<b class="btn-order_link" data-link="${order.pay_no}">${order.pay_no}</b></div>`)
  102. }
  103. a.push(`<div class="btn-order_link" data-link="${order.no}"><b>商品信息:${order.no}</b></div>`)
  104. // a.push(`<div>归属地:${order.info.mobile.province}/${order.info.mobile.city}</div>`)
  105. if(adminInfo.is_manager){
  106. a.push(`<div>供应商:${order.proxy?order.proxy.nickname:''}</div>`)
  107. }
  108. // a.push(`<div>运营商:${order.info?order.info.mobile.network:''}</div>`)
  109. a.push(`<div>卡品牌:${order.brand}</div>`)
  110. if(showAmountDi && is_proxy==0) {
  111. a.push(`<div class="btn-order_link" data-link="${order}">底价:${order.amount_di}</div>`)
  112. }
  113. a.push(`<div class="btn-order_link" data-link="${order.amount_charge}">预存:${order.amount_charge}</div>`)
  114. if(is_proxy == 0 ) {
  115. // 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>`)
  116. a.push(`<div class="btn-order_link" data-link="${order.amount}">订单价格:${order.amount}</div>`)
  117. }
  118. // a.push(`<div class='btn-order_link' data-link="${order.info.info.describe}">套餐:${order.info?order.info.info.describe:''}</div>`)
  119. // a.push(`<div>备注:${order.info?order.info.mobile.remark:''}</div>`)
  120. // a.push(`<a class="btn btn-success btn-sm btn-order_link" data-link="${a.join('')}">点击复制</a>`)
  121. return `<div style="max-width: 250px;word-wrap: break-word;word-break: break-all;white-space: normal;text-align: left;">${a.join('')}</div>`
  122. },width:250,valign:'top',align:'left'},
  123. {field: 'order_no', title: __('收货人'),operate: false,formatter(_,order){
  124. let a=[]
  125. a.push(`<div class="btn-order_link" data-link="${order.name}">收货人:${order.name}</div>`)
  126. a.push(`<div class="btn-order_link" data-link="${order.phone}">手机号:${order.phone}<span style="color: red;">(${order.phone_order_count})</span></div>`)
  127. a.push(`<div class="btn-order_link" data-link="${order.address}">地址:${order.address}</div>`)
  128. if(is_proxy == 0 ) {
  129. a.push(`<div>支付方式:${payType[order.pay_type]}</div>`)
  130. // a.push(`<div>微信商户号:<span style="color: #00b578;">${order.pay_mid_wechat}</span></div>`)
  131. // a.push(`<div>支付宝商户号:<span style="color: #0d6aad;">${order.pay_mid_alipay}</span></div>`)
  132. // a.push(`<div>抖音商户号:<span style="color: #0d6aad;">${order.pay_mid_dy}</span></div>`)
  133. // a.push(`<div>快手商户号:<span style="color: #0d6aad;">${order.pay_mid_ks}</span></div>`)
  134. }
  135. a.push(`<div>备注:${order.remark}</div>`)
  136. a.push(`<div>快递名称:${order.trans_name}</div>`)
  137. a.push(`<div>快递单号:${order.trans_no}</div>`)
  138. a.push(`<a class="btn btn-link btn-click-show-open" style="color: #00a2ff;" data-id="${order.id}" data-open="${order.open_uploaded}">查看资料</a>`)
  139. return `<div style="max-width: 200px;text-align: left;" class="break-words">${a.join('')}</div>`
  140. },width:200,valign:'top',align:'left'},
  141. {field: 'create_time', title: __('订单状态'),operate: false,formatter(_,order){
  142. let a=[]
  143. a.push(`<div class="btn-order_link" data-link="${order.name}">订单状态:</div>`)
  144. a.push(`<div class="btn-order_link" data-link="${order.phone}">激活状态:</div>`)
  145. a.push(`<div class="btn-order_link" data-link="${order.address}">是否首充:</div>`)
  146. a.push(`<div>首充金额:</div>`)
  147. a.push(`<div>创建时间:${order.create_time}</div>`)
  148. a.push(`<div>更新时间:${order.update_time}</div>`)
  149. // a.push(`<a class="btn btn-link btn-click-show-open" style="color: #00a2ff;" data-id="${order.id}" data-open="${order.open_uploaded}">查看资料</a>`)
  150. return `<div style="max-width: 200px;text-align: left;" class="break-words">${a.join('')}</div>`
  151. },width:200,valign:'top',align:'left'},
  152. {field: 'create_time', title: __('生产信息'),operate: false,formatter(_,order){
  153. let a=[]
  154. a.push(`<div class="btn-order_link" data-link="${order.name}">生产号码:</div>`)
  155. a.push(`<div class="btn-order_link" data-link="${order.phone}">订单来源:</div>`)
  156. a.push(`<div class="btn-order_link" data-link="${order.address}">物流名称:</div>`)
  157. a.push(`<div>物流单号:</div>`)
  158. a.push(`<div>物流状态:</div>`)
  159. // a.push(`<a class="btn btn-link btn-click-show-open" style="color: #00a2ff;" data-id="${order.id}" data-open="${order.open_uploaded}">查看资料</a>`)
  160. return `<div style="max-width: 200px;text-align: left;" class="break-words">${a.join('')}</div>`
  161. },width:200,valign:'top',align:'left'},
  162. {field: 'remark', title: '失败原因&备注',operate: 'range'},
  163. // {field: 'remark', title: '失败原因&备注',formatter: Table.api.formatter.datetime,addClass:'datetimerange',operate: 'range'},
  164. {field: 'trans_no', title: __('Trans_no'),visible: false,operate: "like"},
  165. {
  166. field: 'operate',
  167. title: __('Operate'),
  168. table: table,
  169. events: Table.api.events.buttons,
  170. formatter: Table.api.formatter.buttons,
  171. buttons:[
  172. {
  173. name: 'detail',
  174. text: __('编辑'),
  175. title: __('编辑'),
  176. classname: 'btn btn-xs btn-info btn-dialog period',
  177. url: 'Produceorder/edit?a=1',
  178. callback: function (data) {
  179. },
  180. visible: function (row) {
  181. return $('#table').data('add_operation');
  182. }
  183. },
  184. // {
  185. // name: 'detail',
  186. // text: __('退款'),
  187. // title: __('退款'),
  188. // classname: 'btn btn-xs btn-danger btn-dialog period',
  189. // url: 'mobile_order/refund?a=1',
  190. // callback: function (data) {
  191. // },
  192. // visible: function (row) {
  193. // return $('#table').data('mobile_order_refund') && row.status>0 && row.status!=90;
  194. // }
  195. // },
  196. // {
  197. // name: 'detail',
  198. // text: __('发货'),
  199. // title: __('发货'),
  200. // classname: 'btn btn-xs btn-info btn-dialog period',
  201. // url: 'mobile_order/send?a=1',
  202. // callback: function (data) {
  203. // },
  204. // visible: function (row) {
  205. // return $('#table').data('mobile_order_send') && row.status>0;
  206. // }
  207. // },
  208. {
  209. name:'detail',
  210. title:'查看物流',
  211. text: __('查看物流'),
  212. classname: 'btn btn-xs btn-danger btn-dialog',
  213. url: 'Produceorder/see_logistics?a=1',
  214. visible:(row)=>{
  215. return $('#table').data('see_logistics') && row.trans_id>0 && row.trans_no
  216. }
  217. },
  218. // {
  219. // name: 'detail',
  220. // text: __('上架'),
  221. // title: __('上架'),
  222. // classname: 'btn btn-xs btn-success btn-dialog period',
  223. // url: 'mobile_order/mobile_up?a=1',
  224. // callback: function (data) {
  225. // if(data && data.say){
  226. // parent.layer.alert(data.say)
  227. // }
  228. // },
  229. // visible: function (row) {
  230. // return $('#table').data('auth-mobile_up') && [90].indexOf(row.status)>-1;
  231. // },
  232. // disable(row){
  233. // return row.mobile_can_up
  234. // }
  235. // },
  236. // {
  237. // name: 'detail',
  238. // text: __('抖音结算'),
  239. // title: __('抖音结算'),
  240. // classname: 'btn btn-xs btn-success btn-ajax',
  241. // url: 'mobile_order/dy_settle',
  242. // confirm:'确认结算吗?',
  243. // callback: function (data) {
  244. // },
  245. // visible: function (row) {
  246. // return $('#table').data('auth-dy_settle') && row.pay_type===4 && row.pay_time>0 && row.payment && row.payment.settle_status===0;
  247. // },
  248. // disable(row){
  249. // }
  250. // },
  251. ]
  252. }
  253. ]
  254. if(!adminInfo.is_manager){
  255. Table.api.removeColumn('operation_log',columns)
  256. Table.api.removeColumn('anchor.name',columns)
  257. Table.api.removeColumn('s_id',columns)
  258. Table.api.removeColumn('admin.admin_id',columns)
  259. }
  260. // 初始化表格
  261. table.bootstrapTable({
  262. url: $.fn.bootstrapTable.defaults.extend.index_url,
  263. pk: 'id',
  264. sortName: 'id',
  265. search:false,
  266. searchFormVisible:true,
  267. columns: [
  268. columns
  269. ],
  270. fixedColumns:true,
  271. fixedRightNumber:1,
  272. onLoadSuccess(a){
  273. $('.btn-export').attr('href',a.link).show()
  274. // 角标
  275. let arr1 = [];let status_all=0;
  276. a.status_list.forEach(function(item, index) {
  277. $(".nav li .nav_id_"+item.status).text(item.total);
  278. arr1.push(item.status);
  279. status_all = status_all+item.total;
  280. });
  281. // 全部
  282. $(".nav li .nav_id_all").text(status_all);
  283. // 无数据的置0
  284. let arr2 = [0,10,15,17,20,25,30,50,60,70,80,90];
  285. let diff=arr2.filter(item=>arr1.indexOf(item)==-1);
  286. diff.forEach(function (i,k){
  287. $(".nav li .nav_id_"+i).text(0);
  288. });
  289. $(".nav li .nav_id_10").text(a.status_10_count);
  290. /*table.find('thead').css('position','fixed').css('background','white').css('top','370px')
  291. table.css('margin-top',41)
  292. table.find('tbody>tr:first-child>td').each((a,b)=>{
  293. table.find('thead tr th').eq(a).css('width',b.offsetWidth).css('max-width',b.offsetWidth)
  294. })*/
  295. }
  296. });
  297. // 为表格绑定事件
  298. Table.api.bindevent(table);
  299. /* let innerHeight=window.innerHeight
  300. $('.fixed-table-container').css('height',`${innerHeight-420}px`)
  301. window.addEventListener('resize',function (){
  302. let innerHeight=window.innerHeight
  303. $('.fixed-table-container').css('height',`${innerHeight-420}px`)
  304. })*/
  305. },
  306. add: function () {
  307. Controller.api.bindevent();
  308. },
  309. edit: function () {
  310. Controller.api.bindevent();
  311. $(document).on('input propertychange','#c-trans_no',function (){
  312. let no=$(this).val()
  313. if(!no){
  314. return
  315. }
  316. Form.api.guessLogistics(no,'#c-trans_id')
  317. })
  318. },
  319. add_operation(){
  320. Controller.api.bindevent();
  321. $('#c-no').focus()
  322. },
  323. sub_remark(){
  324. Controller.api.bindevent();
  325. $('#c-no').focus()
  326. },
  327. set_anchor(){
  328. Controller.api.bindevent();
  329. },
  330. refund(){
  331. Controller.api.bindevent();
  332. },
  333. mobile_up(){
  334. Controller.api.bindevent()
  335. if(!row){
  336. Fast.api.close({say:'此号码已被删除,无法上架'})
  337. }else if(row.status===0){
  338. //Fast.api.close({say:'此号码已是上架状态'})
  339. }
  340. },
  341. send(){
  342. Controller.api.bindevent();
  343. $(document).on('input propertychange','#c-trans_no',function (){
  344. let no=$(this).val()
  345. if(!no){
  346. return
  347. }
  348. Form.api.guessLogistics(no,'#c-trans_id')
  349. })
  350. },
  351. show_open_data(){
  352. Controller.api.bindevent()
  353. },
  354. api: {
  355. bindevent: function () {
  356. Form.api.bindevent($("form[role=form]"));
  357. }
  358. },
  359. refund_log(){
  360. Table.api.init();
  361. var table = $("#table");
  362. let columns=[
  363. //{field:'id',title:'ID',operate:false},
  364. {field:'od.mobile_id',title:'商品ID',operate:'='},
  365. {field:'od.s_id',title:'代理商ID',operate:'='},
  366. {field:'od.order_no',title:'订单号',operate:'='},
  367. {field:'od.no',title:'手机号',operate:'like'},
  368. {field:'pass',title:'审核状态',searchList:{1:'通过',0:'驳回'},formatter: Table.api.formatter.label},
  369. {field:'reason',title:'备注',formatter: Table.api.formatter.content,width:200},
  370. {field:'od.amount',title:'订单金额',operate:'between'},
  371. {field:'amount_backend',title:'退款金额',operate:'between'},
  372. {field:'create_time',title:'创建时间',operate:'range',addClass:'datetimerange',formatter:Table.api.formatter.datetime},
  373. {field:'admin.nickname',title:' 操作员',operate:'like'},
  374. ];
  375. if(!admin.is_manager){
  376. Table.api.removeColumn('od.s_id',columns)
  377. }
  378. table.bootstrapTable({
  379. url: 'Produceorder/refund_log',
  380. pk: 'id',
  381. sortName: 'id',
  382. search:false,
  383. searchFormVisible:true,
  384. columns: columns,
  385. onLoadSuccess(a){
  386. }
  387. });
  388. Table.api.bindevent(table);
  389. }
  390. };
  391. return Controller;
  392. });