configSourcesJs.jsp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8" %>
  2. <%@include file="/WEB-INF/ehr/commons/jsp/commonInclude.jsp" %>
  3. <script>
  4. /* *************************** 自定义模块 ***************************** */
  5. var configSources = {
  6. dialog: null,
  7. grid: null,
  8. //初始化
  9. init: function () {
  10. var me = this;
  11. $('.m-retrieve-area').show();
  12. me.grid = $("#div_grid").ligerGrid({
  13. url: '${contextRoot}/datasource/getDatasource',
  14. columns: [
  15. {display: '数据源名称', name: 'name', width: '25%'},
  16. {
  17. display: '机构名称',
  18. name: 'orgName',
  19. width: '25%',
  20. dict: false,
  21. dictName: "SYSTEM_ORGANIZATION"
  22. },
  23. {
  24. display: '数据源类型',
  25. name: 'type',
  26. width: '25%',
  27. dict: false,
  28. dictName: "DATASOURCE_TYPE",
  29. render: function (row) {
  30. if (row.type == 1) {
  31. return "Web Service";
  32. } else if (row.type == 2) {
  33. return "文件系统";
  34. } else {
  35. return "数据库";
  36. }
  37. }
  38. },
  39. {
  40. display: '操作', name: 'operator', width: '25%', render: function (row) {
  41. var html = '<div class="m-inline-buttons" style="width:80px;">';
  42. html += "<a class=\"m-btn-edit\" onclick=\"configSources.editorSource('" + row.id + "')\"></a>";
  43. html += "<a class=\"m-btn-delete\" onclick=\"configSources.deleteSource('" + row.id + "')\"></a>";
  44. html += '</div>';
  45. return html;
  46. }
  47. }
  48. ],
  49. onDblClickRow: function (row) {
  50. me.editorSource(row.id);
  51. }
  52. });
  53. me.bindEvents();
  54. },
  55. //绑定按钮事件
  56. bindEvents: function () {
  57. var me = this;
  58. $('#div_new_record').click(function () {
  59. me.editorSource();
  60. });
  61. },
  62. //编辑弹窗
  63. editorSource: function (id) {
  64. var me = this;
  65. var title = "新增数据源";
  66. var params = null;
  67. if (id != undefined && id != null) {
  68. title = "编辑数据源";
  69. params = {sourceId: id};
  70. }
  71. me.dialog = $.ligerDialog.open({
  72. id: 'sourceDialog',
  73. height: 560,
  74. width: 600,
  75. title: title,
  76. url: '${contextRoot}/datasource/editorSource',
  77. //load: true,
  78. urlParms: params
  79. });
  80. },
  81. //删除数据源
  82. deleteSource: function (id) {
  83. var message = "确定要删除该数据源吗?";
  84. jQuery.ligerDialog.confirm(message, function (confirm) {
  85. if (confirm) {
  86. $.ajax({ //ajax处理
  87. type: "POST",
  88. url: "${contextRoot}/datasource/deleteDatasource",
  89. dataType: "json",
  90. data: {id: id},
  91. cache: false,
  92. success: function (data) {
  93. if (data.successFlg) {
  94. $.ligerDialog.success(data.message);
  95. configSources.grid.reload();
  96. }
  97. else {
  98. $.ligerDialog.error(data.message);
  99. }
  100. },
  101. error: function (data) {
  102. $.ligerDialog.error("Status:" + data.status + "(" + data.statusText + ")");
  103. }
  104. });
  105. }
  106. });
  107. },
  108. //关闭弹窗
  109. callbackDialog: function (message) {
  110. var me = this;
  111. if (message != undefined && message.length > 0) {
  112. $.ligerDialog.success(message);
  113. }
  114. me.grid.reload();
  115. me.dialog.close();
  116. }
  117. };
  118. $(function () {
  119. configSources.init();
  120. });
  121. </script>