编辑动态表单的select,radio,checkbox等逻辑
This commit is contained in:
parent
fe23ce4500
commit
9e882e89e4
@ -4,6 +4,7 @@ import com.cm.common.base.AbstractController;
|
||||
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.result.ErrorResult;
|
||||
import io.swagger.annotations.*;
|
||||
@ -15,7 +16,10 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
@ -34,6 +38,8 @@ public class DynamicFormRouteController extends AbstractController {
|
||||
|
||||
@Autowired
|
||||
private IDynamicFormService dynamicFormService;
|
||||
@Autowired
|
||||
private IDataDictionaryService dataDictionaryService;
|
||||
|
||||
@ApiOperation(value = "动态表单新增页面", notes = "动态表单新增页面接口")
|
||||
@ApiImplicitParams({
|
||||
@ -44,11 +50,10 @@ public class DynamicFormRouteController extends AbstractController {
|
||||
public ModelAndView saveDynamicForm(@PathVariable("tableName") String tableName) {
|
||||
ModelAndView mv = new ModelAndView("dynamic/form/savedynamicform");
|
||||
mv.addObject("tableName", tableName);
|
||||
|
||||
List<DynamicFormFormShowFieldDTO> dynamicFormFormShowFieldDTOs = dynamicFormService.listFormShowFieldOfPage(tableName);
|
||||
mv.addObject("dynamicFormFormShowFieldDTOList", dynamicFormFormShowFieldDTOs);
|
||||
for (DynamicFormFormShowFieldDTO dynamicFormFormShowFieldDTO : dynamicFormFormShowFieldDTOs) {
|
||||
|
||||
}
|
||||
setDynamicFieldData(mv, dynamicFormFormShowFieldDTOs);
|
||||
return mv;
|
||||
}
|
||||
|
||||
@ -63,7 +68,10 @@ public class DynamicFormRouteController extends AbstractController {
|
||||
ModelAndView mv = new ModelAndView("dynamic/form/updatedynamicform");
|
||||
mv.addObject("tableName", tableName);
|
||||
mv.addObject("uuidValue", uuidValue);
|
||||
mv.addObject("dynamicFormFormShowFieldDTOList", dynamicFormService.listFormShowFieldOfPage(tableName));
|
||||
|
||||
List<DynamicFormFormShowFieldDTO> dynamicFormFormShowFieldDTOs = dynamicFormService.listFormShowFieldOfPage(tableName);
|
||||
mv.addObject("dynamicFormFormShowFieldDTOList", dynamicFormFormShowFieldDTOs);
|
||||
setDynamicFieldData(mv, dynamicFormFormShowFieldDTOs);
|
||||
return mv;
|
||||
}
|
||||
|
||||
@ -74,21 +82,31 @@ public class DynamicFormRouteController extends AbstractController {
|
||||
* @param dynamicFormFormShowFieldDTOs
|
||||
*/
|
||||
private void setDynamicFieldData(ModelAndView mv, List<DynamicFormFormShowFieldDTO> dynamicFormFormShowFieldDTOs) {
|
||||
List<Map<String, Object>> selectMapList = new ArrayList<>(0);
|
||||
List<Map<String, Object>> checkboxMapList = new ArrayList<>(0);
|
||||
List<Map<String, Object>> radioMapList = new ArrayList<>(0);
|
||||
for (DynamicFormFormShowFieldDTO dynamicFormFormShowFieldDTO : dynamicFormFormShowFieldDTOs) {
|
||||
String dictionaryId = dynamicFormFormShowFieldDTO.getDictionaryId();
|
||||
String fieldDefault = dynamicFormFormShowFieldDTO.getFieldDefault();
|
||||
if (StringUtils.equals(FieldTypeEnum.SELECT.getValue(), dynamicFormFormShowFieldDTO.getFieldType())) {
|
||||
|
||||
Map<String, Object> selectMap = new HashMap<>(2);
|
||||
selectMap.put("name", dynamicFormFormShowFieldDTO.getFieldName());
|
||||
selectMap.put("list", dataDictionaryService.listDictionaryByParentId(dictionaryId));
|
||||
selectMapList.add(selectMap);
|
||||
} else if (StringUtils.equals(FieldTypeEnum.CHECKBOX.getValue(), dynamicFormFormShowFieldDTO.getFieldType())) {
|
||||
|
||||
Map<String, Object> checkboxMap = new HashMap<>(2);
|
||||
checkboxMap.put("name", dynamicFormFormShowFieldDTO.getFieldName());
|
||||
checkboxMap.put("list", dataDictionaryService.listDictionaryByParentId(dictionaryId));
|
||||
checkboxMapList.add(checkboxMap);
|
||||
} else if (StringUtils.equals(FieldTypeEnum.RADIO.getValue(), dynamicFormFormShowFieldDTO.getFieldType())) {
|
||||
|
||||
} else if (StringUtils.equals(FieldTypeEnum.SELECT_USER.getValue(), dynamicFormFormShowFieldDTO.getFieldType())) {
|
||||
|
||||
} else if (StringUtils.equals(FieldTypeEnum.SELECT_DEPARTMENT.getValue(), dynamicFormFormShowFieldDTO.getFieldType())) {
|
||||
|
||||
Map<String, Object> radioMap = new HashMap<>(2);
|
||||
radioMap.put("name", dynamicFormFormShowFieldDTO.getFieldName());
|
||||
radioMap.put("list", dataDictionaryService.listDictionaryByParentId(dictionaryId));
|
||||
radioMapList.add(radioMap);
|
||||
}
|
||||
}
|
||||
mv.addObject("selectMapList", selectMapList);
|
||||
mv.addObject("checkboxMapList", checkboxMapList);
|
||||
mv.addObject("radioMapList", radioMapList);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "动态表单列表页面", notes = "动态表单列表页面接口")
|
||||
|
@ -115,6 +115,7 @@ public class DynamicFormServiceImpl extends AbstractService implements IDynamicF
|
||||
dynamicFormFormShowFieldDTO.setFieldName(WStringUtil.lowerUpper2UnderLine(dynamicFormDTO.getFieldName()));
|
||||
dynamicFormFormShowFieldDTO.setFieldExplain(dynamicFormDTO.getFieldExplain());
|
||||
dynamicFormFormShowFieldDTO.setFieldDefault(dynamicFormDTO.getFieldDefault());
|
||||
dynamicFormFormShowFieldDTO.setDictionaryId(dynamicFormDTO.getDictionaryId());
|
||||
dynamicFormFormShowFieldDTO.setFieldType(dynamicFormDTO.getFieldType());
|
||||
dynamicFormFormShowFieldDTO.setVerifyType(dynamicFormDTO.getVerifyType());
|
||||
dynamicFormFormShowFieldDTO.setVerifyRegular(dynamicFormDTO.getVerifyRegular());
|
||||
|
@ -84,9 +84,10 @@
|
||||
[
|
||||
{type:'checkbox', fixed: 'left'},
|
||||
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
|
||||
{field:'dictionaryName', width:170, title: '字典名称', align:'center',},
|
||||
{field:'dictionarySummary', width:170, title: '字典说明', align:'center',},
|
||||
{field:'dictionaryCode', width:170, title: '字典编码', align:'center',},
|
||||
{field:'dictionaryId', width:200, title: '字典ID', align:'center',},
|
||||
{field:'dictionaryName', width:160, title: '字典名称', align:'center',},
|
||||
{field:'dictionarySummary', width:160, title: '字典说明', align:'center',},
|
||||
{field:'dictionaryCode', width:160, title: '字典编码', align:'center',},
|
||||
{field:'dictionarySort', width:100, title: '字典排序', align:'center',},
|
||||
]
|
||||
],
|
||||
|
@ -61,15 +61,21 @@
|
||||
<script th:id="${dynamicFormFormShowFieldDTO.fieldName}" type="text/plain" style="width:100%;height:400px;"></script>
|
||||
</div>
|
||||
<div class="layui-input-block" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'select'}">
|
||||
<select th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" lay-verify="required">
|
||||
<option value=""></option>
|
||||
<option value="0">北京</option>
|
||||
<option value="1">上海</option>
|
||||
<option value="2">广州</option>
|
||||
<option value="3">深圳</option>
|
||||
<option value="4">杭州</option>
|
||||
<select th:each="selectMap: ${selectMapList}" th:if="${selectMap.name eq dynamicFormFormShowFieldDTO.fieldName}" th:id="${dynamicFormFormShowFieldDTO.fieldName}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" lay-verify="required">
|
||||
<option value="">请选择</option>
|
||||
<option th:each="select: ${selectMap.list}" th:value="${select.dictionaryId}" th:text="${select.dictionaryName}"></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-input-block" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'checkbox'}">
|
||||
<div th:each="checkboxMap: ${checkboxMapList}" th:if="${checkboxMap.name eq dynamicFormFormShowFieldDTO.fieldName}">
|
||||
<input type="checkbox" th:each="checkbox: ${checkboxMap.list}" th:name="${dynamicFormFormShowFieldDTO.fieldName +'['+ checkbox.dictionaryId +']'}" th:title="${checkbox.dictionaryName}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-input-block" th:if="${dynamicFormFormShowFieldDTO.fieldType eq 'radio'}">
|
||||
<div th:each="radioMap: ${radioMapList}" th:if="${radioMap.name eq dynamicFormFormShowFieldDTO.fieldName}">
|
||||
<input type="radio" th:each="radio: ${radioMap.list}" th:name="${dynamicFormFormShowFieldDTO.fieldName}" th:value="${radio.dictionaryId}" th:title="${radio.dictionaryName}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-layout-admin">
|
||||
|
Loading…
Reference in New Issue
Block a user