feat(code): 代码生成新增 curd 页面模板和优化
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.youlai</groupId>
|
<groupId>com.youlai</groupId>
|
||||||
<artifactId>youlai-boot</artifactId>
|
<artifactId>youlai-boot</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.0</version>
|
||||||
<description>基于 Java 17 + SpringBoot 3 + Spring Security 构建的权限管理系统。</description>
|
<description>基于 Java 17 + SpringBoot 3 + Spring Security 构建的权限管理系统。</description>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
|||||||
@@ -451,9 +451,11 @@ CREATE TABLE `gen_config` (
|
|||||||
`entity_name` varchar(100) NOT NULL COMMENT '实体类名',
|
`entity_name` varchar(100) NOT NULL COMMENT '实体类名',
|
||||||
`author` varchar(50) NOT NULL COMMENT '作者',
|
`author` varchar(50) NOT NULL COMMENT '作者',
|
||||||
`parent_menu_id` bigint COMMENT '上级菜单ID,对应sys_menu的id ',
|
`parent_menu_id` bigint COMMENT '上级菜单ID,对应sys_menu的id ',
|
||||||
|
`remove_table_prefix` varchar(20) COMMENT '要移除的表前缀,如: sys_',
|
||||||
|
`page_type` varchar(20) COMMENT '页面类型(classic|curd)',
|
||||||
`create_time` datetime COMMENT '创建时间',
|
`create_time` datetime COMMENT '创建时间',
|
||||||
`update_time` datetime COMMENT '更新时间',
|
`update_time` datetime COMMENT '更新时间',
|
||||||
`is_deleted` bit(1) DEFAULT b'0' COMMENT '是否删除',
|
`is_deleted` tinyint(4) DEFAULT 0 COMMENT '是否删除',
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `uk_tablename` (`table_name`)
|
UNIQUE KEY `uk_tablename` (`table_name`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='代码生成基础配置表';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='代码生成基础配置表';
|
||||||
|
|||||||
@@ -82,17 +82,19 @@ public class CodegenController {
|
|||||||
@Operation(summary = "获取预览生成代码")
|
@Operation(summary = "获取预览生成代码")
|
||||||
@GetMapping("/{tableName}/preview")
|
@GetMapping("/{tableName}/preview")
|
||||||
@Log(value = "预览生成代码", module = LogModuleEnum.OTHER)
|
@Log(value = "预览生成代码", module = LogModuleEnum.OTHER)
|
||||||
public Result<List<CodegenPreviewVO>> getTablePreviewData(@PathVariable String tableName) {
|
public Result<List<CodegenPreviewVO>> getTablePreviewData(@PathVariable String tableName,
|
||||||
List<CodegenPreviewVO> list = codegenService.getCodegenPreviewData(tableName);
|
@RequestParam(value = "pageType", required = false, defaultValue = "classic") String pageType) {
|
||||||
|
List<CodegenPreviewVO> list = codegenService.getCodegenPreviewData(tableName, pageType);
|
||||||
return Result.success(list);
|
return Result.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "下载代码")
|
@Operation(summary = "下载代码")
|
||||||
@GetMapping("/{tableName}/download")
|
@GetMapping("/{tableName}/download")
|
||||||
@Log(value = "下载代码", module = LogModuleEnum.OTHER)
|
@Log(value = "下载代码", module = LogModuleEnum.OTHER)
|
||||||
public void downloadZip(HttpServletResponse response, @PathVariable String tableName) {
|
public void downloadZip(HttpServletResponse response, @PathVariable String tableName,
|
||||||
|
@RequestParam(value = "pageType", required = false, defaultValue = "classic") String pageType) {
|
||||||
String[] tableNames = tableName.split(",");
|
String[] tableNames = tableName.split(",");
|
||||||
byte[] data = codegenService.downloadCode(tableNames);
|
byte[] data = codegenService.downloadCode(tableNames, pageType);
|
||||||
|
|
||||||
response.reset();
|
response.reset();
|
||||||
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(codegenProperties.getDownloadFileName(), StandardCharsets.UTF_8));
|
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(codegenProperties.getDownloadFileName(), StandardCharsets.UTF_8));
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ public interface CodegenConverter {
|
|||||||
@Mapping(source = "genConfig.packageName", target = "packageName")
|
@Mapping(source = "genConfig.packageName", target = "packageName")
|
||||||
@Mapping(source = "genConfig.entityName", target = "entityName")
|
@Mapping(source = "genConfig.entityName", target = "entityName")
|
||||||
@Mapping(source = "genConfig.author", target = "author")
|
@Mapping(source = "genConfig.author", target = "author")
|
||||||
|
@Mapping(source = "genConfig.pageType", target = "pageType")
|
||||||
|
@Mapping(source = "genConfig.removeTablePrefix", target = "removeTablePrefix")
|
||||||
@Mapping(source = "fieldConfigs", target = "fieldConfigs")
|
@Mapping(source = "fieldConfigs", target = "fieldConfigs")
|
||||||
GenConfigForm toGenConfigForm(GenConfig genConfig, List<GenFieldConfig> fieldConfigs);
|
GenConfigForm toGenConfigForm(GenConfig genConfig, List<GenFieldConfig> fieldConfigs);
|
||||||
|
|
||||||
|
|||||||
@@ -51,4 +51,14 @@ public class GenConfig extends BaseEntity {
|
|||||||
* 作者
|
* 作者
|
||||||
*/
|
*/
|
||||||
private String author;
|
private String author;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面类型 classic|curd
|
||||||
|
*/
|
||||||
|
private String pageType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 要移除的表前缀,如: sys_
|
||||||
|
*/
|
||||||
|
private String removeTablePrefix;
|
||||||
}
|
}
|
||||||
@@ -50,6 +50,12 @@ public class GenConfigForm {
|
|||||||
@Schema(description = "前端应用名")
|
@Schema(description = "前端应用名")
|
||||||
private String frontendAppName;
|
private String frontendAppName;
|
||||||
|
|
||||||
|
@Schema(description = "页面类型 classic|curd", example = "classic")
|
||||||
|
private String pageType;
|
||||||
|
|
||||||
|
@Schema(description = "要移除的表前缀,如: sys_", example = "sys_")
|
||||||
|
private String removeTablePrefix;
|
||||||
|
|
||||||
@Schema(description = "字段配置")
|
@Schema(description = "字段配置")
|
||||||
@Data
|
@Data
|
||||||
public static class FieldConfig {
|
public static class FieldConfig {
|
||||||
|
|||||||
@@ -29,12 +29,12 @@ public interface CodegenService {
|
|||||||
* @param tableName 表名
|
* @param tableName 表名
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<CodegenPreviewVO> getCodegenPreviewData(String tableName);
|
List<CodegenPreviewVO> getCodegenPreviewData(String tableName, String pageType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下载代码
|
* 下载代码
|
||||||
* @param tableNames 表名
|
* @param tableNames 表名
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
byte[] downloadCode(String[] tableNames);
|
byte[] downloadCode(String[] tableNames, String pageType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.youlai.boot.shared.codegen.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.io.file.FileNameUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.extra.template.Template;
|
import cn.hutool.extra.template.Template;
|
||||||
@@ -72,7 +73,7 @@ public class CodegenServiceImpl implements CodegenService {
|
|||||||
* @return 预览数据
|
* @return 预览数据
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<CodegenPreviewVO> getCodegenPreviewData(String tableName) {
|
public List<CodegenPreviewVO> getCodegenPreviewData(String tableName, String pageType) {
|
||||||
|
|
||||||
List<CodegenPreviewVO> list = new ArrayList<>();
|
List<CodegenPreviewVO> list = new ArrayList<>();
|
||||||
|
|
||||||
@@ -124,7 +125,9 @@ public class CodegenServiceImpl implements CodegenService {
|
|||||||
|
|
||||||
/* 3. 生成文件内容 */
|
/* 3. 生成文件内容 */
|
||||||
// 将模板文件中的变量替换为具体的值 生成代码内容
|
// 将模板文件中的变量替换为具体的值 生成代码内容
|
||||||
String content = getCodeContent(templateConfig, genConfig, fieldConfigs);
|
// 优先使用保存的 ui,没有则使用请求参数
|
||||||
|
String finalType = StrUtil.blankToDefault(genConfig.getPageType(), pageType);
|
||||||
|
String content = getCodeContent(templateConfig, genConfig, fieldConfigs, finalType);
|
||||||
previewVO.setContent(content);
|
previewVO.setContent(content);
|
||||||
|
|
||||||
list.add(previewVO);
|
list.add(previewVO);
|
||||||
@@ -146,7 +149,8 @@ public class CodegenServiceImpl implements CodegenService {
|
|||||||
} else if ("MapperXml".equals(templateName)) {
|
} else if ("MapperXml".equals(templateName)) {
|
||||||
return entityName + "Mapper" + extension;
|
return entityName + "Mapper" + extension;
|
||||||
} else if ("API".equals(templateName)) {
|
} else if ("API".equals(templateName)) {
|
||||||
return StrUtil.toSymbolCase(entityName, '-') + extension;
|
// 生成 user-api.ts 命名
|
||||||
|
return StrUtil.toSymbolCase(entityName, '-') + "-api" + extension;
|
||||||
} else if ("VIEW".equals(templateName)) {
|
} else if ("VIEW".equals(templateName)) {
|
||||||
return "index.vue";
|
return "index.vue";
|
||||||
}
|
}
|
||||||
@@ -211,7 +215,7 @@ public class CodegenServiceImpl implements CodegenService {
|
|||||||
* @param fieldConfigs 字段配置
|
* @param fieldConfigs 字段配置
|
||||||
* @return 代码内容
|
* @return 代码内容
|
||||||
*/
|
*/
|
||||||
private String getCodeContent(CodegenProperties.TemplateConfig templateConfig, GenConfig genConfig, List<GenFieldConfig> fieldConfigs) {
|
private String getCodeContent(CodegenProperties.TemplateConfig templateConfig, GenConfig genConfig, List<GenFieldConfig> fieldConfigs, String pageType) {
|
||||||
|
|
||||||
Map<String, Object> bindMap = new HashMap<>();
|
Map<String, Object> bindMap = new HashMap<>();
|
||||||
|
|
||||||
@@ -252,7 +256,15 @@ public class CodegenServiceImpl implements CodegenService {
|
|||||||
bindMap.put("hasRequiredField", hasRequiredField);
|
bindMap.put("hasRequiredField", hasRequiredField);
|
||||||
|
|
||||||
TemplateEngine templateEngine = TemplateUtil.createEngine(new TemplateConfig("templates", TemplateConfig.ResourceMode.CLASSPATH));
|
TemplateEngine templateEngine = TemplateUtil.createEngine(new TemplateConfig("templates", TemplateConfig.ResourceMode.CLASSPATH));
|
||||||
Template template = templateEngine.getTemplate(templateConfig.getTemplatePath());
|
// 根据 ui 选择不同的前端页面模板:默认 index.vue.vm;封装版使用 index.curd.vue.vm
|
||||||
|
String path = templateConfig.getTemplatePath();
|
||||||
|
if ("VIEW".equals(FileNameUtil.mainName(path))) {
|
||||||
|
// 无法通过文件名区分时,依据子包名与扩展名判断
|
||||||
|
}
|
||||||
|
if ("curd".equalsIgnoreCase(pageType) && path.endsWith("index.vue.vm")) {
|
||||||
|
path = path.replace("index.vue.vm", "index.curd.vue.vm");
|
||||||
|
}
|
||||||
|
Template template = templateEngine.getTemplate(path);
|
||||||
|
|
||||||
return template.render(bindMap);
|
return template.render(bindMap);
|
||||||
}
|
}
|
||||||
@@ -264,13 +276,13 @@ public class CodegenServiceImpl implements CodegenService {
|
|||||||
* @return 压缩文件字节数组
|
* @return 压缩文件字节数组
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public byte[] downloadCode(String[] tableNames) {
|
public byte[] downloadCode(String[] tableNames, String ui) {
|
||||||
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
ZipOutputStream zip = new ZipOutputStream(outputStream)) {
|
ZipOutputStream zip = new ZipOutputStream(outputStream)) {
|
||||||
|
|
||||||
// 遍历每个表名,生成对应的代码并压缩到 zip 文件中
|
// 遍历每个表名,生成对应的代码并压缩到 zip 文件中
|
||||||
for (String tableName : tableNames) {
|
for (String tableName : tableNames) {
|
||||||
generateAndZipCode(tableName, zip);
|
generateAndZipCode(tableName, zip, ui);
|
||||||
}
|
}
|
||||||
// 确保所有压缩数据写入输出流,避免数据残留在内存缓冲区引发的数据不完整
|
// 确保所有压缩数据写入输出流,避免数据残留在内存缓冲区引发的数据不完整
|
||||||
zip.finish();
|
zip.finish();
|
||||||
@@ -288,8 +300,8 @@ public class CodegenServiceImpl implements CodegenService {
|
|||||||
* @param tableName 表名
|
* @param tableName 表名
|
||||||
* @param zip 压缩文件输出流
|
* @param zip 压缩文件输出流
|
||||||
*/
|
*/
|
||||||
private void generateAndZipCode(String tableName, ZipOutputStream zip) {
|
private void generateAndZipCode(String tableName, ZipOutputStream zip, String ui) {
|
||||||
List<CodegenPreviewVO> codePreviewList = getCodegenPreviewData(tableName);
|
List<CodegenPreviewVO> codePreviewList = getCodegenPreviewData(tableName, ui);
|
||||||
|
|
||||||
for (CodegenPreviewVO codePreview : codePreviewList) {
|
for (CodegenPreviewVO codePreview : codePreviewList) {
|
||||||
String fileName = codePreview.getFileName();
|
String fileName = codePreview.getFileName();
|
||||||
|
|||||||
@@ -83,8 +83,13 @@ public class GenConfigServiceImpl extends ServiceImpl<GenConfigMapper, GenConfig
|
|||||||
if (StrUtil.isNotBlank(tableComment)) {
|
if (StrUtil.isNotBlank(tableComment)) {
|
||||||
genConfig.setBusinessName(tableComment.replace("表", "").trim());
|
genConfig.setBusinessName(tableComment.replace("表", "").trim());
|
||||||
}
|
}
|
||||||
// 根据表名生成实体类名 例如:sys_user -> SysUser
|
// 根据表名生成实体类名,支持去除前缀 例如:sys_user -> SysUser
|
||||||
genConfig.setEntityName(StrUtil.toCamelCase(StrUtil.upperFirst(StrUtil.toCamelCase(tableName))));
|
String removePrefix = genConfig.getRemoveTablePrefix();
|
||||||
|
String processedTable = tableName;
|
||||||
|
if (StrUtil.isNotBlank(removePrefix) && StrUtil.startWith(tableName, removePrefix)) {
|
||||||
|
processedTable = StrUtil.removePrefix(tableName, removePrefix);
|
||||||
|
}
|
||||||
|
genConfig.setEntityName(StrUtil.toCamelCase(StrUtil.upperFirst(StrUtil.toCamelCase(processedTable))));
|
||||||
|
|
||||||
genConfig.setPackageName(YouLaiBootApplication.class.getPackageName());
|
genConfig.setPackageName(YouLaiBootApplication.class.getPackageName());
|
||||||
genConfig.setModuleName(codegenProperties.getDefaultConfig().getModuleName()); // 默认模块名
|
genConfig.setModuleName(codegenProperties.getDefaultConfig().getModuleName()); // 默认模块名
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ const ${entityName}API = {
|
|||||||
*
|
*
|
||||||
* @param data ${businessName}表单数据
|
* @param data ${businessName}表单数据
|
||||||
*/
|
*/
|
||||||
add(data: ${entityName}Form) {
|
create(data: ${entityName}Form) {
|
||||||
return request({
|
return request({
|
||||||
url: `${${entityName.toUpperCase()}_BASE_URL}`,
|
url: `${${entityName.toUpperCase()}_BASE_URL}`,
|
||||||
method: "post",
|
method: "post",
|
||||||
data: data,
|
data,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -43,11 +43,11 @@ const ${entityName}API = {
|
|||||||
* @param id ${businessName}ID
|
* @param id ${businessName}ID
|
||||||
* @param data ${businessName}表单数据
|
* @param data ${businessName}表单数据
|
||||||
*/
|
*/
|
||||||
update(id: number, data: ${entityName}Form) {
|
update(id: string, data: ${entityName}Form) {
|
||||||
return request({
|
return request({
|
||||||
url: `${${entityName.toUpperCase()}_BASE_URL}/${id}`,
|
url: `${${entityName.toUpperCase()}_BASE_URL}/${id}`,
|
||||||
method: "put",
|
method: "put",
|
||||||
data: data,
|
data,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
119
src/main/resources/templates/codegen/index.curd.vue.vm
Normal file
119
src/main/resources/templates/codegen/index.curd.vue.vm
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container h-full flex flex-1 flex-col">
|
||||||
|
<!-- 搜索 -->
|
||||||
|
<page-search
|
||||||
|
ref="searchRef"
|
||||||
|
:search-config="searchConfig"
|
||||||
|
@query-click="handleQueryClick"
|
||||||
|
@reset-click="handleResetClick"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 列表 -->
|
||||||
|
<page-content
|
||||||
|
ref="contentRef"
|
||||||
|
:content-config="contentConfig"
|
||||||
|
@add-click="handleAddClick"
|
||||||
|
@operate-click="handleOperateClick"
|
||||||
|
>
|
||||||
|
#foreach($fieldConfig in $fieldConfigs)
|
||||||
|
#if($fieldConfig.isShowInList == 1 && $fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
||||||
|
<template #$fieldConfig.fieldName="scope">
|
||||||
|
<DictLabel v-model="scope.row[scope.prop]" code="$fieldConfig.dictType" />
|
||||||
|
</template>
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
</page-content>
|
||||||
|
|
||||||
|
<!-- 新增/编辑 -->
|
||||||
|
<page-modal ref="modalRef" :modal-config="modalConfig" @submit-click="handleSubmitClick">
|
||||||
|
#foreach($fieldConfig in $fieldConfigs)
|
||||||
|
#if($fieldConfig.isShowInForm == 1 && $fieldConfig.formType != "HIDDEN" && $fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
||||||
|
<template #$fieldConfig.fieldName="scope">
|
||||||
|
<Dict v-model="scope.formData[scope.prop]" code="$fieldConfig.dictType" v-bind="scope.attrs" />
|
||||||
|
</template>
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
</page-modal>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
defineOptions({ name: "$entityName" });
|
||||||
|
|
||||||
|
import ${entityName}API, { ${entityName}PageVO, ${entityName}Form, ${entityName}PageQuery } from "@/api/${moduleName}/${kebabCaseEntityName}-api";
|
||||||
|
import type { IObject, PageModalInstance } from "@/components/CURD/types";
|
||||||
|
import usePage from "@/components/CURD/usePage";
|
||||||
|
|
||||||
|
// 组合式 CRUD
|
||||||
|
const {
|
||||||
|
searchRef,
|
||||||
|
contentRef,
|
||||||
|
addModalRef: modalRef,
|
||||||
|
handleQueryClick,
|
||||||
|
handleResetClick,
|
||||||
|
handleAddClick,
|
||||||
|
handleEditClick,
|
||||||
|
handleSubmitClick,
|
||||||
|
} = usePage<${entityName}PageQuery, ${entityName}PageVO, ${entityName}Form>();
|
||||||
|
|
||||||
|
// 搜索配置
|
||||||
|
const searchConfig = {
|
||||||
|
formItems: [
|
||||||
|
#foreach($fieldConfig in $fieldConfigs)
|
||||||
|
#if($fieldConfig.isShowInQuery == 1)
|
||||||
|
{
|
||||||
|
type: "$!{fieldConfig.formType.toLowerCase()}",
|
||||||
|
label: "$fieldConfig.fieldComment",
|
||||||
|
field: "$fieldConfig.fieldName",
|
||||||
|
placeholder: "$fieldConfig.fieldComment",
|
||||||
|
},
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
// 列表配置
|
||||||
|
const contentConfig = {
|
||||||
|
api: {
|
||||||
|
page: ${entityName}API.getPage,
|
||||||
|
deleteByIds: ${entityName}API.deleteByIds,
|
||||||
|
},
|
||||||
|
table: {
|
||||||
|
columns: [
|
||||||
|
{ type: "selection", width: 55, align: "center" },
|
||||||
|
#foreach($fieldConfig in $fieldConfigs)
|
||||||
|
#if($fieldConfig.isShowInList == 1)
|
||||||
|
{ label: "$fieldConfig.fieldComment", prop: "$fieldConfig.fieldName", slot: "$fieldConfig.fieldName" },
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
{ label: "操作", prop: "operation", width: 220 }
|
||||||
|
],
|
||||||
|
operate: [
|
||||||
|
{ name: "edit", type: "primary", text: "编辑" },
|
||||||
|
{ name: "delete", type: "danger", text: "删除" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// 弹窗配置
|
||||||
|
const modalConfig = {
|
||||||
|
api: {
|
||||||
|
create: ${entityName}API.create,
|
||||||
|
update: ${entityName}API.update,
|
||||||
|
},
|
||||||
|
formItems: [
|
||||||
|
#foreach($fieldConfig in $fieldConfigs)
|
||||||
|
#if($fieldConfig.isShowInForm == 1 && $fieldConfig.formType != "HIDDEN")
|
||||||
|
{
|
||||||
|
type: "$!{fieldConfig.formType.toLowerCase()}",
|
||||||
|
label: "$fieldConfig.fieldComment",
|
||||||
|
prop: "$fieldConfig.fieldName",
|
||||||
|
attrs: { placeholder: "$fieldConfig.fieldComment" },
|
||||||
|
},
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<div class="search-container">
|
<div class="search-container">
|
||||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||||
#foreach($fieldConfig in $fieldConfigs)
|
#foreach($fieldConfig in $fieldConfigs)
|
||||||
#if($fieldConfig.isShowInQuery == 1)
|
#if($fieldConfig.isShowInQuery == 1)
|
||||||
<el-form-item label="$fieldConfig.fieldComment" prop="$fieldConfig.fieldName">
|
<el-form-item label="$fieldConfig.fieldComment" prop="$fieldConfig.fieldName">
|
||||||
#if($fieldConfig.formType == "INPUT")
|
#if($fieldConfig.formType == "INPUT")
|
||||||
<el-input
|
<el-input
|
||||||
v-model="queryParams.$fieldConfig.fieldName"
|
v-model="queryParams.$fieldConfig.fieldName"
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
/>
|
/>
|
||||||
#elseif($fieldConfig.formType == "SELECT")
|
#elseif($fieldConfig.formType == "SELECT")
|
||||||
#if($fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
#if($fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
||||||
<dict v-model="queryParams.$fieldConfig.fieldName" code="$fieldConfig.dictType" />
|
<Dict v-model="queryParams.$fieldConfig.fieldName" code="$fieldConfig.dictType" />
|
||||||
#else
|
#else
|
||||||
<el-select v-model="queryParams.$fieldConfig.fieldName" placeholder="请选择$fieldConfig.fieldComment">
|
<el-select v-model="queryParams.$fieldConfig.fieldName" placeholder="请选择$fieldConfig.fieldComment">
|
||||||
<el-option :key="1" :value="1" label="选项一"/>
|
<el-option :key="1" :value="1" label="选项一"/>
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
#end
|
#end
|
||||||
#elseif($fieldConfig.formType == "RADIO")
|
#elseif($fieldConfig.formType == "RADIO")
|
||||||
#if($fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
#if($fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
||||||
<dict v-model="queryParams.$fieldConfig.fieldName" type="radio" code="$fieldConfig.dictType" />
|
<Dict v-model="queryParams.$fieldConfig.fieldName" type="radio" code="$fieldConfig.dictType" />
|
||||||
#else
|
#else
|
||||||
<el-radio-group v-model="queryParams.$fieldConfig.fieldName">
|
<el-radio-group v-model="queryParams.$fieldConfig.fieldName">
|
||||||
<el-radio :key="1" :value="1">选项一</el-radio>
|
<el-radio :key="1" :value="1">选项一</el-radio>
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
#end
|
#end
|
||||||
#elseif($fieldConfig.formType == "CHECK_BOX")
|
#elseif($fieldConfig.formType == "CHECK_BOX")
|
||||||
#if($fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
#if($fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
||||||
<dict v-model="queryParams.$fieldConfig.fieldName" type="checkbox" code="$fieldConfig.dictType" />
|
<Dict v-model="queryParams.$fieldConfig.fieldName" type="checkbox" code="$fieldConfig.dictType" />
|
||||||
#else
|
#else
|
||||||
<el-checkbox-group v-model="queryParams.$fieldConfig.fieldName">
|
<el-checkbox-group v-model="queryParams.$fieldConfig.fieldName">
|
||||||
<el-checkbox :key="1" :label="1">选项一</el-checkbox>
|
<el-checkbox :key="1" :label="1">选项一</el-checkbox>
|
||||||
@@ -85,18 +85,12 @@
|
|||||||
value-format="YYYY-MM-DD"
|
value-format="YYYY-MM-DD"
|
||||||
/>
|
/>
|
||||||
#end
|
#end
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#end
|
|
||||||
#end
|
#end
|
||||||
<el-form-item>
|
#end
|
||||||
<el-button type="primary" @click="handleQuery">
|
<el-form-item class="search-buttons">
|
||||||
<template #icon><Search /></template>
|
<el-button type="primary" icon="search" @click="handleQuery">搜索</el-button>
|
||||||
搜索
|
<el-button icon="refresh" @click="handleResetQuery">重置</el-button>
|
||||||
</el-button>
|
|
||||||
<el-button @click="handleResetQuery">
|
|
||||||
<template #icon><Refresh /></template>
|
|
||||||
重置
|
|
||||||
</el-button>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
@@ -106,50 +100,46 @@
|
|||||||
<el-button
|
<el-button
|
||||||
v-hasPerm="['${moduleName}:${kebabCaseEntityName}:add']"
|
v-hasPerm="['${moduleName}:${kebabCaseEntityName}:add']"
|
||||||
type="success"
|
type="success"
|
||||||
|
icon="plus"
|
||||||
@click="handleOpenDialog()"
|
@click="handleOpenDialog()"
|
||||||
>
|
>新增</el-button>
|
||||||
<template #icon><Plus /></template>
|
|
||||||
新增
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
<el-button
|
||||||
v-hasPerm="['${moduleName}:${kebabCaseEntityName}:delete']"
|
v-hasPerm="['${moduleName}:${kebabCaseEntityName}:delete']"
|
||||||
type="danger"
|
type="danger"
|
||||||
:disabled="removeIds.length === 0"
|
:disabled="removeIds.length === 0"
|
||||||
|
icon="delete"
|
||||||
@click="handleDelete()"
|
@click="handleDelete()"
|
||||||
>
|
>删除</el-button>
|
||||||
<template #icon><Delete /></template>
|
|
||||||
删除
|
|
||||||
</el-button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-table
|
<el-table
|
||||||
ref="dataTableRef"
|
ref="dataTableRef"
|
||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
:data="pageData"
|
:data="pageData"
|
||||||
highlight-current-row
|
highlight-current-row
|
||||||
border
|
border
|
||||||
@selection-change="handleSelectionChange"
|
@selection-change="handleSelectionChange"
|
||||||
>
|
>
|
||||||
<el-table-column type="selection" width="55" align="center" />
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
#foreach($fieldConfig in $fieldConfigs)
|
#foreach($fieldConfig in $fieldConfigs)
|
||||||
#if($fieldConfig.isShowInList == 1)
|
#if($fieldConfig.isShowInList == 1)
|
||||||
#if($fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
#if($fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
||||||
<el-table-column label="$fieldConfig.fieldComment" width="150" align="center">
|
<el-table-column label="$fieldConfig.fieldComment" width="150" align="center">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<DictLabel v-model="scope.row.$fieldConfig.fieldName" code="$fieldConfig.dictType" />
|
<DictLabel v-model="scope.row.$fieldConfig.fieldName" code="$fieldConfig.dictType" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
#else
|
#else
|
||||||
<el-table-column
|
<el-table-column
|
||||||
key="$fieldConfig.fieldName"
|
key="$fieldConfig.fieldName"
|
||||||
label="$fieldConfig.fieldComment"
|
label="$fieldConfig.fieldComment"
|
||||||
prop="$fieldConfig.fieldName"
|
prop="$fieldConfig.fieldName"
|
||||||
min-width="150"
|
min-width="150"
|
||||||
align="center"
|
align="center"
|
||||||
/>
|
/>
|
||||||
#end
|
#end
|
||||||
#end
|
|
||||||
#end
|
#end
|
||||||
|
#end
|
||||||
<el-table-column fixed="right" label="操作" width="220">
|
<el-table-column fixed="right" label="操作" width="220">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button
|
<el-button
|
||||||
@@ -157,9 +147,9 @@
|
|||||||
type="primary"
|
type="primary"
|
||||||
size="small"
|
size="small"
|
||||||
link
|
link
|
||||||
|
icon="edit"
|
||||||
@click="handleOpenDialog(scope.row.id)"
|
@click="handleOpenDialog(scope.row.id)"
|
||||||
>
|
>
|
||||||
<template #icon><Edit /></template>
|
|
||||||
编辑
|
编辑
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
@@ -167,9 +157,9 @@
|
|||||||
type="danger"
|
type="danger"
|
||||||
size="small"
|
size="small"
|
||||||
link
|
link
|
||||||
|
icon="delete"
|
||||||
@click="handleDelete(scope.row.id)"
|
@click="handleDelete(scope.row.id)"
|
||||||
>
|
>
|
||||||
<template #icon><Delete /></template>
|
|
||||||
删除
|
删除
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
@@ -203,7 +193,7 @@
|
|||||||
/>
|
/>
|
||||||
#elseif($fieldConfig.formType == "SELECT")
|
#elseif($fieldConfig.formType == "SELECT")
|
||||||
#if($fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
#if($fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
||||||
<dict v-model="formData.$fieldConfig.fieldName" code="$fieldConfig.dictType" />
|
<Dict v-model="formData.$fieldConfig.fieldName" code="$fieldConfig.dictType" />
|
||||||
#else
|
#else
|
||||||
<el-select v-model="formData.$fieldConfig.fieldName" placeholder="请选择$fieldConfig.fieldComment">
|
<el-select v-model="formData.$fieldConfig.fieldName" placeholder="请选择$fieldConfig.fieldComment">
|
||||||
<el-option :value="0" label="选项一"/>
|
<el-option :value="0" label="选项一"/>
|
||||||
@@ -212,7 +202,7 @@
|
|||||||
#end
|
#end
|
||||||
#elseif($fieldConfig.formType == "RADIO")
|
#elseif($fieldConfig.formType == "RADIO")
|
||||||
#if($fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
#if($fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
||||||
<dict v-model="queryParams.$fieldConfig.fieldName" type="radio" code="$fieldConfig.dictType" />
|
<Dict v-model="queryParams.$fieldConfig.fieldName" type="radio" code="$fieldConfig.dictType" />
|
||||||
#else
|
#else
|
||||||
<el-radio-group v-model="formData.$fieldConfig.fieldName">
|
<el-radio-group v-model="formData.$fieldConfig.fieldName">
|
||||||
<el-radio :value="0">选项一</el-radio>
|
<el-radio :value="0">选项一</el-radio>
|
||||||
@@ -221,7 +211,7 @@
|
|||||||
#end
|
#end
|
||||||
#elseif($fieldConfig.formType == "CHECK_BOX")
|
#elseif($fieldConfig.formType == "CHECK_BOX")
|
||||||
#if($fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
#if($fieldConfig.dictType && $fieldConfig.dictType.trim() != "")
|
||||||
<dict v-model="queryParams.$fieldConfig.fieldName" type="checkbox" code="$fieldConfig.dictType" />
|
<Dict v-model="queryParams.$fieldConfig.fieldName" type="checkbox" code="$fieldConfig.dictType" />
|
||||||
#else
|
#else
|
||||||
<el-checkbox-group v-model="formData.$fieldConfig.fieldName">
|
<el-checkbox-group v-model="formData.$fieldConfig.fieldName">
|
||||||
<el-checkbox :value="0">选项一</el-checkbox>
|
<el-checkbox :value="0">选项一</el-checkbox>
|
||||||
@@ -283,7 +273,7 @@
|
|||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
import ${entityName}API, { ${entityName}PageVO, ${entityName}Form, ${entityName}PageQuery } from "@/api/${moduleName}/${kebabCaseEntityName}";
|
import ${entityName}API, { ${entityName}PageVO, ${entityName}Form, ${entityName}PageQuery } from "@/api/${moduleName}/${kebabCaseEntityName}-api";
|
||||||
|
|
||||||
const queryFormRef = ref();
|
const queryFormRef = ref();
|
||||||
const dataFormRef = ref();
|
const dataFormRef = ref();
|
||||||
|
|||||||
Reference in New Issue
Block a user