define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'orders.invoice/index' + location.search, add_url: 'orders.invoice/add', edit_url: 'orders.invoice/edit', del_url: 'orders.invoice/del', multi_url: 'orders.invoice/multi', import_url: 'orders.invoice/import', table: 'order_invoice', } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', fixedColumns: true, fixedRightNumber: 1, columns: [ [ {checkbox: true}, {field: 'id', title: __('Id')}, {field: 'order_id', title: __('Order_id')}, {field: 'invoice_type', title: __('Invoice_type'),formatter: function (val) { return val === 1 ? '公司发票': '个人发票'; }}, {field: 'status', title: __('Status'),formatter:function (val) { let list = [ '代处理', '已开票', '已完成', ]; return list[val] ?? ''; }}, {field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'tax_number', title: __('Tax_number'), operate: 'LIKE'}, {field: 'amount', title: __('Amount'), operate:'BETWEEN'}, // {field: 'invoice_method', title: __('Invoice_method')}, {field: 'recipient_email', title: __('Recipient_email'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'company_address', title: __('Company_address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'company_phone', title: __('Company_phone'), operate: 'LIKE'}, {field: 'bank_name', title: __('Bank_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'bank_account', title: __('Bank_account'), operate: 'LIKE'}, {field: 'recipient_address', title: __('Recipient_address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'recipient_name', title: __('Recipient_name'), operate: 'LIKE'}, {field: 'recipient_phone', title: __('Recipient_phone'), operate: 'LIKE'}, {field: 'issued_at', title: __('Issued_at'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, buttons:[ { name: 'edit', text: "开票", icon: 'fa fa-pencil', title: __('Edit'), extend: 'data-toggle="tooltip" data-container="body"', classname: 'btn btn-xs btn-info btn-editone', }, { name: 'del', text: "删除", icon: 'fa fa-trash', title: __('Delete'), extend: 'data-toggle="tooltip"', classname: 'btn btn-xs btn-danger btn-delone', }, ], formatter: Table.api.formatter.operate} ] ] }); // 为表格绑定事件 Table.api.bindevent(table); }, add: function () { Controller.api.bindevent(); }, edit: function () { function toggleInvoiceFields() { const type = $('#c-source').val(); if (type === '1') { // 公司发票 $('#c-tax_number').closest('.form-group').show(); $('#c-company_address').closest('.form-group').show(); $('#c-company_phone').closest('.form-group').show(); $('#c-bank_name').closest('.form-group').show(); $('#c-bank_account').closest('.form-group').show(); } else { // 个人发票 $('#c-tax_number').closest('.form-group').hide(); $('#c-company_address').closest('.form-group').hide(); $('#c-company_phone').closest('.form-group').hide(); $('#c-bank_name').closest('.form-group').hide(); $('#c-bank_account').closest('.form-group').hide(); } } // 初始化时执行一次 toggleInvoiceFields(); // 监听 select 改变 $('#c-source').on('change',function () { toggleInvoiceFields(); }); Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); } } }; return Controller; });