define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout', 'form'], function ($, undefined, Backend, Table, TableLayout, Form) { var Controller = { index: function () { Table.api.init({ extend: { index_url: 'invoice/index' + location.search, detail_url: 'invoice/detail', edit_url: 'invoice/edit', table: 'invoice', } }); var table = $("#table"); table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', sortOrder: 'desc', fixedColumns: false, fixedRightNumber: 0, columns: [ [ {field: 'index', visible: false, title: '序号', operate: false, formatter: Table.api.formatter.index, width: '55px'}, {field: 'invoice_sn', title: '申请单号', operate: 'LIKE'}, {field: 'title', title: '发票抬头', operate: 'LIKE', align: 'left'}, {field: 'tax_no', title: '税号', operate: 'LIKE', visible: false}, {field: 'title_type', title: '抬头类型', searchList: {"personal":__('Personal'),"enterprise":__('Enterprise')}, visible: false}, {field: 'type', title: '发票类型', searchList: {"normal":__('Ordinary'),"special":__('Special')}, formatter: Table.api.formatter.label, custom: {normal: 'info', special: 'warning'}}, {field: 'amount', title: '开票金额', operate: 'BETWEEN'}, {field: 'merchant.name', title: '申请企业', operate: 'LIKE', align: 'left'}, {field: 'user.nickname', title: '申请用户', operate: 'LIKE'}, {field: 'email', title: '接收邮箱', operate: 'LIKE', visible: false}, {field: 'status', title: '处理状态', searchList: {"wait":__('Wait'),"issued":__('Issued'),"reject":__('Reject'),"cancel":__('Cancel')}, formatter: Table.api.formatter.status, custom: {wait: 'warning', issued: 'success', reject: 'danger', cancel: 'gray'}}, {field: 'invoice_no', visible: false, title: '发票号码', operate: 'LIKE'}, {field: 'invoice_file', visible: false, title: '电子票', operate: false, formatter: function (v) { return v ? '查看' : '—'; }}, {field: 'audit_msg', title: '处理说明', operate: 'LIKE', visible: false}, {field: 'createtime', title: '申请时间', operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime, width: '145px'}, {field: 'operate', title: '操作', table: table, events: Table.api.events.operate, buttons: [ { name: 'detail', text: '详情', title: '开票申请详情', classname: 'btn btn-xs btn-info btn-detailone', extend: 'data-area=\'["920px","86%"]\'' }, { name: 'edit', text: '开票处理', title: '财务开票处理', classname: 'btn btn-xs btn-success btn-editone', extend: 'data-area=\'["920px","86%"]\'', visible: function (row) { return row.status === 'wait'; } } ], formatter: Table.api.formatter.operate} ] ] }); Table.api.bindevent(table); }, edit: function () { $(document).on('change', 'input[name="row[status]"]', function () { var val = $(this).val(); if (val === 'reject') { $('#box-issued-fields').slideUp(150); $('#invoice-issued-hint').hide(); $('#invoice-reject-hint').show(); $('#invoice-submit').text('确认驳回申请'); } else { $('#box-issued-fields').slideDown(150); $('#invoice-issued-hint').show(); $('#invoice-reject-hint').hide(); $('#invoice-submit').text('确认登记开票结果'); } }); $('#edit-form').on('reset', function () { setTimeout(function () { $('input[name="row[status]"]:checked').trigger('change'); }, 0); }); Controller.api.bindevent(); }, detail: function () { Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); } } }; return Controller; });