123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form','selectpage'], function ($, undefined, Backend, Table, Form,selectpage) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'institution/rota/index' + location.search,
- add_url: 'institution/rota/add',
- edit_url: 'institution/rota/edit',
- del_url: 'institution/rota/del',
- multi_url: '',
- table: 'rota',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- // {checkbox: true},
- {field: 'id', title: __('Id'),searchable: false, visible: false},
- {field: 'doctor_id', title: __('Doctor_id'),searchable: false, visible: false},
- {field: 'institution_name', title: __('Institution_name'),searchable: false},
- {field: 'doctor_name', title: __('Doctor_name'),searchable: false},
- {field: 'institution_id', title: __('Institution_id'), visible: false},
- {field: 'createdAt', title: __('Createdat'), operate:'RANGE', addclass:'datetimerange',searchable: false, visible: false},
- {field: 'rota_datetime', title: __('Rota_datetime'), addclass:'datetimepicker',data:'data-date-format="YYYYMMDD" autocomplete="off"'},
- {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;
- $('#institution_id').selectPage({
- data : data,
- orderBy: 'index',
- });
- }
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Controller.api.bindevent();
- initInstitutionSearchList('c-institution_id');
- },
- edit: function () {
- Controller.api.bindevent();
- let ins_val = $('#ins_id').val();
- initDoctorList(ins_val);
- },
- 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',
- pagination: true,
- eSelect: function (data) {
- if($('#c-doctor_id').length){
- let ins_id = data.id;
- initDoctorSearchList(ins_id)
- }
- }
- });
- }
- });
- };
- // 选择医生多选下拉列表
- let initDoctorSearchList = function (ins_id) {
- $.ajax({
- url: 'institution/institution/doctorSelectList/institution_id/' + ins_id,
- type: 'post',
- dataType: 'json',
- success: function success(res) {
- let val = $('#c-doctor_id').val();
- let html = '<input id="c-doctor_id" class="form-control" name="row[doctor_id]" type="text" value="'+ val +'">';
- $('#d-doctor_id').children().remove();
- $('#d-doctor_id').append(html);
- let data = res.rows;
- $('#c-doctor_id').selectPage({
- data : data,
- orderBy: 'index',
- multiple: true
- });
- }
- });
- };
- // 选择医生单选下拉列表
- let initDoctorList = function (ins_id) {
- $.ajax({
- url: 'institution/institution/doctorSelectList/institution_id/' + ins_id,
- type: 'post',
- dataType: 'json',
- success: function success(res) {
- let val = $('#c-doctor_id').val();
- let html = '<input id="c-doctor_id" class="form-control" name="row[doctor_id]" type="text" value="'+ val +'">';
- $('#d-doctor_id').children().remove();
- $('#d-doctor_id').append(html);
- let data = res.rows;
- $('#c-doctor_id').selectPage({
- data : data,
- orderBy: 'index'
- });
- }
- });
- };
- return Controller;
- });
|