123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'selectpage'], function ($, undefined, Backend, Table, Form, selectPage) {
- let typeSearchList = {
- 1: '新增远程申请',
- 2: '远程申请驳回',
- 3: '远程申请被撤回',
- 4: '远程诊断接收',
- 5: '报告已审核',
- 6: '报告确认',
- 7: '对话',
- 8: '审核驳回'
- };
- let Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'messages/messages/index' + location.search,
- add_url: 'messages/messages/add',
- edit_url: 'messages/messages/edit',
- del_url: 'messages/messages/del',
- multi_url: 'messages/messages/multi',
- table: 'messages',
- }
- });
- let table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'ctime',
- showToggle: false,
- showColumns: false,
- columns: [
- [
- {field: 'institution_id', title: __('Institution_name'), visible: false},
- {field: 'institution_name', title: __('Institution_name'), searchable: false, width: '20%'},
- {field: 'department_name', title: __('Department_name')},
- {field: 'doctor_name', title: __('Doctor_name')},
- {field: 'title', title: __('Title'), searchable: false, width: '150'},
- {
- field: 'type', title: __('Type'),
- formatter: Controller.api.formatter.type,
- searchList: typeSearchList,
- },
- {
- field: 'is_read', title: __('Is_read'),
- formatter: Table.api.formatter.status,
- searchList: {1: '已读', 0: '未读'},
- custom: {1: 'success', 0: 'gray'}
- },
- {
- field: 'status',
- title: __('Status'),
- formatter: Table.api.formatter.status,
- searchList: {1: '删除', 0: '正常'},
- custom: {1: 'danger', 0: 'success'}
- },
- {
- field: 'operate', title: __('Operate'),
- table: table,
- events: Table.api.events.operate,
- formatter: Controller.api.formatter.operate,
- align: 'left',
- width: '50'
- }
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- initInstitutionSearchList('institution_id');
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- },
- formatter: {
- operate: function (value, row, index) {
- let table = this.table;
- // 操作配置
- let options = table ? table.bootstrapTable('getOptions') : {};
- // 默认按钮组
- let buttons = $.extend([], this.buttons || []);
- // 所有按钮名称
- let names = [];
- buttons.forEach(function (item) {
- names.push(item.name);
- });
- if (options.extend.edit_url !== '' && names.indexOf('edit') === -1) {
- Table.button.edit.url = options.extend.edit_url;
- buttons.push(Table.button.edit);
- }
- if(row.status != '1'){
- if (options.extend.del_url !== '' && names.indexOf('del') === -1) {
- buttons.push(Table.button.del);
- }
- }
- return Table.api.buttonlink(this, buttons, value, row, index, 'operate');
- },
- type: function (value) {
- return typeSearchList[value];
- }
- }
- }
- };
- // 选择机构下拉列表
- 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;
- });
|