123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form','clipboard'],
- function ($, undefined, Backend, Table, Form,clipboard) {
- var Controller = {
- index: async function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'Produceorder/index' + location.search,
- add_url: 'Produceorder/add',
- edit_url: 'Produceorder/edit',
- del_url: 'Produceorder/del',
- multi_url: 'Produceorder/multi',
- import_url: 'Produceorder/import',
- show_open_data_url: 'Produceorder/show_open_data',
- table: 'Produceorder',
- }
- });
- 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('Produceorder/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('Produceorder/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: '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: 'create_time', title: __('订单状态'),operate: false,formatter(_,order){
- let a=[]
- a.push(`<div class="btn-order_link" data-link="${order.name}">订单状态:</div>`)
- a.push(`<div class="btn-order_link" data-link="${order.phone}">激活状态:</div>`)
- a.push(`<div class="btn-order_link" data-link="${order.address}">是否首充:</div>`)
- a.push(`<div>首充金额:</div>`)
- a.push(`<div>创建时间:${order.create_time}</div>`)
- a.push(`<div>更新时间:${order.update_time}</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: 'create_time', title: __('生产信息'),operate: false,formatter(_,order){
- let a=[]
- a.push(`<div class="btn-order_link" data-link="${order.name}">生产号码:</div>`)
- a.push(`<div class="btn-order_link" data-link="${order.phone}">订单来源:</div>`)
- a.push(`<div class="btn-order_link" data-link="${order.address}">物流名称:</div>`)
- a.push(`<div>物流单号:</div>`)
- a.push(`<div>物流状态:</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: 'remark', title: '失败原因&备注',operate: 'range'},
- // {field: 'remark', title: '失败原因&备注',formatter: Table.api.formatter.datetime,addClass:'datetimerange',operate: 'range'},
- {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: 'Produceorder/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: 'Produceorder/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: 'Produceorder/refund_log',
- pk: 'id',
- sortName: 'id',
- search:false,
- searchFormVisible:true,
- columns: columns,
- onLoadSuccess(a){
- }
- });
- Table.api.bindevent(table);
- }
- };
- return Controller;
- });
|