(1)tree属性扩展,支持新增节点
(2)特定服务增加一列标记新增节点
This commit is contained in:
@@ -31,7 +31,14 @@ public class SpecificServiceCfg extends BaseEntity<SpecificServiceCfg>{
|
||||
private Date endDate; // 结束日期
|
||||
private String showSequence; //显示序号
|
||||
private String businessType;
|
||||
private Integer addFlag;//app界面添加标记
|
||||
|
||||
public Integer getAddFlag() {
|
||||
return addFlag;
|
||||
}
|
||||
public void setAddFlag(Integer addFlag) {
|
||||
this.addFlag = addFlag;
|
||||
}
|
||||
public String getBusinessType() {
|
||||
return businessType;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import java.util.Map;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
public final class Constants {
|
||||
public static Integer APP_SPEC_SERVICE_CODE_MIN_VAL=Configurations.getIntProperty("app_spec_service_code_min_val", 300001);
|
||||
public static Integer APP_SPEC_SERVICE_CODE_MAX_VAL=Configurations.getIntProperty("app_spec_service_code_max_val", 268435455);
|
||||
public static String APP_CFG_USERREGION_SPLITOR=Configurations.getStringProperty("app_cfg_userregion_splitor", "&");
|
||||
/**
|
||||
* MaatConfig 默认值
|
||||
|
||||
@@ -7,6 +7,8 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import com.nis.web.security.UserUtils;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping("${adminPath}/tag")
|
||||
@@ -26,7 +28,9 @@ public class TagController extends BaseController {
|
||||
model.addAttribute("selectIds", request.getParameter("selectIds")); // 指定默认选中的ID
|
||||
model.addAttribute("isAll", request.getParameter("isAll")); // 是否读取全部数据,不进行权限过滤
|
||||
model.addAttribute("module", request.getParameter("module")); // 过滤栏目模型(仅针对CMS的Category树)
|
||||
model.addAttribute("title", request.getParameter("title"));
|
||||
model.addAttribute("title", request.getParameter("title"));//根节点替换文本
|
||||
model.addAttribute("enableAddBtn", request.getParameter("enableAddBtn"));//节点是否可编辑
|
||||
model.addAttribute("userId", UserUtils.getUser().getId());//如果启用了addBtn,则使用userId判断是否是用户自己创建的,用户自己创建的节点可删除
|
||||
return "/sys/tagTreeselect";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.nis.web.controller.specific;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
@@ -13,6 +12,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
@@ -22,6 +22,8 @@ import com.google.common.collect.Maps;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.SysDataDictionaryItem;
|
||||
import com.nis.domain.specific.SpecificServiceCfg;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.StringUtils;
|
||||
import com.nis.web.controller.BaseController;
|
||||
@@ -201,8 +203,9 @@ public class SpecificServiceCfgController extends BaseController {
|
||||
Map<String, Object> map2 = Maps.newHashMap();
|
||||
map2.put("id", 0);
|
||||
map2.put("pId", 0);
|
||||
map2.put("type",0);
|
||||
map2.put("serviceType",0);
|
||||
map2.put("business",-2);
|
||||
map2.put("groupId",0);
|
||||
map2.put("name","root_node");
|
||||
//map2.put("placeholder","0");
|
||||
mapList.add(map2);
|
||||
@@ -222,6 +225,7 @@ public class SpecificServiceCfgController extends BaseController {
|
||||
map.put("name",props.getProperty(dict.getItemValue(), dict.getItemValue()));
|
||||
map.put("serviceType",cfgType);
|
||||
map.put("businessType","-1");
|
||||
map.put("groupId",0);
|
||||
businessList.add(map);
|
||||
}
|
||||
mapList.addAll(businessList);
|
||||
@@ -242,7 +246,12 @@ public class SpecificServiceCfgController extends BaseController {
|
||||
map.put("pId", "businessType"+business.getItemCode());
|
||||
map.put("name",specificServiceCfg.getSpecServiceName());
|
||||
map.put("serviceType",specificServiceCfg.getCfgType());
|
||||
map.put("serviceCode",specificServiceCfg.getSpecServiceCode());
|
||||
map.put("businessType",specificServiceCfg.getBusinessType());
|
||||
map.put("groupId",specificServiceCfg.getGroupId());
|
||||
if(specificServiceCfg.getAddFlag()!=null) {
|
||||
map.put("user",specificServiceCfg.getAddFlag());
|
||||
}
|
||||
mapList.add(map);
|
||||
break;
|
||||
}
|
||||
@@ -253,6 +262,7 @@ public class SpecificServiceCfgController extends BaseController {
|
||||
map.put("pId", specificServiceCfg.getParent().getSpecServiceId());
|
||||
map.put("name",specificServiceCfg.getSpecServiceName());
|
||||
map.put("serviceType",specificServiceCfg.getCfgType());
|
||||
map.put("groupId",specificServiceCfg.getGroupId());
|
||||
mapList.add(map);
|
||||
}
|
||||
}
|
||||
@@ -272,6 +282,10 @@ public class SpecificServiceCfgController extends BaseController {
|
||||
map.put("pId", specificServiceCfg.getParent().getSpecServiceId());
|
||||
map.put("name",specificServiceCfg.getSpecServiceName());
|
||||
map.put("type",specificServiceCfg.getCfgType());
|
||||
map.put("groupId",specificServiceCfg.getGroupId());
|
||||
if(specificServiceCfg.getAddFlag()!=null) {
|
||||
map.put("user",specificServiceCfg.getAddFlag());
|
||||
}
|
||||
mapList.add(map);
|
||||
}
|
||||
}
|
||||
@@ -380,5 +394,70 @@ public class SpecificServiceCfgController extends BaseController {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "ajaxSaveOrUpdateApp",method=RequestMethod.POST )
|
||||
public Map<String,Object> ajaxSaveOrUpdateApp(@RequestParam(required=true,value="specServiceId")String specServiceId,@RequestParam(required=false,value="specServiceCode")String specServiceCode,@RequestParam(required=true,value="specServiceName") String specServiceName,
|
||||
@RequestParam(required=true,value="cfgType") String cfgType, @RequestParam(required=true,value="businessType")String businessType,@RequestParam(required=false,value="addFlag")String addFlag,
|
||||
@RequestParam(required=false,value="groupId")String groupId){
|
||||
Map<String, Object> map = Maps.newHashMap();
|
||||
//校验是真ID还是假ID,假的Id以manual开头无法转换成数字
|
||||
boolean isTrueId=false;
|
||||
try {
|
||||
Long.parseLong(specServiceId);
|
||||
isTrueId=true;
|
||||
}catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
try{
|
||||
SpecificServiceCfg cfg=new SpecificServiceCfg();
|
||||
if(isTrueId) {
|
||||
cfg.setSpecServiceId(Integer.parseInt(specServiceId));
|
||||
}
|
||||
if(StringUtils.isNotBlank(specServiceCode)) {
|
||||
cfg.setSpecServiceCode(Integer.parseInt(specServiceCode));
|
||||
}
|
||||
cfg.setAddFlag(Integer.parseInt(addFlag));
|
||||
cfg.setSpecServiceName(specServiceName);
|
||||
cfg.setBusinessType(businessType);
|
||||
cfg.setCfgType(Integer.parseInt(cfgType));
|
||||
cfg.setIsValid(Constants.VALID_YES);
|
||||
if(StringUtils.isNotBlank(groupId)) {
|
||||
cfg.setGroupId(Integer.parseInt(groupId));
|
||||
}
|
||||
|
||||
SpecificServiceCfg parent=new SpecificServiceCfg();
|
||||
parent.setSpecServiceId(0);
|
||||
cfg.setParent(parent);
|
||||
specificServiceCfgService.saveOrUpdate(cfg);
|
||||
cfg=specificServiceCfgService.getBySpecServiceId(cfg.getSpecServiceId());
|
||||
map.put("id", cfg.getSpecServiceId());
|
||||
map.put("pId", "businessType"+cfg.getBusinessType());
|
||||
map.put("name",cfg.getSpecServiceName());
|
||||
map.put("serviceType",cfg.getCfgType());
|
||||
map.put("businessType",cfg.getBusinessType());
|
||||
map.put("groupId",cfg.getGroupId());
|
||||
return map;
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if(e instanceof MaatConvertException) {
|
||||
map.put("errTip", "request_service_failed");
|
||||
}else {
|
||||
map.put("errTip", "save_failed");
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "ajaxRemoveApp",method=RequestMethod.POST )
|
||||
public boolean ajaxRemoveApp(@RequestParam(required=true,value="specServiceId")Integer specServiceId){
|
||||
try{
|
||||
specificServiceCfgService.delete(String.valueOf(specServiceId));
|
||||
return true;
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,5 +50,6 @@ public interface SpecificServiceCfgDao extends CrudDao<SpecificServiceCfg> {
|
||||
Integer getParentType(Integer specServiceId);
|
||||
Integer getParentCode(Integer specServiceId);
|
||||
SpecificServiceCfg getRepeat(@Param("specServiceCode")Integer code, @Param("cfgType")Integer cfgType,@Param("parentId")Integer parentId);
|
||||
Integer getMaxServiceCode(@Param("maxCode")Integer code, @Param("cfgType")Integer cfgType,@Param("addFlag")Integer addFlag);
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@
|
||||
<result column="is_leaf" property="isLeaf" jdbcType="INTEGER" />
|
||||
<result column="group_id" property="groupId" jdbcType="INTEGER" />
|
||||
<result column="cfg_type" property="cfgType" jdbcType="INTEGER" />
|
||||
<result column="add_flag" property="addFlag" jdbcType="INTEGER" />
|
||||
<result column="business_type" property="businessType" jdbcType="VARCHAR" />
|
||||
<!-- 父id -->
|
||||
<association property="parent" javaType="com.nis.domain.specific.SpecificServiceCfg">
|
||||
@@ -30,7 +31,8 @@
|
||||
s.is_leaf AS isLeaf,
|
||||
s.group_id AS groupId,
|
||||
s.cfg_type AS cfgType,
|
||||
s.business_type AS businessType
|
||||
s.business_type AS businessType,
|
||||
s.add_flag AS addFlag
|
||||
</sql>
|
||||
|
||||
|
||||
@@ -152,6 +154,9 @@
|
||||
<if test="specificServiceCfg.endDate != null" >
|
||||
AND op_time < #{specificServiceCfg.endDate}
|
||||
</if>
|
||||
<if test="specificServiceCfg.addFlag != null and specificServiceCfg.addFlag != '' ">
|
||||
AND add_flag = #{specificServiceCfg.addFlag}
|
||||
</if>
|
||||
<choose>
|
||||
<when test="orderBy != null and orderBy != '' ">
|
||||
ORDER BY ${orderBy}
|
||||
@@ -161,11 +166,23 @@
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
<select id="getMaxServiceCode" resultType="java.lang.Integer" >
|
||||
SELECT MAX(spec_service_code) FROM specific_service_cfg WHERE is_valid=1 AND spec_service_code < #{maxCode}
|
||||
<if test="cfgType != null and cfgType != '' ">
|
||||
AND cfg_type = #{cfgType}
|
||||
</if>
|
||||
<if test="addFlag != null and addFlag != '' ">
|
||||
AND add_flag = #{addFlag}
|
||||
</if>
|
||||
</select>
|
||||
<!-- 新增 -->
|
||||
<insert id="insert" parameterType="com.nis.domain.specific.SpecificServiceCfg" useGeneratedKeys="true">
|
||||
insert into specific_service_cfg (spec_service_code,spec_service_name,spec_service_desc,is_valid, op_time, parent_id,is_leaf,group_id,cfg_type,business_type)
|
||||
values(#{specServiceCode},#{specServiceName},#{specServiceDesc},#{isValid},#{opTime},#{parent.specServiceId},#{isLeaf},#{groupId},#{cfgType},#{businessType})
|
||||
<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="specServiceId">
|
||||
SELECT LAST_INSERT_ID()
|
||||
</selectKey>
|
||||
insert into specific_service_cfg (spec_service_code,spec_service_name,spec_service_desc,is_valid, op_time, parent_id,is_leaf,group_id,cfg_type,business_type,add_flag)
|
||||
values(#{specServiceCode},#{specServiceName},#{specServiceDesc},#{isValid},#{opTime},#{parent.specServiceId},#{isLeaf},#{groupId},#{cfgType},
|
||||
#{businessType},#{addFlag})
|
||||
</insert>
|
||||
|
||||
<!-- 修改 -->
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.nis.domain.Page;
|
||||
import com.nis.domain.specific.ConfigGroupInfo;
|
||||
import com.nis.domain.specific.SpecificServiceCfg;
|
||||
import com.nis.util.ConfigServiceUtil;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.web.dao.specific.SpecificServiceCfgDao;
|
||||
import com.nis.web.service.BaseService;
|
||||
|
||||
@@ -89,6 +90,21 @@ public class SpecificServiceCfgService extends BaseService{
|
||||
|
||||
specificServiceCfg.setIsValid(1);
|
||||
specificServiceCfg.setOpTime(new Date());
|
||||
//用户添加的需要自增
|
||||
if(specificServiceCfg.getAddFlag()!=null) {
|
||||
Integer serviceCode=specificServiceCfgDao.getMaxServiceCode(Constants.APP_SPEC_SERVICE_CODE_MAX_VAL,specificServiceCfg.getCfgType(),specificServiceCfg.getAddFlag());
|
||||
if(serviceCode==null) {//用户没有添加标签,获取最大的
|
||||
serviceCode=specificServiceCfgDao.getMaxServiceCode(Constants.APP_SPEC_SERVICE_CODE_MAX_VAL,specificServiceCfg.getCfgType(),null);
|
||||
}
|
||||
if(serviceCode==null) {//没有标签,取开始值
|
||||
serviceCode=Constants.APP_SPEC_SERVICE_CODE_MIN_VAL;
|
||||
}else if(serviceCode>Constants.APP_SPEC_SERVICE_CODE_MAX_VAL){
|
||||
throw new RuntimeException("Get specific service code failed,specific service code is beyond the scope of application");
|
||||
}else if(serviceCode<Constants.APP_SPEC_SERVICE_CODE_MIN_VAL) {
|
||||
serviceCode=Constants.APP_SPEC_SERVICE_CODE_MIN_VAL;
|
||||
}
|
||||
specificServiceCfg.setSpecServiceCode(serviceCode.intValue()+1);
|
||||
}
|
||||
specificServiceCfgDao.insert(specificServiceCfg);
|
||||
}else{//修改
|
||||
if(specificServiceCfg.getIsLeaf()==null){
|
||||
@@ -145,5 +161,8 @@ public class SpecificServiceCfgService extends BaseService{
|
||||
public SpecificServiceCfg getRepeat (Integer code,Integer cfgType,Integer parentId) {
|
||||
return specificServiceCfgDao.getRepeat(code,cfgType,parentId);
|
||||
}
|
||||
public Integer getMaxServiceCode (Integer code, Integer cfgType,Integer addFlag) {
|
||||
return specificServiceCfgDao.getMaxServiceCode(code,cfgType,addFlag);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1100,4 +1100,8 @@ min_tcp=Minimum Session Number
|
||||
max_tcp=Maximum Session Number
|
||||
tcp_unit=Unit / byte
|
||||
app_tcp_config=APP TCP Session Feature
|
||||
app_tcp_max_min=Maximum Session Should Not Exceed 4294967295
|
||||
app_tcp_max_min=Maximum Session Should Not Exceed 4294967295
|
||||
new=New
|
||||
BASIC_PROTOCOL_BUSINESS_TYPE=Basic protpcol business classification
|
||||
TUNNEL_BEHAV_BUSINESS_TYPE=Tunnel behavior business classification
|
||||
APP_BUSINESS_TYPE=Application business classification
|
||||
@@ -1096,4 +1096,8 @@ min_tcp=\u6700\u5c0f\u4f1a\u8bdd\u6570
|
||||
max_tcp=\u6700\u5927\u4f1a\u8bdd\u6570
|
||||
tcp_unit=\u5355\u4f4d/\u5b57\u8282
|
||||
app_tcp_config=APP TCP\u4f1a\u8bdd\u5b57\u8282\u6570\u7279\u5f81
|
||||
app_tcp_max_min=\u6700\u5927\u4f1a\u8bdd\u6570\u4e0d\u80fd\u8d85\u8fc74294967295
|
||||
app_tcp_max_min=\u6700\u5927\u4f1a\u8bdd\u6570\u4e0d\u80fd\u8d85\u8fc74294967295
|
||||
new=新
|
||||
BASIC_PROTOCOL_BUSINESS_TYPE=基础协议业务类别
|
||||
TUNNEL_BEHAV_BUSINESS_TYPE=加密隧道行为业务类别
|
||||
APP_BUSINESS_TYPE=社交应用业务类别
|
||||
@@ -461,4 +461,7 @@ maat_cfg_dolog_configpercent_default=100
|
||||
maat_cfg_dolog_configoption_default=1
|
||||
#app\uff0c\u57fa\u7840\u534f\u8bae\uff0c\u7279\u5b9a\u670d\u52a1\u7684userregion\u5206\u9694\u7b26
|
||||
app_cfg_userregion_splitor=&
|
||||
app_id_region=APP_ID
|
||||
app_id_region=APP_ID
|
||||
#application spec service code scope
|
||||
app_spec_service_code_max_val=310000
|
||||
app_spec_service_code_min_val=300001
|
||||
1
src/main/resources/sql/add_spec_add_flag.sql
Normal file
1
src/main/resources/sql/add_spec_add_flag.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE specific_service_cfg ADD add_flag INT(11) NULL COMMENT '添加标记,APP特征界面上添加的为用户自己添加的';
|
||||
@@ -26,6 +26,7 @@
|
||||
<%@ attribute name="showParentName" type="java.lang.String" required="false" description="显示父类名称"%>
|
||||
<%@ attribute name="checkedPS" type="java.lang.String" required="false" description="复选框选中时是否关联父子节点,ps关联父子,p关联父,s关联子,都不关联为空"%>
|
||||
<%@ attribute name="unCheckedPS" type="java.lang.String" required="false" description="复选框取消选中时是否关联父子节点,ps关联父子,p关联父,s关联子,都不关联为空"%>
|
||||
<%@ attribute name="enableAddBtn" type="java.lang.Boolean" required="false" description="节点是否可编辑"%>
|
||||
<div class="input-group">
|
||||
<input id="${id}Id" name="${name}" class="${cssClass} singleClass" type="hidden" value="${value}" />
|
||||
<input id="${id}Name" name="${labelName}" ${allowInput?'':'readonly="readonly"'} type="text" value="<spring:message code='${empty value?"":labelValue}'/>" data-msg-required="${dataMsgRequired}" placeholder="${empty value?labelValue:value}"
|
||||
@@ -45,7 +46,7 @@
|
||||
return true;
|
||||
}
|
||||
// 正常打开
|
||||
top.$.jBox.open("iframe:${ctx}/tag/treeselect?url="+encodeURIComponent("${url}")+"&selectIds="+$("#${id}Id").val()+"&module=${module}&checked=${checked}&extId=${extId}&isAll=${isAll}&title=${title}", "<spring:message code='choose'/> <spring:message code='${title}'/>", 320, 420, {
|
||||
top.$.jBox.open("iframe:${ctx}/tag/treeselect?url="+encodeURIComponent("${url}")+"&selectIds="+$("#${id}Id").val()+"&module=${module}&checked=${checked}&extId=${extId}&isAll=${isAll}&title=${title}&enableAddBtn=${enableAddBtn}", "<spring:message code='choose'/> <spring:message code='${title}'/>", 320, 420, {
|
||||
ajaxData:{selectIds: $("#${id}Id").val()},buttons:{"<spring:message code='ok'/>":"ok", "<spring:message code='clear'/>":"clear","<spring:message code='close'/>":true}, submit:function(v, h, f){
|
||||
if (v == "ok"){
|
||||
var tree = h.find("iframe")[0].contentWindow.tree;//h.find("iframe").contents();
|
||||
@@ -57,6 +58,7 @@
|
||||
}
|
||||
//wx提示,c:if标签前加了//注释,c:if标签的判断条件仍会生效
|
||||
for(var i=0; i<nodes.length; i++) {
|
||||
console.log(nodes[i]);
|
||||
//<c:if test="${checked && notAllowSelectParent}">
|
||||
if (nodes[i].isParent && "${checkedPS}"!=''){
|
||||
continue; // 如果为复选框选择,并且父子节点有关联,则过滤掉父节点
|
||||
|
||||
@@ -82,7 +82,7 @@ $(function(){
|
||||
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="social_app"/></label>
|
||||
<div class="col-md-6">
|
||||
<sys:treeselect id="specServiceId" name="specServiceId" value="${_cfg.specServiceId}"
|
||||
labelName="parent.specServiceName" notAllowSelectRoot="true" notAllowSelectParent="true"
|
||||
labelName="parent.specServiceName" notAllowSelectRoot="true" notAllowSelectParent="true" enableAddBtn="true"
|
||||
labelValue="${empty _cfg.specServiceId?spec_service_id:fns:getBySpecServiceId(_cfg.specServiceId).specServiceName}"
|
||||
title="${spec_service_id}" url="/specific/specificServiceCfg/treeData?isLeafShow=false&cfgType=${app}" extId=""
|
||||
cssClass="form-control required"/>
|
||||
|
||||
@@ -78,7 +78,7 @@ $(function(){
|
||||
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="social_app"/></label>
|
||||
<div class="col-md-6">
|
||||
<sys:treeselect id="specServiceId" name="specServiceId" value="${_cfg.specServiceId}"
|
||||
labelName="parent.specServiceName" notAllowSelectRoot="true" notAllowSelectParent="true"
|
||||
labelName="parent.specServiceName" notAllowSelectRoot="true" notAllowSelectParent="true" enableAddBtn="true"
|
||||
labelValue="${empty _cfg.specServiceId?spec_service_id:fns:getBySpecServiceId(_cfg.specServiceId).specServiceName}"
|
||||
title="${spec_service_id}" url="/specific/specificServiceCfg/treeData?isLeafShow=false&cfgType=${app}" extId=""
|
||||
cssClass="form-control required"/>
|
||||
|
||||
@@ -6,12 +6,33 @@
|
||||
<title>数据选择</title>
|
||||
<link href="${pageContext.request.contextPath}/static/global/plugins/jquery-ztree/3.5.12/css/zTreeStyle/zTreeStyle.min.css" rel="stylesheet" type="text/css"/>
|
||||
<script src="${pageContext.request.contextPath}/static/global/plugins/jquery-ztree/3.5.12/js/jquery.ztree.all-3.5.min.js" type="text/javascript"></script>
|
||||
<%--解决ztree add小图标丢失 --%>
|
||||
<style type="text/css">
|
||||
.ztree li span.button.add{margin-right:2px;background-position:-144px 0;vertical-align:top;*vertical-align:middle}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
var key, lastValue = "", nodeList = [], type = getQueryString("type", "${url}");
|
||||
var tree, setting = {view:{selectedMulti:false,dblClickExpand:false},check:{enable:"${checked}",chkboxType: { "Y" : "${checkedPS}", "N" : "${unCheckedPS}" },nocheckInherit:true},
|
||||
var tree, setting = {
|
||||
view:{
|
||||
addHoverDom: addHoverDom,
|
||||
removeHoverDom: removeHoverDom,
|
||||
selectedMulti:false,
|
||||
dblClickExpand:false
|
||||
},
|
||||
edit: {
|
||||
enable: true,
|
||||
showRemoveBtn: showRemoveBtn,
|
||||
showRenameBtn: showRenameBtn,
|
||||
removeTitle: "remove",
|
||||
renameTitle: "rename",
|
||||
},
|
||||
check:{enable:"${checked}",chkboxType: { "Y" : "${checkedPS}", "N" : "${unCheckedPS}" },nocheckInherit:true},
|
||||
async:{enable:(type==6),url:"${ctx}/sys/user/treeData",autoParam:["id=officeId"]},
|
||||
data:{simpleData:{enable:true}},callback:{
|
||||
|
||||
data:{simpleData:{enable:true}},
|
||||
callback:{
|
||||
beforeEditName:beforeEditName,
|
||||
beforeRename:beforeRename,
|
||||
beforeRemove:beforeRemove,
|
||||
//beforeClick: function(treeId, treeNode){
|
||||
//if("${checked}" == "true"){
|
||||
//tree.checkNode(treeNode, !node.checked, true, true);
|
||||
@@ -36,7 +57,9 @@
|
||||
},onDblClick: function(){//<c:if test="${!checked}">
|
||||
top.$.jBox.getBox().find("button[value='ok']").trigger("click");
|
||||
//$("input[type='text']", top.mainFrame.document).focus();//</c:if>
|
||||
}
|
||||
},
|
||||
onRename:onRename,
|
||||
onRemove:onRemove
|
||||
}
|
||||
};
|
||||
function expandNodes(nodes) {
|
||||
@@ -61,12 +84,15 @@
|
||||
}else{
|
||||
map.name="<spring:message code='root_node' />";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
tree = $.fn.zTree.init($("#tree"), setting, zNodes);
|
||||
// 默认展开一级节点
|
||||
var nodes = tree.getNodesByParam("level", 0);
|
||||
// 默认展开一二级节点
|
||||
var nodes = tree.getNodesByParam("level", 1);
|
||||
for(var i=0; i<nodes.length; i++) {
|
||||
tree.expandNode(nodes[i], true, false, false);
|
||||
}
|
||||
nodes=tree.getNodesByParam("level", 0);
|
||||
for(var i=0; i<nodes.length; i++) {
|
||||
tree.expandNode(nodes[i], true, false, false);
|
||||
}
|
||||
@@ -195,7 +221,145 @@
|
||||
$("#txt").toggle();
|
||||
$("#key").focus();
|
||||
}
|
||||
|
||||
function beforeEditName(treeId, treeNode) {
|
||||
var zTree = $.fn.zTree.getZTreeObj("tree");
|
||||
zTree.selectNode(treeNode);
|
||||
return confirm("<spring:message code='edit' />" + treeNode.name + "?");
|
||||
}
|
||||
function beforeRename(treeId, treeNode, newName) {
|
||||
var zTree = $.fn.zTree.getZTreeObj("tree");
|
||||
if (newName.length == 0) {
|
||||
var tip="<spring:message code='can_not_null' />";
|
||||
alert("<spring:message code='${title}' />"+tip.replace("%s"," "));
|
||||
setTimeout(function(){zTree.editName(treeNode)}, 10);
|
||||
return false;
|
||||
}
|
||||
if(confirm("<spring:message code='save' />" + treeNode.name + "?")){
|
||||
return true;
|
||||
}else{
|
||||
setTimeout(function(){zTree.editName(treeNode)}, 10);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
function beforeRemove(treeId, treeNode, newName) {
|
||||
return confirm("<spring:message code='remove' /> " + treeNode.name + "?");
|
||||
}
|
||||
//在重命名节点时,调用后台存储,将返回结果更新
|
||||
function onRename(e, treeId, treeNode) {
|
||||
loading("<spring:message code='loading' />...");
|
||||
$.ajax({
|
||||
type:'post',
|
||||
async:true,
|
||||
cache:false,
|
||||
url:'${ctx}/specific/specificServiceCfg/ajaxSaveOrUpdateApp',
|
||||
data:{
|
||||
"specServiceId":treeNode.id,
|
||||
"specServiceCode":treeNode.serviceCode,
|
||||
"specServiceName":treeNode.name,
|
||||
"cfgType":treeNode.serviceType,
|
||||
"groupId":treeNode.groupId,
|
||||
"businessType":treeNode.pId.replace("businessType",""),
|
||||
"addFlag":treeNode.user
|
||||
},
|
||||
//dataType:"json",
|
||||
//contentType:"application/json; charset=utf-8",
|
||||
success:function(data){
|
||||
treeNode.groupId=data.data;
|
||||
treeNode.specServiceCode=data.specServiceCode;
|
||||
treeNode.user=data.addFlag;
|
||||
var zTree = $.fn.zTree.getZTreeObj("tree");
|
||||
zTree.updateNode(treeNode);
|
||||
closeTip();
|
||||
}
|
||||
});
|
||||
}
|
||||
function onRemove(e, treeId, treeNode) {
|
||||
loading("<spring:message code='loading' />...");
|
||||
if(typeof treeNode=="string"){
|
||||
var zTree = $.fn.zTree.getZTreeObj("tree");
|
||||
zTree.removeNode(treeNode,true);
|
||||
}else{
|
||||
$.ajax({
|
||||
type:'post',
|
||||
async:true,
|
||||
cache:false,
|
||||
url:'${ctx}/specific/specificServiceCfg/ajaxRemoveApp',
|
||||
data:{
|
||||
"specServiceId":treeNode.id
|
||||
},
|
||||
//dataType:"json",
|
||||
//contentType:"application/json; charset=utf-8",
|
||||
success:function(data){
|
||||
if(data){
|
||||
var zTree = $.fn.zTree.getZTreeObj("tree");
|
||||
zTree.removeNode(treeNode,false);
|
||||
}
|
||||
closeTip();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
//用户只能rename自己添加的节点
|
||||
function showRenameBtn(treeId, treeNode) {
|
||||
if(treeNode.isParent){
|
||||
return false;
|
||||
}
|
||||
if("${enableAddBtn}"&&"${enableAddBtn}"=="true"&&treeNode.user&&treeNode.user=="${userId}"){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//用户只能remove自己添加的节点
|
||||
function showRemoveBtn(treeId, treeNode) {
|
||||
if(treeNode.isParent){
|
||||
return false;
|
||||
}
|
||||
if("${enableAddBtn}"&&"${enableAddBtn}"=="true"&&treeNode.user&&treeNode.user=="${userId}"){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//只有在配置了enableAddBtn的界面上才会显示添加按钮
|
||||
function addHoverDom(treeId, treeNode) {
|
||||
//开启节点增加
|
||||
if("${enableAddBtn}"&&"${enableAddBtn}"=="true"){
|
||||
//根节点不需要增加节点
|
||||
if(treeNode.pId==null||(treeNode.businessType&&treeNode.businessType!=-1)){
|
||||
return;
|
||||
}
|
||||
var sObj = $("#" + treeNode.tId + "_span");
|
||||
if (treeNode.editNameFlag || $("#addBtn_"+treeNode.id).length>0) return;
|
||||
var title="<spring:message code='add' /> <spring:message code='${title}' />";
|
||||
var addStr = "<span class='button add' id='addBtn_" + treeNode.id
|
||||
+ "' title='"+title+"' onfocus='this.blur();'></span>";
|
||||
sObj.after(addStr);
|
||||
var btn = $("#addBtn_"+treeNode.id);
|
||||
if (btn){
|
||||
btn.bind("click", function(){
|
||||
//区别人工添加,在ID前加上manual
|
||||
var id="manual"+new Date().getTime();
|
||||
var zTree = $.fn.zTree.getZTreeObj("tree"); //addSelectedNode
|
||||
zTree.addNodes(treeNode, {id:id, pId:treeNode.id, name:"<spring:message code='new' /> <spring:message code='${title}' />",
|
||||
businessType:treeNode.id.replace("businessType",""),user:"${userId}",serviceType:treeNode.serviceType,groupId:"",
|
||||
serviceCode:""});
|
||||
var node = zTree.getNodeByParam("id", id,treeNode);
|
||||
if(node){
|
||||
zTree.updateNode(node);
|
||||
zTree.editName(node);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
function removeHoverDom(treeId, treeNode) {
|
||||
$("#addBtn_"+treeNode.id).unbind().remove();
|
||||
};
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user