Browse Source

自动关联部门下的数据库

hujie 1 year ago
parent
commit
c6744e5ba5

+ 5 - 0
cn.com.taiji.system/src/main/java/cn/com/taiji/zhongxiao/web/TinfoClassHitchController.java

@@ -242,6 +242,11 @@ public class TinfoClassHitchController {
 	model.addAttribute("opinionList", opinionList);
 	model.addAttribute("opinionList", opinionList);
 	List<Dbinfo> dblist= dbinfoService.findDbinfoListByDeptid(info.getProvidebmcode());
 	List<Dbinfo> dblist= dbinfoService.findDbinfoListByDeptid(info.getProvidebmcode());
 	model.addAttribute("dblist", dblist);
 	model.addAttribute("dblist", dblist);
+	String defaultdb = "0";
+	if (dblist!= null && dblist.size() > 0) {
+		defaultdb = dblist.get(0).getDbId();
+	}
+	model.addAttribute("defaultdb",defaultdb);
 	model.addAttribute("gjchange",gjchange);
 	model.addAttribute("gjchange",gjchange);
 	loginfoService.logDealInfo("3", modelType,"信息类查看", "t_infoclass", id, ToolUtil.getIpAddr(request), request.getRequestURI(),userInfo);
 	loginfoService.logDealInfo("3", modelType,"信息类查看", "t_infoclass", id, ToolUtil.getIpAddr(request), request.getRequestURI(),userInfo);
 	return "thymeleaf/tinfohitchclass/tinfoclass_view";
 	return "thymeleaf/tinfohitchclass/tinfoclass_view";

+ 19 - 4
cn.com.taiji.system/src/main/resources/templates/thymeleaf/tinfohitchclass/tinfoclass_onlyview.html

@@ -60,7 +60,7 @@
                        <select name="dbid" id="dbid" class="input-select" datatype="*1-100" nullmsg="必填" sucmsg="&nbsp;" errormsg="不超过100个字符" >
                        <select name="dbid" id="dbid" class="input-select" datatype="*1-100" nullmsg="必填" sucmsg="&nbsp;" errormsg="不超过100个字符" >
                        <option value="" title="请选择">请选择</option>
                        <option value="" title="请选择">请选择</option>
                        <option  th:each="code,codeStat:${dblist}" th:value="${code.dbId}" 
                        <option  th:each="code,codeStat:${dblist}" th:value="${code.dbId}" 
-                       th:attr="dbName=${code.dbName},dbPwd=${code.dbPwd},dbUsername=${code.dbUsername},dbIp=${code.dbIp},dbPort=${code.dbPort},dbType=${code.dbType}, dbConnectname=${code.dbConnectname}" 
+                       th:attr="id=${code.dbId},dbName=${code.dbName},dbPwd=${code.dbPwd},dbUsername=${code.dbUsername},dbIp=${code.dbIp},dbPort=${code.dbPort},dbType=${code.dbType}, dbConnectname=${code.dbConnectname}"
                        th:title="${code.dbConnectname}" th:text="${code.dbConnectname}" 
                        th:title="${code.dbConnectname}" th:text="${code.dbConnectname}" 
                        th:selected="${info.dbid==code.dbId}">请选择</option>
                        th:selected="${info.dbid==code.dbId}">请选择</option>
                        </select>
                        </select>
@@ -86,12 +86,12 @@
                        <td id="dbIp">
                        <td id="dbIp">
                        </td>
                        </td>
                  </tr>
                  </tr>
-                  <tr th:if="${info.sharemodetypename=='数据库'}">
+                  <tr th:if="${info.sharemodetypename=='数据库'}" style="display: none;">
                  <th>数据库用户</th>
                  <th>数据库用户</th>
                        <td id="dbUsername">
                        <td id="dbUsername">
                        </td>
                        </td>
                  </tr>
                  </tr>
-                  <tr th:if="${info.sharemodetypename=='数据库'}">
+                  <tr th:if="${info.sharemodetypename=='数据库'}" style="display: none;">
                  <th>数据库密码</th>
                  <th>数据库密码</th>
                        <td id="dbPwd">
                        <td id="dbPwd">
                        </td>
                        </td>
@@ -161,7 +161,22 @@
 		
 		
 <script th:inline="javascript">
 <script th:inline="javascript">
  /*<![CDATA[*/
  /*<![CDATA[*/
-	 
+    var defaultdb=/*[[${info.dbid}]]*/;
+     $(document).ready(function(){
+         $("#dbid").change(function(){
+             var options=$("#dbid option:selected");
+             $("#dbName").text(options.attr("dbName"));
+             $("#dbPwd").text(options.attr("dbPwd"));
+             $("#dbUsername").text(options.attr("dbUsername"));
+             $("#dbIp").text(options.attr("dbIp"));
+             $("#dbPort").text(options.attr("dbPort"));
+             $("#dbType").text(options.attr("dbType"));
+         });
+         if (defaultdb != undefined && defaultdb != null && defaultdb != "") {
+             $("#dbid").val(defaultdb);
+             $("#dbid").change();
+         }
+     });
  /*]]>*/
  /*]]>*/
  </script>	
  </script>	
  <script type="text/javascript" th:src="@{/theme/listscroll_js.js}"></script>
  <script type="text/javascript" th:src="@{/theme/listscroll_js.js}"></script>

+ 26 - 18
cn.com.taiji.system/src/main/resources/templates/thymeleaf/tinfohitchclass/tinfoclass_view.html

@@ -81,7 +81,7 @@
                        <select name="dbid" id="dbid" class="input-select" >
                        <select name="dbid" id="dbid" class="input-select" >
                        <option value="" title="请选择">请选择</option>
                        <option value="" title="请选择">请选择</option>
                        <option  th:each="code,codeStat:${dblist}" th:value="${code.dbId}" 
                        <option  th:each="code,codeStat:${dblist}" th:value="${code.dbId}" 
-                       th:attr="dbName=${code.dbName},dbPwd=${code.dbPwd},dbUsername=${code.dbUsername},dbIp=${code.dbIp},dbPort=${code.dbPort},dbType=${code.dbType}, dbConnectname=${code.dbConnectname}" 
+                       th:attr="id=${code.dbId},dbName=${code.dbName},dbPwd=${code.dbPwd},dbUsername=${code.dbUsername},dbIp=${code.dbIp},dbPort=${code.dbPort},dbType=${code.dbType}, dbConnectname=${code.dbConnectname}"
                        th:title="${code.dbConnectname}" th:text="${code.dbConnectname}" 
                        th:title="${code.dbConnectname}" th:text="${code.dbConnectname}" 
                        th:selected="${info.dbid==code.dbId}">请选择</option>
                        th:selected="${info.dbid==code.dbId}">请选择</option>
                        </select>
                        </select>
@@ -107,19 +107,19 @@
                        <td id="dbIp">
                        <td id="dbIp">
                        </td>
                        </td>
                  </tr>
                  </tr>
-                  <tr th:if="${info.sharemodetypename=='数据库'}">
+                  <tr th:if="${info.sharemodetypename=='数据库'}" style="display: none;">
                  <th>数据库用户</th>
                  <th>数据库用户</th>
                        <td id="dbUsername">
                        <td id="dbUsername">
                        </td>
                        </td>
                  </tr>
                  </tr>
-                  <tr th:if="${info.sharemodetypename=='数据库'}">
+                  <tr th:if="${info.sharemodetypename=='数据库'}" style="display: none;">
                  <th>数据库密码</th>
                  <th>数据库密码</th>
                        <td id="dbPwd">
                        <td id="dbPwd">
                        </td>
                        </td>
                  </tr>
                  </tr>
                     <tr>
                     <tr>
                         <th><font class="fontred">*</font>挂接情况说明</th>
                         <th><font class="fontred">*</font>挂接情况说明</th>
-                       <td >
+                       <td>
                        		<textarea datatype="*1-200" nullmsg="必填" sucmsg="&nbsp;" errormsg="不超过200个字符" class="input-textarea" placeholder="前置机存储绝对路径如D:/ABC;接口挂接方式示例:服务名称为sgat_rkxx_cx_sjw" rows="" cols="" name="hitch" th:text="${info.hitch}" id="hitch" style="  width: 100%; height: 90px; ">
                        		<textarea datatype="*1-200" nullmsg="必填" sucmsg="&nbsp;" errormsg="不超过200个字符" class="input-textarea" placeholder="前置机存储绝对路径如D:/ABC;接口挂接方式示例:服务名称为sgat_rkxx_cx_sjw" rows="" cols="" name="hitch" th:text="${info.hitch}" id="hitch" style="  width: 100%; height: 90px; ">
                        		</textarea>
                        		</textarea>
                        </td>
                        </td>
@@ -215,25 +215,33 @@
  /*<![CDATA[*/
  /*<![CDATA[*/
 	 //获取变更状态
 	 //获取变更状态
 	 var gjchange=/*[[${gjchange}]]*/;
 	 var gjchange=/*[[${gjchange}]]*/;
-	 $(document).ready(function(){ 
-		 $("#gjchange").val(gjchange);
-	 });
+     var defaultdb=/*[[${defaultdb}]]*/;
  
  
 	 //点击上传附件   跟新表单内容
 	 //点击上传附件   跟新表单内容
 	   //$("#hitchUpBut").click(function(){
 	   //$("#hitchUpBut").click(function(){
 		/*  setTimeout(function(){
 		/*  setTimeout(function(){
 			 countSecond();
 			 countSecond();
 			 },800);   */
 			 },800);   */
-	  //} ) 
-    $("#dbid").change(function(){
-    	var options=$("#dbid option:selected");
-    	$("#dbName").text(options.attr("dbName"));
-    	$("#dbPwd").text(options.attr("dbPwd"));
-    	$("#dbUsername").text(options.attr("dbUsername"));
-    	$("#dbIp").text(options.attr("dbIp"));
-    	$("#dbPort").text(options.attr("dbPort"));
-    	$("#dbType").text(options.attr("dbType"));
-    });
+	  //} )
+     $(document).ready(function(){
+         $("#dbid").change(function(){
+             var options=$("#dbid option:selected");
+             changeDbId(options);
+         });
+         $("#gjchange").val(gjchange);
+         if (defaultdb != "0") {
+             $("#dbid").val(defaultdb);
+             $("#dbid").change();
+         }
+     });
+ var changeDbId = function(options){
+     $("#dbName").text(options.attr("dbName"));
+     $("#dbPwd").text(options.attr("dbPwd"));
+     $("#dbUsername").text(options.attr("dbUsername"));
+     $("#dbIp").text(options.attr("dbIp"));
+     $("#dbPort").text(options.attr("dbPort"));
+     $("#dbType").text(options.attr("dbType"));
+ }
 	var upLoadFlag = false;  
 	var upLoadFlag = false;  
  	$("input[type='file']").change(function(){
  	$("input[type='file']").change(function(){
  		$("#hitchUpName").text($("input[type='file']").context.activeElement.files["0"].name);
  		$("#hitchUpName").text($("input[type='file']").context.activeElement.files["0"].name);
@@ -255,7 +263,7 @@
 						//这里明确return false的话表单将不会提交;	
 						//这里明确return false的话表单将不会提交;	
 						if( upLoadFlag ){
 						if( upLoadFlag ){
 							$("#hitchUpBut").submit();
 							$("#hitchUpBut").submit();
-						} 
+						}
 					},
 					},
 					callback : function(form) {
 					callback : function(form) {
                         	var check = confirm("您确定要提交表单吗?");
                         	var check = confirm("您确定要提交表单吗?");