新增静态代码验证
This commit is contained in:
parent
d6e8e59c63
commit
4b25d1a1b2
@ -4,6 +4,8 @@ import com.cm.common.annotation.CheckRequestBodyAnnotation;
|
||||
import com.cm.common.base.AbstractController;
|
||||
import com.cm.common.constants.ISystemConstant;
|
||||
import com.cm.common.exception.SearchException;
|
||||
import com.cm.common.plugin.enums.dynamic.FieldRequireTypeEnum;
|
||||
import com.cm.common.plugin.enums.dynamic.FieldTypeEnum;
|
||||
import com.cm.common.plugin.pojo.dtos.dynamic.config.form.DynamicConfigFormDTO;
|
||||
import com.cm.common.plugin.pojo.vos.dynamic.config.form.DynamicConfigFormVO;
|
||||
import com.cm.common.plugin.pojo.vos.dynamic.config.form.FieldShowVO;
|
||||
@ -13,6 +15,7 @@ import com.cm.common.result.ErrorResult;
|
||||
import com.cm.common.result.SuccessResult;
|
||||
import com.cm.common.result.SuccessResultList;
|
||||
import io.swagger.annotations.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -41,6 +44,8 @@ public class DynamicConfigFormController extends AbstractController {
|
||||
@PostMapping("saveform")
|
||||
@CheckRequestBodyAnnotation
|
||||
public SuccessResult saveForm(@RequestBody DynamicConfigFormVO dynamicConfigFormVO) throws Exception {
|
||||
restVerifyConfig(dynamicConfigFormVO);
|
||||
restJoinTableConfig(dynamicConfigFormVO);
|
||||
return dynamicConfigFormService.saveForm(dynamicConfigFormVO);
|
||||
}
|
||||
|
||||
@ -62,9 +67,45 @@ public class DynamicConfigFormController extends AbstractController {
|
||||
@PutMapping("updateform/{id}")
|
||||
@CheckRequestBodyAnnotation
|
||||
public SuccessResult updateForm(@PathVariable("id") String id, @RequestBody DynamicConfigFormVO dynamicConfigFormVO) throws Exception {
|
||||
restVerifyConfig(dynamicConfigFormVO);
|
||||
restJoinTableConfig(dynamicConfigFormVO);
|
||||
return dynamicConfigFormService.updateForm(id, dynamicConfigFormVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化验证字段
|
||||
*
|
||||
* @param dynamicConfigFormVO
|
||||
*/
|
||||
private void restVerifyConfig(DynamicConfigFormVO dynamicConfigFormVO) {
|
||||
if (!StringUtils.equals(FieldTypeEnum.STRING.getValue(), dynamicConfigFormVO.getFieldType())) {
|
||||
dynamicConfigFormVO.setVerifyType(null);
|
||||
dynamicConfigFormVO.setVerifyRegular(null);
|
||||
return;
|
||||
}
|
||||
if (!StringUtils.equals(FieldRequireTypeEnum.CUSTOM.getValue(), dynamicConfigFormVO.getVerifyType())) {
|
||||
dynamicConfigFormVO.setVerifyRegular(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化联表字段
|
||||
*
|
||||
* @param dynamicConfigFormVO
|
||||
*/
|
||||
private void restJoinTableConfig(DynamicConfigFormVO dynamicConfigFormVO) {
|
||||
boolean isJoin = StringUtils.equals(FieldTypeEnum.INNER_JOIN.getValue(), dynamicConfigFormVO.getFieldType())
|
||||
|| StringUtils.equals(FieldTypeEnum.LEFT_JOIN.getValue(), dynamicConfigFormVO.getFieldType())
|
||||
|| StringUtils.equals(FieldTypeEnum.RIGHT_JOIN.getValue(), dynamicConfigFormVO.getFieldType());
|
||||
if (!isJoin) {
|
||||
dynamicConfigFormVO.setJoinTable(null);
|
||||
dynamicConfigFormVO.setJoinTableField(null);
|
||||
dynamicConfigFormVO.setJoinTableListShow(null);
|
||||
dynamicConfigFormVO.setJoinTableFormShow(null);
|
||||
dynamicConfigFormVO.setJoinTableSort(1);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "字段列表显示修改", notes = "字段列表显示修改接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "表单ID", paramType = "path")
|
||||
|
@ -10,8 +10,6 @@ import com.cm.common.exception.UpdateException;
|
||||
import com.cm.common.plugin.dao.dynamic.config.IDynamicConfigTableDao;
|
||||
import com.cm.common.plugin.enums.dynamic.FieldTypeEnum;
|
||||
import com.cm.common.plugin.pojo.dtos.database.table.TableDTO;
|
||||
import com.cm.common.plugin.pojo.dtos.dynamic.DynamicFormDTO;
|
||||
import com.cm.common.plugin.pojo.dtos.dynamic.DynamicFormListShowFieldDTO;
|
||||
import com.cm.common.plugin.pojo.dtos.dynamic.config.DynamicConfigTableDTO;
|
||||
import com.cm.common.plugin.pojo.dtos.dynamic.config.form.DynamicConfigFormDTO;
|
||||
import com.cm.common.plugin.pojo.vos.dynamic.DynamicFormFieldVO;
|
||||
@ -34,7 +32,6 @@ import org.joda.time.DateTime;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
|
||||
import sun.jvm.hotspot.oops.FieldType;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
|
@ -2,10 +2,12 @@ package ${basePackage}.controller.apis.${lowerTableName};
|
||||
|
||||
import com.cm.common.annotation.CheckRequestBodyAnnotation;
|
||||
import com.cm.common.base.AbstractController;
|
||||
import com.cm.common.component.SecurityComponent;
|
||||
import com.cm.common.constants.ISystemConstant;
|
||||
import com.cm.common.exception.RemoveException;
|
||||
import com.cm.common.exception.SearchException;
|
||||
import com.cm.common.pojo.ListPage;
|
||||
import com.cm.common.pojo.dtos.CurrentUserIdInfoDTO;
|
||||
import com.cm.common.result.ErrorResult;
|
||||
import com.cm.common.result.SuccessResult;
|
||||
import com.cm.common.result.SuccessResultList;
|
||||
@ -34,6 +36,8 @@ public class ${firstUpperTableName}Controller extends AbstractController {
|
||||
|
||||
@Autowired
|
||||
private I${firstUpperTableName}Service ${firstLowerTableName}Service;
|
||||
@Autowired
|
||||
private SecurityComponent securityComponent;
|
||||
|
||||
@ApiOperation(value = "新增${tableExplain}", notes = "新增${tableExplain}接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@ -98,4 +102,11 @@ public class ${firstUpperTableName}Controller extends AbstractController {
|
||||
return ${firstLowerTableName}Service.listPage${firstUpperTableName}(page);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "当前用户id信息", notes = "当前用户id信息接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("getcurrentuseridinfo")
|
||||
public CurrentUserIdInfoDTO getCurrentUserIdInfo() {
|
||||
return securityComponent.getCurrentUserIdInfo();
|
||||
}
|
||||
|
||||
}
|
@ -74,7 +74,7 @@
|
||||
${field.underLineFieldName} = ${r"#{"}${field.fieldName}${r"}"},
|
||||
</if>
|
||||
<#else>
|
||||
<if test="${field.fieldName} != null ${field.fieldName} != ''">
|
||||
<if test="${field.fieldName} != null and ${field.fieldName} != ''">
|
||||
${field.underLineFieldName} = ${r"#{"}${field.fieldName}${r"}"},
|
||||
</if>
|
||||
</#if>
|
||||
@ -112,7 +112,7 @@
|
||||
t1.${field.underLineFieldName},
|
||||
<#-- 字典 start -->
|
||||
<#if field.fieldType == "radio" || field.fieldType == "checkbox" || field.fieldType == "select">
|
||||
GROUP_CONCAT(dt${field.dictionaryIndex}.dictionary_name) ${field.underLineFieldName}_dictionary_name,
|
||||
GROUP_CONCAT(DISTINCT dt${field.dictionaryIndex}.dictionary_name) ${field.underLineFieldName}_dictionary_name,
|
||||
</#if>
|
||||
<#-- 字典 end -->
|
||||
</#if>
|
||||
|
@ -1,7 +1,5 @@
|
||||
package ${basePackage}.pojo.dtos.${lowerTableName};
|
||||
|
||||
import com.cm.common.annotation.CheckEmptyAnnotation;
|
||||
import com.cm.common.annotation.CheckNumberAnnotation;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
|
@ -18,17 +18,55 @@ public class ${firstUpperTableName}VO {
|
||||
|
||||
<#list fieldList! as field>
|
||||
@ApiModelProperty(name = "${field.fieldName}", value = "${field.fieldExplain}")
|
||||
<#if field.fieldType == "number">
|
||||
<#if field.fieldType == "join">
|
||||
@CheckEmptyAnnotation(name = "${field.fieldExplain}")
|
||||
private String ${field.fieldName};
|
||||
<#elseif field.fieldType == "number">
|
||||
@CheckNumberAnnotation(name = "${field.fieldExplain}")
|
||||
private Integer ${field.fieldName};
|
||||
<#elseif field.fieldType == "double">
|
||||
@CheckNumberAnnotation(name = "${field.fieldExplain}")
|
||||
private Double ${field.fieldName};
|
||||
<#elseif field.fieldType == "date" || field.fieldType == "datetime">
|
||||
@CheckEmptyAnnotation(name = "${field.fieldExplain}", verifyType = "date")
|
||||
private String ${field.fieldName};
|
||||
<#else>
|
||||
<#if field.fieldType == "string">
|
||||
<#if field.verifyType?? && field.verifyType != "none">
|
||||
<#if field.verifyType == "phone">
|
||||
@CheckEmptyAnnotation(name = "${field.fieldExplain}", verifyType = "phone")
|
||||
<#elseif field.verifyType == "email">
|
||||
@CheckEmptyAnnotation(name = "${field.fieldExplain}", verifyType = "email")
|
||||
<#elseif field.verifyType == "url">
|
||||
@CheckEmptyAnnotation(name = "${field.fieldExplain}", verifyType = "url")
|
||||
<#elseif field.verifyType == "number">
|
||||
@CheckEmptyAnnotation(name = "${field.fieldExplain}", verifyType = "number")
|
||||
<#elseif field.verifyType == "date">
|
||||
@CheckEmptyAnnotation(name = "${field.fieldExplain}", verifyType = "date")
|
||||
<#elseif field.verifyType == "identity">
|
||||
@CheckEmptyAnnotation(name = "${field.fieldExplain}", verifyType = "identity")
|
||||
<#elseif field.verifyType == "custom">
|
||||
@CheckEmptyAnnotation(name = "${field.fieldExplain}", verifyType = "custom", regex = "${field.verifyType}")
|
||||
<#elseif field.verifyType == "required">
|
||||
@CheckEmptyAnnotation(name = "${field.fieldExplain}")
|
||||
</#if>
|
||||
</#if>
|
||||
</#if>
|
||||
private String ${field.fieldName};
|
||||
</#if>
|
||||
</#list>
|
||||
|
||||
<#list fieldList! as field>
|
||||
<#if field.fieldType == "number">
|
||||
<#if field.fieldType == "join">
|
||||
public String get${field.firstUpperFieldName}() {
|
||||
return ${field.fieldName} == null ? "" : ${field.fieldName};
|
||||
}
|
||||
|
||||
public void set${field.firstUpperFieldName}(String ${field.fieldName}) {
|
||||
this.${field.fieldName} = ${field.fieldName};
|
||||
}
|
||||
|
||||
<#elseif field.fieldType == "number">
|
||||
public Integer get${field.firstUpperFieldName}() {
|
||||
return ${field.fieldName} == null ? 0 : ${field.fieldName};
|
||||
}
|
||||
@ -42,6 +80,15 @@ public class ${firstUpperTableName}VO {
|
||||
return ${field.fieldName} == null ? 0D : ${field.fieldName};
|
||||
}
|
||||
|
||||
public void set${field.firstUpperFieldName}(String ${field.fieldName}) {
|
||||
this.${field.fieldName} = ${field.fieldName};
|
||||
}
|
||||
|
||||
<#elseif field.fieldType == "date" || field.fieldType == "datetime">
|
||||
public String get${field.firstUpperFieldName}() {
|
||||
return ${field.fieldName} == null ? "" : ${field.fieldName};
|
||||
}
|
||||
|
||||
public void set${field.firstUpperFieldName}(String ${field.fieldName}) {
|
||||
this.${field.fieldName} = ${field.fieldName};
|
||||
}
|
||||
|
@ -52,7 +52,7 @@
|
||||
</div>
|
||||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
|
||||
<script th:inline="javascript">
|
||||
<script>
|
||||
layui.config({
|
||||
base: 'assets/layuiadmin/'
|
||||
}).extend({
|
||||
|
@ -23,27 +23,25 @@
|
||||
<form class="layui-form layui-form-pane" lay-filter="dataForm">
|
||||
<#list fieldList! as field>
|
||||
<#if field.formShow == 1>
|
||||
<#if field.fieldType == "join">
|
||||
<input type="hidden" id="${field.fieldName}" name="${field.fieldName}" lay-verify="required">
|
||||
<#elseif field.fieldType == "datetime" || field.fieldType == "date">
|
||||
<#if field.fieldType == "datetime" || field.fieldType == "date">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.fieldExplain}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="${field.fieldName}" name="${field.fieldName}" class="layui-input" value="${field.fieldDefault}" placeholder="请选择${field.fieldExplain}" lay-verify="required" readonly style="cursor: pointer;">
|
||||
<input type="text" id="${field.fieldName}" name="${field.fieldName}" class="layui-input" value="${field.fieldDefault}" placeholder="请选择${field.fieldExplain}" readonly style="cursor: pointer;" lay-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.fieldType == "number">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.fieldExplain}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" id="${field.fieldName}" name="${field.fieldName}" class="layui-input" value="${field.fieldDefault}" placeholder="请输入${field.fieldExplain}">
|
||||
<input type="number" id="${field.fieldName}" name="${field.fieldName}" class="layui-input" value="${field.fieldDefault}" placeholder="请输入${field.fieldExplain}" lay-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.fieldType == "double">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.fieldExplain}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" step="0.01" id="${field.fieldName}" name="${field.fieldName}" class="layui-input" value="${field.fieldDefault}" placeholder="请输入${field.fieldExplain}">
|
||||
<input type="number" step="0.01" id="${field.fieldName}" name="${field.fieldName}" class="layui-input" value="${field.fieldDefault}" placeholder="请输入${field.fieldExplain}" lay-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.fieldType == "textarea">
|
||||
@ -63,7 +61,7 @@
|
||||
<#elseif field.fieldType == "select">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.fieldExplain}</label>
|
||||
<div class="layui-input-block" id="${field.fieldName}SelectTemplateBox" lay-filter="${field.fieldName}SelectTemplateBox"></div>
|
||||
<div class="layui-input-block layui-form" id="${field.fieldName}SelectTemplateBox" lay-filter="${field.fieldName}SelectTemplateBox"></div>
|
||||
<script id="${field.fieldName}SelectTemplate" type="text/html">
|
||||
<select id="${field.fieldName}" name="${field.fieldName}">
|
||||
<option value="">请选择${field.fieldExplain}</option>
|
||||
@ -76,7 +74,7 @@
|
||||
<#elseif field.fieldType == "checkbox">
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">${field.fieldExplain}</label>
|
||||
<div class="layui-input-block" id="${field.fieldName}CheckboxTemplateBox" lay-filter="${field.fieldName}CheckboxTemplateBox"></div>
|
||||
<div class="layui-input-block layui-form" id="${field.fieldName}CheckboxTemplateBox" lay-filter="${field.fieldName}CheckboxTemplateBox"></div>
|
||||
<script id="${field.fieldName}CheckboxTemplate" type="text/html">
|
||||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||||
<input type="checkbox" name="${field.fieldName}[{{item.dictionaryId}}]" value="{{item.dictionaryId}}" title="{{item.dictionaryName}}">
|
||||
@ -86,7 +84,7 @@
|
||||
<#elseif field.fieldType == "radio">
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">${field.fieldExplain}</label>
|
||||
<div class="layui-input-block" id="${field.fieldName}RadioTemplateBox" lay-filter="${field.fieldName}RadioTemplateBox"></div>
|
||||
<div class="layui-input-block layui-form" id="${field.fieldName}RadioTemplateBox" lay-filter="${field.fieldName}RadioTemplateBox"></div>
|
||||
<script id="${field.fieldName}RadioTemplate" type="text/html">
|
||||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||||
<input type="radio" name="${field.fieldName}" value="{{item.dictionaryId}}" title="{{item.dictionaryName}}">
|
||||
@ -136,7 +134,7 @@
|
||||
<label class="layui-form-label">${field.fieldExplain}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="${field.fieldName}" name="${field.fieldName}">
|
||||
<input type="text" class="layui-input" id="${field.fieldName}CurrentUser" readonly>
|
||||
<input type="text" class="layui-input" id="${field.fieldName}CurrentUser" name="${field.fieldName}CurrentUser" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.fieldType == "currentDepartment">
|
||||
@ -144,15 +142,7 @@
|
||||
<label class="layui-form-label">${field.fieldExplain}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="${field.fieldName}" name="${field.fieldName}">
|
||||
<input type="text" class="layui-input" id="${field.fieldName}CurrentDepartment" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.fieldType == "currentDepartment">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.fieldExplain}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="${field.fieldName}" name="${field.fieldName}">
|
||||
<input type="text" class="layui-input" id="${field.fieldName}CurrentDepartment" readonly>
|
||||
<input type="text" class="layui-input" id="${field.fieldName}CurrentDepartment" name="${field.fieldName}CurrentDepartment" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.fieldType == "currentRole">
|
||||
@ -160,7 +150,7 @@
|
||||
<label class="layui-form-label" >${field.fieldExplain}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="${field.fieldName}" name="${field.fieldName}">
|
||||
<input type="text" class="layui-input" id="${field.fieldName}CurrentRole" readonly>
|
||||
<input type="text" class="layui-input" id="${field.fieldName}CurrentRole" name="${field.fieldName}CurrentRole" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.fieldType == "currentGroup">
|
||||
@ -168,7 +158,7 @@
|
||||
<label class="layui-form-label">${field.fieldExplain}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="${field.fieldName}" name="${field.fieldName}">
|
||||
<input type="text" class="layui-input" id="${field.fieldName}CurrentGroup" readonly>
|
||||
<input type="text" class="layui-input" id="${field.fieldName}CurrentGroup" name="${field.fieldName}CurrentGroup" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.fieldType == "currentPosition">
|
||||
@ -176,7 +166,7 @@
|
||||
<label class="layui-form-label">${field.fieldExplain}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="${field.fieldName}" name="${field.fieldName}">
|
||||
<input type="text" class="layui-input" id="${field.fieldName}CurrentPosition" readonly>
|
||||
<input type="text" class="layui-input" id="${field.fieldName}CurrentPosition" name="${field.fieldName}CurrentPosition" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.fieldType == "leftJoin" || field.fieldType == "innerJoin" || field.fieldType == "rightJoin">
|
||||
@ -192,11 +182,11 @@
|
||||
</select>
|
||||
</script>
|
||||
</div>
|
||||
<#else>
|
||||
<#elseif field.fieldType == "string">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.fieldExplain}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="${field.fieldName}" name="${field.fieldName}" class="layui-input" value="${field.fieldDefault}" placeholder="请输入${field.fieldExplain}">
|
||||
<input type="text" id="${field.fieldName}" name="${field.fieldName}" class="layui-input" value="${field.fieldDefault}" placeholder="请输入${field.fieldExplain}" <#if field.verifyType?? && field.verifyType != "none">lay-verify="<#if field.verifyType == "phone">phone<#elseif field.verifyType == "email">email<#elseif field.verifyType == "url">url<#elseif field.verifyType == "number">number<#elseif field.verifyType == "date">date<#elseif field.verifyType == "identity">identity<#elseif field.verifyType == "custom">${field.fieldName}CustomVerify<#elseif field.verifyType == "required">required</#if>"</#if>>
|
||||
</div>
|
||||
</div>
|
||||
</#if>
|
||||
@ -216,7 +206,7 @@
|
||||
</div>
|
||||
<script src="assets/js/vendor/wangEditor/wangEditor.min.js"></script>
|
||||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||
<script th:inline="javascript">
|
||||
<script>
|
||||
layui.config({
|
||||
base: 'assets/layuiadmin/' //静态资源所在路径
|
||||
}).extend({
|
||||
@ -314,7 +304,7 @@
|
||||
laytpl(document.getElementById('${field.fieldName}CheckboxTemplate').innerHTML).render(data, function(html) {
|
||||
document.getElementById('${field.fieldName}CheckboxTemplateBox').innerHTML = html;
|
||||
});
|
||||
form.render('checkbox');
|
||||
form.render('checkbox', '${field.fieldName}CheckboxTemplateBox');
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
});
|
||||
@ -327,7 +317,7 @@
|
||||
laytpl(document.getElementById('${field.fieldName}RadioTemplate').innerHTML).render(data, function(html) {
|
||||
document.getElementById('${field.fieldName}RadioTemplateBox').innerHTML = html;
|
||||
});
|
||||
form.render('radio');
|
||||
form.render('radio', '${field.fieldName}RadioTemplateBox');
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
});
|
||||
@ -479,6 +469,51 @@
|
||||
});
|
||||
}
|
||||
|
||||
<#elseif field.fieldType == "currentUser">
|
||||
// 初始化${field.fieldExplain}当前用户
|
||||
function init${field.firstUpperFieldName}CurrentUser(userIdAndValue, userNameValue) {
|
||||
var currentUserObj = {};
|
||||
currentUserObj['${field.fieldName}'] = userIdAndValue;
|
||||
currentUserObj['${field.fieldName}CurrentUser'] = userNameValue;
|
||||
form.val('dataForm', currentUserObj);
|
||||
}
|
||||
|
||||
<#elseif field.fieldType == "currentDepartment">
|
||||
// 初始化${field.fieldExplain}当前部门
|
||||
function init${field.firstUpperFieldName}CurrentDepartment(departmentIdAndNamesValue, departmentNamesValue) {
|
||||
var currentUserObj = {};
|
||||
currentUserObj['${field.fieldName}'] = departmentIdAndNamesValue;
|
||||
currentUserObj['${field.fieldName}CurrentDepartment'] = departmentNamesValue;
|
||||
form.val('dataForm', currentUserObj);
|
||||
}
|
||||
|
||||
<#elseif field.fieldType == "currentRole">
|
||||
// 初始化${field.fieldExplain}当前角色
|
||||
function init${field.firstUpperFieldName}CurrentRole(roleIdAndNamesValue, roleNamesValue) {
|
||||
var currentUserObj = {};
|
||||
currentUserObj['${field.fieldName}'] = roleIdAndNamesValue;
|
||||
currentUserObj['${field.fieldName}CurrentRole'] = roleNamesValue;
|
||||
form.val('dataForm', currentUserObj);
|
||||
}
|
||||
|
||||
<#elseif field.fieldType == "currentGroup">
|
||||
// 初始化${field.fieldExplain}当前组
|
||||
function init${field.firstUpperFieldName}CurrentGroup(groupIdAndNamesValue, groupNamesValue) {
|
||||
var currentUserObj = {};
|
||||
currentUserObj['${field.fieldName}'] = groupIdAndNamesValue;
|
||||
currentUserObj['${field.fieldName}CurrentGroup'] = groupNamesValue;
|
||||
form.val('dataForm', currentUserObj);
|
||||
}
|
||||
|
||||
<#elseif field.fieldType == "currentPosition">
|
||||
// 初始化${field.fieldExplain}当前职位
|
||||
function init${field.firstUpperFieldName}CurrentPosition(positionIdAndNamesValue, positionNamesValue) {
|
||||
var currentUserObj = {};
|
||||
currentUserObj['${field.fieldName}'] = positionIdAndNamesValue;
|
||||
currentUserObj['${field.fieldName}CurrentPosition'] = positionNamesValue;
|
||||
form.val('dataForm', currentUserObj);
|
||||
}
|
||||
|
||||
<#elseif field.fieldType == "leftJoin" || field.fieldType == "innerJoin" || field.fieldType == "rightJoin">
|
||||
// 初始化${field.fieldExplain}联表
|
||||
function init${field.firstUpperFieldName}JoinTable(){
|
||||
@ -498,6 +533,7 @@
|
||||
|
||||
// 初始化内容
|
||||
function initData() {
|
||||
top.restAjax.get(top.restAjax.path('api/userinfo/getcurrentuseridinfo', []), {}, null, function(code, data) {
|
||||
<#list fieldList! as field>
|
||||
<#if field.formShow == 1>
|
||||
<#if field.fieldType == "date">
|
||||
@ -518,11 +554,28 @@
|
||||
init${field.firstUpperFieldName}SelectUser();
|
||||
<#elseif field.fieldType == "selectDepartment">
|
||||
init${field.firstUpperFieldName}SelectDepartment();
|
||||
<#elseif field.fieldType == "currentUser">
|
||||
init${field.firstUpperFieldName}CurrentUser(data.userIdAndValue, data.userNameValue);
|
||||
<#elseif field.fieldType == "currentDepartment">
|
||||
init${field.firstUpperFieldName}CurrentDepartment(data.departmentIdAndNamesValue, data.departmentNamesValue);
|
||||
<#elseif field.fieldType == "currentRole">
|
||||
init${field.firstUpperFieldName}CurrentRole(data.roleIdAndNamesValue, data.roleNamesValue);
|
||||
<#elseif field.fieldType == "currentGroup">
|
||||
init${field.firstUpperFieldName}CurrentGroup(data.groupIdAndNamesValue, data.groupNamesValue);
|
||||
<#elseif field.fieldType == "currentPosition">
|
||||
init${field.firstUpperFieldName}CurrentPosition(data.positionIdAndNamesValue, data.positionNamesValue);
|
||||
<#elseif field.fieldType == "leftJoin" || field.fieldType == "innerJoin" || field.fieldType == "rightJoin">
|
||||
init${field.firstUpperFieldName}JoinTable();
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
}
|
||||
initData();
|
||||
|
||||
@ -567,6 +620,25 @@
|
||||
$('.close').on('click', function() {
|
||||
closeBox();
|
||||
});
|
||||
|
||||
// 校验
|
||||
form.verify({
|
||||
<#list fieldList! as field>
|
||||
<#if field.formShow == 1>
|
||||
<#if field.fieldType == "string">
|
||||
<#if field.verifyType??>
|
||||
<#if field.verifyType == "custom">
|
||||
${field.fieldName}CustomVerify: function(value, item){
|
||||
if(!new RegExp('${field.verifyRegular}').test(value)){
|
||||
return '${field.fieldExplain}格式错误';
|
||||
}
|
||||
}
|
||||
</#if>
|
||||
</#if>
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
@ -36,14 +36,14 @@
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.fieldExplain}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" id="${field.fieldName}" name="${field.fieldName}" class="layui-input" value="${field.fieldDefault}" placeholder="请输入${field.fieldExplain}">
|
||||
<input type="number" id="${field.fieldName}" name="${field.fieldName}" class="layui-input" value="${field.fieldDefault}" placeholder="请输入${field.fieldExplain}" lay-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.fieldType == "double">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.fieldExplain}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" step="0.01" id="${field.fieldName}" name="${field.fieldName}" class="layui-input" value="${field.fieldDefault}" placeholder="请输入${field.fieldExplain}">
|
||||
<input type="number" step="0.01" id="${field.fieldName}" name="${field.fieldName}" class="layui-input" value="${field.fieldDefault}" placeholder="请输入${field.fieldExplain}" lay-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.fieldType == "textarea">
|
||||
@ -55,7 +55,7 @@
|
||||
</div>
|
||||
<#elseif field.fieldType == "richText">
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">${field.fieldExplain}</label>
|
||||
<label class="layui-form-label layui-form">${field.fieldExplain}</label>
|
||||
<div class="layui-input-block">
|
||||
<div id="${field.fieldName}"></div>
|
||||
</div>
|
||||
@ -63,7 +63,7 @@
|
||||
<#elseif field.fieldType == "select">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.fieldExplain}</label>
|
||||
<div class="layui-input-block" id="${field.fieldName}SelectTemplateBox"></div>
|
||||
<div class="layui-input-block layui-form" id="${field.fieldName}SelectTemplateBox"></div>
|
||||
<script id="${field.fieldName}SelectTemplate" type="text/html">
|
||||
<select id="${field.fieldName}" name="${field.fieldName}">
|
||||
<option value="">请选择${field.fieldExplain}</option>
|
||||
@ -76,10 +76,10 @@
|
||||
<#elseif field.fieldType == "checkbox">
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">${field.fieldExplain}</label>
|
||||
<div class="layui-input-block" id="${field.fieldName}CheckboxTemplateBox"></div>
|
||||
<div class="layui-input-block layui-form" id="${field.fieldName}CheckboxTemplateBox"></div>
|
||||
<script id="${field.fieldName}CheckboxTemplate" type="text/html">
|
||||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||||
<input type="checkbox" name="${field.fieldName}[{{item.dictionaryId}}] value="{{item.dictionaryId}}"" title="{{item.dictionaryName}}">
|
||||
<input type="checkbox" name="${field.fieldName}[{{item.dictionaryId}}]" value="{{item.dictionaryId}}" title="{{item.dictionaryName}}">
|
||||
{{# } }}
|
||||
</script>
|
||||
</div>
|
||||
@ -136,7 +136,7 @@
|
||||
<label class="layui-form-label">${field.fieldExplain}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="${field.fieldName}" name="${field.fieldName}">
|
||||
<input type="text" class="layui-input" id="${field.fieldName}CurrentUser" readonly>
|
||||
<input type="text" class="layui-input" id="${field.fieldName}CurrentUser" name="${field.fieldName}CurrentUser" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.fieldType == "currentDepartment">
|
||||
@ -144,15 +144,7 @@
|
||||
<label class="layui-form-label">${field.fieldExplain}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="${field.fieldName}" name="${field.fieldName}">
|
||||
<input type="text" class="layui-input" id="${field.fieldName}CurrentDepartment" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.fieldType == "currentDepartment">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.fieldExplain}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="${field.fieldName}" name="${field.fieldName}">
|
||||
<input type="text" class="layui-input" id="${field.fieldName}CurrentDepartment" readonly>
|
||||
<input type="text" class="layui-input" id="${field.fieldName}CurrentDepartment" name="${field.fieldName}CurrentDepartment" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.fieldType == "currentRole">
|
||||
@ -160,7 +152,7 @@
|
||||
<label class="layui-form-label">${field.fieldExplain}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="${field.fieldName}" name="${field.fieldName}">
|
||||
<input type="text" class="layui-input" id="${field.fieldName}CurrentRole" readonly>
|
||||
<input type="text" class="layui-input" id="${field.fieldName}CurrentRole" name="${field.fieldName}CurrentRole" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.fieldType == "currentGroup">
|
||||
@ -168,7 +160,7 @@
|
||||
<label class="layui-form-label">${field.fieldExplain}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="${field.fieldName}" name="${field.fieldName}">
|
||||
<input type="text" class="layui-input" id="${field.fieldName}CurrentGroup" readonly>
|
||||
<input type="text" class="layui-input" id="${field.fieldName}CurrentGroup" name="${field.fieldName}CurrentGroup" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.fieldType == "currentPosition">
|
||||
@ -176,7 +168,7 @@
|
||||
<label class="layui-form-label">${field.fieldExplain}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="${field.fieldName}" name="${field.fieldName}">
|
||||
<input type="text" class="layui-input" id="${field.fieldName}CurrentPosition" readonly>
|
||||
<input type="text" class="layui-input" id="${field.fieldName}CurrentPosition" name="${field.fieldName}CurrentPosition" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.fieldType == "leftJoin" || field.fieldType == "innerJoin" || field.fieldType == "rightJoin">
|
||||
@ -192,11 +184,11 @@
|
||||
</select>
|
||||
</script>
|
||||
</div>
|
||||
<#else>
|
||||
<#elseif field.fieldType == "string">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.fieldExplain}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="${field.fieldName}" name="${field.fieldName}" class="layui-input" value="${field.fieldDefault}" placeholder="请输入${field.fieldExplain}">
|
||||
<input type="text" id="${field.fieldName}" name="${field.fieldName}" class="layui-input" value="${field.fieldDefault}" placeholder="请输入${field.fieldExplain}" <#if field.verifyType?? && field.verifyType != "none">lay-verify="<#if field.verifyType == "phone">phone<#elseif field.verifyType == "email">email<#elseif field.verifyType == "url">url<#elseif field.verifyType == "number">number<#elseif field.verifyType == "date">date<#elseif field.verifyType == "identity">identity<#elseif field.verifyType == "custom">${field.fieldName}CustomVerify<#elseif field.verifyType == "required">required</#if>"</#if>>
|
||||
</div>
|
||||
</div>
|
||||
</#if>
|
||||
@ -227,6 +219,7 @@
|
||||
var laytpl = layui.laytpl;
|
||||
var laydate = layui.laydate;
|
||||
var ${firstLowerTableName}Id = top.restAjax.params(window.location.href).${firstLowerTableName}Id;
|
||||
|
||||
var wangEditor = window.wangEditor;
|
||||
var wangEditorObj = {};
|
||||
|
||||
@ -249,21 +242,7 @@
|
||||
|
||||
<#list fieldList! as field>
|
||||
<#if field.formShow == 1>
|
||||
<#if field.fieldType == "checkbox">
|
||||
// 初始化${field.fieldExplain}复选框
|
||||
function init${field.firstUpperFieldName}CheckBox(checkboxValue) {
|
||||
if(!checkboxValue) {
|
||||
return;
|
||||
}
|
||||
var checkboxValue = checkboxValue.split(',');
|
||||
var checkboxObj = {};
|
||||
for(var j = 0, checkbox = checkboxValue[j]; checkbox = checkboxValue[j++];) {
|
||||
checkboxObj['${field.fieldName}['+ checkbox +']'] = true;
|
||||
form.val('dataForm', checkboxObj);
|
||||
}
|
||||
}
|
||||
|
||||
<#elseif field.fieldType == "date">
|
||||
<#if field.fieldType == "date">
|
||||
// 初始化${field.fieldExplain}日期
|
||||
function init${field.firstUpperFieldName}Date() {
|
||||
laydate.render({
|
||||
@ -309,6 +288,7 @@
|
||||
editor.txt.html(value);
|
||||
wangEditorObj['${field.fieldName}'] = editor;
|
||||
}
|
||||
|
||||
<#elseif field.fieldType == "select">
|
||||
// 初始化${field.fieldExplain}下拉选择
|
||||
function init${field.firstUpperFieldName}Select(selectValue) {
|
||||
@ -333,7 +313,7 @@
|
||||
laytpl(document.getElementById('${field.fieldName}CheckboxTemplate').innerHTML).render(data, function(html) {
|
||||
document.getElementById('${field.fieldName}CheckboxTemplateBox').innerHTML = html;
|
||||
});
|
||||
form.render('checkbox');
|
||||
form.render('checkbox', '${field.fieldName}CheckboxTemplateBox');
|
||||
|
||||
var checkboxValue = selectValues.split(',');
|
||||
var checkboxObj = {};
|
||||
@ -353,7 +333,7 @@
|
||||
laytpl(document.getElementById('${field.fieldName}RadioTemplate').innerHTML).render(data, function(html) {
|
||||
document.getElementById('${field.fieldName}RadioTemplateBox').innerHTML = html;
|
||||
});
|
||||
form.render('radio');
|
||||
form.render('radio', '${field.fieldName}RadioTemplateBox');
|
||||
|
||||
var radioObj = {};
|
||||
radioObj['${field.fieldName}'] = selectValue;
|
||||
@ -541,6 +521,56 @@
|
||||
});
|
||||
}
|
||||
|
||||
<#elseif field.fieldType == "currentUser">
|
||||
// 初始化${field.fieldExplain}当前用户
|
||||
function init${field.firstUpperFieldName}CurrentUser(idAndNameValue) {
|
||||
var nameValue = (typeof(idAndNameValue) != 'undefined' && idAndNameValue != null && idAndNameValue != '') ? idAndNameValue.split('|')[1] : '';
|
||||
var currentUserObj = {};
|
||||
currentUserObj['${field.fieldName}'] = idAndNameValue;
|
||||
currentUserObj['${field.fieldName}CurrentUser'] = nameValue;
|
||||
form.val('dataForm', currentUserObj);
|
||||
}
|
||||
|
||||
<#elseif field.fieldType == "currentDepartment">
|
||||
// 初始化${field.fieldExplain}当前部门
|
||||
function init${field.firstUpperFieldName}CurrentDepartment(idAndNameValue) {
|
||||
var nameValue = (typeof(idAndNameValue) != 'undefined' && idAndNameValue != null && idAndNameValue != '') ? idAndNameValue.split('|')[1] : '';
|
||||
var currentUserObj = {};
|
||||
currentUserObj['${field.fieldName}'] = idAndNameValue;
|
||||
currentUserObj['${field.fieldName}CurrentDepartment'] = nameValue;
|
||||
form.val('dataForm', currentUserObj);
|
||||
}
|
||||
|
||||
<#elseif field.fieldType == "currentRole">
|
||||
// 初始化${field.fieldExplain}当前角色
|
||||
function init${field.firstUpperFieldName}CurrentRole(idAndNameValue) {
|
||||
var nameValue = (typeof(idAndNameValue) != 'undefined' && idAndNameValue != null && idAndNameValue != '') ? idAndNameValue.split('|')[1] : '';
|
||||
var currentUserObj = {};
|
||||
currentUserObj['${field.fieldName}'] = idAndNameValue;
|
||||
currentUserObj['${field.fieldName}CurrentRole'] = nameValue;
|
||||
form.val('dataForm', currentUserObj);
|
||||
}
|
||||
|
||||
<#elseif field.fieldType == "currentGroup">
|
||||
// 初始化${field.fieldExplain}当前组
|
||||
function init${field.firstUpperFieldName}CurrentGroup(idAndNameValue) {
|
||||
var nameValue = (typeof(idAndNameValue) != 'undefined' && idAndNameValue != null && idAndNameValue != '') ? idAndNameValue.split('|')[1] : '';
|
||||
var currentUserObj = {};
|
||||
currentUserObj['${field.fieldName}'] = idAndNameValue;
|
||||
currentUserObj['${field.fieldName}CurrentGroup'] = nameValue;
|
||||
form.val('dataForm', currentUserObj);
|
||||
}
|
||||
|
||||
<#elseif field.fieldType == "currentPosition">
|
||||
// 初始化${field.fieldExplain}当前职位
|
||||
function init${field.firstUpperFieldName}CurrentPosition(idAndNameValue) {
|
||||
var nameValue = (typeof(idAndNameValue) != 'undefined' && idAndNameValue != null && idAndNameValue != '') ? idAndNameValue.split('|')[1] : '';
|
||||
var currentUserObj = {};
|
||||
currentUserObj['${field.fieldName}'] = idAndNameValue;
|
||||
currentUserObj['${field.fieldName}CurrentPosition'] = nameValue;
|
||||
form.val('dataForm', currentUserObj);
|
||||
}
|
||||
|
||||
<#elseif field.fieldType == "leftJoin" || field.fieldType == "innerJoin" || field.fieldType == "rightJoin">
|
||||
// 初始化${field.fieldExplain}联表
|
||||
function init${field.firstUpperFieldName}JoinTable(joinValue){
|
||||
@ -575,9 +605,7 @@
|
||||
form.render(null, 'dataForm');
|
||||
<#list fieldList! as field>
|
||||
<#if field.formShow == 1>
|
||||
<#if field.fieldType == "checkbox">
|
||||
init${field.firstUpperFieldName}CheckBox(data['${field.fieldName}']);
|
||||
<#elseif field.fieldType == "date">
|
||||
<#if field.fieldType == "date">
|
||||
init${field.firstUpperFieldName}Date();
|
||||
<#elseif field.fieldType == "datetime">
|
||||
init${field.firstUpperFieldName}DateTime();
|
||||
@ -595,6 +623,16 @@
|
||||
init${field.firstUpperFieldName}SelectUser();
|
||||
<#elseif field.fieldType == "selectDepartment">
|
||||
init${field.firstUpperFieldName}SelectDepartment();
|
||||
<#elseif field.fieldType == "currentUser">
|
||||
init${field.firstUpperFieldName}CurrentUser(data['${field.fieldName}']);
|
||||
<#elseif field.fieldType == "currentDepartment">
|
||||
init${field.firstUpperFieldName}CurrentDepartment(data['${field.fieldName}']);
|
||||
<#elseif field.fieldType == "currentRole">
|
||||
init${field.firstUpperFieldName}CurrentRole(data['${field.fieldName}']);
|
||||
<#elseif field.fieldType == "currentGroup">
|
||||
init${field.firstUpperFieldName}CurrentGroup(data['${field.fieldName}']);
|
||||
<#elseif field.fieldType == "currentPosition">
|
||||
init${field.firstUpperFieldName}CurrentPosition(data['${field.fieldName}']);
|
||||
<#elseif field.fieldType == "leftJoin" || field.fieldType == "innerJoin" || field.fieldType == "rightJoin">
|
||||
init${field.firstUpperFieldName}JoinTable(data['${field.fieldName}']);
|
||||
</#if>
|
||||
@ -651,6 +689,25 @@
|
||||
$('.close').on('click', function() {
|
||||
closeBox();
|
||||
});
|
||||
|
||||
// 校验
|
||||
form.verify({
|
||||
<#list fieldList! as field>
|
||||
<#if field.formShow == 1>
|
||||
<#if field.fieldType == "string">
|
||||
<#if field.verifyType??>
|
||||
<#if field.verifyType == "custom">
|
||||
${field.fieldName}CustomVerify: function(value, item){
|
||||
if(!new RegExp('${field.verifyRegular}').test(value)){
|
||||
return '${field.fieldExplain}格式错误';
|
||||
}
|
||||
}
|
||||
</#if>
|
||||
</#if>
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
@ -1,3 +1,4 @@
|
||||
DROP TABLE IF EXISTS `${tablePrefix}${underLineTableName}`;
|
||||
CREATE TABLE `${tablePrefix}${underLineTableName}`(
|
||||
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增主键',
|
||||
`${underLineTableName}_id` CHAR(36) NOT NULL COMMENT '主键',
|
||||
|
@ -129,7 +129,7 @@
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">校验类型 *</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="verifyType" lay-verify="required">
|
||||
<select name="verifyType" lay-filter="verifyType" lay-verify="required">
|
||||
<option value="none">无</option>
|
||||
<option value="required">不为空</option>
|
||||
<option value="phone">手机号</option>
|
||||
@ -142,7 +142,7 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div id="verifyRegularBox" class="layui-form-item" style="display: none">
|
||||
<label class="layui-form-label">校验正则</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="verifyRegular" placeholder="请输入校验正则" class="layui-input">
|
||||
@ -200,6 +200,49 @@
|
||||
function closeBox() {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
}
|
||||
|
||||
form.on('select(fieldType)', function(data) {
|
||||
// 联表
|
||||
if(data.value === 'leftJoin' || data.value === 'innerJoin' || data.value === 'rightJoin') {
|
||||
$('#normalFieldBox').hide();
|
||||
$('#joinFieldBox').show();
|
||||
$('#fieldDefaultBox').hide();
|
||||
$('#verifyBox').hide();
|
||||
if($('#joinTable').val() != '') {
|
||||
$('#joinFieldDetailBox').show();
|
||||
} else {
|
||||
$('#joinFieldDetailBox').hide();
|
||||
}
|
||||
return;
|
||||
}
|
||||
$('#joinFieldBox').hide();
|
||||
$('#normalFieldBox').show();
|
||||
// 选择关联字典
|
||||
if(data.value === 'select' || data.value === 'checkbox' || data.value === 'radio') {
|
||||
$('#dictionaryNameBox').show();
|
||||
return;
|
||||
}
|
||||
$('#dictionaryNameBox').hide();
|
||||
if(data.value === 'string') {
|
||||
$('#verifyBox').show();
|
||||
$('#fieldDefaultBox').show();
|
||||
return;
|
||||
}
|
||||
$('#verifyBox').hide();
|
||||
if(data.value === 'number' || data.value === 'double') {
|
||||
$('#fieldDefaultBox').show();
|
||||
return;
|
||||
}
|
||||
$('#fieldDefaultBox').hide();
|
||||
});
|
||||
form.on('select(verifyType)', function(data) {
|
||||
if(data.value === 'custom') {
|
||||
$('#verifyRegularBox').show();
|
||||
return;
|
||||
}
|
||||
$('#verifyRegularBox').hide();
|
||||
});
|
||||
|
||||
// 初始化
|
||||
function initData() {}
|
||||
initData();
|
||||
@ -239,40 +282,6 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
form.on('select(fieldType)', function(data) {
|
||||
// 联表
|
||||
if(data.value === 'leftJoin' || data.value === 'innerJoin' || data.value === 'rightJoin') {
|
||||
$('#normalFieldBox').hide();
|
||||
$('#joinFieldBox').show();
|
||||
$('#fieldDefaultBox').hide();
|
||||
$('#verifyBox').hide();
|
||||
if($('#joinTable').val() != '') {
|
||||
$('#joinFieldDetailBox').show();
|
||||
} else {
|
||||
$('#joinFieldDetailBox').hide();
|
||||
}
|
||||
return;
|
||||
}
|
||||
$('#joinFieldBox').hide();
|
||||
$('#normalFieldBox').show();
|
||||
// 选择关联字典
|
||||
if(data.value === 'select' || data.value === 'checkbox' || data.value === 'radio') {
|
||||
$('#dictionaryNameBox').show();
|
||||
return;
|
||||
}
|
||||
$('#dictionaryNameBox').hide();
|
||||
if(data.value === 'string') {
|
||||
$('#verifyBox').show();
|
||||
$('#fieldDefaultBox').show();
|
||||
return;
|
||||
}
|
||||
$('#verifyBox').hide();
|
||||
if(data.value === 'number' || data.value === 'double') {
|
||||
$('#fieldDefaultBox').show();
|
||||
return;
|
||||
}
|
||||
$('#fieldDefaultBox').hide();
|
||||
});
|
||||
$(document.body).on('click', '#dictionaryName', function() {
|
||||
top.dialog.tree({
|
||||
title: '绑定数据字典',
|
||||
|
@ -129,7 +129,7 @@
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">校验类型 *</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="verifyType" lay-verify="required">
|
||||
<select name="verifyType" lay-filter="verifyType" lay-verify="required">
|
||||
<option value="none">无</option>
|
||||
<option value="required">不为空</option>
|
||||
<option value="phone">手机号</option>
|
||||
@ -142,7 +142,7 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div id="verifyRegularBox" class="layui-form-item" style="display: none">
|
||||
<label class="layui-form-label">校验正则</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="verifyRegular" placeholder="请输入校验正则" class="layui-input">
|
||||
@ -202,6 +202,57 @@
|
||||
function closeBox() {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
}
|
||||
|
||||
// 显示或隐藏form表单元素
|
||||
function initFormItemShowHide(value) {
|
||||
// 联表
|
||||
if(value === 'leftJoin' || value === 'innerJoin' || value === 'rightJoin') {
|
||||
$('#normalFieldBox').hide();
|
||||
$('#joinFieldBox').show();
|
||||
$('#fieldDefaultBox').hide();
|
||||
$('#verifyBox').hide();
|
||||
if($('#joinTable').val() != '') {
|
||||
$('#joinFieldDetailBox').show();
|
||||
} else {
|
||||
$('#joinFieldDetailBox').hide();
|
||||
}
|
||||
return;
|
||||
}
|
||||
$('#joinFieldBox').hide();
|
||||
$('#normalFieldBox').show();
|
||||
// 选择关联字典
|
||||
if(value === 'select' || value === 'checkbox' || value === 'radio') {
|
||||
$('#dictionaryNameBox').show();
|
||||
return;
|
||||
}
|
||||
$('#dictionaryNameBox').hide();
|
||||
if(value === 'string') {
|
||||
$('#verifyBox').show();
|
||||
$('#fieldDefaultBox').show();
|
||||
return;
|
||||
}
|
||||
$('#verifyBox').hide();
|
||||
if(value === 'number' || value === 'double') {
|
||||
$('#fieldDefaultBox').show();
|
||||
return;
|
||||
}
|
||||
$('#fieldDefaultBox').hide();
|
||||
}
|
||||
form.on('select(fieldType)', function(data) {
|
||||
initFormItemShowHide(data.value);
|
||||
});
|
||||
// 验证
|
||||
function initVerifyRegular(value) {
|
||||
if(value === 'custom') {
|
||||
$('#verifyRegularBox').show();
|
||||
return;
|
||||
}
|
||||
$('#verifyRegularBox').hide();
|
||||
}
|
||||
form.on('select(verifyType)', function(data) {
|
||||
initVerifyRegular(data.value);
|
||||
});
|
||||
|
||||
// 初始化
|
||||
function initData() {
|
||||
var loadLayerIndex;
|
||||
@ -229,6 +280,7 @@
|
||||
form.render(null, 'dataForm');
|
||||
|
||||
initFormItemShowHide(data.fieldType);
|
||||
initVerifyRegular(data.verifyType);
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
@ -274,44 +326,6 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
// 显示或隐藏form表单元素
|
||||
function initFormItemShowHide(value) {
|
||||
// 联表
|
||||
if(value === 'leftJoin' || value === 'innerJoin' || value === 'rightJoin') {
|
||||
$('#normalFieldBox').hide();
|
||||
$('#joinFieldBox').show();
|
||||
$('#fieldDefaultBox').hide();
|
||||
$('#verifyBox').hide();
|
||||
if($('#joinTable').val() != '') {
|
||||
$('#joinFieldDetailBox').show();
|
||||
} else {
|
||||
$('#joinFieldDetailBox').hide();
|
||||
}
|
||||
return;
|
||||
}
|
||||
$('#joinFieldBox').hide();
|
||||
$('#normalFieldBox').show();
|
||||
// 选择关联字典
|
||||
if(value === 'select' || value === 'checkbox' || value === 'radio') {
|
||||
$('#dictionaryNameBox').show();
|
||||
return;
|
||||
}
|
||||
$('#dictionaryNameBox').hide();
|
||||
if(value === 'string') {
|
||||
$('#verifyBox').show();
|
||||
$('#fieldDefaultBox').show();
|
||||
return;
|
||||
}
|
||||
$('#verifyBox').hide();
|
||||
if(value === 'number' || value === 'double') {
|
||||
$('#fieldDefaultBox').show();
|
||||
return;
|
||||
}
|
||||
$('#fieldDefaultBox').hide();
|
||||
}
|
||||
form.on('select(fieldType)', function(data) {
|
||||
initFormItemShowHide(data.value);
|
||||
});
|
||||
$(document.body).on('click', '#dictionaryName', function() {
|
||||
top.dialog.tree({
|
||||
title: '绑定数据字典',
|
||||
|
@ -21,4 +21,8 @@ public @interface CheckEmptyAnnotation {
|
||||
|
||||
String[] types() default {};
|
||||
|
||||
String verifyType() default "";
|
||||
|
||||
String regex() default "";
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.cm.common.component;
|
||||
|
||||
import com.cm.common.pojo.bos.*;
|
||||
import com.cm.common.pojo.dtos.CurrentUserIdInfoDTO;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.swing.text.Position;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -122,4 +122,33 @@ public class SecurityComponent {
|
||||
return userInfoBO.getUserUsername();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户ID信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CurrentUserIdInfoDTO getCurrentUserIdInfo() {
|
||||
UserInfoBO userInfoBO = getCurrentUser();
|
||||
CurrentUserIdInfoDTO currentUserIdInfoDTO = new CurrentUserIdInfoDTO();
|
||||
currentUserIdInfoDTO.setUserIdAndValue(new StringBuilder(userInfoBO.getUserId()).append("|").append(userInfoBO.getUserName()).toString());
|
||||
currentUserIdInfoDTO.setUserNameValue(userInfoBO.getUserName());
|
||||
|
||||
String departmentIdAndNamesValue = userInfoBO.getDepartmentIdAndNamesValue();
|
||||
currentUserIdInfoDTO.setDepartmentIdAndNamesValue(departmentIdAndNamesValue);
|
||||
currentUserIdInfoDTO.setDepartmentNamesValue(departmentIdAndNamesValue.isEmpty() ? departmentIdAndNamesValue : departmentIdAndNamesValue.split("\\|")[1]);
|
||||
|
||||
String roleIdAndNamesValue = userInfoBO.getRoleIdAndNamesValue();
|
||||
currentUserIdInfoDTO.setRoleIdAndNamesValue(roleIdAndNamesValue);
|
||||
currentUserIdInfoDTO.setRoleNamesValue(roleIdAndNamesValue.isEmpty() ? roleIdAndNamesValue : roleIdAndNamesValue.split("\\|")[1]);
|
||||
|
||||
String groupIdAndNamesValue = userInfoBO.getGroupIdAndNamesValue();
|
||||
currentUserIdInfoDTO.setGroupIdAndNamesValue(groupIdAndNamesValue);
|
||||
currentUserIdInfoDTO.setGroupNamesValue(groupIdAndNamesValue.isEmpty() ? groupIdAndNamesValue : groupIdAndNamesValue.split("\\|")[1]);
|
||||
|
||||
String positionIdAndNamesValue = userInfoBO.getPositionIdAndNamesValue();
|
||||
currentUserIdInfoDTO.setPositionIdAndNamesValue(positionIdAndNamesValue);
|
||||
currentUserIdInfoDTO.setPositionNamesValue(positionIdAndNamesValue.isEmpty() ? positionIdAndNamesValue : positionIdAndNamesValue.split("\\|")[1]);
|
||||
return currentUserIdInfoDTO;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,146 @@
|
||||
package com.cm.common.pojo.dtos;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: CurrentUserInfoDTO
|
||||
* @Description: 当前用户信息
|
||||
* @Author: WangGeng
|
||||
* @Date: 2020/2/24 2:20 下午
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class CurrentUserIdInfoDTO {
|
||||
|
||||
@ApiModelProperty(name = "userIdAndValue", value = "用户ID")
|
||||
private String userIdAndValue;
|
||||
@ApiModelProperty(name = "userNameValue", value = "用户名称")
|
||||
private String userNameValue;
|
||||
@ApiModelProperty(name = "departmentIdAndNamesValue", value = "部门ID和名称")
|
||||
private String departmentIdAndNamesValue;
|
||||
@ApiModelProperty(name = "departmentNamesValue", value = "部门名称")
|
||||
private String departmentNamesValue;
|
||||
@ApiModelProperty(name = "roleIdAndNamesValue", value = "角色ID和名称")
|
||||
private String roleIdAndNamesValue;
|
||||
@ApiModelProperty(name = "roleNamesValue", value = "角色名称")
|
||||
private String roleNamesValue;
|
||||
@ApiModelProperty(name = "groupIdAndNamesValue", value = "组名ID和名称")
|
||||
private String groupIdAndNamesValue;
|
||||
@ApiModelProperty(name = "groupNamesValue", value = "组名称")
|
||||
private String groupNamesValue;
|
||||
@ApiModelProperty(name = "positionIdAndNamesValue", value = "职位ID和名称")
|
||||
private String positionIdAndNamesValue;
|
||||
@ApiModelProperty(name = "positionNamesValue", value = "职位名称")
|
||||
private String positionNamesValue;
|
||||
|
||||
public String getUserIdAndValue() {
|
||||
return userIdAndValue == null ? "" : userIdAndValue.trim();
|
||||
}
|
||||
|
||||
public void setUserIdAndValue(String userIdAndValue) {
|
||||
this.userIdAndValue = userIdAndValue;
|
||||
}
|
||||
|
||||
public String getUserNameValue() {
|
||||
return userNameValue == null ? "" : userNameValue.trim();
|
||||
}
|
||||
|
||||
public void setUserNameValue(String userNameValue) {
|
||||
this.userNameValue = userNameValue;
|
||||
}
|
||||
|
||||
public String getDepartmentIdAndNamesValue() {
|
||||
return departmentIdAndNamesValue == null ? "" : departmentIdAndNamesValue.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentIdAndNamesValue(String departmentIdAndNamesValue) {
|
||||
this.departmentIdAndNamesValue = departmentIdAndNamesValue;
|
||||
}
|
||||
|
||||
public String getDepartmentNamesValue() {
|
||||
return departmentNamesValue == null ? "" : departmentNamesValue.trim();
|
||||
}
|
||||
|
||||
public void setDepartmentNamesValue(String departmentNamesValue) {
|
||||
this.departmentNamesValue = departmentNamesValue;
|
||||
}
|
||||
|
||||
public String getRoleIdAndNamesValue() {
|
||||
return roleIdAndNamesValue == null ? "" : roleIdAndNamesValue.trim();
|
||||
}
|
||||
|
||||
public void setRoleIdAndNamesValue(String roleIdAndNamesValue) {
|
||||
this.roleIdAndNamesValue = roleIdAndNamesValue;
|
||||
}
|
||||
|
||||
public String getRoleNamesValue() {
|
||||
return roleNamesValue == null ? "" : roleNamesValue.trim();
|
||||
}
|
||||
|
||||
public void setRoleNamesValue(String roleNamesValue) {
|
||||
this.roleNamesValue = roleNamesValue;
|
||||
}
|
||||
|
||||
public String getGroupIdAndNamesValue() {
|
||||
return groupIdAndNamesValue == null ? "" : groupIdAndNamesValue.trim();
|
||||
}
|
||||
|
||||
public void setGroupIdAndNamesValue(String groupIdAndNamesValue) {
|
||||
this.groupIdAndNamesValue = groupIdAndNamesValue;
|
||||
}
|
||||
|
||||
public String getGroupNamesValue() {
|
||||
return groupNamesValue == null ? "" : groupNamesValue.trim();
|
||||
}
|
||||
|
||||
public void setGroupNamesValue(String groupNamesValue) {
|
||||
this.groupNamesValue = groupNamesValue;
|
||||
}
|
||||
|
||||
public String getPositionIdAndNamesValue() {
|
||||
return positionIdAndNamesValue == null ? "" : positionIdAndNamesValue.trim();
|
||||
}
|
||||
|
||||
public void setPositionIdAndNamesValue(String positionIdAndNamesValue) {
|
||||
this.positionIdAndNamesValue = positionIdAndNamesValue;
|
||||
}
|
||||
|
||||
public String getPositionNamesValue() {
|
||||
return positionNamesValue == null ? "" : positionNamesValue.trim();
|
||||
}
|
||||
|
||||
public void setPositionNamesValue(String positionNamesValue) {
|
||||
this.positionNamesValue = positionNamesValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"userIdAndValue\":")
|
||||
.append("\"").append(userIdAndValue).append("\"");
|
||||
sb.append(",\"userNameValue\":")
|
||||
.append("\"").append(userNameValue).append("\"");
|
||||
sb.append(",\"departmentIdAndNamesValue\":")
|
||||
.append("\"").append(departmentIdAndNamesValue).append("\"");
|
||||
sb.append(",\"departmentNamesValue\":")
|
||||
.append("\"").append(departmentNamesValue).append("\"");
|
||||
sb.append(",\"roleIdAndNamesValue\":")
|
||||
.append("\"").append(roleIdAndNamesValue).append("\"");
|
||||
sb.append(",\"roleNamesValue\":")
|
||||
.append("\"").append(roleNamesValue).append("\"");
|
||||
sb.append(",\"groupIdAndNamesValue\":")
|
||||
.append("\"").append(groupIdAndNamesValue).append("\"");
|
||||
sb.append(",\"groupNamesValue\":")
|
||||
.append("\"").append(groupNamesValue).append("\"");
|
||||
sb.append(",\"positionIdAndNamesValue\":")
|
||||
.append("\"").append(positionIdAndNamesValue).append("\"");
|
||||
sb.append(",\"positionNamesValue\":")
|
||||
.append("\"").append(positionNamesValue).append("\"");
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package com.cm.common.utils.annotation;
|
||||
|
||||
import com.cm.common.annotation.*;
|
||||
import com.cm.common.exception.ParamsException;
|
||||
import com.cm.common.utils.RegexUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
|
||||
@ -11,6 +12,7 @@ import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
@ -53,6 +55,7 @@ public class AnnotationUtil {
|
||||
if (StringUtils.isBlank(fieldValue.toString())) {
|
||||
throw new ParamsException(String.format("%s不能为空或空串", checkEmptyAnnotation.name()));
|
||||
}
|
||||
checkRegular(checkEmptyAnnotation.name(), fieldValue.toString(), checkEmptyAnnotation.verifyType(), checkEmptyAnnotation.regex());
|
||||
checkTypes(checkEmptyAnnotation.name(), fieldValue.toString(), checkEmptyAnnotation.types());
|
||||
} else if (field.isAnnotationPresent(CheckNumberAnnotation.class)) {
|
||||
CheckNumberAnnotation checkNumberAnnotation = field.getAnnotation(CheckNumberAnnotation.class);
|
||||
@ -121,6 +124,58 @@ public class AnnotationUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查正则
|
||||
*
|
||||
* @param name
|
||||
* @param value
|
||||
* @param verifyType
|
||||
* @param regex
|
||||
*/
|
||||
private static void checkRegular(String name, String value, String verifyType, String regex) {
|
||||
if (StringUtils.isBlank(verifyType)) {
|
||||
return;
|
||||
}
|
||||
if (StringUtils.equals("phone", verifyType)) {
|
||||
if (!RegexUtil.isPhone(value)) {
|
||||
throw new ParamsException(String.format("%s格式不手机格式", name));
|
||||
}
|
||||
return;
|
||||
} else if (StringUtils.equals("email", verifyType)) {
|
||||
if (!RegexUtil.isEmail(value)) {
|
||||
throw new ParamsException(String.format("%s格式不邮件格式", name));
|
||||
}
|
||||
return;
|
||||
} else if (StringUtils.equals("url", verifyType)) {
|
||||
if (!RegexUtil.isUrl(value)) {
|
||||
throw new ParamsException(String.format("%s格式不url格式", name));
|
||||
}
|
||||
return;
|
||||
} else if (StringUtils.equals("number", verifyType)) {
|
||||
if (!NumberUtils.isNumber(value)) {
|
||||
throw new ParamsException(String.format("%s格式不数字格式", name));
|
||||
}
|
||||
return;
|
||||
} else if (StringUtils.equals("date", verifyType)) {
|
||||
if (!RegexUtil.isDate(value)) {
|
||||
throw new ParamsException(String.format("%s格式不日期格式", name));
|
||||
}
|
||||
return;
|
||||
} else if (StringUtils.equals("identity", verifyType)) {
|
||||
if (!RegexUtil.isIdentity(value)) {
|
||||
throw new ParamsException(String.format("%s格式不身份证格式", name));
|
||||
}
|
||||
return;
|
||||
} else if (StringUtils.equals("custom", verifyType)) {
|
||||
if (StringUtils.isBlank(regex)) {
|
||||
return;
|
||||
}
|
||||
if (!Pattern.compile(regex).matcher(value).matches()) {
|
||||
throw new ParamsException(String.format("%s格式不正确", name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过字段获取get方法
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user