增强字符串配置,如果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) {
this.cfgKeywords = cfgKeywords;
}
public String getDistrictShowName() {
return districtShowName;
}
public void setDistrictShowName(String districtShowName) {
this.districtShowName = districtShowName;
}
/**
* exprType
* 继承此类的类会覆盖该方法写自己的缺省值

View File

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

View File

@@ -3,11 +3,7 @@
<html>
<head>
<title></title>
<script type="text/javascript">
$(function(){
});
</script>
</head>
<c:forEach items="${regionList}" var="regionDistrict">
<c:if
@@ -33,18 +29,19 @@ $(function(){
<spring:message code="district" /></label>
<div class="col-md-6">
<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:if
test="${_cfg.functionId eq regionDistrict.functionId and regionValue eq regionDistrict.configRegionValue}">
<c:forEach items="${fn:split(regionDistrict.configDistrict,',')}"
var="_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:if>
</c:forEach>
</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 for="${cfgName}.district"></div>
</div>
@@ -134,4 +131,11 @@ $(function(){
</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() {
$(".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

@@ -92,6 +92,16 @@
/* $("span[title='add']").on("click", function() {
$(".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");
}
}
});
});