define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'selectpage'], function ($, undefined, Backend, Table, Form, SelectPage) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'manage/standards/index' + location.search, add_url: 'manage/standards/add', edit_url: 'manage/standards/edit', del_url: 'manage/standards/del', multi_url: 'manage/standards/multi', table: 'qc_standards', } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', columns: [ [ {field: 'institution_id', title: __('机构名称'), visible: false}, {field: 'institution_name', title: __('机构名称'), align: 'left', searchable: false}, // {field: 'depart_id', title: __('Depart_id')}, {field: 'title', title: __('Title')}, {field: 'desc', title: __('Desc')}, {field: 'status', title: __('Status'),formatter: function (value){ if(value == 0){return '禁用'}else if(value == 1){return '启用'}else{return ''} }}, {field: 'createdAt', title: __('Createdat'), operate:'RANGE', addclass:'datetimerange'}, {field: 'updatedAt', title: __('修改时间'), operate:'RANGE', addclass:'datetimerange'}, {field: 'type', title: __('Type'),formatter: function (value){ if(value == 1){return '技术质控'}else if(value == 2){return '诊断质控'}else{return ''} },searchList:{"1":"技术质控","2":"诊断质控"}}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] }); // 为表格绑定事件 Table.api.bindevent(table); initInstitutionSearchList('institution_id'); }, add: function () { initInstitutionSearchList('institution_id'); Controller.api.bindevent(); }, edit: function () { initInstitutionSearchList('institution_id'); Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); } } }; // 选择机构下拉列表 let initInstitutionSearchList = function (id) { $.ajax({ url: 'institution/institution/institutionSelectList', type: 'post', dataType: 'json', success: function success(res) { let data = res.rows; $('#'+id).selectPage({ data : data, orderBy: 'index' }); } }); }; return Controller; });