dbInfoJs.jsp 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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 dbInfo = {
  6. grid: null,
  7. dialog: null,
  8. init: function () {
  9. this.bindEvents();
  10. this.initForm();
  11. },
  12. initForm: function () {
  13. var me = this;
  14. $('.m-retrieve-area').show();
  15. $("#txtName").ligerSearch({
  16. onClick:function(value){
  17. me.reloadGrid();
  18. }});
  19. var dbInfoStatus = liger.get("valid").value;
  20. if(dbInfoStatus ==undefined || dbInfoStatus ==null || dbInfoStatus.length<=0){
  21. liger.get("valid").selectValue("");
  22. }
  23. me.grid = $("#div_grid").ligerGrid({
  24. url: '${contextRoot}/tenant/dataBase/getDBList',
  25. parms: {
  26. name: $('#txtName').val(),
  27. valid:dbInfoStatus
  28. },
  29. columns: [
  30. {display: '实例名称', id: 'id', name: 'name', width: '20%'},
  31. {display: '主机', name: 'host', width: '15%'},
  32. {display: '端口', name: 'port', width: '10%'},
  33. {display: '用户', name: 'usrName', width: '10%'},
  34. {display: '状态', name: 'valid', width: '10%',align: 'center', render: function (rowdata, rowindex, value) {
  35. if(rowdata.valid==1 ){
  36. return ' <div style="vertical-align:middle;margin-top: 10px;"><span>有效 </span></div>';
  37. }else if(rowdata.valid==0){
  38. return ' <div style="vertical-align:middle;margin-top: 10px;"><span>无效 </span></div>';
  39. }
  40. }},
  41. {
  42. display: '操作', name: 'operator', width: '40%', render: function (row) {
  43. var html = '<div class="m-inline-buttons" style="width:350px;">';
  44. html += "<a class=\"m-btn\" style=\"padding-right:10px\" onclick=\"dbInfo.editorDialog('"+row.id+"','disabled')\">查看详情</a>";
  45. html += "<a class=\"m-btn-edit\" onclick=\"dbInfo.editorDialog('"+row.id+"','')\"></a>";
  46. html += "<a class=\"m-btn-delete\" onclick=\"dbInfo.delete('"+row.id+"')\"></a>";
  47. html += '</div>';
  48. return html;
  49. }
  50. }
  51. ],
  52. onDblClickRow: function (row) {
  53. me.editorDialog(row.id);
  54. }
  55. });
  56. },
  57. bindEvents: function () {
  58. var me = this;
  59. var flag = false;
  60. $('#div_new_record').click(function () {
  61. me.editorDialog();
  62. });
  63. $("#valid").ligerComboBox({data : [{"value":"全部","code":""},{"value":"有效","code":"1"},{"value":"无效","code":"0"}],
  64. cancelable:false,
  65. initIsTriggerEvent: false,
  66. onSelected: function (value)
  67. {
  68. if (flag) {
  69. me.reloadGrid();
  70. } else {
  71. flag = true;
  72. }
  73. },
  74. onSuccess:function(data){
  75. }});
  76. $(".l-text").css("display","inline-block");
  77. $(".l-text-wrapper").css("display","inline-block");
  78. },
  79. delete:function(id){
  80. var message = "确定要删除该应用信息吗?";
  81. jQuery.ligerDialog.confirm(message, function (confirm) {
  82. if (confirm)
  83. {
  84. $.ajax({ //ajax处理
  85. type: "POST",
  86. url : "${contextRoot}/tenant/dataBase/deleteDBInfo",
  87. dataType : "json",
  88. data:{id:id},
  89. cache:false,
  90. success :function(data){
  91. if(data.successFlg) {
  92. $.ligerDialog.success(data.message);
  93. dbInfo.grid.reload();
  94. }
  95. else{
  96. $.ligerDialog.error(data.message);
  97. }
  98. },
  99. error :function(data){
  100. $.ligerDialog.error("Status:"+data.status +"(" +data.statusText+")");
  101. }
  102. });
  103. }
  104. });
  105. },
  106. //刷新列表数据
  107. reloadGrid: function () {
  108. this.grid.set({
  109. parms: {name: $('#txtName').val(),valid:$('#valid_val').val()}
  110. });
  111. this.grid.reload();
  112. },
  113. //编辑弹窗
  114. editorDialog: function (id, flag) {
  115. var me = this;
  116. var title = "新增数据库实例";
  117. var params = null;
  118. if (id != undefined && id != null) {
  119. title = "编辑数据库实例";
  120. params = {"id": id, "flag": flag};
  121. }
  122. me.dialog = $.ligerDialog.open({
  123. height: 600,
  124. width: 500,
  125. title: title,
  126. url: '${contextRoot}/tenant/dataBase/editorDbInfo',
  127. //load: true,
  128. urlParms: params
  129. });
  130. },
  131. anthorize: function (id) {
  132. },
  133. //弹窗返回
  134. dialogSuccess: function (message) {
  135. $.ligerDialog.success(message);
  136. dbInfo.reloadGrid();
  137. dbInfo.dialog.close();
  138. }
  139. };
  140. $(function () {
  141. dbInfo.init();
  142. });
  143. </script>