From 6e533fca4187acf4499b0f8f978a3ea0b0979f96 Mon Sep 17 00:00:00 2001 From: zhangshilin Date: Wed, 28 Mar 2018 13:05:56 +0800 Subject: [PATCH] =?UTF-8?q?=E8=9E=8D=E5=90=88=E4=BB=A3=E7=A0=81=20?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=9C=AC=E5=9C=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .settings/org.eclipse.wst.common.component | 3 ++ .../basics/ServiceDictInfoController.java | 33 ++++++++++++++- .../basics/SysDictInfoController.java | 8 ++-- .../nis/web/dao/basics/ServiceDictInfoDao.xml | 2 +- .../com/nis/web/dao/basics/SysDictInfoDao.xml | 2 +- .../resources/messages/message_en.properties | 6 +-- .../resources/messages/message_ru.properties | 2 +- .../messages/message_zh_CN.properties | 3 +- .../webapp/WEB-INF/tags/sys/treeselect.tag | 4 +- .../WEB-INF/views/basics/serviceDictForm.jsp | 42 +++++++++++++++---- 10 files changed, 79 insertions(+), 26 deletions(-) diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index dbec03a4c..02aec5565 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -4,6 +4,9 @@ + + uses + diff --git a/src/main/java/com/nis/web/controller/basics/ServiceDictInfoController.java b/src/main/java/com/nis/web/controller/basics/ServiceDictInfoController.java index 266555c27..d995d1eaf 100644 --- a/src/main/java/com/nis/web/controller/basics/ServiceDictInfoController.java +++ b/src/main/java/com/nis/web/controller/basics/ServiceDictInfoController.java @@ -1,6 +1,7 @@ package com.nis.web.controller.basics; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -396,14 +397,42 @@ public class ServiceDictInfoController extends BaseController { } }else{ ServiceDictInfo c = serviceDictInfoService.getDictById(currentId); - if((p.getLevelNo()+c.getLevelNo())<(max+1)){ - return true; + if(p.getLevelNo() list = serviceDictInfoService.getDictByParentId(currentId); + if(list==null||list.size()==0){ + return true; + } + List resultList = Lists.newArrayList(); + List intList = Lists.newArrayList(); + allTreeNode(1,list,resultList); + for(ServiceDictInfo se:resultList){ + intList.add(se.getLevelNo()); + } + int x = Collections.max(intList); + if((p.getLevelNo()+x)<(max+1)){ + return true; + } } } } return false; } + /** + * 查出所该节点下有树形子节点 + */ + + void allTreeNode(Integer levelNo, List list,List resultList){ + if(list!=null&&list.size()>0){ + for(ServiceDictInfo se:list){ + se.setLevelNo(levelNo+1); + resultList.add(se); + List newList = serviceDictInfoService.getDictByParentId(se.getServiceDictId()); + allTreeNode(se.getLevelNo(),newList,resultList); + } + } + } } diff --git a/src/main/java/com/nis/web/controller/basics/SysDictInfoController.java b/src/main/java/com/nis/web/controller/basics/SysDictInfoController.java index ba4b87420..d8379797c 100644 --- a/src/main/java/com/nis/web/controller/basics/SysDictInfoController.java +++ b/src/main/java/com/nis/web/controller/basics/SysDictInfoController.java @@ -185,10 +185,10 @@ public class SysDictInfoController extends BaseController { try { sysDictInfoService.saveOrUpdate(sysDictInfo); - addMessage(redirectAttributes, "保存成功"); + addMessage(redirectAttributes, "save_success"); } catch (Exception e) { e.printStackTrace(); - addMessage(redirectAttributes, "保存失败!"); + addMessage(redirectAttributes, "save_failed"); } return "redirect:" + adminPath + "/basics/sysDictInfo/list?itType="+itType; @@ -205,10 +205,10 @@ public class SysDictInfoController extends BaseController { public String delete(SysDictInfo sysDictInfo, RedirectAttributes redirectAttributes, String itType, String mulitId) { try { sysDictInfoService.deleteDict(mulitId); - addMessage(redirectAttributes, "删除成功"); + addMessage(redirectAttributes, "delete_success"); } catch (Exception e) { e.printStackTrace(); - addMessage(redirectAttributes, "删除失败!"); + addMessage(redirectAttributes, "delete_failed"); } return "redirect:" + adminPath + "/basics/sysDictInfo/list?itType="+itType; } diff --git a/src/main/java/com/nis/web/dao/basics/ServiceDictInfoDao.xml b/src/main/java/com/nis/web/dao/basics/ServiceDictInfoDao.xml index 202027d2e..fbac199f3 100644 --- a/src/main/java/com/nis/web/dao/basics/ServiceDictInfoDao.xml +++ b/src/main/java/com/nis/web/dao/basics/ServiceDictInfoDao.xml @@ -300,7 +300,7 @@ diff --git a/src/main/java/com/nis/web/dao/basics/SysDictInfoDao.xml b/src/main/java/com/nis/web/dao/basics/SysDictInfoDao.xml index b3193b41b..7385a81a3 100644 --- a/src/main/java/com/nis/web/dao/basics/SysDictInfoDao.xml +++ b/src/main/java/com/nis/web/dao/basics/SysDictInfoDao.xml @@ -313,7 +313,7 @@ diff --git a/src/main/resources/messages/message_en.properties b/src/main/resources/messages/message_en.properties index b3370d051..596f0bc20 100644 --- a/src/main/resources/messages/message_en.properties +++ b/src/main/resources/messages/message_en.properties @@ -147,8 +147,7 @@ desc=description parent_id=parentid is_leaf=whether leaf node is_valid=whether valid -create_time=createtime -edit_time=edittime +create_time=create time superior_config=superior configuration config_content=configuration content root_node=root node @@ -156,7 +155,7 @@ leafChange=this configuration includes subnode,cannot be leaf node typeChild=this data type will be not same with subnode typeSame=please select the consistent upper and lower data types isLevelNoSure=more than the maximum level -is_repeat=field content is repeat +is_repeat=content is repeat submitting=submitting #============yewu end====================== @@ -304,7 +303,6 @@ audit_time=audit time yes=yes no=no deleted=deleted -cancel_approved=cancel approved #==========youjianguankong end===================== diff --git a/src/main/resources/messages/message_ru.properties b/src/main/resources/messages/message_ru.properties index 85a155908..f9927ae5e 100644 --- a/src/main/resources/messages/message_ru.properties +++ b/src/main/resources/messages/message_ru.properties @@ -156,7 +156,7 @@ leafChange=this configuration includes subnode,cannot be leaf node typeChild=this data type will be not same with subnode typeSame=please select the consistent upper and lower data types isLevelNoSure=more than the maximum level -is_repeat=field content is repeat +is_repeat=content is repeat submitting=submitting #============yewu end====================== diff --git a/src/main/resources/messages/message_zh_CN.properties b/src/main/resources/messages/message_zh_CN.properties index 2a5269352..a308afc51 100644 --- a/src/main/resources/messages/message_zh_CN.properties +++ b/src/main/resources/messages/message_zh_CN.properties @@ -19,6 +19,7 @@ show=\u67e5\u770b edit=\u4fee\u6539 hi=\u4f60\u597d exit=\u9000\u51fa +choose=\u9009\u62e9 #==========menu begin===================== requestInfo=\u6765\u51fd\u4fe1\u606f @@ -138,7 +139,6 @@ parent_id=\u7236ID is_leaf=\u662f\u5426\u53f6\u5b50\u8282\u70b9 is_valid=\u6709\u6548\u6807\u5fd7 create_time=\u521b\u5efa\u65f6\u95f4 -edit_time=\u4fee\u6539\u65f6\u95f4 superior_config=\u4e0a\u7ea7\u914d\u7f6e config_content=\u914d\u7f6e\u5185\u5bb9 root_node=\u6839\u8282\u70b9 @@ -174,7 +174,6 @@ begin_date=\u5f00\u59cb\u65f6\u95f4 end_date=\u7ed3\u675f\u65f6\u95f4 delete=\u5220\u9664 special_task=\u4e13\u9879\u4efb\u52a1 -cancel_approved=\u914d\u7f6e\u53d6\u6d88 task_name=\u4e13\u9879\u540d\u79f0 task_org=\u62a5\u9001\u5355\u4f4d task_time=\u62a5\u9001\u65f6\u95f4 diff --git a/src/main/webapp/WEB-INF/tags/sys/treeselect.tag b/src/main/webapp/WEB-INF/tags/sys/treeselect.tag index c551f505b..83ac743de 100644 --- a/src/main/webapp/WEB-INF/tags/sys/treeselect.tag +++ b/src/main/webapp/WEB-INF/tags/sys/treeselect.tag @@ -43,8 +43,8 @@ return true; } // 正常打开 - top.$.jBox.open("iframe:${ctx}/tag/treeselect?url="+encodeURIComponent("${url}")+"&module=${module}&checked=${checked}&extId=${extId}&isAll=${isAll}", "选择${title}", 320, 420, { - ajaxData:{selectIds: $("#${id}Id").val()},buttons:{"":"ok", ${allowClear?"\"\":\"clear\", ":""}"":true}, submit:function(v, h, f){ + top.$.jBox.open("iframe:${ctx}/tag/treeselect?url="+encodeURIComponent("${url}")+"&module=${module}&checked=${checked}&extId=${extId}&isAll=${isAll}", "${title}", 320, 420, { + ajaxData:{selectIds: $("#${id}Id").val()},buttons:{"ok":"ok", ${allowClear?"\"clear\":\"clear\", ":""}"close":true}, submit:function(v, h, f){ if (v=="ok"){ var tree = h.find("iframe")[0].contentWindow.tree;//h.find("iframe").contents(); var ids = [], names = [], nodes = []; diff --git a/src/main/webapp/WEB-INF/views/basics/serviceDictForm.jsp b/src/main/webapp/WEB-INF/views/basics/serviceDictForm.jsp index cff7bde40..25682aab4 100644 --- a/src/main/webapp/WEB-INF/views/basics/serviceDictForm.jsp +++ b/src/main/webapp/WEB-INF/views/basics/serviceDictForm.jsp @@ -23,18 +23,36 @@ } }); - + errorShow(); } + function errorShow(){ + var flaelNoSure = false; + $.ajax({ + type:'post', + async:false, + url:'${ctx}/basics/serviceDictInfo/isLevelTotalSure', + data:{parentId:$(".singleClass").val(),currentId:'${serviceDictInfo.serviceDictId}'}, + success:function(data){ + if(data){ + $(".errorShow").hide(); + }else{ + $(".errorShow").show(); + } + flaelNoSure = data; + } + }); + return flaelNoSure; + } $(document).ready(function() { + $("#serviceDictInfoId").on('onchange',errorShow); - //层级校验 - jQuery.validator.addMethod("isLevelNoSure",function(value,element){ + //层级校验 + /* jQuery.validator.addMethod("isLevelNoSure",function(value,element){ var flagIsLevelNoSure = false; $.ajax({ type:'post', async:false, - cache:false, url:'${ctx}/basics/serviceDictInfo/isLevelTotalSure', data:{parentId:$(".singleClass").val(),currentId:'${serviceDictInfo.serviceDictId}'}, success:function(data){ @@ -43,7 +61,7 @@ }); return flagIsLevelNoSure; - },"选择此配置上下层级数将超过最大层级"); + },"选择此配置上下层级数将超过最大层级"); */ //类型选择与上级是否冲突 jQuery.validator.addMethod("typeSame",function(value,element){ @@ -109,9 +127,9 @@ //ignore:[], //需验证 item_code item_value rules: { - 'parent.itemValue':{ + /* 'parent.itemValue':{ isLevelNoSure:true - }, + }, */ 'itemCode':{ //isLevelNoSure:true, @@ -132,9 +150,9 @@ }, messages: { - 'parent.itemValue':{ + /* 'parent.itemValue':{ isLevelNoSure:'' - }, + }, */ 'itemCode':{ //isLevelNoSure:"选择此配置上下层级数将超过四级", required:'', @@ -154,6 +172,11 @@ }, submitHandler: function(form){ + var is_level_wrong=errorShow(); + if(!is_level_wrong){ + return false; + $(".errorShow").show(); + } loading(''); form.submit(); }, @@ -215,6 +238,7 @@ +