define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'selectpage'], function ($, undefined, Backend, Table, Form, SelectPage) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'institution/contact/index' + location.search, add_url: 'institution/contact/add', edit_url: 'institution/contact/edit', del_url: 'institution/contact/del', multi_url: 'institution/contact/multi', table: 'remote_contact', } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', showToggle: false, showColumns: false, columns: [ [ {field: 'hospital_name', title: __('Hospital_id'), searchable: false}, {field: 'super_hospital_name', title: __('Super_hospital_id'), searchable: false}, {field: 'hospital_id', title: __('Hospital_id'), visible: false}, {field: 'super_hospital_id', title: __('Super_hospital_id'), visible: false}, { field: 'pay_type', title: __('Pay_type'), formatter: Table.api.formatter.label, searchList: {0: '患者支付', 1: '医院挂账'}, }, {field: 'lower_ratio', title: __('Lower_ratio'), searchable: false}, {field: 'super_ratio', title: __('Super_ratio'), searchable: false}, {field: 'zskk_ratio', title: __('Zskk_ratio'), searchable: false}, {field: 'createdAt', title: __('Createdat'), operate:'RANGE', addclass:'datetimerange', searchable: false}, { field: 'sort', title: __('Sort'), searchable: false }, { field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {0: '禁用', 1: '正常'}, custom: {0: 'danger', 1: 'success'}, }, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] }); $.ajax({ url: 'institution/institution/institutionSelectList', type: 'post', dataType: 'json', success: function success(res) { var data = res.rows; $('#hospital_id').selectPage({ data : data, orderBy: 'index', }); $('#super_hospital_id').selectPage({ data : data, orderBy: 'index', }); } }); // 为表格绑定事件 Table.api.bindevent(table); }, add: function () { $('#c-remote_doctor').selectPage({ data : [], multiple: true }); lowerInstitutionList(); superInstitutionList(); Controller.api.bindevent(); }, edit: function () { let ins_id = $("#c-super_hospital_id").val(); $.ajax({ url: 'institution/institution/initRemoteDoctor/institution_id/' + ins_id, type: 'post', dataType: 'json', success: function success(res) { let data = res.rows; $('#c-remote_doctor').selectPage({ data : data, multiple: true }); } }); Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); } } }; let lowerInstitutionList = function () { $.ajax({ url: 'institution/institution/institutionContactList/level/lower', type: 'post', dataType: 'json', success: function success(res) { var data = res.rows; $('#c-hospital_id').selectPage({ data : data, orderBy: 'index', eSelect: function () { $('#c-hospital_name').val($('#c-hospital_id').selectPageText()); } }); } }); }; let superInstitutionList = function () { $.ajax({ url: 'institution/institution/institutionContactList/level/super', type: 'post', dataType: 'json', success: function success(res) { var data = res.rows; $('#c-super_hospital_id').selectPage({ data : data, orderBy: 'index', eSelect: function (data) { $('#c-super_hospital_name').val($('#c-super_hospital_id').selectPageText()); let ins_id = data.id; initRemoteDoctor(ins_id); } }); } }); }; let initRemoteDoctor = function (ins_id) { $.ajax({ url: 'institution/institution/initRemoteDoctor/institution_id/' + ins_id, type: 'post', dataType: 'json', success: function success(res) { let data = res.rows; let ids = res.ids; // $('#c-remote_doctor').selectPageData(data); $('#c-remote_doctor').selectPageData(data); if($('#c-remote_doctor').val().length === 0){ $('#c-remote_doctor'). val(ids) } $('#c-remote_doctor').selectPageRefresh(); } }); }; return Controller; });