hospital.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /**
  2. * 角色管理的单例
  3. */
  4. var Hospital = {
  5. id: "hospitalTable", //表格id
  6. seItem: null, //选中的条目
  7. table: null,
  8. layerIndex: -1
  9. };
  10. /**
  11. * 初始化表格的列
  12. */
  13. Hospital.initColumn = function () {
  14. var columns = [
  15. {field: 'selectItem', radio: true},
  16. {title: 'id', field: 'id', visible: false, align: 'center', valign: 'middle'},
  17. {title: '医院名称', field: 'name', align: 'center', valign: 'middle', sortable: true,
  18. formatter: function (value, row) {
  19. if (row.isGeneral == 1) {
  20. return value + "<span style='color:#4781f0;'>(总院)</span>";
  21. }
  22. return value;
  23. }
  24. },
  25. {title: '医共体', field: 'medicalCommunityName', align: 'center', valign: 'middle', sortable: true},
  26. {title: '备注', field: 'description', align: 'center', valign: 'middle', sortable: true},
  27. {title: '排序', field: 'num', align: 'center', valign: 'middle', sortable: true},
  28. {title: '状态', field: 'status', align: 'center', valign: 'middle', sortable: true,
  29. formatter: function (value) {
  30. if (value == 1) {
  31. return "正常";
  32. }
  33. return "停用";
  34. }
  35. }
  36. ]
  37. return columns;
  38. };
  39. /**
  40. * 检查是否选中
  41. */
  42. Hospital.check = function () {
  43. var selected = $('#' + this.id).bootstrapTable('getSelections');
  44. if (selected.length == 0) {
  45. Feng.info("请先选中表格中的某一记录!");
  46. return false;
  47. } else {
  48. Hospital.seItem = selected[0];
  49. return true;
  50. }
  51. };
  52. /**
  53. * 点击添加菜单
  54. */
  55. Hospital.openAddHospital = function () {
  56. var index = layer.open({
  57. type: 2,
  58. title: '添加医院',
  59. area: ['830px', '450px'], //宽高
  60. fix: false, //不固定
  61. maxmin: true,
  62. content: Feng.ctxPath + '/admin/nhc.hospital/add'
  63. });
  64. this.layerIndex = index;
  65. };
  66. /**
  67. * 点击修改
  68. */
  69. Hospital.openChangeHospital = function () {
  70. if (this.check()) {
  71. var index = layer.open({
  72. type: 2,
  73. title: '修改医院',
  74. area: ['800px', '450px'], //宽高
  75. fix: false, //不固定
  76. maxmin: true,
  77. content: Feng.ctxPath + '/admin/nhc.hospital/edit/id/' + this.seItem.id
  78. });
  79. this.layerIndex = index;
  80. }
  81. };
  82. /**
  83. * 设为总院
  84. */
  85. Hospital.setGeneral = function () {
  86. if (this.check()) {
  87. var operation = function () {
  88. var ajax = new $ax(Feng.ctxPath + "/admin/nhc.hospital/setGeneral", function (data) {
  89. if (data.code == 200) {
  90. Feng.success(data.msg);
  91. $('#hospitalTable').bootstrapTable('refresh');
  92. } else {
  93. Feng.error(data.msg);
  94. }
  95. }, function (data) {
  96. Feng.error("设置失败!" + data.responseJSON.message + "!");
  97. });
  98. ajax.set("id", Hospital.seItem.id);
  99. ajax.start();
  100. };
  101. Feng.confirm("是否设置该医院为其所在医共体的总院?", operation);
  102. }
  103. }
  104. /**
  105. * 删除
  106. */
  107. Hospital.delHospital = function () {
  108. if (this.check()) {
  109. var operation = function () {
  110. var ajax = new $ax(Feng.ctxPath + "/admin/nhc.hospital/delete", function (data) {
  111. Feng.success("删除成功!");
  112. $('#hospitalTable').bootstrapTable('refresh');
  113. }, function (data) {
  114. Feng.error("删除失败!" + data.responseJSON.message + "!");
  115. });
  116. ajax.set("id", Hospital.seItem.id);
  117. ajax.start();
  118. };
  119. Feng.confirm("是否刪除该医院?", operation);
  120. }
  121. };
  122. /**
  123. * 搜索
  124. */
  125. Hospital.search = function () {
  126. var queryData = {};
  127. queryData['communityId'] = $("#communityId").val();
  128. queryData['name'] = $("#name").val();
  129. $('#hospitalTable').bootstrapTable('refresh', {query: queryData});
  130. }
  131. /**
  132. * 重置
  133. */
  134. Hospital.reset = function () {
  135. $("#name").val("");
  136. $("#communityId").val("");
  137. }
  138. $(function () {
  139. Hospital.table = $('#hospitalTable').bootstrapTable({
  140. url: "/admin/nhc.hospital/list",
  141. method: 'POST',
  142. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  143. search: false, // 是否显示表格搜索,此搜索是客户端搜索,不会进服务端
  144. showRefresh: false, // 是否显示刷新按钮
  145. clickToSelect: true, // 是否启用点击选中行
  146. singleSelect: false, // 设置True 将禁止多选
  147. striped: true, // 是否显示行间隔色
  148. pagination: false, // 设置为 true 会在表格底部显示分页条
  149. paginationHAlign: "left",
  150. paginationDetailHAlign: "right",
  151. sidePagination: "client", // 设置在哪里进行分页,可选值为 'client' 或者 'server'
  152. pageNumber: 1, //初始化加载第一页,默认第一页
  153. pageSize: 10, //每页的记录行数(*)
  154. pageList: [10, 25, 50, 100, 500, 1000, 1500], //可供选择的每页的行数(*)
  155. maintainSelected: true, //全表全选需要开启
  156. showColumns: false,
  157. columns: Hospital.initColumn(),
  158. onDblClickRow: function () {
  159. Hospital.openChangeHospital();
  160. }
  161. });
  162. });