feat: 完成生成文本修改
This commit is contained in:
parent
51515d2d5f
commit
06f458bec2
|
@ -23,6 +23,9 @@ public class ColumnMetaData {
|
|||
/* Java类型 */
|
||||
private String javaType;
|
||||
|
||||
/* Javascript类型 */
|
||||
private String javascriptType;
|
||||
|
||||
/* 是否为主键 */
|
||||
private Boolean isPrimaryKey;
|
||||
|
||||
|
|
|
@ -30,30 +30,41 @@ public class VmsServiceImpl implements VmsService {
|
|||
*/
|
||||
@Override
|
||||
public List<GeneratorVo> generator(VmsArgumentDto dto) {
|
||||
String tableName = dto.getTableName();
|
||||
|
||||
return dto.getPath().stream().map(path -> {
|
||||
StringWriter writer = new StringWriter();
|
||||
|
||||
String vmsPath = "vms/" + path + ".vm";
|
||||
String tableName = dto.getTableName();
|
||||
|
||||
// 表格属性名 和 列信息
|
||||
TableInfoVo tableMetaData = tableService.getTableMetaData(tableName);
|
||||
List<ColumnMetaData> columnInfo = tableService.getColumnInfo(tableName);
|
||||
|
||||
List<ColumnMetaData> columnInfoList = tableService.getColumnInfo(tableName);
|
||||
List<String> list = columnInfoList.stream().map(ColumnMetaData::getColumnName).toList();
|
||||
|
||||
// 添加要生成的属性
|
||||
VelocityContext context = new VelocityContext();
|
||||
context.put("tableName", tableMetaData.getComment());
|
||||
context.put("package", dto.getPackageName());
|
||||
context.put("columnInfo", columnInfo);
|
||||
|
||||
// VmsUtil.commonVms(writer, context, "vms/server/controller.vm", dto);
|
||||
VmsUtil.commonVms(writer, context, vmsPath, dto);
|
||||
String code = writer.toString();
|
||||
// 当前的表名
|
||||
context.put("tableName", tableMetaData.getTableName());
|
||||
|
||||
// 表字段的注释内容
|
||||
context.put("comment", tableMetaData.getComment());
|
||||
|
||||
// 设置包名称
|
||||
context.put("package", dto.getPackageName());
|
||||
|
||||
// 当前表的列信息
|
||||
context.put("columnInfoList", columnInfoList);
|
||||
|
||||
// 数据库sql列
|
||||
context.put("baseColumnList", String.join(",", list));
|
||||
|
||||
VmsUtil.commonVms(writer, context, "vms/" + path + ".vm", dto);
|
||||
|
||||
return GeneratorVo.builder()
|
||||
.code(code)
|
||||
.code(writer.toString())
|
||||
.comment(tableMetaData.getComment())
|
||||
.tableName(tableMetaData.getTableName())
|
||||
.path(vmsPath)
|
||||
.path(path)
|
||||
.build();
|
||||
}).toList();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package cn.bunny.utils;
|
|||
|
||||
import cn.bunny.dao.entity.ColumnMetaData;
|
||||
import cn.bunny.dao.entity.TableMetaData;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -35,7 +36,7 @@ public class DbInfoUtil {
|
|||
ResultSet pkResultSet = metaData.getPrimaryKeys(null, null, tableName);
|
||||
|
||||
while (pkResultSet.next()) {
|
||||
primaryKeys.add(pkResultSet.getString("COLUMN_NAME").toLowerCase());
|
||||
primaryKeys.add(pkResultSet.getString("COLUMN_NAME" ).toLowerCase());
|
||||
}
|
||||
|
||||
return primaryKeys;
|
||||
|
@ -50,7 +51,7 @@ public class DbInfoUtil {
|
|||
List<TableMetaData> list = new ArrayList<>();
|
||||
|
||||
while (tables.next()) {
|
||||
String tableName = tables.getString("TABLE_NAME");
|
||||
String tableName = tables.getString("TABLE_NAME" );
|
||||
TableMetaData tableMetaData = tableInfo(tableName);
|
||||
list.add(tableMetaData);
|
||||
}
|
||||
|
@ -75,15 +76,15 @@ public class DbInfoUtil {
|
|||
|
||||
// 获取表的注释信息
|
||||
if (tables.next()) {
|
||||
String remarks = tables.getString("REMARKS");
|
||||
String tableCat = tables.getString("TABLE_CAT");
|
||||
String tableSchem = tables.getString("TABLE_SCHEM");
|
||||
String tableType = tables.getString("TABLE_TYPE");
|
||||
String typeCat = tables.getString("TYPE_CAT");
|
||||
String typeSchem = tables.getString("TYPE_SCHEM");
|
||||
String typeName = tables.getString("TYPE_NAME");
|
||||
String selfReferencingColName = tables.getString("SELF_REFERENCING_COL_NAME");
|
||||
String refGeneration = tables.getString("REF_GENERATION");
|
||||
String remarks = tables.getString("REMARKS" );
|
||||
String tableCat = tables.getString("TABLE_CAT" );
|
||||
String tableSchem = tables.getString("TABLE_SCHEM" );
|
||||
String tableType = tables.getString("TABLE_TYPE" );
|
||||
String typeCat = tables.getString("TYPE_CAT" );
|
||||
String typeSchem = tables.getString("TYPE_SCHEM" );
|
||||
String typeName = tables.getString("TYPE_NAME" );
|
||||
String selfReferencingColName = tables.getString("SELF_REFERENCING_COL_NAME" );
|
||||
String refGeneration = tables.getString("REF_GENERATION" );
|
||||
|
||||
tableMetaData = TableMetaData.builder()
|
||||
.tableName(tableName)
|
||||
|
@ -98,7 +99,7 @@ public class DbInfoUtil {
|
|||
.refGeneration(refGeneration)
|
||||
.build();
|
||||
} else {
|
||||
throw new RuntimeException("数据表不存在");
|
||||
throw new RuntimeException("数据表不存在" );
|
||||
}
|
||||
|
||||
return tableMetaData;
|
||||
|
@ -122,13 +123,16 @@ public class DbInfoUtil {
|
|||
try (ResultSet columnsRs = metaData.getColumns(null, null, tableName, null)) {
|
||||
while (columnsRs.next()) {
|
||||
ColumnMetaData column = new ColumnMetaData();
|
||||
String columnName = columnsRs.getString("COLUMN_NAME");
|
||||
String columnName = columnsRs.getString("COLUMN_NAME" );
|
||||
|
||||
String javaType = ConvertUtil.convertToJavaType(column.getJdbcType());
|
||||
|
||||
column.setColumnName(columnName);
|
||||
column.setFieldName(ConvertUtil.convertToFieldName(column.getColumnName()));
|
||||
column.setJdbcType(columnsRs.getString("TYPE_NAME"));
|
||||
column.setJavaType(ConvertUtil.convertToJavaType(column.getJdbcType()));
|
||||
column.setComment(columnsRs.getString("REMARKS"));
|
||||
column.setJdbcType(columnsRs.getString("TYPE_NAME" ));
|
||||
column.setJavaType(javaType);
|
||||
column.setJavascriptType(StringUtils.uncapitalize(javaType));
|
||||
column.setComment(columnsRs.getString("REMARKS" ));
|
||||
|
||||
// 确保 primaryKeyColumns 不为空
|
||||
if (!primaryKeyColumns.isEmpty()) {
|
||||
|
|
|
@ -30,11 +30,12 @@ public class VmsUtil {
|
|||
}
|
||||
|
||||
String date = new SimpleDateFormat(dto.getSimpleDateFormat()).format(new Date());
|
||||
context.put("date" , date);
|
||||
context.put("author" , author);
|
||||
context.put("requestMapping" , requestMapping);
|
||||
context.put("classLowercaseName" , ConvertUtil.convertToCamelCase(replaceTableName.get()));
|
||||
context.put("classUppercaseName" , ConvertUtil.convertToCamelCase(replaceTableName.get(), true));
|
||||
context.put("leftBrace", "{" );
|
||||
context.put("date", date);
|
||||
context.put("author", author);
|
||||
context.put("requestMapping", requestMapping);
|
||||
context.put("classLowercaseName", ConvertUtil.convertToCamelCase(replaceTableName.get()));
|
||||
context.put("classUppercaseName", ConvertUtil.convertToCamelCase(replaceTableName.get(), true));
|
||||
|
||||
Template servicePathTemplate = Velocity.getTemplate(templateName, "UTF-8" );
|
||||
servicePathTemplate.merge(context, writer);
|
||||
|
|
|
@ -15,13 +15,13 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* <p>
|
||||
* ${tableName}表 前端控制器
|
||||
* ${comment}表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Tag(name = "${tableName}" , description = "${tableName}相关接口" )
|
||||
@Tag(name = "${comment}", description = "${comment}相关接口" )
|
||||
@RestController
|
||||
@RequestMapping("${requestMapping}/${classLowercaseName}" )
|
||||
public class ${classUppercaseName}Controller {
|
||||
|
@ -29,37 +29,37 @@ public class ${classUppercaseName}Controller {
|
|||
@Autowired
|
||||
private ${classUppercaseName}Service ${classLowercaseName}Service;
|
||||
|
||||
@Operation(summary = "分页查询${tableName}" , description = "分页查询${tableName}" )
|
||||
@Operation(summary = "分页查询${comment}", description = "分页查询${comment}" )
|
||||
@GetMapping("get${classUppercaseName}List/{page}/{limit}" )
|
||||
public Result<PageResult<${classUppercaseName}Vo>> get${classUppercaseName}List(
|
||||
@Parameter(name = "page" , description = "当前页" , required = true)
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
@PathVariable("page" ) Integer page,
|
||||
@Parameter(name = "limit" , description = "每页记录数" , required = true)
|
||||
@Parameter(name = "limit", description = "每页记录数", required = true)
|
||||
@PathVariable("limit" ) Integer limit,
|
||||
${classUppercaseName}Dto dto) {
|
||||
Page<${classUppercaseName}> pageParams = new Page<>(page, limit);
|
||||
PageResult<${classUppercaseName}Vo> pageResult = ${classLowercaseName}Service.get${classUppercaseName}List(pageParams, dto);
|
||||
return Mono.just(Result.success(pageResult));
|
||||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加${tableName}" , description = "添加${tableName}" )
|
||||
@Operation(summary = "添加${comment}", description = "添加${comment}" )
|
||||
@PostMapping("add${classUppercaseName}" )
|
||||
public Result<String> add${classUppercaseName}(@Valid @RequestBody ${classUppercaseName}AddDto dto) {
|
||||
${classLowercaseName}Service.add${classUppercaseName}(dto);
|
||||
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
|
||||
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新${tableName}" , description = "更新${tableName}" )
|
||||
@Operation(summary = "更新${comment}", description = "更新${comment}" )
|
||||
@PutMapping("update${classUppercaseName}" )
|
||||
public Result<String> update${classUppercaseName}(@Valid @RequestBody ${classUppercaseName}UpdateDto dto) {
|
||||
${classLowercaseName}Service.update${classUppercaseName}(dto);
|
||||
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
|
||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除${tableName}" , description = "删除${tableName}" )
|
||||
@Operation(summary = "删除${comment}", description = "删除${comment}" )
|
||||
@DeleteMapping("delete${classUppercaseName}" )
|
||||
public Result<String> delete${classUppercaseName}(@RequestBody List<Long> ids) {
|
||||
${classLowercaseName}Service.delete${classUppercaseName}(ids);
|
||||
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
|
||||
return Result.success(ResultCodeEnum.DELETE_SUCCESS);
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* <p>
|
||||
* ${tableName} Mapper 接口
|
||||
* ${comment} Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author ${author}
|
||||
|
@ -19,16 +19,16 @@ import java.util.List;
|
|||
public interface ${classUppercaseName}Mapper extends BaseMapper<${classUppercaseName}> {
|
||||
|
||||
/**
|
||||
* * 分页查询${tableName}内容
|
||||
* * 分页查询${comment}内容
|
||||
*
|
||||
* @param pageParams ${tableName}分页参数
|
||||
* @param dto ${tableName}查询表单
|
||||
* @return ${tableName}分页结果
|
||||
* @param pageParams ${comment}分页参数
|
||||
* @param dto ${comment}查询表单
|
||||
* @return ${comment}分页结果
|
||||
*/
|
||||
IPage<${classUppercaseName}Vo> selectListByPage(@Param("page") Page<${classUppercaseName}> pageParams, @Param("dto") ${classUppercaseName}Dto dto);
|
||||
IPage<${classUppercaseName}Vo> selectListByPage(@Param("page" ) Page<${classUppercaseName}> pageParams, @Param("dto" ) ${classUppercaseName}Dto dto);
|
||||
|
||||
/**
|
||||
* 物理删除${tableName}
|
||||
* 物理删除${comment}
|
||||
*
|
||||
* @param ids 删除 id 列表
|
||||
*/
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.bunny.services.mapper.${originalName}Mapper">
|
||||
<mapper namespace="${package}.mapper.${classUppercaseName}Mapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="$type">
|
||||
#foreach($field in $baseResultMaps)
|
||||
<id column="$field.column" property="$field.property"/>
|
||||
<resultMap id="BaseResultMap" type="${classUppercaseName}">
|
||||
#foreach($field in ${columnInfoList})
|
||||
<id column="${field.column}" property="${field.fieldName}"/>
|
||||
#end
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
$baseColumnList
|
||||
${baseColumnList}
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询${classTitle}内容 -->
|
||||
<!-- 分页查询${comment}内容 -->
|
||||
<select id="selectListByPage" resultType="${voClassType}">
|
||||
select
|
||||
base.*,
|
||||
|
@ -25,18 +25,17 @@
|
|||
left join sys_user update_user on update_user.id = base.update_user
|
||||
<where>
|
||||
base.is_deleted = 0
|
||||
#foreach($field in $pageQueryMap)
|
||||
<if test="dto.${field.property} != null and dto.${field.property} != ''">
|
||||
and base.$field.column like CONCAT('%',#{dto.${field.property}},'%')
|
||||
#foreach($field in $columnInfoList)
|
||||
<if test="dto.${field.fieldName} != null and dto.${field.fieldName} != ''">
|
||||
and base.${field.columnName} like CONCAT('%',#{dto.${field.fieldName}},'%')
|
||||
</if>
|
||||
#end
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 物理删除${classTitle} -->
|
||||
<!-- 物理删除${comment} -->
|
||||
<delete id="deleteBatchIdsWithPhysics">
|
||||
delete
|
||||
from $tableName
|
||||
delete from ${tableName}
|
||||
where id in
|
||||
<foreach collection="ids" item="id" open="(" close=")" separator=",">
|
||||
#{id}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package cn.bunny.services.service;
|
||||
package ${package}.service;
|
||||
|
||||
import cn.bunny.dao.entity.system.MenuIcon;
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
|
@ -11,39 +11,39 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* <p>
|
||||
* ${classTitle} 服务类
|
||||
* ${comment} 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since ${date}
|
||||
*/
|
||||
public interface ${originalName}Service extends IService<${originalName}> {
|
||||
public interface ${classUppercaseName}Service extends IService<${classUppercaseName}> {
|
||||
|
||||
/**
|
||||
* * 获取${classTitle}列表
|
||||
* * 获取${comment}列表
|
||||
*
|
||||
* @return ${classTitle}返回列表
|
||||
* @return ${comment}返回列表
|
||||
*/
|
||||
PageResult<${originalName}Vo> get${originalName}List(Page<${originalName}> pageParams, ${originalName}Dto dto);
|
||||
PageResult<${classUppercaseName}Vo> get${classUppercaseName}List(Page<${classUppercaseName}> pageParams, ${classUppercaseName}Dto dto);
|
||||
|
||||
/**
|
||||
* * 添加${classTitle}
|
||||
* * 添加${comment}
|
||||
*
|
||||
* @param dto 添加表单
|
||||
*/
|
||||
void add${originalName}(@Valid ${originalName}AddDto dto);
|
||||
void add${classUppercaseName}(@Valid ${classUppercaseName}AddDto dto);
|
||||
|
||||
/**
|
||||
* * 更新${classTitle}
|
||||
* * 更新${comment}
|
||||
*
|
||||
* @param dto 更新表单
|
||||
*/
|
||||
void update${originalName}(@Valid ${originalName}UpdateDto dto);
|
||||
void update${classUppercaseName}(@Valid ${classUppercaseName}UpdateDto dto);
|
||||
|
||||
/**
|
||||
* * 删除|批量删除${classTitle}类型
|
||||
* * 删除|批量删除${comment}类型
|
||||
*
|
||||
* @param ids 删除id列表
|
||||
*/
|
||||
void delete${originalName}(List<Long> ids);
|
||||
void delete${classUppercaseName}(List<Long> ids);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package cn.bunny.services.service.impl;
|
||||
package ${package}.service.impl;
|
||||
|
||||
import cn.bunny.dao.pojo.result.PageResult;
|
||||
import cn.bunny.services.mapper.${originalName}Mapper;
|
||||
import cn.bunny.services.service.${originalName}Service;
|
||||
import ${package}.mapper.${classUppercaseName}Mapper;
|
||||
import ${package}.service.${classUppercaseName}Service;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
@ -13,66 +13,67 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* <p>
|
||||
* ${classTitle} 服务实现类
|
||||
* ${comment} 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since ${date}
|
||||
*/
|
||||
@Service
|
||||
public class ${originalName}ServiceImpl extends ServiceImpl<${originalName}Mapper, ${originalName}> implements ${originalName}Service {
|
||||
public class ${classUppercaseName}ServiceImpl extends ServiceImpl<${classUppercaseName}Mapper, ${classUppercaseName}> implements ${classUppercaseName}Service {
|
||||
|
||||
/**
|
||||
* * ${classTitle} 服务实现类
|
||||
* * ${comment} 服务实现类
|
||||
*
|
||||
* @param pageParams ${classTitle}分页查询page对象
|
||||
* @param dto ${classTitle}分页查询对象
|
||||
* @return 查询分页${classTitle}返回对象
|
||||
* @param pageParams ${comment}分页查询page对象
|
||||
* @param dto ${comment}分页查询对象
|
||||
* @return 查询分页${comment}返回对象
|
||||
*/
|
||||
@Override
|
||||
public PageResult<${originalName}Vo> get${originalName}List(Page<${originalName}> pageParams, ${originalName}Dto dto) {
|
||||
IPage<${originalName}Vo> page = baseMapper.selectListByPage(pageParams, dto);
|
||||
public PageResult<${classUppercaseName}Vo> get${classUppercaseName}List(Page<${classUppercaseName}> pageParams, ${classUppercaseName}Dto dto) {
|
||||
IPage<${classUppercaseName}Vo> page = baseMapper.selectListByPage(pageParams, dto);
|
||||
|
||||
return PageResult.<${originalName}Vo>builder()
|
||||
return PageResult.<${classUppercaseName}Vo>builder()
|
||||
.list(page.getRecords())
|
||||
.pageNo(page.getCurrent())
|
||||
.pageSize(page.getSize())
|
||||
.total(page.getTotal())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加${classTitle}
|
||||
* 添加${comment}
|
||||
*
|
||||
* @param dto ${classTitle}添加
|
||||
* @param dto ${comment}添加
|
||||
*/
|
||||
@Override
|
||||
public void add${originalName}(@Valid ${originalName}AddDto dto) {
|
||||
public void add${classUppercaseName}(@Valid ${classUppercaseName}AddDto dto) {
|
||||
// 保存数据
|
||||
${originalName} ${lowercaseName} = new ${originalName}();
|
||||
BeanUtils.copyProperties(dto, ${lowercaseName});
|
||||
save(${lowercaseName});
|
||||
${classUppercaseName} ${classLowercaseName} =new ${classUppercaseName}();
|
||||
BeanUtils.copyProperties(dto, ${classLowercaseName});
|
||||
save(${classLowercaseName});
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新${classTitle}
|
||||
* 更新${comment}
|
||||
*
|
||||
* @param dto ${classTitle}更新
|
||||
* @param dto ${comment}更新
|
||||
*/
|
||||
@Override
|
||||
public void update${originalName}(@Valid ${originalName}UpdateDto dto) {
|
||||
public void update${classUppercaseName}(@Valid ${classUppercaseName}UpdateDto dto) {
|
||||
// 更新内容
|
||||
${originalName} ${lowercaseName} = new ${originalName}();
|
||||
BeanUtils.copyProperties(dto, ${lowercaseName});
|
||||
updateById(${lowercaseName});
|
||||
${classUppercaseName} ${classLowercaseName} =new ${classUppercaseName}();
|
||||
BeanUtils.copyProperties(dto, ${classLowercaseName});
|
||||
updateById(${classLowercaseName});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除|批量删除${classTitle}
|
||||
* 删除|批量删除${comment}
|
||||
*
|
||||
* @param ids 删除id列表
|
||||
*/
|
||||
@Override
|
||||
public void delete${originalName}(List<Long> ids) {
|
||||
public void delete${classUppercaseName}(List<Long> ids) {
|
||||
baseMapper.deleteBatchIdsWithPhysics(ids);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,22 +1,22 @@
|
|||
import { http } from '@/api/service/request';
|
||||
import type { BaseResult, ResultTable } from '@/api/service/types';
|
||||
import {http} from '@/api/service/request';
|
||||
import type {BaseResult, ResultTable} from '@/api/service/types';
|
||||
|
||||
/** ${classDescription}---获取${classDescription}列表 */
|
||||
export const fetchGet${originalName}List = (data: any) => {
|
||||
return http.request<BaseResult<ResultTable>>('get', `${lowercaseName}/get${originalName}List/${data.currentPage}/${data.pageSize}`, { params: data });
|
||||
/** ${comment}---获取${comment}列表 */
|
||||
export const fetchGet${classUppercaseName}List = (data: any) => {
|
||||
return http.request<BaseResult<ResultTable>>('get', `${classLowercaseName}/get${classUppercaseName}List/${data.currentPage}/${data.pageSize}`, {params: data});
|
||||
};
|
||||
|
||||
/** ${classDescription}---添加${classDescription} */
|
||||
export const fetchAdd${originalName} = (data: any) => {
|
||||
return http.request<BaseResult<object>>('post', '${lowercaseName}/add${originalName}', { data });
|
||||
/** ${comment}---添加${comment} */
|
||||
export const fetchAdd${classUppercaseName} = (data: any) => {
|
||||
return http.request<BaseResult<any>>('post', '${classLowercaseName}/add${classUppercaseName}', {data});
|
||||
};
|
||||
|
||||
/** ${classDescription}---更新${classDescription} */
|
||||
export const fetchUpdate${originalName} = (data: any) => {
|
||||
return http.request<BaseResult<object>>('put', '${lowercaseName}/update${originalName}', { data });
|
||||
/** ${comment}---更新${comment} */
|
||||
export const fetchUpdate${classUppercaseName} = (data: any) => {
|
||||
return http.request<BaseResult<any>>('put', '${classLowercaseName}/update${classUppercaseName}', {data});
|
||||
};
|
||||
|
||||
/** ${classDescription}---删除${classDescription} */
|
||||
export const fetchDelete${originalName} = (data: any) => {
|
||||
return http.request<BaseResult<object>>('delete', '${lowercaseName}/delete${originalName}', { data });
|
||||
/** ${comment}---删除${comment} */
|
||||
export const fetchDelete${classUppercaseName} = (data: any) => {
|
||||
return http.request<BaseResult<any>>('delete', '${classLowercaseName}/delete${classUppercaseName}', {data});
|
||||
};
|
|
@ -1,27 +1,31 @@
|
|||
import { reactive, ref } from 'vue';
|
||||
import {reactive} from 'vue';
|
||||
import type {FormRules} from 'element-plus';
|
||||
import { $t } from '@/plugins/i18n';
|
||||
import type { FormRules } from 'element-plus';
|
||||
|
||||
// 表格列
|
||||
export const columns: TableColumnList = [
|
||||
{ type: 'selection', align: 'left' },
|
||||
{ type: 'index', index: (index: number) => index + 1, label: '序号', width: 60 },
|
||||
#foreach($field in $baseFieldList)
|
||||
// $field.annotation
|
||||
{ label: $t('$field.name'), prop: '$field.name' },
|
||||
#end
|
||||
{ label: $t('table.updateTime'), prop: 'updateTime', sortable: true, width: 160 },
|
||||
{ label: $t('table.createTime'), prop: 'createTime', sortable: true, width: 160 },
|
||||
{ label: $t('table.createUser'), prop: 'createUser', slot: 'createUser', width: 130 },
|
||||
{ label: $t('table.updateUser'), prop: 'updateUser', slot: 'updateUser', width: 130 },
|
||||
{ label: $t('table.operation'), fixed: 'right', width: 210, slot: 'operation' },
|
||||
{type: 'selection', align: 'left'},
|
||||
{type: 'index', index: (index: number) => index + 1, label: '序号', width: 60},
|
||||
#foreach($field in $columnInfoList)
|
||||
// $field.comment
|
||||
{label: $t('$field.fieldName'), prop: '$field.fieldName'},
|
||||
#end
|
||||
{label: $t('table.updateTime'), prop: 'updateTime', sortable: true, width: 160},
|
||||
{label: $t('table.createTime'), prop: 'createTime', sortable: true, width: 160},
|
||||
{label: $t('table.createUser'), prop: 'createUser', slot: 'createUser', width: 130},
|
||||
{label: $t('table.updateUser'), prop: 'updateUser', slot: 'updateUser', width: 130},
|
||||
{label: $t('table.operation'), fixed: 'right', width: 210, slot: 'operation'},
|
||||
];
|
||||
|
||||
// 添加规则
|
||||
export const rules = reactive
|
||||
<FormRules>({
|
||||
#foreach($field in $baseFieldList)
|
||||
// $field.annotation
|
||||
$field.name: [{ required: true, message: `$leftBrace$t('input')}$leftBrace$t('${field.name}')}`, trigger: 'blur' }],
|
||||
export const rules = reactive < FormRules > ({
|
||||
#foreach($field in $columnInfoList)
|
||||
// $field.comment
|
||||
$field.fieldName: [{
|
||||
required: true,
|
||||
message: `$leftBrace$t('input')}$leftBrace$t('${field.fieldName}')}`,
|
||||
trigger: 'blur'
|
||||
}],
|
||||
#end
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -1,36 +1,34 @@
|
|||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { FormInstance } from 'element-plus';
|
||||
import { rules } from '${columnsPath}';
|
||||
import { FormProps } from '${typesPath}';
|
||||
import { frameSureOptions } from '@/enums';
|
||||
import { $t } from '@/plugins/i18n';
|
||||
import {ref} from 'vue';
|
||||
import {FormInstance} from 'element-plus';
|
||||
import {FormProps} from '';
|
||||
|
||||
const props = withDefaults(defineProps<FormProps>(), {
|
||||
formInline: () => ({
|
||||
#foreach($item in $baseFieldList)
|
||||
#if(${item.name})
|
||||
// $!{item.annotation}
|
||||
${item.name}: undefined,
|
||||
#end
|
||||
#end
|
||||
}),
|
||||
});
|
||||
const props = withDefaults(defineProps<FormProps>(), {
|
||||
formInline: () => ({
|
||||
#foreach($item in $columnInfoList)
|
||||
#if(${item.fieldName})
|
||||
// $!{item.comment}
|
||||
${item.fieldName}: undefined,
|
||||
#end
|
||||
#end
|
||||
}),
|
||||
});
|
||||
|
||||
const formRef = ref<FormInstance>();
|
||||
const form = ref(props.formInline);
|
||||
const formRef = ref<FormInstance>();
|
||||
const form = ref(props.formInline);
|
||||
|
||||
defineExpose({ formRef });
|
||||
defineExpose({formRef});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="auto">
|
||||
#foreach($item in $baseFieldList)
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="auto">
|
||||
#foreach($item in $columnInfoList)
|
||||
|
||||
<!-- $item.annotation -->
|
||||
<el-form-item :label="$t('${item.name}')" prop="$item.name">
|
||||
<el-input v-model="form.$item.name" autocomplete="off" type="text" :placeholder="$t('input') + $t('${item.name}')" />
|
||||
<!-- $item.comment -->
|
||||
<el-form-item :label="$t('${item.fieldName}')" prop="$item.fieldName">
|
||||
<el-input v-model="form.$item.fieldName" autocomplete="off" type="text"
|
||||
:placeholder="$t('input') + $t('${item.fieldName}')"/>
|
||||
</el-form-item>
|
||||
#end
|
||||
</el-form>
|
||||
#end
|
||||
</el-form>
|
||||
</template>
|
||||
|
|
|
@ -1,130 +1,124 @@
|
|||
import { deviceDetection } from '@pureadmin/utils';
|
||||
import { addDialog } from '@/components/BaseDialog/index';
|
||||
import ${originalName}Dialog from '${dialogPath}';
|
||||
import { use${originalName}Store } from '${storePath}';
|
||||
import { h, ref } from 'vue';
|
||||
import { messageBox } from '@/utils/message';
|
||||
import type { FormItemProps } from '${typesPath}';
|
||||
import { $t } from '@/plugins/i18n';
|
||||
import { message, messageBox } from "@/utils/message";
|
||||
import {addDialog} from '@/components/BaseDialog/index';
|
||||
import {h, ref} from 'vue';
|
||||
import {message, messageBox} from '@/utils/message';
|
||||
import DeleteBatchDialog from "@/components/Table/DeleteBatchDialog.vue";
|
||||
|
||||
export const formRef = ref();
|
||||
// 删除ids
|
||||
export const deleteIds = ref([]);
|
||||
const ${lowercaseName}Store = use${originalName}Store();
|
||||
const ${classLowercaseName}Store = use${classUppercaseName}Store();
|
||||
|
||||
/** 搜索初始化${classTitle} */
|
||||
/** 搜索初始化${comment} */
|
||||
export async function onSearch() {
|
||||
${lowercaseName}Store.loading = true;
|
||||
await ${lowercaseName}Store.get${originalName}List();
|
||||
${lowercaseName}Store.loading = false;
|
||||
${classLowercaseName}Store.loading = true;
|
||||
await ${classLowercaseName}Store.get${classUppercaseName}List();
|
||||
${classLowercaseName}Store.loading = false;
|
||||
}
|
||||
|
||||
/** 添加${classTitle} */
|
||||
/** 添加${comment} */
|
||||
export function onAdd() {
|
||||
addDialog({
|
||||
title: `$leftBrace $t("addNew")}$leftBrace$t("${lowercaseName}")}`,
|
||||
width: '30%',
|
||||
props: {
|
||||
formInline: {
|
||||
#foreach($item in $addFormList)
|
||||
$!{item}: undefined,
|
||||
#end
|
||||
},
|
||||
},
|
||||
draggable: true,
|
||||
fullscreenIcon: true,
|
||||
closeOnClickModal: false,
|
||||
contentRenderer: () => h(${originalName}Dialog, { ref: formRef }),
|
||||
beforeSure: (done, { options }) => {
|
||||
const form = options.props.formInline as FormItemProps;
|
||||
formRef.value.formRef.validate(async (valid: any) => {
|
||||
if (!valid) return;
|
||||
addDialog({
|
||||
title: `$leftBrace $t("addNew")}$leftBrace$t("${classLowercaseName}")}`,
|
||||
width: '30%',
|
||||
props: {
|
||||
formInline: {
|
||||
#foreach($item in $columnInfoList)
|
||||
$!{item.fieldName}: undefined,
|
||||
#end
|
||||
},
|
||||
},
|
||||
draggable: true,
|
||||
fullscreenIcon: true,
|
||||
closeOnClickModal: false,
|
||||
contentRenderer: () => h(${classUppercaseName}Dialog, {ref: formRef}),
|
||||
beforeSure: (done, {options}) => {
|
||||
const form = options.props.formInline as FormItemProps;
|
||||
formRef.value.formRef.validate(async (valid: any) => {
|
||||
if (!valid) return;
|
||||
|
||||
const result = await ${lowercaseName}Store.add${originalName}(form);
|
||||
if (!result) return;
|
||||
done();
|
||||
await onSearch();
|
||||
});
|
||||
},
|
||||
});
|
||||
const result = await ${classLowercaseName}Store.add${classUppercaseName}(form);
|
||||
if (!result) return;
|
||||
done();
|
||||
await onSearch();
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/** 更新${classTitle} */
|
||||
/** 更新${comment} */
|
||||
export function onUpdate(row: any) {
|
||||
addDialog({
|
||||
title: `$leftBrace$t("modify")}$leftBrace$t("${lowercaseName}")}`,
|
||||
width: '30%',
|
||||
props: {
|
||||
formInline: {
|
||||
#foreach($item in $addFormList)
|
||||
$!{item}: row.$!{item},
|
||||
#end
|
||||
}
|
||||
},
|
||||
draggable: true,
|
||||
fullscreenIcon: true,
|
||||
closeOnClickModal: false,
|
||||
contentRenderer: () => h(${originalName}Dialog, { ref: formRef }),
|
||||
beforeSure: (done, { options }) => {
|
||||
const form = options.props.formInline as FormItemProps;
|
||||
formRef.value.formRef.validate(async (valid: any) => {
|
||||
if (!valid) return;
|
||||
addDialog({
|
||||
title: `$leftBrace$t("modify")}$leftBrace$t("${classLowercaseName}")}`,
|
||||
width: '30%',
|
||||
props: {
|
||||
formInline: {
|
||||
#foreach($item in $columnInfoList)
|
||||
$!{item.fieldName}: row.$!{item.fieldName},
|
||||
#end
|
||||
}
|
||||
},
|
||||
draggable: true,
|
||||
fullscreenIcon: true,
|
||||
closeOnClickModal: false,
|
||||
contentRenderer: () => h(${classUppercaseName}Dialog, {ref: formRef}),
|
||||
beforeSure: (done, {options}) => {
|
||||
const form = options.props.formInline as FormItemProps;
|
||||
formRef.value.formRef.validate(async (valid: any) => {
|
||||
if (!valid) return;
|
||||
|
||||
const result = await ${lowercaseName}Store.update${originalName}({ ...form, id: row.id });
|
||||
if (!result) return;
|
||||
done();
|
||||
await onSearch();
|
||||
});
|
||||
},
|
||||
});
|
||||
const result = await ${classLowercaseName}Store.update${classUppercaseName}({...form, id: row.id});
|
||||
if (!result) return;
|
||||
done();
|
||||
await onSearch();
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/** 删除${classTitle} */
|
||||
/** 删除${comment} */
|
||||
export const onDelete = async (row: any) => {
|
||||
const id = row.id;
|
||||
const id = row.id;
|
||||
|
||||
// 是否确认删除
|
||||
const result = await messageBox({
|
||||
title: $t('confirmDelete'),
|
||||
showMessage: false,
|
||||
confirmMessage: undefined,
|
||||
cancelMessage: $t("cancel_delete"),
|
||||
});
|
||||
if (!result) return;
|
||||
// 是否确认删除
|
||||
const result = await messageBox({
|
||||
title: $t('confirmDelete'),
|
||||
showMessage: false,
|
||||
confirmMessage: undefined,
|
||||
cancelMessage: $t("cancel_delete"),
|
||||
});
|
||||
if (!result) return;
|
||||
|
||||
// 删除数据
|
||||
await ${lowercaseName}Store.delete${originalName}([id]);
|
||||
await onSearch();
|
||||
// 删除数据
|
||||
await ${classLowercaseName}Store.delete${classUppercaseName}([id]);
|
||||
await onSearch();
|
||||
};
|
||||
|
||||
/** 批量删除 */
|
||||
export const onDeleteBatch = async () => {
|
||||
const ids = deleteIds.value;
|
||||
const formDeletedBatchRef = ref();
|
||||
const ids = deleteIds.value;
|
||||
const formDeletedBatchRef = ref();
|
||||
|
||||
addDialog({
|
||||
title: $t('deleteBatchTip'),
|
||||
width: '30%',
|
||||
props: { formInline: { confirmText: '' } },
|
||||
draggable: true,
|
||||
fullscreenIcon: true,
|
||||
closeOnClickModal: false,
|
||||
contentRenderer: () => h(DeleteBatchDialog, { ref: formDeletedBatchRef }),
|
||||
beforeSure: (done, { options }) => {
|
||||
formDeletedBatchRef.value.formDeletedBatchRef.validate(async (valid: any) => {
|
||||
if (!valid) return;
|
||||
addDialog({
|
||||
title: $t('deleteBatchTip'),
|
||||
width: '30%',
|
||||
props: {formInline: {confirmText: ''}},
|
||||
draggable: true,
|
||||
fullscreenIcon: true,
|
||||
closeOnClickModal: false,
|
||||
contentRenderer: () => h(DeleteBatchDialog, {ref: formDeletedBatchRef}),
|
||||
beforeSure: (done, {options}) => {
|
||||
formDeletedBatchRef.value.formDeletedBatchRef.validate(async (valid: any) => {
|
||||
if (!valid) return;
|
||||
|
||||
const text = options.props.formInline.confirmText.toLowerCase();
|
||||
if (text === 'yes' || text === 'y') {
|
||||
const text = options.props.formInline.confirmText.toLowerCase();
|
||||
if (text === 'yes' || text === 'y') {
|
||||
// 删除数据
|
||||
await ${lowercaseName}Store.delete${originalName}(ids);
|
||||
await ${classLowercaseName}Store.delete${classUppercaseName}(ids);
|
||||
await onSearch();
|
||||
|
||||
done();
|
||||
} else message($t('deleteBatchTip'), { type: 'warning' });
|
||||
});
|
||||
},
|
||||
});
|
||||
done();
|
||||
} else message($t('deleteBatchTip'), {type: 'warning'});
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
|
@ -1,121 +1,127 @@
|
|||
<script lang="ts" setup>
|
||||
import {onMounted, ref} from 'vue';
|
||||
import {deleteIds, onSearch} from '';
|
||||
import {FormInstance} from "element-plus";
|
||||
import {onMounted, ref} from 'vue';
|
||||
import {deleteIds, onSearch} from '';
|
||||
import {FormInstance} from "element-plus";
|
||||
|
||||
const tableRef = ref();
|
||||
const formRef = ref();
|
||||
const ${lowercaseName}Store = use${originalName}Store();
|
||||
const tableRef = ref();
|
||||
const formRef = ref();
|
||||
const ${classLowercaseName}Store = use${classUppercaseName}Store();
|
||||
|
||||
/** 当前页改变时 */
|
||||
const onCurrentPageChange = async (value: number) => {
|
||||
${lowercaseName}Store.pagination.currentPage = value;
|
||||
await onSearch();
|
||||
};
|
||||
/** 当前页改变时 */
|
||||
const onCurrentPageChange = async (value: number) => {
|
||||
${classLowercaseName}Store.pagination.currentPage = value;
|
||||
await onSearch();
|
||||
};
|
||||
|
||||
/** 当分页发生变化 */
|
||||
const onPageSizeChange = async (value: number) => {
|
||||
${lowercaseName}Store.pagination.pageSize = value;
|
||||
await onSearch();
|
||||
};
|
||||
/** 当分页发生变化 */
|
||||
const onPageSizeChange = async (value: number) => {
|
||||
${classLowercaseName}Store.pagination.pageSize = value;
|
||||
await onSearch();
|
||||
};
|
||||
|
||||
/** 选择多行 */
|
||||
const onSelectionChange = (rows: Array<any>) => {
|
||||
deleteIds.value = rows.map((row: any) => row.id);
|
||||
};
|
||||
/** 选择多行 */
|
||||
const onSelectionChange = (rows: Array<any>) => {
|
||||
deleteIds.value = rows.map((row: any) => row.id);
|
||||
};
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = async (formEl: FormInstance | undefined) => {
|
||||
if (!formEl) return;
|
||||
formEl.resetFields();
|
||||
await onSearch();
|
||||
};
|
||||
/** 重置表单 */
|
||||
const resetForm = async (formEl: FormInstance | undefined) => {
|
||||
if (!formEl) return;
|
||||
formEl.resetFields();
|
||||
await onSearch();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
onSearch();
|
||||
});
|
||||
onMounted(() => {
|
||||
onSearch();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="main">
|
||||
<el-form ref="formRef" :inline="true" :model="${lowercaseName}Store.form" class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px] overflow-auto">
|
||||
#foreach($item in $formList)
|
||||
<div class="main">
|
||||
<el-form ref="formRef" :inline="true" :model="${classLowercaseName}Store.form"
|
||||
class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px] overflow-auto">
|
||||
#foreach($item in $columnInfoList)
|
||||
|
||||
<!-- $item.annotation -->
|
||||
<el-form-item :label="$t('${item.name}')" prop="${item.name}">
|
||||
<el-input v-model="${lowercaseName}Store.form.${item.name}" :placeholder="`$leftBrace$t('input')}$leftBrace$t('${item.name}')}`"
|
||||
class="!w-[180px]" clearable/>
|
||||
</el-form-item>
|
||||
#end
|
||||
<el-form-item>
|
||||
<el-button :icon="useRenderIcon('ri:search-line')" :loading="${lowercaseName}Store.loading" type="primary" @click="onSearch"> {{ $t('search')
|
||||
}}
|
||||
<!-- $item.comment -->
|
||||
<el-form-item :label="$t('${item.fieldName}')" prop="${item.fieldName}">
|
||||
<el-input v-model="${classLowercaseName}Store.form.${item.fieldName}"
|
||||
:placeholder="`$leftBrace$t('input')}$leftBrace$t('${item.fieldName}')}`"
|
||||
class="!w-[180px]" clearable/>
|
||||
</el-form-item>
|
||||
#end
|
||||
<el-form-item>
|
||||
<el-button :icon="useRenderIcon('ri:search-line')" :loading="${classLowercaseName}Store.loading" type="primary"
|
||||
@click="onSearch"> {{ $t('search')
|
||||
}}
|
||||
</el-button>
|
||||
<el-button :icon="useRenderIcon(Refresh)" @click="resetForm(formRef)"> {{ $t('buttons.reset') }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<PureTableBar :columns="columns" title="${classDescription}" @fullscreen="tableRef.setAdaptive()"
|
||||
@refresh="onSearch">
|
||||
<template #buttons>
|
||||
<el-button :icon="useRenderIcon(AddFill)" type="primary" @click="onAdd"> {{ $t('addNew') }}</el-button>
|
||||
|
||||
<!-- 批量删除按钮 -->
|
||||
<el-button v-show="deleteIds.length > 0" :icon="useRenderIcon(Delete)" type="danger" @click="onDeleteBatch">
|
||||
{{ $t('delete_batches') }}
|
||||
</el-button>
|
||||
</template>
|
||||
|
||||
<template v-slot="{ size, dynamicColumns }">
|
||||
<pure-table
|
||||
ref="tableRef"
|
||||
:adaptiveConfig="{ offsetBottom: 96 }"
|
||||
:columns="dynamicColumns"
|
||||
:data="${classLowercaseName}Store.datalist"
|
||||
:header-cell-style="{ background: 'var(--el-fill-color-light)', color: 'var(--el-text-color-primary)' }"
|
||||
:loading="${classLowercaseName}Store.loading"
|
||||
:size="size"
|
||||
adaptive
|
||||
align-whole="center"
|
||||
border
|
||||
highlight-current-row
|
||||
row-key="id"
|
||||
showOverflowTooltip
|
||||
table-layout="auto"
|
||||
:pagination="${classLowercaseName}Store.pagination"
|
||||
@page-size-change="onPageSizeChange"
|
||||
@selection-change="onSelectionChange"
|
||||
@page-current-change="onCurrentPageChange"
|
||||
>
|
||||
|
||||
<template #createUser="{ row }">
|
||||
<el-button v-show="row.createUser" link type="primary" @click="selectUserinfo(row.createUser)">
|
||||
{{ row.createUsername }}
|
||||
</el-button>
|
||||
</template>
|
||||
|
||||
<template #updateUser="{ row }">
|
||||
<el-button v-show="row.updateUser" link type="primary" @click="selectUserinfo(row.updateUser)">
|
||||
{{ row.updateUsername }}
|
||||
</el-button>
|
||||
</template>
|
||||
|
||||
<template #operation="{ row }">
|
||||
<el-button :icon="useRenderIcon(EditPen)" :size="size" class="reset-margin" link type="primary"
|
||||
@click="onUpdate(row)"> {{ $t('modify')
|
||||
}}
|
||||
</el-button>
|
||||
<el-button :icon="useRenderIcon(AddFill)" :size="size" class="reset-margin" link type="primary"
|
||||
@click="onAdd"> {{ $t('addNew') }}
|
||||
</el-button>
|
||||
<!-- TODO 待完成 -->
|
||||
<el-popconfirm :title="`${leftBrace}$t('delete')}${row.email}?`" @confirm="onDelete(row)">
|
||||
<template #reference>
|
||||
<el-button :icon="useRenderIcon(Delete)" :size="size" class="reset-margin" link type="primary">
|
||||
{{ $t('delete') }}
|
||||
</el-button>
|
||||
<el-button :icon="useRenderIcon(Refresh)" @click="resetForm(formRef)"> {{ $t('buttons.reset') }}</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<PureTableBar :columns="columns" title="${classDescription}" @fullscreen="tableRef.setAdaptive()" @refresh="onSearch">
|
||||
<template #buttons>
|
||||
<el-button :icon="useRenderIcon(AddFill)" type="primary" @click="onAdd"> {{ $t('addNew') }}</el-button>
|
||||
|
||||
<!-- 批量删除按钮 -->
|
||||
<el-button v-show="deleteIds.length > 0" :icon="useRenderIcon(Delete)" type="danger" @click="onDeleteBatch">
|
||||
{{ $t('delete_batches') }}
|
||||
</el-button>
|
||||
</template>
|
||||
|
||||
<template v-slot="{ size, dynamicColumns }">
|
||||
<pure-table
|
||||
ref="tableRef"
|
||||
:adaptiveConfig="{ offsetBottom: 96 }"
|
||||
:columns="dynamicColumns"
|
||||
:data="${lowercaseName}Store.datalist"
|
||||
:header-cell-style="{ background: 'var(--el-fill-color-light)', color: 'var(--el-text-color-primary)' }"
|
||||
:loading="${lowercaseName}Store.loading"
|
||||
:size="size"
|
||||
adaptive
|
||||
align-whole="center"
|
||||
border
|
||||
highlight-current-row
|
||||
row-key="id"
|
||||
showOverflowTooltip
|
||||
table-layout="auto"
|
||||
:pagination="${lowercaseName}Store.pagination"
|
||||
@page-size-change="onPageSizeChange"
|
||||
@selection-change="onSelectionChange"
|
||||
@page-current-change="onCurrentPageChange"
|
||||
>
|
||||
|
||||
<template #createUser="{ row }">
|
||||
<el-button v-show="row.createUser" link type="primary" @click="selectUserinfo(row.createUser)">
|
||||
{{ row.createUsername }}
|
||||
</el-button>
|
||||
</template>
|
||||
|
||||
<template #updateUser="{ row }">
|
||||
<el-button v-show="row.updateUser" link type="primary" @click="selectUserinfo(row.updateUser)">
|
||||
{{ row.updateUsername }}
|
||||
</el-button>
|
||||
</template>
|
||||
|
||||
<template #operation="{ row }">
|
||||
<el-button :icon="useRenderIcon(EditPen)" :size="size" class="reset-margin" link type="primary" @click="onUpdate(row)"> {{ $t('modify')
|
||||
}}
|
||||
</el-button>
|
||||
<el-button :icon="useRenderIcon(AddFill)" :size="size" class="reset-margin" link type="primary" @click="onAdd"> {{ $t('addNew') }}
|
||||
</el-button>
|
||||
<!-- TODO 待完成 -->
|
||||
<el-popconfirm :title="`${leftBrace}$t('delete')}${row.email}?`" @confirm="onDelete(row)">
|
||||
<template #reference>
|
||||
<el-button :icon="useRenderIcon(Delete)" :size="size" class="reset-margin" link type="primary">
|
||||
{{ $t('delete') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</template>
|
||||
</pure-table>
|
||||
</template>
|
||||
</PureTableBar>
|
||||
</div>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</template>
|
||||
</pure-table>
|
||||
</template>
|
||||
</PureTableBar>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -1,69 +1,69 @@
|
|||
import { defineStore } from 'pinia';
|
||||
import { fetchAdd${originalName}, fetchDelete${originalName}, fetchGet${originalName}List, fetchUpdate${originalName} } from '${apiPath}';
|
||||
import { pageSizes } from '@/enums/baseConstant';
|
||||
import { storeMessage } from '@/utils/message';
|
||||
import { storePagination } from '@/store/useStorePagination';
|
||||
import {defineStore} from 'pinia';
|
||||
import {fetchAdd${classUppercaseName}, fetchDelete${classUppercaseName}, fetchUpdate${classUppercaseName}} from '';
|
||||
import {pageSizes} from '@/enums/baseConstant';
|
||||
import {storeMessage} from '@/utils/message';
|
||||
import {storePagination} from '@/store/useStorePagination';
|
||||
|
||||
/**
|
||||
* ${classTitle} Store
|
||||
*/
|
||||
export const use${originalName}Store = defineStore('${lowercaseName}Store', {
|
||||
state() {
|
||||
return {
|
||||
// ${classTitle}列表
|
||||
datalist: [],
|
||||
// 查询表单
|
||||
form: {
|
||||
#foreach($item in $formList)
|
||||
// $!{item.annotation}
|
||||
$!{item.name}: undefined,
|
||||
#end
|
||||
},
|
||||
// 分页查询结果
|
||||
pagination: {
|
||||
currentPage: 1,
|
||||
pageSize: 30,
|
||||
total: 1,
|
||||
pageSizes,
|
||||
},
|
||||
// 加载
|
||||
loading: false,
|
||||
};
|
||||
},
|
||||
getters: {},
|
||||
actions: {
|
||||
/** 获取${classTitle} */
|
||||
async get${originalName}List() {
|
||||
// 整理请求参数
|
||||
const data = { ...this.pagination, ...this.form };
|
||||
delete data.pageSizes;
|
||||
delete data.total;
|
||||
delete data.background;
|
||||
* ${comment} Store
|
||||
*/
|
||||
export const use${classUppercaseName}Store = defineStore('${lowercaseName}Store', {
|
||||
state() {
|
||||
return {
|
||||
// ${comment}列表
|
||||
datalist: [],
|
||||
// 查询表单
|
||||
form: {
|
||||
#foreach($item in $columnInfoList)
|
||||
// $!{item.comment}
|
||||
$!{item.fieldName}: undefined,
|
||||
#end
|
||||
},
|
||||
// 分页查询结果
|
||||
pagination: {
|
||||
currentPage: 1,
|
||||
pageSize: 30,
|
||||
total: 1,
|
||||
pageSizes,
|
||||
},
|
||||
// 加载
|
||||
loading: false,
|
||||
};
|
||||
},
|
||||
getters: {},
|
||||
actions: {
|
||||
/** 获取${comment} */
|
||||
async get${classUppercaseName}List() {
|
||||
// 整理请求参数
|
||||
const data = {...this.pagination, ...this.form};
|
||||
delete data.pageSizes;
|
||||
delete data.total;
|
||||
delete data.background;
|
||||
|
||||
// 获取${classTitle}列表
|
||||
const result = await fetchGet${originalName}List(data);
|
||||
// 获取${comment}列表
|
||||
const result = await fetchGet${classUppercaseName}List(data);
|
||||
|
||||
// 公共页面函数hook
|
||||
const pagination = storePagination.bind(this);
|
||||
return pagination(result);
|
||||
},
|
||||
// 公共页面函数hook
|
||||
const pagination = storePagination.bind(this);
|
||||
return pagination(result);
|
||||
},
|
||||
|
||||
/** 添加${classTitle} */
|
||||
async add${originalName}(data: any) {
|
||||
const result = await fetchAdd${originalName}(data);
|
||||
return storeMessage(result);
|
||||
},
|
||||
/** 添加${comment} */
|
||||
async add${classUppercaseName}(data: any) {
|
||||
const result = await fetchAdd${classUppercaseName}(data);
|
||||
return storeMessage(result);
|
||||
},
|
||||
|
||||
/** 修改${classTitle} */
|
||||
async update${originalName}(data: any) {
|
||||
const result = await fetchUpdate${originalName}(data);
|
||||
return storeMessage(result);
|
||||
},
|
||||
/** 修改${comment} */
|
||||
async update${classUppercaseName}(data: any) {
|
||||
const result = await fetchUpdate${classUppercaseName}(data);
|
||||
return storeMessage(result);
|
||||
},
|
||||
|
||||
/** 删除${classTitle} */
|
||||
async delete${originalName}(data: any) {
|
||||
const result = await fetchDelete${originalName}(data);
|
||||
return storeMessage(result);
|
||||
},
|
||||
},
|
||||
/** 删除${comment} */
|
||||
async delete${classUppercaseName}(data: any) {
|
||||
const result = await fetchDelete${classUppercaseName}(data);
|
||||
return storeMessage(result);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
// 添加或者修改表单元素
|
||||
export interface FormItemProps {
|
||||
#foreach($field in $baseFieldList)
|
||||
// $field.annotation
|
||||
$field.name: $field.type;
|
||||
#end
|
||||
#foreach($field in $columnInfoList)
|
||||
// $field.comment
|
||||
#if($field.javascriptType == "object")
|
||||
$field.fieldName: any
|
||||
#else
|
||||
$field.fieldName: $field.javascriptType
|
||||
#end
|
||||
#end
|
||||
}
|
||||
|
||||
// 添加或修改表单Props
|
||||
export interface FormProps {
|
||||
formInline: FormItemProps;
|
||||
formInline: FormItemProps;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,34 @@
|
|||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.bunny</groupId>
|
||||
<artifactId>dao</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
</dependency>
|
||||
<!-- hutool -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
</dependency>
|
||||
<!-- mysql连接驱动 -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
<!-- mysql连接池 -->
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
|
|
|
@ -12,38 +12,7 @@
|
|||
<name>common Maven Webapp</name>
|
||||
<url>https://maven.apache.org</url>
|
||||
<modules>
|
||||
<!-- <module>service-utils</module> -->
|
||||
<module>generator-code</module>
|
||||
<module>generator-v1</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.bunny</groupId>
|
||||
<artifactId>dao</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
</dependency>
|
||||
<!-- hutool -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
</dependency>
|
||||
<!-- mysql连接驱动 -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
<!-- mysql连接池 -->
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
Loading…
Reference in New Issue