123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'orders/index' + location.search,
- add_url: 'orders/add',
- edit_url: 'orders/edit',
- del_url: 'orders/del',
- multi_url: 'orders/multi',
- import_url: 'orders/import',
- table: 'orders',
- }
- });
- var table = $("#table");
- let s=JSON.parse(JSON.stringify(status))
- s[40]='售后'
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- searchFormVisible:true,
- search:false,
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- {field: 'order_no', title: __('Order_no'),operate: 'like',},
- {field: 'status', title: __('Status'),formatter(status,order,index){
- /*if(status===0 && order.voucher && order.voucher.status===0){
- return `<span class="label label-default">待审核</span>`
- }*/
- let s=Table.api.formatter.status.call(this,status,order,index)
- let info=[]
- order.info.forEach(item=>{
- if(item.refund && item.refund.is_pass && info.indexOf(item.refund.refund_type_text)===-1){
- info.push(item.refund.refund_type_text)
- }
- })
- if(info.length){
- s+=`<div><a class="text-danger">${info.join(',')}</a></div>`
- }
- return s
- },searchList:s},
- {field: 'user.nickname', title: __('下单用户'),operate: 'like',formatter:Table.api.formatter.normal},
- {field: 'info', title: __('商品信息'),operate: false,formatter(info, order, index) {
- let a=[];
- info.forEach(item=>{
- a.push(`<div class="">商品:${item.goods_name},规格:${item.sku_name},数量:${item.num},安装量:${item.num_install},金额:${item.amount_pay}</div>`)
- })
- return Table.api.formatter.content.call(this,a.join('<br/>'),order,index)
- }},
- {field: 'amount_total', title: __('Amount_total'), operate:'BETWEEN'},
- {field: 'amount_pay', title: __('Amount_pay'), operate:'BETWEEN'},
- /* {field: 'amount_install', title: __('Amount_install'), operate:'BETWEEN'},
- {field: 'num', title: __('Num'),operate: 'between'},
- {field: 'num_install', title: __('Num_install'),operate: 'between'},*/
- {field: 'admin.nickname', title: __('销售人员'), operate:'like'},
- {field: 'tax_link', title: __('发票状态'), operate:'=',searchList: {'NULL':'未开票','NOT NULL':'已开票'},formatter(a){
- if(a){
- return `<span class="label label-success">已开票</span>`
- }
- return `<span class="label label-default">未开票</span>`
- }},
- {field: 'create_time', title: __('Create_time'),addClass:'datetimerange',formatter: Table.api.formatter.datetime,operate: 'range'},
- //{field: 'update_time', title: __('Update_time'),addClass:'datetimerange',formatter: Table.api.formatter.datetime,operate: 'range'},
- {field: 'pay_type', title: __('Pay_type'),formatter: Table.api.formatter.label,searchList:payTypes},
- {field: 'pay_time', title: __('支付时间'),addClass:'datetimerange',formatter: Table.api.formatter.datetime,operate: 'range'},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,buttons:[
- {
- name: 'edit',
- text: __('发货'),
- title: __('发货'),
- classname: 'btn btn-xs btn-info btn-dialog',
- icon: 'fa',
- url: 'orders/send',
- callback: function (data) {
- //Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
- $('.btn-refresh').trigger('click')
- },
- visible: function (row) {
- //返回true时按钮显示,返回false隐藏
- return row.status===5 && table.data('operate-send');
- }
- },
- {
- name: 'edit',
- text: __('已收款'),
- title: __('已收款'),
- classname: 'btn btn-xs btn-info btn-ajax',
- icon: 'fa',
- url: 'orders/payed',
- confirm:'确认已收款?',
- success: function (data) {
- $('.btn-refresh').trigger('click')
- },
- visible: function (row) {
- //返回true时按钮显示,返回false隐藏
- return row.status===0 && table.data('operate-payed') && row.pay_type===6
- }
- },
- {
- name: 'edit',
- text: __('订单详情'),
- title: __('订单详情'),
- classname: 'btn btn-xs btn-info btn-detail btn-dialog',
- icon: 'fa fa-outdent',
- url: 'orders/detail',
- extend:'data-area=\'["1200px","100%"]\'',
- callback: function (data) {
- //Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
- $('.btn-refresh').trigger('click')
- },
- visible: function (row) {
- //返回true时按钮显示,返回false隐藏
- return table.data('operate-detail');
- }
- },
- {
- name: 'edit',
- text: __('上传发票'),
- title: __('上传发票'),
- classname: 'btn btn-xs btn-warning btn-dialog',
- icon: 'fa',
- url: 'orders/tax',
- callback: function (data) {
- //Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
- $('.btn-refresh').trigger('click')
- },
- visible: function (row) {
- //返回true时按钮显示,返回false隐藏
- return !row.tax_link && row.tax && table.data('operate-tax');
- }
- },
- {
- name: 'edit',
- text: __('查看物流'),
- title: __('查看物流'),
- classname: 'btn btn-xs btn-warning btn-dialog',
- icon: 'fa',
- url: 'orders/logistics',
- callback: function (data) {
- //Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
- $('.btn-refresh').trigger('click')
- },
- extend: `data-area='["800px","80%"]'`,
- visible: function (row) {
- //返回true时按钮显示,返回false隐藏
- return table.data('operate-logistics') && row.logistics && row.logistics.trans_no;
- }
- },
- /*{
- name: 'edit',
- text: __('电子面单'),
- title: __('电子面单'),
- classname: 'btn btn-xs btn-success btn-dialog',
- icon: 'fa',
- url: 'orders/md',
- callback: function (data) {
- $('.btn-refresh').trigger('click')
- },
- extend: `data-area='["800px","80%"]'`,
- visible: function (row) {
- //返回true时按钮显示,返回false隐藏
- return table.data('operate-md') && row.logistics && row.logistics.trans_no;
- }
- },*/
- ]}
- ]
- ],
- onLoadSuccess(a) {
- $('.btn-export').attr('href',a.link)
- }
- });
- $('.btn-export').click(function (){
- })
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Controller.api.bindevent();
- },
- send: function () {
- Controller.api.bindevent();
- $(document).on("change", "#c-name", function(){
- //后续操作
- var address_id = $(this).val();
- if(!address_id){
- $('#province1').fadeOut();
- $('#province2').fadeOut();
- return false;
- }
- $.ajax({
- url: 'orders/is_same_city',
- data: {address_id: $(this).val(),order_id:$('#order_id').val()},
- dataType: 'json',
- cache: false,
- success: function (row) {
- if(!row.code){
- Toastr.error(row.msg);
- }
- if(row.data.type == 1){
- $('#province1').fadeIn();
- $('#province2').fadeOut();
- }
- if(row.data.type == 0){
- $('#province1').fadeOut();
- $('#province2').fadeIn();
- }
- }, error: function () {
- Toastr.error(__('Network error'));
- }
- });
- });
- },
- tax: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- },
- md(){
- $('.btn-print').click(function (){
- Fast.api.ajax({},(res)=>{
- console.log(res)
- })
- })
- },
- detail: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: location.pathname + location.search,
- refund_detail_url:'order_info_refund/audit'
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- commonSearch:false,
- search:false,
- pagination:false,
- columns: [
- [
- {field: 'id', title: __('Id')},
- {field: 'logo', title: __('商品图片'),formatter: Table.api.formatter.image,events:Table.api.events.image,operate: false},
- {field: 'goods_name', title: __('商品名称'),operate: false,formatter(name,orderInfo,index){
- let a=[]
- a.push(`<div>${name}</div>`)
- if(orderInfo.refund){
- a.push(`<div>
- <a class="label label-default btnViewRefund" data-id="${orderInfo.refund.id}">售后详情</a>
- <span class="label label-danger">${refundStatus[orderInfo.refund.refund_status]}</span>
- </div>`)
- }
- return a.join('')
- },width:200},
- {field: 'sku_name', title: __('商品规格'),operate: false},
- {field: 'amount_pay', title: __('Amount_total'), operate:'BETWEEN'},
- {field: 'amount_goods_real', title: __('商品金额'), operate:'BETWEEN'},
- {field: 'amount_install', title: __('Amount_install'), operate:'BETWEEN'},
- {field: 'num', title: __('购买数量'),operate: 'between'},
- {field: 'num_install', title: __('安装数量'),operate: 'between'},
- //{field: 'refund.refund_status', title: __('售后'),operate: 'eq',formatter: Table.api.formatter.label,searchList:refundStatus},
- ]
- ],
- onLoadSuccess(){
- setTimeout(()=>{
- $('.btn-detail').data('area',["500px","900px"])
- },200)
- }
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- $(document).on('click','.btnViewRefund',function (){
- let id=$(this).data('id')
- parent.Fast.api.open(`${$.fn.bootstrapTable.defaults.extend.refund_detail_url}?ids=${id}`,'售后详情')
- })
- },
- };
- return Controller;
- });
|