produceorder.js 23 KB

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