feat: 代码生成支持字典类型
This commit is contained in:
@@ -44,6 +44,13 @@ public class SysDictController {
|
||||
return PageResult.success(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "字典列表")
|
||||
@GetMapping("/list")
|
||||
public Result<List<Option>> getDictList() {
|
||||
List<Option> list = dictService.getDictList();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
@Operation(summary = "字典数据项列表")
|
||||
@GetMapping("/{code}/options")
|
||||
public Result<List<Option>> getDictOptions(
|
||||
|
||||
@@ -96,4 +96,10 @@ public class GenFieldConfig extends BaseEntity {
|
||||
private String tsType;
|
||||
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
private String dictType;
|
||||
|
||||
|
||||
}
|
||||
@@ -81,5 +81,8 @@ public class GenConfigForm {
|
||||
@Schema(description = "查询类型")
|
||||
private QueryTypeEnum queryType;
|
||||
|
||||
@Schema(description = "字典类型")
|
||||
private String dictType;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,4 +72,10 @@ public interface SysDictService extends IService<SysDict> {
|
||||
List<Option> listDictItemsByCode(String code);
|
||||
|
||||
|
||||
/**
|
||||
* 获取字典列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<Option> getDictList();
|
||||
}
|
||||
|
||||
@@ -222,7 +222,18 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
return dictItemConverter.convertToOption(dictItems);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取字典列表
|
||||
*/
|
||||
@Override
|
||||
public List<Option> getDictList() {
|
||||
return this.list(new LambdaQueryWrapper<SysDict>()
|
||||
.eq(SysDict::getStatus, 1)
|
||||
.select(SysDict::getName, SysDict::getCode)
|
||||
).stream()
|
||||
.map(dict -> new Option(dict.getCode(), dict.getName()))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
#foreach($fieldConfig in $fieldConfigs)
|
||||
#if($fieldConfig.isShowInQuery == 1)
|
||||
<el-form-item :label="$fieldConfig.fieldComment" :key="$fieldConfig.fieldName">
|
||||
<el-form-item label="$fieldConfig.fieldComment" prop="$fieldConfig.fieldName">
|
||||
#if($fieldConfig.formType == "INPUT")
|
||||
<el-input v-model="queryParams.$fieldConfig.fieldName" :placeholder="$fieldConfig.fieldComment" clearable @keyup.enter="handleQuery" />
|
||||
#elseif($fieldConfig.formType == "SELECT")
|
||||
@@ -88,14 +88,19 @@
|
||||
<el-form ref="dataFormRef" :model="formData" :rules="rules" label-width="100px">
|
||||
#foreach($fieldConfig in $fieldConfigs)
|
||||
#if($fieldConfig.isShowInForm == 1)
|
||||
<el-form-item :label="$fieldConfig.fieldComment" :key="$fieldConfig.fieldName">
|
||||
<el-form-item abel="$fieldConfig.fieldComment" prop="$fieldConfig.fieldName">
|
||||
#if($fieldConfig.formType == "INPUT")
|
||||
<el-input v-model="formData.$fieldConfig.fieldName" :placeholder="'请输入$fieldConfig.fieldComment" />
|
||||
#elseif($fieldConfig.formType == "SELECT")
|
||||
#if($fieldConfig.dictType != "")
|
||||
<dictionary v-model="formData.$fieldConfig.fieldName" code="$fieldConfig.dictType" />
|
||||
#else
|
||||
<el-select v-model="formData.$fieldConfig.fieldName" :placeholder="'请选择$fieldConfig.fieldComment">
|
||||
<!-- 这里可以根据具体需求生成select options -->
|
||||
<el-option v-for="option in $fieldConfig.options" :key="option.value" :label="option.label" :value="option.value"></el-option>
|
||||
<el-option :key="1" :value="1" :label="下拉项1"/>
|
||||
<el-option :key="2" :value="2" :label="下拉项2"/>
|
||||
<el-option :key="3" :value="3" :label="下拉项3"/>
|
||||
</el-select>
|
||||
#end
|
||||
#elseif($fieldConfig.formType == "RADIO")
|
||||
<el-radio-group v-model="formData.$fieldConfig.fieldName">
|
||||
<el-radio v-for="option in $fieldConfig.options" :key="option.value" :label="option.value">{{ option.label }}</el-radio>
|
||||
|
||||
Reference in New Issue
Block a user