123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: async function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'mobile_order_flow/index' + location.search,
- add_url: 'mobile_order_flow/add',
- edit_url: 'mobile_order_flow/edit',
- del_url: 'mobile_order_flow/del',
- multi_url: 'mobile_order_flow/multi',
- import_url: 'mobile_order_flow/import',
- table: 'mobile_order',
- show_open_data_url: 'mobile_order_flow/show_open_data',
- }
- });
- var table = $("#table");
- let status = await $.getJSON('mobile_order_flow/status')
- let statusColor={};
- let colors=['label-default','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'];
- Object.keys(status).forEach((item,idx)=>{
- statusColor[item]=colors[idx];
- });
- statusColor[50]='label-default';
- let payType = await $.getJSON('mobile_order/pay_type')
- table.on('load-success.bs.table', function (_, data) {
- let e=data.extend;
- });
- $(document).on('click','.btn-sub-remark',function (){
- let id=$(this).data('id')
- let url=table.data('url-sub-remark')+`/id/${id}`
- Fast.api.open(url,'备注')
- })
- $(document).on('click','.btn-click-show-open',function (){
- if(!$(this).data('open')){
- parent.layer.msg('该用户未上传开卡资料')
- return
- }
- Fast.api.open($.fn.bootstrapTable.defaults.extend.show_open_data_url+'/id/'+$(this).data('id'),'查看资料',{
- shade:.3,
- shadeClose:false,
- })
- })
- let columns=[
- //{checkbox: true},
- {field: 'id', title: __('ID'),operate:false,},
- {field: 'order_no', title: __('订单号'),visible:false,operate: 'like'},
- {field: 'pay_no', title: __('支付单号'),visible: false,operate: '='},
- {field: 'mobile.name', title: __('商品信息'),visible:false,operate: 'like'},
- {field: 'mobile.product_no', title: __('产品编码'),visible:false,operate: '='},
- {field: 's_id', title: __('来源渠道'),formatter(_, order) {
- let a=[]
- a.push(`<div>${order.s_id}</div>`);
- a.push(`<div>${order.s_name}</div>`);
- return a.join('')
- },searchList: subs,width: 100},
- {field: 'pay_type', title: __('支付方式'),searchList: payType,visible: false},
- {field: 'pay_mid_wechat', title: __('微信商户号'),visible: false,operate: 'LIKE'},
- {field: 'pay_mid_alipay', title: __('支付宝商户号'),visible: false,operate: 'LIKE'},
- {field: 'pay_mid_dy', title: __('抖音商户号'),visible: false,operate: 'LIKE'},
- {field: 'pay_mid_ks', title: __('快手商户号'),visible: false,operate: 'LIKE'},
- {field: 'name', title: __('收货人'),visible: false,operate: 'LIKE'},
- {field: 'phone', title: __('收货人手机'),visible: false,operate: 'LIKE'},
- {field: 'id_no', title: __('收货人身份证'),visible: false,operate: "like"},
- {field: 'order_no', title: __('订单信息'),operate: false,formatter(_,order){
- let a=[], product_no = '', product_brand = brands[order.brand];
- if(order.info.mobile.product_no && order.info.mobile.product_no != undefined){
- product_no = order.info.mobile.product_no;
- }
- if(order.info.mobile.logo){
- a.push(`<div><img src="${order.info.mobile.logo}" style="width: 50px;height: 50px;object-fit: cover;" alt="${order.name}"></div>`)
- }
- a.push(`<div>订单号:<b>${order.order_no}</b></div>`)
- if(order.pay_no){
- a.push(`<div>支付单号:<b>${order.pay_no}</b></div>`)
- }
- if(product_brand == undefined){
- product_brand = order.brand;
- }
- a.push(`<div>产品编码:<b>${product_no}</b></div>`)
- a.push(`<div>商品信息:<b>${order.info.mobile.name}</b></div>`)
- a.push(`<div>运营商:${product_brand}</div>`)
- a.push(`<div>商品名称:${order.info.mobile.name}</div>`)
- a.push(`<div>套餐:${order.info?order.info.mobile.summary:''}</div>`)
- return `<div class="break-words" style="width: inherit;">${a.join('')}</div>`
- },width:300,align:'left',valign:'top'},
- {
- field:'amount',
- title:'支付信息',
- operate: false,
- align:'left',
- valign: 'top',
- width: 125,
- formatter(_, order) {
- let a=[]
- a.push(`<div><b>支付金额:${order.amount}</b></div>`)
- a.push(`<div>支付方式:${payType[order.pay_type]}</div>`)
- return a.join('')
- }
- },
- {field: 'order_no', title: __('收货人'),operate: false,formatter(_,order){
- let a=[]
- a.push(`<div>收货人:${order.name}</div>`)
- a.push(`<div>手机号:${order.phone}<span style="color: red;">(${order.phone_order_flow_count})</span></div>`)
- a.push(`<div>地址:${order.address}</div>`)
- a.push(`<div>备注:${order.remark}</div>`)
- a.push(`<div>快递名称:${order.trans_name||''}</div>`)
- a.push(`<div>快递单号:${order.trans_no||''}</div>`)
- 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>`)
- // if(order.open_idcard_face_img){
- // a.push(`<img src="${order.open_idcard_face_img}" style="width: 50px;height: 50px;object-fit: cover;" alt="${order.name}">`)
- // }
- // if(order.open_idcard_back_img){
- // a.push(`<img src="${order.open_idcard_back_img}" style="width: 50px;height: 50px;object-fit: cover;" alt="${order.name}">`)
- // }
- // if(order.open_face_img){
- // a.push(`<img src="${order.open_face_img}" style="width: 50px;height: 50px;object-fit: cover;" alt="${order.name}">`)
- // }
- return `<div style="width: 200px;" class="break-words">${a.join('')}</div>`
- },width:200,align:'left',valign:'top'},
- {field: 'order_no', title: __('生产信息'),operate: false,formatter(_,order){
- let a=[], product_no = '';
- a.push(`<div>生产号码:${order.gantanhao_data_notify?order.gantanhao_data_notify.plan_mobile_produced:''}</div>`)
- return `<div class="break-words" style="width: inherit;">${a.join('')}</div>`
- },width:140,align:'left',valign:'top'},
- {field: 'status', title: __('Status'),formatter(a,order){
- if(a===30) {
- return `<span class="label label-primary">${status[order.status_bak]||''}-${status[a]}</span>`;
- }
- return `<span class="label ${statusColor[a]}">${status[a]}</span>`
- },searchList:status},
- {field: 'gantanhao_status', title: __('运营商结果'),formatter(a,order){
- var str = '';
- if(order.gantanhao_data_notify && order.status == '110' && order.gantanhao_data_notify.reason != undefined){
- str = `<div style="width: 200px;" class="break-words">${order.gantanhao_data_notify.reason}</div>`;
- }
- return str;
- },searchable:false},
- {field: 'anchor.name', title:__('主播名称') ,searchList(){return Template('anchor-search',{});},width:100,formatter:Table.api.formatter.width},
- {field: 'sub_anchor.mobile_anchor.name', title: __(adminInfo.is_sub?'主播名称':'分站主播'),searchList(){return Template('anchor-sub-search',{});},width:100,formatter:Table.api.formatter.width},
- {field: 'sub_log', title: __(adminInfo.is_manager?'分站备注':'备注'),formatter(_,order){
- let a=[]
- order.sub_remark.forEach(item=>{
- 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>`)
- })
- if(table.data('auth-url-sub-remark')) {
- a.push(`<a class="btn btn-info btn-xs btn-sub-remark" data-id="${order.id}">备注</a>`)
- }
- return `<div style="text-align: left;font-size: 10px;width: 200px;" class="break-words">${a.join('')}</div>`
- },operate:false,valign:'top',align:'left',width:200},
- {field: 'operation_log', title: __('客服记录'),formatter(_,order){
- let a=[]
- order.operation.forEach(item=>{
- 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>`)
- })
- return `<div style="text-align: left;font-size: 10px;width: 200px;white-space: break-spaces;">${a.join('')}</div>`
- },operate:false,align:'left',valign:'top',width: 200},
- {field: 'admin.admin_id', title: __('操作员'),formatter(_,order){
- let a=[]
- order.admin.forEach(item=>{
- a.push(`<div>${item.admin.nickname}</div>`)
- })
- return `<div style="text-align: left;font-size: 10px;width: 100px;">${a.join('')}</div>`
- },operate:"=",searchList: admins,align:'left',valign:'top',width: 100},
- {field: 'create_time', title: __('创建时间'),formatter: Table.api.formatter.datetime,addClass:'datetimerange',operate: 'range'},
- {field: 'update_time', title: __('更新时间'),formatter: Table.api.formatter.datetime,addClass:'datetimerange',operate: 'range'},
- {field: 'trans_no', title: __('快递单号'),visible: false},
- {
- field: 'operate',
- title: __('Operate'),
- table: table,
- events: Table.api.events.buttons,
- formatter: Table.api.formatter.buttons,
- buttons:[
- {
- name: 'detail',
- text: __('设置主播'),
- title: __('设置主播'),
- classname: 'btn btn-xs btn-info btn-dialog period',
- url: table.data('url-set_anchor'),
- callback: function (data) {
- },
- visible: function (row) {
- return $('#table').data('auth-set_anchor');
- }
- },
- {
- name: 'detail',
- text: __('添加备注'),
- title: __('添加备注'),
- classname: 'btn btn-xs btn-info btn-dialog',
- url: 'mobile_order_flow/add_operation?a=1',
- callback: function (data) {
- },
- visible: function (row) {
- return $('#table').data('add_operation');
- }
- },
- {
- name: 'detail',
- text: __('编辑'),
- title: __('编辑'),
- classname: 'btn btn-xs btn-info btn-dialog',
- url: 'mobile_order_flow/edit?a=1',
- callback: function (data) {
- },
- visible: function (row) {
- return $('#table').data('operate-edit');
- }
- },
- {
- name: 'detail',
- text: __('发货'),
- title: __('发货'),
- classname: 'btn btn-xs btn-info btn-dialog period',
- url: 'mobile_order_flow/send?a=1',
- callback: function (data) {
- },
- visible: function (row) {
- return $('#table').data('mobile_order_send') && row.status>0;
- }
- },
- {
- name: '重新提交',
- text: __('重新提交'),
- title: __('重新提交'),
- classname: 'btn btn-xs btn-info btn-ajax',
- url: 'mobile_order_flow/reSubmit?a=1',
- refresh: true,
- callback: function (data) {
- },
- visible: function (row) {
- return row.status==10;
- }
- },
- {
- name:'detail',
- title:'查看物流',
- text: __('查看物流'),
- classname: 'btn btn-xs btn-danger btn-dialog',
- url: 'mobile_order/see_logistics?a=1',
- visible:(row)=>{
- return $('#table').data('see_logistics') && row.trans_id>0 && row.trans_no
- }
- },
- {
- name: 'detail',
- text: __('抖音结算'),
- title: __('抖音结算'),
- classname: 'btn btn-xs btn-success btn-ajax',
- url: 'mobile_order/dy_settle',
- confirm:'确认结算吗?',
- callback: function (data) {
- },
- visible: function (row) {
- return $('#table').data('auth-dy_settle') && row.pay_type===4 && row.pay_time>0 && row.payment && row.payment.settle_status===0;
- },
- disable(row){
- }
- },
- {
- name: 'detail',
- text: __('退款'),
- title: __('退款'),
- classname: 'btn btn-xs btn-danger btn-dialog period',
- url: 'mobile_order/refund?a=1',
- callback: function (data) {
- },
- visible: function (row) {
- return $('#table').data('mobile_order_refund') && row.status>0 && row.status==10 && row.amount>0;
- }
- },
- ]
- }
- ]
- if(adminInfo.is_sub){
- Table.api.removeColumn('operation_log',columns)
- Table.api.removeColumn('anchor.name',columns)
- Table.api.removeColumn('sub',columns)
- Table.api.removeColumn('admin.admin_id',columns)
- Table.api.removeColumn('s_id',columns)
- }
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- searchFormVisible:true,
- search:false,
- fixedColumns:true,
- fixedRightNumber:1,
- columns: [
- columns
- ],
- onLoadSuccess(a){
- $('.btn-export').attr('href',a.link).show();
-
- let arr1 = [];let status_all=0;
- a.status_list.forEach(function(item, index) {
- $(".nav li .nav_id_"+item.status).text(item.total);
- arr1.push(item.status);
- status_all = status_all+item.total;
- });
- // 全部
- $(".nav li .nav_id_all").text(status_all);
- // 无数据的置0
- let arr2 = [0,10,15,20,23,25,30,50,90,110];
- let diff=arr2.filter(item=>arr1.indexOf(item)==-1);
- diff.forEach(function (i,k){
- $(".nav li .nav_id_"+i).text(0);
- });
-
- /*table.find('thead').css('position','fixed').css('background','white').css('top','365px')
- table.css('margin-top',41)
- table.find('tbody>tr:first-child>td').each((a,b)=>{
- table.find('thead tr th').eq(a).css('width',b.offsetWidth).css('max-width',b.offsetWidth)
- table.find('thead tr th .th-inner').eq(a).css('width',b.offsetWidth)
- })*/
- }
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- /*let innerHeight=window.innerHeight
- $('.fixed-table-container').css('height',`${innerHeight-420}px`)
- window.addEventListener('resize',function (){
- let innerHeight=window.innerHeight
- $('.fixed-table-container').css('height',`${innerHeight-420}px`)
- })*/
- },
- edit: function () {
- Controller.api.bindevent();
- $(document).on('input propertychange','#c-trans_no',function (){
- let no=$(this).val()
- if(!no){
- return
- }
- Form.api.guessLogistics(no,'#c-trans_id')
- })
- },
- add_operation(){
- Controller.api.bindevent();
- },
- sub_remark(){
- Controller.api.bindevent();
- $('#c-no').focus()
- },
- send(){
- Controller.api.bindevent();
- $(document).on('input propertychange','#c-trans_no',function (){
- let no=$(this).val()
- if(!no){
- return
- }
- Form.api.guessLogistics(no,'#c-trans_id')
- })
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|