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"); // 初始化表格 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')}, {field: 'status', title: __('Status'),formatter: Table.api.formatter.label,searchList:status}, {field: 'user.nickname', title: __('下单用户')}, {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: '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-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; } }, ]} ] ] }); // 为表格绑定事件 Table.api.bindevent(table); }, add: function () { Controller.api.bindevent(); }, send: function () { Controller.api.bindevent(); }, tax: function () { Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); } }, detail: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: location.pathname + location.search, } }); 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: Table.api.formatter.content,width:200}, {field: 'sku_name', title: __('商品规格'),operate: false}, {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: __('购买数量'),operate: 'between'}, {field: 'num_install', title: __('安装数量'),operate: 'between'}, ] ], onLoadSuccess(){ setTimeout(()=>{ $('.btn-detail').data('area',["500px","900px"]) },200) } }); // 为表格绑定事件 Table.api.bindevent(table); }, }; return Controller; });