123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form','clipboard'],
- function ($, undefined, Backend, Table, Form,clipboard) {
- var Controller = {
- index: async function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'mobile_order/index' + location.search,
- add_url: 'mobile_order/add',
- edit_url: 'mobile_order/edit',
- del_url: 'mobile_order/del',
- multi_url: 'mobile_order/multi',
- import_url: 'mobile_order/import',
- show_open_data_url: 'mobile_order/show_open_data',
- table: 'mobile_order',
- }
- });
- var table = $("#table");
- table.on('post-common-search.bs.table', function (event, table) {
- var form = $("form", table.$commonsearch);
- $("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");
- Form.events.cxselect(form);
- Form.events.selectpage(form);
- });
- let is_proxy = Config.is_proxy;
- let is_proxy_operate = false;
- let is_proxy_operate_eq = false;
- if(is_proxy==0){
- is_proxy_operate = 'LIKE';
- is_proxy_operate_eq = '=';
- }
- let clip=new clipboard('.btn-pay_link',{
- text(a){
- let link=$(a).data('link')
- return link
- }
- })
- clip.on('success',function (){
- parent.layer.msg('复制成功')
- })
- //订单信息复制
- let order_clip=new clipboard('.btn-order_link',{
- text(a){
- // let link=$(a).data('link').replace(/<[^>]*>/g, '')
- let link=$(a).data('link');
- // console.log(JSON.stringify(link));
- return link + ''
- }
- })
- console.log(order_clip,'22222222')
- order_clip.on('success',function (){
- console.log(order_clip);
- parent.layer.msg('复制成功')
- })
- let status = await $.getJSON('mobile_order/status');
- let statusColor={};
- 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'];
- Object.keys(status).forEach((item,idx)=>{
- statusColor[item]=colors[idx];
- });
- statusColor[50]='label-default';
- let payType = await $.getJSON('mobile_order/pay_type');
- let mobileRules = await $.getJSON('mobile/mobile_rules');
- table.on('load-success.bs.table', function (_, data) {
- let e=data.extend;
- $('#orderAmount').html(`收入:${e.total},支付宝:${e.alipay},微信:${e.wechat},抖音:${e.dy},快手:${e.ks},成本:${e.di},利润:${e.profit},退款:${e.refund}`)
- });
- $(document).on('click','.btn-click-show-open',function (){
- if($(this).data('open')!==1){
- parent.layer.msg('该用户未上传开卡资料')
- return
- }
- Fast.api.open($.fn.bootstrapTable.defaults.extend.show_open_data_url+'/id/'+$(this).data('id'),'查看资料',{
- shade:.3,
- shadeClose:false,
- })
- })
- $(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,'备注')
- })
- 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: 's_id', title: __('来源渠道'),formatter(_, order) {
- let a=[]
- a.push(`<div>${order.s_id}</div>`);
- a.push(`<div>${order.s_name}</div>`);
- return a.join('')
- }},
- // {field: 'anchor.name', title:__('主播名称') ,searchList(){return Template('anchor-sub-search',{});},width: 100},
- {field: 'pay_type', title: __('支付方式'),searchList: payType,visible: false, operate: is_proxy_operate},
- {field: 'no', title: __('手机号'),visible: false,operate: 'LIKE'},
- {field: 'phone', title: __('收货人手机'),visible: false,operate: 'LIKE'},
- {field: 'name', title: __('收货人'),visible: false,operate: 'LIKE'},
- {field: 'id_no', title: __('收货人身份证'),visible: false,operate: "like"},
- {field: 'pay_mid_wechat', title: __('微信商户号'),visible: false, operate: is_proxy_operate},
- {field: 'pay_mid_alipay', title: __('支付宝商户号'),visible: false,operate: is_proxy_operate},
- {field: 'pay_mid_dy', title: __('抖音商户号'),visible: false,operate: is_proxy_operate},
- {field: 'pay_mid_ks', title: __('快手商户号'),visible: false,operate: is_proxy_operate},
- {field: 'order_no', title: __('订单信息'),operate: false,formatter(_,order){
- let a=[]
- a.push(`<div>订单号:<b class="btn-order_link" data-link="${order.order_no}">${order.order_no}</b></div>`)
- if(order.pay_no){
- a.push(`<div>支付单号:<b class="btn-order_link" data-link="${order.pay_no}">${order.pay_no}</b></div>`)
- }
- a.push(`<div class="btn-order_link" data-link="${order.no}"><b>商品信息:${order.no}</b></div>`)
- a.push(`<div>归属地:${order.info.mobile.province}/${order.info.mobile.city}</div>`)
- if(adminInfo.is_manager){
- a.push(`<div>供应商:${order.proxy?order.proxy.nickname:''}</div>`)
- }
- a.push(`<div>运营商:${order.info?order.info.mobile.network:''}</div>`)
- a.push(`<div>卡品牌:${order.brand}</div>`)
- if(showAmountDi && is_proxy==0) {
- a.push(`<div class="btn-order_link" data-link="${order}">底价:${order.amount_di}</div>`)
- }
- a.push(`<div class="btn-order_link" data-link="${order.amount_charge}">预存:${order.amount_charge}</div>`)
- if(is_proxy == 0 ) {
- 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>`)
- a.push(`<div class="btn-order_link" data-link="${order.amount}">订单价格:${order.amount}</div>`)
- }
- a.push(`<div class='btn-order_link' data-link="${order.info.info.describe}">套餐:${order.info?order.info.info.describe:''}</div>`)
- a.push(`<div>备注:${order.info?order.info.mobile.remark:''}</div>`)
- // a.push(`<a class="btn btn-success btn-sm btn-order_link" data-link="${a.join('')}">点击复制</a>`)
- return `<div style="max-width: 250px;word-wrap: break-word;word-break: break-all;white-space: normal;text-align: left;">${a.join('')}</div>`
- },width:250,valign:'top',align:'left'},
- {field: 'order_no', title: __('收货人'),operate: false,formatter(_,order){
- let a=[]
- a.push(`<div class="btn-order_link" data-link="${order.name}">收货人:${order.name}</div>`)
- a.push(`<div class="btn-order_link" data-link="${order.phone}">手机号:${order.phone}<span style="color: red;">(${order.phone_order_count})</span></div>`)
- a.push(`<div class="btn-order_link" data-link="${order.address}">地址:${order.address}</div>`)
- if(is_proxy == 0 ) {
- a.push(`<div>支付方式:${payType[order.pay_type]}</div>`)
- a.push(`<div>微信商户号:<span style="color: #00b578;">${order.pay_mid_wechat}</span></div>`)
- a.push(`<div>支付宝商户号:<span style="color: #0d6aad;">${order.pay_mid_alipay}</span></div>`)
- a.push(`<div>抖音商户号:<span style="color: #0d6aad;">${order.pay_mid_dy}</span></div>`)
- a.push(`<div>快手商户号:<span style="color: #0d6aad;">${order.pay_mid_ks}</span></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_uploaded}">查看资料</a>`)
- return `<div style="max-width: 200px;text-align: left;" class="break-words">${a.join('')}</div>`
- },width:200,valign:'top',align:'left'},
- {field: 'status', title: __('Status'),formatter(a,order){
- if(a===30) {
- return `<span class="label label-primary">${status[order.status_bak]||''}-${status[a]}</span>`
- }
- if(`${status[a]}` == '待付款'){
- return `<span class="label ${statusColor[a]}" style="background-color: green">${status[a]}</span>`
- }
- if(`${status[a]}` == '已完成'){
- return `<span class="label ${statusColor[a]}" style="background-color: RGB(243,156,18)">${status[a]}</span>`
- }
- return `<span class="label ${statusColor[a]}">${status[a]}</span>`
- },searchList:status,operate: is_proxy_operate_eq},
- {field: 'platform_source', title: __('来源'),operate: is_proxy_operate},
- {field: 'anchor.name', title:__('主播名称') ,searchList(){return Template('anchor-search',{});},width: 100},
- {field: 'sub_anchor.mobile_anchor.name', title: __(adminInfo.is_sub?'主播名称':'分站主播'),searchList(){return Template('anchor-sub-search',{});},width: 100,operate: is_proxy_operate,visible:is_proxy_operate},
- {field: 'rules.rule', title: __('规律'),visible: false,searchList:mobileRules},
- {field: '', title: __('退款记录'),formatter(_,order){
- let a=[]
- order.refund_log.forEach(item=>{
- a.push(`<div>${item.create_time_format} ${item.pass?'同意':'驳回'} ${item.reason}</div>`)
- })
- return `<div style="text-align: left;font-size: 10px;" class="break-words">${a.join('')}</div>`
- },operate:false,valign:'top',align:'left',width: 200,visible:is_proxy_operate},
- {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;max-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:'-'}</span> ${item.content}</div>`)
- })
- return `<div style="text-align: left;font-size: 10px;max-width: 200px;" class="break-words">${a.join('')}</div>`
- },operate:false,valign:'top',align:'left',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;">${a.join('')}</div>`
- },operate:"=",searchList: admins,valign:'top',align:'left',width: 100},
- {field: 'pay_link', title: __('付款链接'),formatter(_,order){
- if(order.status!==0){
- return ''
- }
- return `<button class="btn btn-success btn-sm btn-pay_link" data-link="${order.pay_link}">点击复制</button>`
- },operate:false,width: 150,visible:is_proxy_operate},
- {field: 'create_time', title: __('Create_time'),formatter: Table.api.formatter.datetime,addClass:'datetimerange',operate: 'range'},
- //{field: 'update_time', title: __('更新时间'),formatter: Table.api.formatter.datetime,addClass:'datetimerange',operate: 'range'},
- /* {field: 'pay_time', title: __('Pay_time'),formatter: Table.api.formatter.datetime,addClass:'datetimerange',operate: 'range'},
- {field: 'trans_name', title: __('Trans_name')},
- {field: 'trans_no', title: __('Trans_no')},
- {field: 'amount_original', title: __('Amount_original'), operate: 'BETWEEN'},
- {field: 'amount_hd', title: __('Amount_hd'), operate: 'BETWEEN'},
- {field: 'amount_charge', title: __('Amount_charge'), operate: 'BETWEEN'},
- {field: 'amount', title: __('Amount'), operate: 'BETWEEN'},
- {field: 'open_idcard_face_img', title: __('开卡身份证正面照'),formatter: Table.api.formatter.image,events: Table.api.events.image,opera: false},
- {field: 'open_idcard_back_img', title: __('开卡身份证背面照'),formatter: Table.api.formatter.image,events: Table.api.events.image,operate:false},
- {field: 'open_face_img', title: __('开卡人头像'),formatter: Table.api.formatter.image,events: Table.api.events.image,operate:false},
- {field: 'open_name', title: __('开卡人姓名')},
- {field: 'open_id_no', title: __('开卡人身份证号码')},
- {field: 'open_phone', title: __('开卡人手机号')},*/
- {field: 'trans_no', title: __('Trans_no'),visible: false,operate: "like"},
- {
- 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 period',
- url: 'mobile_order/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 period',
- url: 'mobile_order/edit?a=1',
- callback: function (data) {
- },
- visible: function (row) {
- return $('#table').data('add_operation');
- }
- },
- {
- 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!=90;
- }
- },
- {
- name: 'detail',
- text: __('发货'),
- title: __('发货'),
- classname: 'btn btn-xs btn-info btn-dialog period',
- url: 'mobile_order/send?a=1',
- callback: function (data) {
- },
- visible: function (row) {
- return $('#table').data('mobile_order_send') && row.status>0;
- }
- },
- {
- 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-dialog period',
- url: 'mobile_order/mobile_up?a=1',
- callback: function (data) {
- if(data && data.say){
- parent.layer.alert(data.say)
- }
- },
- visible: function (row) {
- return $('#table').data('auth-mobile_up') && [90].indexOf(row.status)>-1;
- },
- disable(row){
- return row.mobile_can_up
- }
- },
- {
- 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){
- }
- },
- ]
- }
- ]
- if(!adminInfo.is_manager){
- Table.api.removeColumn('operation_log',columns)
- Table.api.removeColumn('anchor.name',columns)
- Table.api.removeColumn('s_id',columns)
- Table.api.removeColumn('admin.admin_id',columns)
- }
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- search:false,
- searchFormVisible:true,
- columns: [
- columns
- ],
- fixedColumns:true,
- fixedRightNumber:1,
- 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,17,20,25,30,50,60,70,80,90];
- let diff=arr2.filter(item=>arr1.indexOf(item)==-1);
- diff.forEach(function (i,k){
- $(".nav li .nav_id_"+i).text(0);
- });
- $(".nav li .nav_id_10").text(a.status_10_count);
- /*table.find('thead').css('position','fixed').css('background','white').css('top','370px')
- 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.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`)
- })*/
- },
- add: function () {
- Controller.api.bindevent();
- },
- 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();
- $('#c-no').focus()
- },
- sub_remark(){
- Controller.api.bindevent();
- $('#c-no').focus()
- },
- set_anchor(){
- Controller.api.bindevent();
- },
- refund(){
- Controller.api.bindevent();
- },
- mobile_up(){
- Controller.api.bindevent()
- if(!row){
- Fast.api.close({say:'此号码已被删除,无法上架'})
- }else if(row.status===0){
- //Fast.api.close({say:'此号码已是上架状态'})
- }
- },
- 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')
- })
- },
- show_open_data(){
- Controller.api.bindevent()
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- },
- refund_log(){
- Table.api.init();
- var table = $("#table");
- let columns=[
- //{field:'id',title:'ID',operate:false},
- {field:'od.mobile_id',title:'商品ID',operate:'='},
- {field:'od.s_id',title:'代理商ID',operate:'='},
- {field:'od.order_no',title:'订单号',operate:'='},
- {field:'od.no',title:'手机号',operate:'like'},
- {field:'pass',title:'审核状态',searchList:{1:'通过',0:'驳回'},formatter: Table.api.formatter.label},
- {field:'reason',title:'备注',formatter: Table.api.formatter.content,width:200},
- {field:'od.amount',title:'订单金额',operate:'between'},
- {field:'amount_backend',title:'退款金额',operate:'between'},
- {field:'create_time',title:'创建时间',operate:'range',addClass:'datetimerange',formatter:Table.api.formatter.datetime},
- {field:'admin.nickname',title:' 操作员',operate:'like'},
- ];
- if(!admin.is_manager){
- Table.api.removeColumn('od.s_id',columns)
- }
- table.bootstrapTable({
- url: 'mobile_order/refund_log',
- pk: 'id',
- sortName: 'id',
- search:false,
- searchFormVisible:true,
- columns: columns,
- onLoadSuccess(a){
- }
- });
- Table.api.bindevent(table);
- }
- };
- return Controller;
- });
|