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: 'merchant/index' + location.search, add_url: 'merchant/add', edit_url: 'merchant/edit', del_url: 'merchant/del', detail_url: 'merchant/detail', multi_url: 'merchant/multi', table: 'merchant', } }); var table = $("#table"); table.on('post-body.bs.table', function () { $(".btn-detail-mer", this).data("area", ["1040px", "88%"]); $(".btn-editone", this).data("area", ["920px", "85%"]); }); $(".btn-add, .btn-edit").data("area", ["920px", "85%"]); table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', sortOrder: 'desc', fixedColumns: false, fixedRightNumber: 0, columns: [ [ {checkbox: true}, {field: 'index', title: '序号', operate: false, formatter: Table.api.formatter.index, width: '55px'}, {field: 'name', title: '企业名称', operate: 'LIKE', align: 'left'}, {field: 'license_no', title: __('License_no'), operate: 'LIKE', visible: false}, {field: 'legal_person', title: '法人代表', operate: 'LIKE'}, {field: 'contact', title: '业务对接人', operate: 'LIKE', align: 'left'}, {field: 'mobile', title: __('Mobile'), operate: 'LIKE'}, {field: 'city', title: '所在城市', operate: 'LIKE'}, { field: 'settle_type', title: '结算模式', searchList: {"prepay": __('Prepay'), "monthly": __('Monthly')}, formatter: function (val) { return val === 'monthly' ? '月结账期' : '预付现结'; } }, {field: 'order_count', title: '发包单数', operate: false}, {field: 'total_amount', title: '成交额', operate: false}, { field: 'member_count', title: '协同员工', operate: false, formatter: function (val) { return '' + (val || 0) + ' 人'; } }, {field: 'verify_status', title: __('Verify_status'), searchList: {"pending": __('Pending'), "pass": __('Pass'), "reject": __('Reject')}, formatter: Table.api.formatter.status}, {field: 'createtime', title: __('Createtime'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime}, { field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate, buttons: [ { name: 'detail', text: '详情', title: function (row) { return '企业全景资质看板 - ' + row.name; }, icon: 'fa fa-eye', classname: 'btn btn-xs btn-info btn-dialog btn-detail-mer', url: 'merchant/detail' } ] } ] ] }); Table.api.bindevent(table); }, certificates: function () { var certsTable = $("#certs-table"); function auditCert(row, decision, reason) { Fast.api.ajax({url: 'merchant/index', type: 'POST', data: { view: 'audit_cert', id: row.id, decision: decision, audit_msg: reason || '', __token__: $('#cert-audit-token input[name="__token__"]').val() }}, function () { location.reload(); }); } certsTable.bootstrapTable({ url: 'merchant/index?view=certs', pk: 'id', toolbar: '#certs-toolbar', search: true, searchOnEnterKey: true, searchPlaceholder: '搜索企业名称、证照号码或手机号', commonSearch: false, showExport: false, pagination: true, pageList: [10, 20, 50, 100], sidePagination: 'server', escape: true, responseHandler: function (res) { if (!res || !Array.isArray(res.rows)) { Toastr.error((res && res.msg) || '企业资质列表加载失败'); return {total: 0, rows: []}; } return res; }, columns: [[ {field: 'id', title: '申请编号', operate: false}, {field: 'nickname', title: '用户昵称', operate: false}, {field: 'mobile', title: '手机号', operate: false}, {field: 'user_type', title: '用户类型', operate: false, formatter: function (v) { return v === 'merchant' ? '商家用户' : '个人用户'; }}, {field: 'company_name', title: '企业名称', operate: false}, {field: 'license_no', title: '营业执照号码', operate: false}, {field: 'legal_person', title: '法人姓名', operate: false}, {field: 'license_url', title: '营业执照', operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, {field: 'verify_status', title: '审核状态', operate: false, formatter: function (v) { return {pending: '待审核', pass: '已通过', reject: '已驳回'}[v] || ''; }}, {field: 'audit_msg', title: '驳回原因', operate: false}, {field: 'createtime', title: '提交时间', operate: false, formatter: Table.api.formatter.datetime}, {field: 'operate', title: '操作', operate: false, events: { 'click .cert-approve': function (e, value, row) { Layer.confirm('确认通过该企业资质认证?', function () { auditCert(row, 'pass', ''); }); }, 'click .cert-reject': function (e, value, row) { Layer.prompt({title: '请输入驳回原因', formType: 2}, function (reason) { auditCert(row, 'reject', reason); }); } }, formatter: function (value, row) { return row.verify_status === 'pending' && certsTable.data('operate-audit') ? '通过 驳回' : ''; }} ]] }); $('#certs-refresh').on('click', function () { certsTable.bootstrapTable('refresh'); }); }, add: function () { Controller.api.bindevent(); }, edit: function () { Controller.api.bindevent(); }, detail: function () { }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); } } }; return Controller; });