增强字符串配置,如果district字段内容为others,用户可手动输入匹配区域。

This commit is contained in:
zhangwei
2018-06-04 14:31:26 +08:00
parent 24c37c1834
commit 50e1b73d44
5 changed files with 55 additions and 8 deletions

View File

@@ -78,6 +78,12 @@ public class ComplexkeywordCfg extends BaseCfg<ComplexkeywordCfg>{
public void setCfgKeywords(String cfgKeywords) { public void setCfgKeywords(String cfgKeywords) {
this.cfgKeywords = cfgKeywords; this.cfgKeywords = cfgKeywords;
} }
public String getDistrictShowName() {
return districtShowName;
}
public void setDistrictShowName(String districtShowName) {
this.districtShowName = districtShowName;
}
/** /**
* exprType * exprType
* 继承此类的类会覆盖该方法写自己的缺省值 * 继承此类的类会覆盖该方法写自己的缺省值

View File

@@ -149,12 +149,18 @@ public class WebsiteCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo> {
if(entity.getHttpReqHdrList()!=null){ if(entity.getHttpReqHdrList()!=null){
for(HttpReqHeadCfg cfg:entity.getHttpReqHdrList()){ for(HttpReqHeadCfg cfg:entity.getHttpReqHdrList()){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
if(StringUtils.isNoneBlank(cfg.getDistrictShowName()) && cfg.getDistrict().equals("others")){
cfg.setDistrict(cfg.getDistrictShowName());
}
websiteCfgDao.saveHttpReqHdrCfg(cfg); websiteCfgDao.saveHttpReqHdrCfg(cfg);
} }
} }
if(entity.getHttpResHdrList()!=null){ if(entity.getHttpResHdrList()!=null){
for(HttpResHeadCfg cfg:entity.getHttpResHdrList()){ for(HttpResHeadCfg cfg:entity.getHttpResHdrList()){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
if(StringUtils.isNoneBlank(cfg.getDistrictShowName()) && cfg.getDistrict().equals("others")){
cfg.setDistrict(cfg.getDistrictShowName());
}
websiteCfgDao.saveHttpResHdrCfg(cfg); websiteCfgDao.saveHttpResHdrCfg(cfg);
} }
} }
@@ -213,12 +219,18 @@ public class WebsiteCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo> {
if(entity.getHttpReqHdrList()!=null){ if(entity.getHttpReqHdrList()!=null){
for(HttpReqHeadCfg cfg:entity.getHttpReqHdrList()){ for(HttpReqHeadCfg cfg:entity.getHttpReqHdrList()){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
if(StringUtils.isNoneBlank(cfg.getDistrictShowName()) && cfg.getDistrict().equals("others")){
cfg.setDistrict(cfg.getDistrictShowName());
}
websiteCfgDao.saveHttpReqHdrCfg(cfg); websiteCfgDao.saveHttpReqHdrCfg(cfg);
} }
} }
if(entity.getHttpResHdrList()!=null){ if(entity.getHttpResHdrList()!=null){
for(HttpResHeadCfg cfg:entity.getHttpResHdrList()){ for(HttpResHeadCfg cfg:entity.getHttpResHdrList()){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
if(StringUtils.isNoneBlank(cfg.getDistrictShowName()) && cfg.getDistrict().equals("others")){
cfg.setDistrict(cfg.getDistrictShowName());
}
websiteCfgDao.saveHttpResHdrCfg(cfg); websiteCfgDao.saveHttpResHdrCfg(cfg);
} }
} }
@@ -683,6 +695,9 @@ public class WebsiteCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo> {
for(ComplexkeywordCfg cfg:entity.getDomainList()){ for(ComplexkeywordCfg cfg:entity.getDomainList()){
if(StringUtils.isNotBlank(cfg.getCfgKeywords())){ if(StringUtils.isNotBlank(cfg.getCfgKeywords())){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
if(StringUtils.isNoneBlank(cfg.getDistrictShowName()) && cfg.getDistrict().equals("others")){
cfg.setDistrict(cfg.getDistrictShowName());
}
websiteCfgDao.saveDnsDomainCfg(cfg); websiteCfgDao.saveDnsDomainCfg(cfg);
} }
} }
@@ -722,6 +737,9 @@ public class WebsiteCfgService extends CrudService<WebsiteCfgDao,CfgIndexInfo> {
for(ComplexkeywordCfg cfg:entity.getDomainList()){ for(ComplexkeywordCfg cfg:entity.getDomainList()){
if(StringUtils.isNotBlank(cfg.getCfgKeywords())){ if(StringUtils.isNotBlank(cfg.getCfgKeywords())){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
if(StringUtils.isNoneBlank(cfg.getDistrictShowName()) && cfg.getDistrict().equals("others")){
cfg.setDistrict(cfg.getDistrictShowName());
}
websiteCfgDao.saveDnsDomainCfg(cfg); websiteCfgDao.saveDnsDomainCfg(cfg);
} }
} }

View File

@@ -3,11 +3,7 @@
<html> <html>
<head> <head>
<title></title> <title></title>
<script type="text/javascript">
$(function(){
});
</script>
</head> </head>
<c:forEach items="${regionList}" var="regionDistrict"> <c:forEach items="${regionList}" var="regionDistrict">
<c:if <c:if
@@ -33,18 +29,19 @@ $(function(){
<spring:message code="district" /></label> <spring:message code="district" /></label>
<div class="col-md-6"> <div class="col-md-6">
<select name="${cfgName}.district" <select name="${cfgName}.district"
class="selectpicker show-tick form-control required"> class="selectpicker show-tick form-control required district" onchange="changeDistrict($(this))">
<c:forEach items="${regionList}" var="regionDistrict"> <c:forEach items="${regionList}" var="regionDistrict">
<c:if <c:if
test="${_cfg.functionId eq regionDistrict.functionId and regionValue eq regionDistrict.configRegionValue}"> test="${_cfg.functionId eq regionDistrict.functionId and regionValue eq regionDistrict.configRegionValue}">
<c:forEach items="${fn:split(regionDistrict.configDistrict,',')}" <c:forEach items="${fn:split(regionDistrict.configDistrict,',')}"
var="_district"> var="_district">
<option value="${_district }" <option value="${_district }"
<c:if test="${complexCfg.district==_district || complexCfg.district==null}">selected</c:if>>${_district }</option> <c:if test="${complexCfg.district==_district}">selected</c:if>>${_district }</option>
</c:forEach> </c:forEach>
</c:if> </c:if>
</c:forEach> </c:forEach>
</select> </select>
<input type="hidden" name="${cfgName}.districtShowName" placeholder="<spring:message code='please_input'/> <spring:message code='custom_region'/>" class="otherValue form-control" value="${complexCfg.district}"/>
</div> </div>
<div for="${cfgName}.district"></div> <div for="${cfgName}.district"></div>
</div> </div>
@@ -135,3 +132,10 @@ $(function(){
</div> </div>
</div> </div>
</html> </html>
<script type="text/javascript">
function changeDistrict(obj){
if("others"==obj.val()){
obj.parent().siblings(".otherValue").prop("type","text");
}
}
</script>

View File

@@ -71,6 +71,15 @@
/* $("span[title='add']").on("click", function() { /* $("span[title='add']").on("click", function() {
$(".ipPort0").removeClass("hidden"); $(".ipPort0").removeClass("hidden");
}); */ }); */
$(".district").each(function(){
if($(this).siblings(".otherValue").val()!=''){
if($(this).val()!=$(this).siblings(".otherValue").val()){
$(this).find("option[value=others]").attr("selected","selected");
$(this).siblings(".otherValue").prop("type","text");
}
}
});
}); });

View File

@@ -93,6 +93,16 @@
$(".ipPort0").removeClass("hidden"); $(".ipPort0").removeClass("hidden");
}); */ }); */
$(".district").each(function(){
if($(this).siblings(".otherValue").val()!=''){
if($(this).val()!=$(this).siblings(".otherValue").val()){
$(this).find("option[value=others]").attr("selected","selected");
$(this).siblings(".otherValue").prop("type","text");
}
}
});
}); });
//业务窗口打开 //业务窗口打开