medicalCommunity.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /**
  2. * 角色管理的单例
  3. */
  4. var MedicalCommunity = {
  5. id: "medicalCommunityTable", //表格id
  6. seItem: null, //选中的条目
  7. table: null,
  8. layerIndex: -1
  9. };
  10. /**
  11. * 初始化表格的列
  12. */
  13. MedicalCommunity.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. {title: '备注', field: 'description', align: 'center', valign: 'middle', sortable: true},
  19. {title: '排序', field: 'num', align: 'center', valign: 'middle', sortable: true},
  20. {title: '状态', field: 'status', align: 'center', valign: 'middle', sortable: true,
  21. formatter: function (value) {
  22. if (value == 1) {
  23. return "正常";
  24. }
  25. return "停用";
  26. }
  27. }
  28. ]
  29. return columns;
  30. };
  31. /**
  32. * 检查是否选中
  33. */
  34. MedicalCommunity.check = function () {
  35. var selected = $('#' + this.id).bootstrapTable('getSelections');
  36. if (selected.length == 0) {
  37. Feng.info("请先选中表格中的某一记录!");
  38. return false;
  39. } else {
  40. MedicalCommunity.seItem = selected[0];
  41. return true;
  42. }
  43. };
  44. /**
  45. * 点击添加菜单
  46. */
  47. MedicalCommunity.openAddCommunity = function () {
  48. var index = layer.open({
  49. type: 2,
  50. title: '添加医共体',
  51. area: ['830px', '450px'], //宽高
  52. fix: false, //不固定
  53. maxmin: true,
  54. content: Feng.ctxPath + '/admin/nhc.medical_community/add'
  55. });
  56. this.layerIndex = index;
  57. };
  58. /**
  59. * 点击修改
  60. */
  61. MedicalCommunity.openChangeCommunity = function () {
  62. if (this.check()) {
  63. var index = layer.open({
  64. type: 2,
  65. title: '修改医共体',
  66. area: ['800px', '450px'], //宽高
  67. fix: false, //不固定
  68. maxmin: true,
  69. content: Feng.ctxPath + '/admin/nhc.medical_community/edit/id/' + this.seItem.id
  70. });
  71. this.layerIndex = index;
  72. }
  73. };
  74. /**
  75. * 删除
  76. */
  77. MedicalCommunity.delCommunity = function () {
  78. if (this.check()) {
  79. var operation = function () {
  80. var ajax = new $ax(Feng.ctxPath + "/admin/nhc.medical_community/delete", function (data) {
  81. Feng.success("删除成功!");
  82. MedicalCommunity.table.refresh();
  83. }, function (data) {
  84. Feng.error("删除失败!" + data.responseJSON.message + "!");
  85. });
  86. ajax.set("id", MedicalCommunity.seItem.id);
  87. ajax.start();
  88. };
  89. Feng.confirm("是否刪除该医共体?", operation);
  90. }
  91. };
  92. /**
  93. * 搜索
  94. */
  95. MedicalCommunity.search = function () {
  96. var queryData = {};
  97. queryData['name'] = $("#name").val();
  98. MedicalCommunity.table.refresh({query: queryData});
  99. }
  100. /**
  101. * 重置
  102. */
  103. MedicalCommunity.reset = function () {
  104. $("#name").val("");
  105. }
  106. $(function () {
  107. var defaultColunms = MedicalCommunity.initColumn();
  108. var table = new BSTable(MedicalCommunity.id, "/admin/nhc.medical_community/list", defaultColunms);
  109. table.init();
  110. MedicalCommunity.table = table;
  111. });