messages.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'selectpage'], function ($, undefined, Backend, Table, Form, selectPage) {
  2. let typeSearchList = {
  3. 1: '新增远程申请',
  4. 2: '远程申请驳回',
  5. 3: '远程申请被撤回',
  6. 4: '远程诊断接收',
  7. 5: '报告已审核',
  8. 6: '报告确认',
  9. 7: '对话',
  10. 8: '审核驳回'
  11. };
  12. let Controller = {
  13. index: function () {
  14. // 初始化表格参数配置
  15. Table.api.init({
  16. extend: {
  17. index_url: 'messages/messages/index' + location.search,
  18. add_url: 'messages/messages/add',
  19. edit_url: 'messages/messages/edit',
  20. del_url: 'messages/messages/del',
  21. multi_url: 'messages/messages/multi',
  22. table: 'messages',
  23. }
  24. });
  25. let table = $("#table");
  26. // 初始化表格
  27. table.bootstrapTable({
  28. url: $.fn.bootstrapTable.defaults.extend.index_url,
  29. pk: 'id',
  30. sortName: 'ctime',
  31. showToggle: false,
  32. showColumns: false,
  33. columns: [
  34. [
  35. {field: 'institution_id', title: __('Institution_name'), visible: false},
  36. {field: 'institution_name', title: __('Institution_name'), searchable: false, width: '20%'},
  37. {field: 'department_name', title: __('Department_name')},
  38. {field: 'doctor_name', title: __('Doctor_name')},
  39. {field: 'title', title: __('Title'), searchable: false, width: '150'},
  40. {
  41. field: 'type', title: __('Type'),
  42. formatter: Controller.api.formatter.type,
  43. searchList: typeSearchList,
  44. },
  45. {
  46. field: 'is_read', title: __('Is_read'),
  47. formatter: Table.api.formatter.status,
  48. searchList: {1: '已读', 0: '未读'},
  49. custom: {1: 'success', 0: 'gray'}
  50. },
  51. {
  52. field: 'status',
  53. title: __('Status'),
  54. formatter: Table.api.formatter.status,
  55. searchList: {1: '删除', 0: '正常'},
  56. custom: {1: 'danger', 0: 'success'}
  57. },
  58. {
  59. field: 'operate', title: __('Operate'),
  60. table: table,
  61. events: Table.api.events.operate,
  62. formatter: Controller.api.formatter.operate,
  63. align: 'left',
  64. width: '50'
  65. }
  66. ]
  67. ]
  68. });
  69. // 为表格绑定事件
  70. Table.api.bindevent(table);
  71. initInstitutionSearchList('institution_id');
  72. },
  73. add: function () {
  74. Controller.api.bindevent();
  75. },
  76. edit: function () {
  77. Controller.api.bindevent();
  78. },
  79. api: {
  80. bindevent: function () {
  81. Form.api.bindevent($("form[role=form]"));
  82. },
  83. formatter: {
  84. operate: function (value, row, index) {
  85. let table = this.table;
  86. // 操作配置
  87. let options = table ? table.bootstrapTable('getOptions') : {};
  88. // 默认按钮组
  89. let buttons = $.extend([], this.buttons || []);
  90. // 所有按钮名称
  91. let names = [];
  92. buttons.forEach(function (item) {
  93. names.push(item.name);
  94. });
  95. if (options.extend.edit_url !== '' && names.indexOf('edit') === -1) {
  96. Table.button.edit.url = options.extend.edit_url;
  97. buttons.push(Table.button.edit);
  98. }
  99. if(row.status != '1'){
  100. if (options.extend.del_url !== '' && names.indexOf('del') === -1) {
  101. buttons.push(Table.button.del);
  102. }
  103. }
  104. return Table.api.buttonlink(this, buttons, value, row, index, 'operate');
  105. },
  106. type: function (value) {
  107. return typeSearchList[value];
  108. }
  109. }
  110. }
  111. };
  112. // 选择机构下拉列表
  113. let initInstitutionSearchList = function (id) {
  114. $.ajax({
  115. url: 'institution/institution/institutionSelectList',
  116. type: 'post',
  117. dataType: 'json',
  118. success: function success(res) {
  119. let data = res.rows;
  120. $('#'+id).selectPage({
  121. data : data,
  122. orderBy: 'index'
  123. });
  124. }
  125. });
  126. };
  127. return Controller;
  128. });