contact.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'selectpage'], function ($, undefined, Backend, Table, Form, SelectPage) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'institution/contact/index' + location.search,
  8. add_url: 'institution/contact/add',
  9. edit_url: 'institution/contact/edit',
  10. del_url: 'institution/contact/del',
  11. multi_url: 'institution/contact/multi',
  12. table: 'remote_contact',
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. pk: 'id',
  20. sortName: 'id',
  21. showToggle: false,
  22. showColumns: false,
  23. columns: [
  24. [
  25. {field: 'hospital_name', title: __('Hospital_id'), searchable: false},
  26. {field: 'super_hospital_name', title: __('Super_hospital_id'), searchable: false},
  27. {field: 'hospital_id', title: __('Hospital_id'), visible: false},
  28. {field: 'super_hospital_id', title: __('Super_hospital_id'), visible: false},
  29. {
  30. field: 'pay_type',
  31. title: __('Pay_type'),
  32. formatter: Table.api.formatter.label,
  33. searchList: {0: '患者支付', 1: '医院挂账'},
  34. },
  35. {field: 'lower_ratio', title: __('Lower_ratio'), searchable: false},
  36. {field: 'super_ratio', title: __('Super_ratio'), searchable: false},
  37. {field: 'zskk_ratio', title: __('Zskk_ratio'), searchable: false},
  38. {field: 'createdAt', title: __('Createdat'), operate:'RANGE', addclass:'datetimerange', searchable: false},
  39. {
  40. field: 'sort',
  41. title: __('Sort'),
  42. searchable: false
  43. },
  44. {
  45. field: 'status',
  46. title: __('Status'),
  47. formatter: Table.api.formatter.status,
  48. searchList: {0: '禁用', 1: '正常'},
  49. custom: {0: 'danger', 1: 'success'},
  50. },
  51. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  52. ]
  53. ]
  54. });
  55. $.ajax({
  56. url: 'institution/institution/institutionSelectList',
  57. type: 'post',
  58. dataType: 'json',
  59. success: function success(res) {
  60. var data = res.rows;
  61. $('#hospital_id').selectPage({
  62. data : data,
  63. orderBy: 'index',
  64. });
  65. $('#super_hospital_id').selectPage({
  66. data : data,
  67. orderBy: 'index',
  68. });
  69. }
  70. });
  71. // 为表格绑定事件
  72. Table.api.bindevent(table);
  73. },
  74. add: function () {
  75. $('#c-remote_doctor').selectPage({
  76. data : [],
  77. multiple: true
  78. });
  79. lowerInstitutionList();
  80. superInstitutionList();
  81. Controller.api.bindevent();
  82. },
  83. edit: function () {
  84. let ins_id = $("#c-super_hospital_id").val();
  85. $.ajax({
  86. url: 'institution/institution/initRemoteDoctor/institution_id/' + ins_id,
  87. type: 'post',
  88. dataType: 'json',
  89. success: function success(res) {
  90. let data = res.rows;
  91. $('#c-remote_doctor').selectPage({
  92. data : data,
  93. multiple: true
  94. });
  95. }
  96. });
  97. Controller.api.bindevent();
  98. },
  99. api: {
  100. bindevent: function () {
  101. Form.api.bindevent($("form[role=form]"));
  102. }
  103. }
  104. };
  105. let lowerInstitutionList = function () {
  106. $.ajax({
  107. url: 'institution/institution/institutionContactList/level/lower',
  108. type: 'post',
  109. dataType: 'json',
  110. success: function success(res) {
  111. var data = res.rows;
  112. $('#c-hospital_id').selectPage({
  113. data : data,
  114. orderBy: 'index',
  115. eSelect: function () {
  116. $('#c-hospital_name').val($('#c-hospital_id').selectPageText());
  117. }
  118. });
  119. }
  120. });
  121. };
  122. let superInstitutionList = function () {
  123. $.ajax({
  124. url: 'institution/institution/institutionContactList/level/super',
  125. type: 'post',
  126. dataType: 'json',
  127. success: function success(res) {
  128. var data = res.rows;
  129. $('#c-super_hospital_id').selectPage({
  130. data : data,
  131. orderBy: 'index',
  132. eSelect: function (data) {
  133. $('#c-super_hospital_name').val($('#c-super_hospital_id').selectPageText());
  134. let ins_id = data.id;
  135. initRemoteDoctor(ins_id);
  136. }
  137. });
  138. }
  139. });
  140. };
  141. let initRemoteDoctor = function (ins_id) {
  142. $.ajax({
  143. url: 'institution/institution/initRemoteDoctor/institution_id/' + ins_id,
  144. type: 'post',
  145. dataType: 'json',
  146. success: function success(res) {
  147. let data = res.rows;
  148. let ids = res.ids;
  149. // $('#c-remote_doctor').selectPageData(data);
  150. $('#c-remote_doctor').selectPageData(data);
  151. if($('#c-remote_doctor').val().length === 0){
  152. $('#c-remote_doctor'). val(ids)
  153. }
  154. $('#c-remote_doctor').selectPageRefresh();
  155. }
  156. });
  157. };
  158. return Controller;
  159. });