动态表单新增当前用户、部门、角色、组、职位

This commit is contained in:
wenc000 2020-02-07 23:18:18 +08:00
parent 407e3bee7d
commit 793d9583f5
11 changed files with 422 additions and 2 deletions

View File

@ -1,11 +1,14 @@
package com.cm.common.plugin.controller.routes.dynamic;
import com.cm.common.base.AbstractController;
import com.cm.common.component.SecurityComponent;
import com.cm.common.constants.ISystemConstant;
import com.cm.common.plugin.enums.dynamic.FieldTypeEnum;
import com.cm.common.plugin.pojo.dtos.dynamic.DynamicFormFormShowFieldDTO;
import com.cm.common.plugin.service.datadictionary.IDataDictionaryService;
import com.cm.common.plugin.service.dynamic.IDynamicFormService;
import com.cm.common.pojo.bos.RoleBO;
import com.cm.common.pojo.bos.UserInfoBO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@ -42,6 +45,8 @@ public class DynamicFormRouteController extends AbstractController {
private IDynamicFormService dynamicFormService;
@Autowired
private IDataDictionaryService dataDictionaryService;
@Autowired
private SecurityComponent securityComponent;
@ApiOperation(value = "动态表单新增页面", notes = "动态表单新增页面接口")
@ApiImplicitParams({
@ -55,6 +60,7 @@ public class DynamicFormRouteController extends AbstractController {
List<DynamicFormFormShowFieldDTO> dynamicFormFormShowFieldDTOs = dynamicFormService.listFormShowFieldOfPage(tableName);
mv.addObject("dynamicFormFormShowFieldDTOList", dynamicFormFormShowFieldDTOs);
setDynamicFieldData(mv, dynamicFormFormShowFieldDTOs);
setCurrentUserIdAndNameValues(mv, dynamicFormFormShowFieldDTOs);
return mv;
}
@ -140,4 +146,34 @@ public class DynamicFormRouteController extends AbstractController {
return mv;
}
/**
* 设置ID和名称值当前用户部门角色职位等
*
* @param mv
*/
private void setCurrentUserIdAndNameValues(ModelAndView mv, List<DynamicFormFormShowFieldDTO> dynamicFormFormShowFieldDTOs) {
dynamicFormFormShowFieldDTOs.forEach(dynamicFormFormShowFieldDTO -> {
if (StringUtils.equals(FieldTypeEnum.CURRENT_USER.getValue(), dynamicFormFormShowFieldDTO.getFieldType())) {
mv.addObject("userIdAndValue", String.format("%s|%s", securityComponent.getCurrentUser().getUserId(), securityComponent.getCurrentUser().getUserName()));
mv.addObject("userNameValue", securityComponent.getCurrentUser().getUserName());
} else if (StringUtils.equals(FieldTypeEnum.CURRENT_DEPARTMENT.getValue(), dynamicFormFormShowFieldDTO.getFieldType())) {
String departmentIdAndNamesValue = securityComponent.getCurrentUser().getDepartmentIdAndNamesValue();
mv.addObject("departmentIdAndNamesValue", departmentIdAndNamesValue);
mv.addObject("departmentNamesValue", departmentIdAndNamesValue.isEmpty() ? departmentIdAndNamesValue : departmentIdAndNamesValue.split("\\|")[1]);
} else if (StringUtils.equals(FieldTypeEnum.CURRENT_ROLE.getValue(), dynamicFormFormShowFieldDTO.getFieldType())) {
String roleIdAndNamesValue = securityComponent.getCurrentUser().getRoleIdAndNamesValue();
mv.addObject("roleIdAndNamesValue", roleIdAndNamesValue);
mv.addObject("roleNamesValue", roleIdAndNamesValue.isEmpty() ? roleIdAndNamesValue : roleIdAndNamesValue.split("\\|")[1]);
} else if (StringUtils.equals(FieldTypeEnum.CURRENT_GROUP.getValue(), dynamicFormFormShowFieldDTO.getFieldType())) {
String groupIdAndNamesValue = securityComponent.getCurrentUser().getGroupIdAndNamesValue();
mv.addObject("groupIdAndNamesValue", groupIdAndNamesValue);
mv.addObject("groupNamesValue", groupIdAndNamesValue.isEmpty() ? groupIdAndNamesValue : groupIdAndNamesValue.split("\\|")[1]);
} else if (StringUtils.equals(FieldTypeEnum.CURRENT_POSITION.getValue(), dynamicFormFormShowFieldDTO.getFieldType())) {
String positionIdAndNamesValue = securityComponent.getCurrentUser().getPositionIdAndNamesValue();
mv.addObject("positionIdAndNamesValue", positionIdAndNamesValue);
mv.addObject("positionNamesValue", positionIdAndNamesValue.isEmpty() ? positionIdAndNamesValue : positionIdAndNamesValue.split("\\|")[1]);
}
});
}
}

View File

@ -47,7 +47,15 @@ public enum ColumnDataTypeEnum {
/**
* 长文本
*/
LONGTEXT("longtext");
LONGTEXT("longtext"),
/**
* ID和名称
*/
ID_AND_NAME("idAndName"),
/**
* ID列表和名称列表
*/
IDS_AND_NAMES("idsAndNames");
private String dataType;

View File

@ -79,7 +79,27 @@ public enum FieldTypeEnum {
/**
* 右联
*/
RIGHT_JOIN("rightJoin");
RIGHT_JOIN("rightJoin"),
/**
* 当前用户
*/
CURRENT_USER("currentUser"),
/**
* 当前部门
*/
CURRENT_DEPARTMENT("currentDepartment"),
/**
* 当前角色
*/
CURRENT_ROLE("currentRole"),
/**
* 当前组
*/
CURRENT_GROUP("currentGroup"),
/**
* 当前职位
*/
CURRENT_POSITION("currentPosition");
private String value;

View File

@ -41,6 +41,7 @@ public class DynamicFormServiceImpl extends AbstractService implements IDynamicF
@Autowired
private IDynamicTableService dynamicTableService;
@Override
public void saveDynamicForm(DynamicFormVO dynamicFormVO) throws SaveException {
saveDynamicFormInfo(dynamicFormVO);
@ -420,6 +421,16 @@ public class DynamicFormServiceImpl extends AbstractService implements IDynamicF
} else if (StringUtils.equals(FieldTypeEnum.RIGHT_JOIN.getValue(), dynamicFormFieldVO.getFieldType())) {
tableColumnVO.setDataType(ColumnDataTypeEnum.VARCHAR.getDataType());
tableColumnVO.setColumnLength(255);
} else if (StringUtils.equals(FieldTypeEnum.CURRENT_USER.getValue(), dynamicFormFieldVO.getFieldType())) {
tableColumnVO.setDataType(ColumnDataTypeEnum.ID_AND_NAME.getDataType());
} else if (StringUtils.equals(FieldTypeEnum.CURRENT_DEPARTMENT.getValue(), dynamicFormFieldVO.getFieldType())) {
tableColumnVO.setDataType(ColumnDataTypeEnum.IDS_AND_NAMES.getDataType());
} else if (StringUtils.equals(FieldTypeEnum.CURRENT_ROLE.getValue(), dynamicFormFieldVO.getFieldType())) {
tableColumnVO.setDataType(ColumnDataTypeEnum.IDS_AND_NAMES.getDataType());
} else if (StringUtils.equals(FieldTypeEnum.CURRENT_GROUP.getValue(), dynamicFormFieldVO.getFieldType())) {
tableColumnVO.setDataType(ColumnDataTypeEnum.IDS_AND_NAMES.getDataType());
} else if (StringUtils.equals(FieldTypeEnum.CURRENT_POSITION.getValue(), dynamicFormFieldVO.getFieldType())) {
tableColumnVO.setDataType(ColumnDataTypeEnum.IDS_AND_NAMES.getDataType());
}
return tableColumnVO;
}

View File

@ -123,6 +123,10 @@ public class DynamicTableServiceImpl extends AbstractService implements IDynamic
} else if (StringUtils.equals(tableColumn.getDataType(), ColumnDataTypeEnum.LONGTEXT.getDataType())) {
columnSql.append(String.format("`%s` LONGTEXT DEFAULT NULL", WStringUtil.lowerUpper2UnderLine(tableColumn.getColumnName()), tableColumn.getColumnLength()));
notNull = false;
} else if (StringUtils.equals(tableColumn.getDataType(), ColumnDataTypeEnum.ID_AND_NAME.getDataType())
|| StringUtils.equals(tableColumn.getDataType(), ColumnDataTypeEnum.IDS_AND_NAMES.getDataType())) {
columnSql.append(String.format("`%s` VARCHAR(500) DEFAULT NULL", WStringUtil.lowerUpper2UnderLine(tableColumn.getColumnName()), tableColumn.getColumnLength()));
notNull = false;
}
if (notNull && StringUtils.equals(tableColumn.getIsNullable(), ColumnIsNullableEnum.YES.getIsNullable())) {
columnSql.append(" NOT NULL");

View File

@ -162,6 +162,21 @@
return value;
}
});
} else if(item.fieldTyp === 'currentUser'
|| item.fieldTyp === 'currentDepartment'
|| item.fieldTyp === 'currentRole'
|| item.fieldTyp === 'currentGroup'
|| item.fieldTyp === 'currentPosition') {
autoCols.push({field: item.fieldName, width: 150, title: item.fieldExplain, align:'center',
templet: function(row) {
var currentData = row[this.field];
if(typeof(currentData) === 'undefined' || currentData == null || currentData == '') {
return '-';
}
var idAndNameValue = currentData;
return idAndNameValue != null && idAndNameValue != '' ? idAndNameValue.splice('\\|')[1] : '无';
}
});
} else {
autoCols.push({field: item.fieldName, width: 150, title: item.fieldExplain, align:'center',
templet: function(row) {

View File

@ -122,6 +122,46 @@
<input type="text" th:id="${dynamicFormFormShowFieldDTO.fieldName +'SelectDepartment'}" class="layui-input" th:placeholder="${'请选择'+ dynamicFormFormShowFieldDTO.fieldExplain}" th:attr="data-name=${dynamicFormFormShowFieldDTO.fieldName}" readonly style="cursor:pointer;">
</div>
</div>
<!--/* 当前用户 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'currentUser'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block">
<input type="hidden" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" th:value="${userIdAndValue}">
<input type="text" class="layui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName +'CurrentUser'}" th:value="${userNameValue}" readonly>
</div>
</div>
<!--/* 当前组织 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'currentDepartment'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block">
<input type="hidden" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" th:value="${departmentIdAndNamesValue}">
<input type="text" class="layui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName +'CurrentDepartment'}" th:value="${departmentNamesValue}" readonly>
</div>
</div>
<!--/* 当前角色 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'currentRole'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block">
<input type="hidden" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" th:value="${roleIdAndNamesValue}">
<input type="text" class="layui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName +'CurrentRole'}" th:value="${roleNamesValue}" readonly>
</div>
</div>
<!--/* 当前组 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'currentGroup'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block">
<input type="hidden" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" th:value="${groupIdAndNamesValue}">
<input type="text" class="layui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName +'CurrentGroup'}" th:value="${groupNamesValue}" readonly>
</div>
</div>
<!--/* 当前职位 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'currentPosition'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block">
<input type="hidden" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" th:value="${positionIdAndNamesValue}">
<input type="text" class="layui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName +'CurrentPosition'}" th:value="${positionNamesValue}" readonly>
</div>
</div>
<!--/* 选择联表 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'leftJoin' or dynamicFormFormShowFieldDTO.fieldType eq 'innerJoin' or dynamicFormFormShowFieldDTO.fieldType eq 'rightJoin'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>

View File

@ -122,6 +122,46 @@
<input type="text" th:id="${dynamicFormFormShowFieldDTO.fieldName +'SelectDepartment'}" class="layui-input" th:placeholder="${'请选择'+ dynamicFormFormShowFieldDTO.fieldExplain}" th:attr="data-name=${dynamicFormFormShowFieldDTO.fieldName}" readonly style="cursor:pointer;">
</div>
</div>
<!--/* 当前用户 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'currentUser'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block">
<input type="hidden" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}">
<input type="text" class="layui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName +'CurrentUser'}" readonly>
</div>
</div>
<!--/* 当前组织 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'currentDepartment'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block">
<input type="hidden" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}">
<input type="text" class="layui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName +'CurrentDepartment'}" readonly>
</div>
</div>
<!--/* 当前角色 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'currentRole'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block">
<input type="hidden" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}">
<input type="text" class="layui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName +'CurrentRole'}" readonly>
</div>
</div>
<!--/* 当前组 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'currentGroup'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block">
<input type="hidden" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}">
<input type="text" class="layui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName +'CurrentGroup'}" readonly>
</div>
</div>
<!--/* 当前职位 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'currentPosition'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block">
<input type="hidden" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}">
<input type="text" class="layui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName +'CurrentPosition'}" readonly>
</div>
</div>
<!--/* 选择联表 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'leftJoin' or dynamicFormFormShowFieldDTO.fieldType eq 'innerJoin' or dynamicFormFormShowFieldDTO.fieldType eq 'rightJoin'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
@ -427,6 +467,41 @@
}, function(code, data) {
top.dialog.msg(data.msg);
});
} else if(item.fieldTyp === 'currentUser') {
var formData = {};
var idAndNameValue = dataFormData[item.fieldName];
var nameValue = idAndNameValue != null && idAndNameValue != '' ? idAndNameValue.splice('\\|')[1] : '';
formData[item.fieldName] = idAndNameValue;
formData[item.fieldName +'CurrentUser'] = nameValue;
form.val('dataForm', formData);
} else if(item.fieldTyp === 'currentDepartment') {
var formData = {};
var idAndNameValue = dataFormData[item.fieldName];
var nameValue = idAndNameValue != null && idAndNameValue != '' ? idAndNameValue.splice('\\|')[1] : '';
formData[item.fieldName] = idAndNameValue;
formData[item.fieldName +'CurrentDepartment'] = nameValue;
form.val('dataForm', formData);
} else if(item.fieldTyp === 'currentRole') {
var formData = {};
var idAndNameValue = dataFormData[item.fieldName];
var nameValue = idAndNameValue != null && idAndNameValue != '' ? idAndNameValue.splice('\\|')[1] : '';
formData[item.fieldName] = idAndNameValue;
formData[item.fieldName +'CurrentRole'] = nameValue;
form.val('dataForm', formData);
} else if(item.fieldTyp === 'currentGroup') {
var formData = {};
var idAndNameValue = dataFormData[item.fieldName];
var nameValue = idAndNameValue != null && idAndNameValue != '' ? idAndNameValue.splice('\\|')[1] : '';
formData[item.fieldName] = idAndNameValue;
formData[item.fieldName +'CurrentGroup'] = nameValue;
form.val('dataForm', formData);
} else if(item.fieldTyp === 'currentPosition') {
var formData = {};
var idAndNameValue = dataFormData[item.fieldName];
var nameValue = idAndNameValue != null && idAndNameValue != '' ? idAndNameValue.splice('\\|')[1] : '';
formData[item.fieldName] = idAndNameValue;
formData[item.fieldName +'CurrentPosition'] = nameValue;
form.val('dataForm', formData);
}
}
}, function(code, data) {

View File

@ -116,6 +116,46 @@
<input type="text" th:id="${dynamicFormFormShowFieldDTO.fieldName +'SelectDepartment'}" class="layui-input" th:placeholder="${'请选择'+ dynamicFormFormShowFieldDTO.fieldExplain}" th:attr="data-name=${dynamicFormFormShowFieldDTO.fieldName}" readonly style="cursor:pointer;">
</div>
</div>
<!--/* 当前用户 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'currentUser'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block">
<input type="hidden" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}">
<input type="text" class="layui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName +'CurrentUser'}" readonly>
</div>
</div>
<!--/* 当前组织 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'currentDepartment'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block">
<input type="hidden" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}">
<input type="text" class="layui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName +'CurrentDepartment'}" readonly>
</div>
</div>
<!--/* 当前角色 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'currentRole'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block">
<input type="hidden" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}">
<input type="text" class="layui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName +'CurrentRole'}" readonly>
</div>
</div>
<!--/* 当前组 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'currentGroup'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block">
<input type="hidden" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}">
<input type="text" class="layui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName +'CurrentGroup'}" readonly>
</div>
</div>
<!--/* 当前职位 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'currentPosition'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
<div class="layui-input-block">
<input type="hidden" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}">
<input type="text" class="layui-input" th:id="${dynamicFormFormShowFieldDTO.fieldName +'CurrentPosition'}" readonly>
</div>
</div>
<!--/* 选择联表 */-->
<div class="layui-form-item" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'leftJoin' or dynamicFormFormShowFieldDTO.fieldType eq 'innerJoin' or dynamicFormFormShowFieldDTO.fieldType eq 'rightJoin'}">
<label class="layui-form-label" th:text="${dynamicFormFormShowFieldDTO.fieldExplain}"></label>
@ -426,6 +466,41 @@
}, function(code, data) {
top.dialog.msg(data.msg);
});
} else if(item.fieldTyp === 'currentUser') {
var formData = {};
var idAndNameValue = dataFormData[item.fieldName];
var nameValue = idAndNameValue != null && idAndNameValue != '' ? idAndNameValue.splice('\\|')[1] : '';
formData[item.fieldName] = idAndNameValue;
formData[item.fieldName +'CurrentUser'] = nameValue;
form.val('dataForm', formData);
} else if(item.fieldTyp === 'currentDepartment') {
var formData = {};
var idAndNameValue = dataFormData[item.fieldName];
var nameValue = idAndNameValue != null && idAndNameValue != '' ? idAndNameValue.splice('\\|')[1] : '';
formData[item.fieldName] = idAndNameValue;
formData[item.fieldName +'CurrentDepartment'] = nameValue;
form.val('dataForm', formData);
} else if(item.fieldTyp === 'currentRole') {
var formData = {};
var idAndNameValue = dataFormData[item.fieldName];
var nameValue = idAndNameValue != null && idAndNameValue != '' ? idAndNameValue.splice('\\|')[1] : '';
formData[item.fieldName] = idAndNameValue;
formData[item.fieldName +'CurrentRole'] = nameValue;
form.val('dataForm', formData);
} else if(item.fieldTyp === 'currentGroup') {
var formData = {};
var idAndNameValue = dataFormData[item.fieldName];
var nameValue = idAndNameValue != null && idAndNameValue != '' ? idAndNameValue.splice('\\|')[1] : '';
formData[item.fieldName] = idAndNameValue;
formData[item.fieldName +'CurrentGroup'] = nameValue;
form.val('dataForm', formData);
} else if(item.fieldTyp === 'currentPosition') {
var formData = {};
var idAndNameValue = dataFormData[item.fieldName];
var nameValue = idAndNameValue != null && idAndNameValue != '' ? idAndNameValue.splice('\\|')[1] : '';
formData[item.fieldName] = idAndNameValue;
formData[item.fieldName +'CurrentPosition'] = nameValue;
form.val('dataForm', formData);
}
}
}, function(code, data) {

View File

@ -27,6 +27,10 @@ public class UserBO extends User {
private List<GroupBO> groups;
private List<DepartmentBO> departments;
private List<PositionBO> positions;
private String roleIdAndNamesValue;
private String groupIdAndNamesValue;
private String departmentIdAndNamesValue;
private String positionIdAndNamesValue;
public UserBO() {
super("", "", null);
@ -110,6 +114,17 @@ public class UserBO extends User {
public void setRoles(List<RoleBO> roles) {
this.roles = roles;
StringBuilder idSB = new StringBuilder();
StringBuilder nameSB = new StringBuilder();
roles.forEach(roleBO -> {
if (idSB.length() > 0) {
idSB.append(",");
nameSB.append(",");
}
idSB.append(roleBO.getRoleId());
nameSB.append(roleBO.getRoleName());
});
this.roleIdAndNamesValue = idSB.append("|").append(nameSB).toString();
}
public List<GroupBO> getGroups() {
@ -118,6 +133,17 @@ public class UserBO extends User {
public void setGroups(List<GroupBO> groups) {
this.groups = groups;
StringBuilder idSB = new StringBuilder();
StringBuilder nameSB = new StringBuilder();
groups.forEach(groupBO -> {
if (idSB.length() > 0) {
idSB.append(",");
nameSB.append(",");
}
idSB.append(groupBO.getGroupId());
nameSB.append(groupBO.getGroupName());
});
this.groupIdAndNamesValue = idSB.append("|").append(nameSB).toString();
}
public List<DepartmentBO> getDepartments() {
@ -126,6 +152,17 @@ public class UserBO extends User {
public void setDepartments(List<DepartmentBO> departments) {
this.departments = departments;
StringBuilder idSB = new StringBuilder();
StringBuilder nameSB = new StringBuilder();
departments.forEach(departmentBO -> {
if (idSB.length() > 0) {
idSB.append(",");
nameSB.append(",");
}
idSB.append(departmentBO.getDepartmentId());
nameSB.append(departmentBO.getDepartmentName());
});
this.departmentIdAndNamesValue = idSB.append("|").append(nameSB).toString();
}
public List<PositionBO> getPositions() {
@ -134,6 +171,33 @@ public class UserBO extends User {
public void setPositions(List<PositionBO> positions) {
this.positions = positions;
StringBuilder idSB = new StringBuilder();
StringBuilder nameSB = new StringBuilder();
positions.forEach(positionBO -> {
if (idSB.length() > 0) {
idSB.append(",");
nameSB.append(",");
}
idSB.append(positionBO.getPositionId());
nameSB.append(positionBO.getPositionName());
});
this.positionIdAndNamesValue = idSB.append("|").append(nameSB).toString();
}
public String getRoleIdAndNamesValue() {
return roleIdAndNamesValue == null ? "" : roleIdAndNamesValue.trim();
}
public String getGroupIdAndNamesValue() {
return groupIdAndNamesValue == null ? "" : groupIdAndNamesValue.trim();
}
public String getDepartmentIdAndNamesValue() {
return departmentIdAndNamesValue == null ? "" : departmentIdAndNamesValue.trim();
}
public String getPositionIdAndNamesValue() {
return positionIdAndNamesValue == null ? "" : positionIdAndNamesValue.trim();
}
@Override
@ -163,6 +227,14 @@ public class UserBO extends User {
.append(departments);
sb.append(",\"positions\":")
.append(positions);
sb.append(",\"roleIdAndNamesValue\":")
.append("\"").append(roleIdAndNamesValue).append("\"");
sb.append(",\"groupIdAndNamesValue\":")
.append("\"").append(groupIdAndNamesValue).append("\"");
sb.append(",\"departmentIdAndNamesValue\":")
.append("\"").append(departmentIdAndNamesValue).append("\"");
sb.append(",\"positionIdAndNamesValue\":")
.append("\"").append(positionIdAndNamesValue).append("\"");
sb.append('}');
return sb.toString();
}

View File

@ -23,6 +23,10 @@ public class UserInfoBO {
private List<RoleBO> roles;
private List<GroupBO> groups;
private List<PositionBO> positions;
private String roleIdAndNamesValue;
private String groupIdAndNamesValue;
private String departmentIdAndNamesValue;
private String positionIdAndNamesValue;
public String getUserId() {
return userId == null ? "" : userId.trim();
@ -86,6 +90,17 @@ public class UserInfoBO {
public void setDepartments(List<DepartmentBO> departments) {
this.departments = departments;
StringBuilder idSB = new StringBuilder();
StringBuilder nameSB = new StringBuilder();
departments.forEach(departmentBO -> {
if (idSB.length() > 0) {
idSB.append(",");
nameSB.append(",");
}
idSB.append(departmentBO.getDepartmentId());
nameSB.append(departmentBO.getDepartmentName());
});
this.departmentIdAndNamesValue = idSB.append("|").append(nameSB).toString();
}
public List<RoleBO> getRoles() {
@ -94,6 +109,17 @@ public class UserInfoBO {
public void setRoles(List<RoleBO> roles) {
this.roles = roles;
StringBuilder idSB = new StringBuilder();
StringBuilder nameSB = new StringBuilder();
roles.forEach(roleBO -> {
if (idSB.length() > 0) {
idSB.append(",");
nameSB.append(",");
}
idSB.append(roleBO.getRoleId());
nameSB.append(roleBO.getRoleName());
});
this.roleIdAndNamesValue = idSB.append("|").append(nameSB).toString();
}
public List<GroupBO> getGroups() {
@ -102,6 +128,17 @@ public class UserInfoBO {
public void setGroups(List<GroupBO> groups) {
this.groups = groups;
StringBuilder idSB = new StringBuilder();
StringBuilder nameSB = new StringBuilder();
groups.forEach(groupBO -> {
if (idSB.length() > 0) {
idSB.append(",");
nameSB.append(",");
}
idSB.append(groupBO.getGroupId());
nameSB.append(groupBO.getGroupName());
});
this.groupIdAndNamesValue = idSB.append("|").append(nameSB).toString();
}
public List<PositionBO> getPositions() {
@ -110,6 +147,33 @@ public class UserInfoBO {
public void setPositions(List<PositionBO> positions) {
this.positions = positions;
StringBuilder idSB = new StringBuilder();
StringBuilder nameSB = new StringBuilder();
positions.forEach(positionBO -> {
if (idSB.length() > 0) {
idSB.append(",");
nameSB.append(",");
}
idSB.append(positionBO.getPositionId());
nameSB.append(positionBO.getPositionName());
});
this.positionIdAndNamesValue = idSB.append("|").append(nameSB).toString();
}
public String getRoleIdAndNamesValue() {
return roleIdAndNamesValue == null ? "" : roleIdAndNamesValue.trim();
}
public String getGroupIdAndNamesValue() {
return groupIdAndNamesValue == null ? "" : groupIdAndNamesValue.trim();
}
public String getDepartmentIdAndNamesValue() {
return departmentIdAndNamesValue == null ? "" : departmentIdAndNamesValue.trim();
}
public String getPositionIdAndNamesValue() {
return positionIdAndNamesValue == null ? "" : positionIdAndNamesValue.trim();
}
@Override