init
This commit is contained in:
34
ruoyi-modules/ruoyi-gen/src/main/resources/application.yml
Normal file
34
ruoyi-modules/ruoyi-gen/src/main/resources/application.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
# Tomcat
|
||||
server:
|
||||
port: 9202
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: ruoyi-gen
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: @profiles.active@
|
||||
|
||||
--- # nacos 配置
|
||||
spring:
|
||||
cloud:
|
||||
nacos:
|
||||
# nacos 服务地址
|
||||
server-addr: @nacos.server@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
discovery:
|
||||
# 注册组
|
||||
group: @nacos.discovery.group@
|
||||
namespace: ${spring.profiles.active}
|
||||
config:
|
||||
# 配置组
|
||||
group: @nacos.config.group@
|
||||
namespace: ${spring.profiles.active}
|
||||
config:
|
||||
import:
|
||||
- optional:nacos:application-common.yml
|
||||
- optional:nacos:datasource.yml
|
||||
- optional:nacos:${spring.application.name}.yml
|
10
ruoyi-modules/ruoyi-gen/src/main/resources/banner.txt
Normal file
10
ruoyi-modules/ruoyi-gen/src/main/resources/banner.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Application Name: ${spring.application.name}
|
||||
_
|
||||
(_)
|
||||
_ __ _ _ ___ _ _ _ ______ __ _ ___ _ __
|
||||
| '__|| | | | / _ \ | | | || ||______| / _` | / _ \| '_ \
|
||||
| | | |_| || (_) || |_| || | | (_| || __/| | | |
|
||||
|_| \__,_| \___/ \__, ||_| \__, | \___||_| |_|
|
||||
__/ | __/ |
|
||||
|___/ |___/
|
25
ruoyi-modules/ruoyi-gen/src/main/resources/logback-plus.xml
Normal file
25
ruoyi-modules/ruoyi-gen/src/main/resources/logback-plus.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/${project.artifactId}"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="console.log.pattern"
|
||||
value="%cyan(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}%n) - %msg%n"/>
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${console.log.pattern}</pattern>
|
||||
<charset>utf-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<include resource="logback-common.xml" />
|
||||
|
||||
<include resource="logback-logstash.xml" />
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
</configuration>
|
@@ -0,0 +1,10 @@
|
||||
<?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="org.dromara.gen.mapper.GenTableColumnMapper">
|
||||
|
||||
<resultMap type="org.dromara.gen.domain.GenTableColumn" id="GenTableColumnResult">
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
@@ -0,0 +1,42 @@
|
||||
<?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="org.dromara.gen.mapper.GenTableMapper">
|
||||
|
||||
<!-- 多结构嵌套自动映射需带上每个实体的主键id 否则映射会失败 -->
|
||||
<resultMap type="org.dromara.gen.domain.GenTable" id="GenTableResult">
|
||||
<id property="tableId" column="table_id" />
|
||||
<collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="org.dromara.gen.domain.GenTableColumn" id="GenTableColumnResult">
|
||||
<id property="columnId" column="column_id"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="genSelect">
|
||||
SELECT t.table_id, t.data_name, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
||||
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
||||
FROM gen_table t
|
||||
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
||||
</sql>
|
||||
|
||||
<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
|
||||
<include refid="genSelect"/>
|
||||
where t.table_id = #{tableId} order by c.sort
|
||||
</select>
|
||||
|
||||
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
|
||||
<include refid="genSelect"/>
|
||||
where t.table_name = #{tableName} order by c.sort
|
||||
</select>
|
||||
|
||||
<select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
|
||||
<include refid="genSelect"/>
|
||||
order by c.sort
|
||||
</select>
|
||||
|
||||
<select id="selectTableNameList" resultType="java.lang.String">
|
||||
select table_name from gen_table where data_name = #{dataName,jdbcType=VARCHAR}
|
||||
</select>
|
||||
</mapper>
|
@@ -0,0 +1,3 @@
|
||||
java包使用 `.` 分割 resource 目录使用 `/` 分割
|
||||
<br>
|
||||
此文件目的 防止文件夹粘连找不到 `xml` 文件
|
@@ -0,0 +1,50 @@
|
||||
package ${packageName}.domain.bo;
|
||||
|
||||
import ${packageName}.domain.${ClassName};
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
#foreach ($import in $importList)
|
||||
import ${import};
|
||||
#end
|
||||
|
||||
/**
|
||||
* ${functionName}业务对象 ${tableName}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = ${ClassName}.class, reverseConvertGenerate = false)
|
||||
public class ${ClassName}Bo extends BaseEntity {
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if(!$table.isSuperColumn($column.javaField) && ($column.query || $column.insert || $column.edit))
|
||||
/**
|
||||
* $column.columnComment
|
||||
*/
|
||||
#if($column.insert && $column.edit)
|
||||
#set($Group="AddGroup.class, EditGroup.class")
|
||||
#elseif($column.insert)
|
||||
#set($Group="AddGroup.class")
|
||||
#elseif($column.edit)
|
||||
#set($Group="EditGroup.class")
|
||||
#end
|
||||
#if($column.required)
|
||||
#if($column.javaType == 'String')
|
||||
@NotBlank(message = "$column.columnComment不能为空", groups = { $Group })
|
||||
#else
|
||||
@NotNull(message = "$column.columnComment不能为空", groups = { $Group })
|
||||
#end
|
||||
#end
|
||||
private $column.javaType $column.javaField;
|
||||
|
||||
#end
|
||||
#end
|
||||
|
||||
}
|
@@ -0,0 +1,116 @@
|
||||
package ${packageName}.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import ${packageName}.domain.vo.${ClassName}Vo;
|
||||
import ${packageName}.domain.bo.${ClassName}Bo;
|
||||
import ${packageName}.service.I${ClassName}Service;
|
||||
#if($table.crud)
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
#elseif($table.tree)
|
||||
#end
|
||||
|
||||
/**
|
||||
* ${functionName}
|
||||
* 前端访问路由地址为:/${moduleName}/${businessName}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/${businessName}")
|
||||
public class ${ClassName}Controller extends BaseController {
|
||||
|
||||
private final I${ClassName}Service ${className}Service;
|
||||
|
||||
/**
|
||||
* 查询${functionName}列表
|
||||
*/
|
||||
@SaCheckPermission("${permissionPrefix}:list")
|
||||
@GetMapping("/list")
|
||||
#if($table.crud)
|
||||
public TableDataInfo<${ClassName}Vo> list(${ClassName}Bo bo, PageQuery pageQuery) {
|
||||
return ${className}Service.queryPageList(bo, pageQuery);
|
||||
}
|
||||
#elseif($table.tree)
|
||||
public R<List<${ClassName}Vo>> list(${ClassName}Bo bo) {
|
||||
List<${ClassName}Vo> list = ${className}Service.queryList(bo);
|
||||
return R.ok(list);
|
||||
}
|
||||
#end
|
||||
|
||||
/**
|
||||
* 导出${functionName}列表
|
||||
*/
|
||||
@SaCheckPermission("${permissionPrefix}:export")
|
||||
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(${ClassName}Bo bo, HttpServletResponse response) {
|
||||
List<${ClassName}Vo> list = ${className}Service.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "${functionName}", ${ClassName}Vo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取${functionName}详细信息
|
||||
*
|
||||
* @param ${pkColumn.javaField} 主键
|
||||
*/
|
||||
@SaCheckPermission("${permissionPrefix}:query")
|
||||
@GetMapping("/{${pkColumn.javaField}}")
|
||||
public R<${ClassName}Vo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) {
|
||||
return R.ok(${className}Service.queryById(${pkColumn.javaField}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增${functionName}
|
||||
*/
|
||||
@SaCheckPermission("${permissionPrefix}:add")
|
||||
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody ${ClassName}Bo bo) {
|
||||
return toAjax(${className}Service.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改${functionName}
|
||||
*/
|
||||
@SaCheckPermission("${permissionPrefix}:edit")
|
||||
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ${ClassName}Bo bo) {
|
||||
return toAjax(${className}Service.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField}s 主键串
|
||||
*/
|
||||
@SaCheckPermission("${permissionPrefix}:remove")
|
||||
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{${pkColumn.javaField}s}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable("${pkColumn.javaField}s") ${pkColumn.javaType}[] ${pkColumn.javaField}s) {
|
||||
return toAjax(${className}Service.deleteWithValidByIds(List.of(${pkColumn.javaField}s), true));
|
||||
}
|
||||
}
|
@@ -0,0 +1,60 @@
|
||||
package ${packageName}.domain;
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if($column.javaField=='tenantId')
|
||||
#set($IsTenant=1)
|
||||
#end
|
||||
#end
|
||||
#if($IsTenant==1)
|
||||
import org.dromara.common.tenant.core.TenantEntity;
|
||||
#else
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
#end
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
#foreach ($import in $importList)
|
||||
import ${import};
|
||||
#end
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* ${functionName}对象 ${tableName}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
#if($IsTenant==1)
|
||||
#set($Entity="TenantEntity")
|
||||
#else
|
||||
#set($Entity="BaseEntity")
|
||||
#end
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("${tableName}")
|
||||
public class ${ClassName} extends ${Entity} {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if(!$table.isSuperColumn($column.javaField))
|
||||
/**
|
||||
* $column.columnComment
|
||||
*/
|
||||
#if($column.javaField=='delFlag')
|
||||
@TableLogic
|
||||
#end
|
||||
#if($column.javaField=='version')
|
||||
@Version
|
||||
#end
|
||||
#if($column.isPk==1)
|
||||
@TableId(value = "$column.columnName")
|
||||
#end
|
||||
private $column.javaType $column.javaField;
|
||||
|
||||
#end
|
||||
#end
|
||||
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
package ${packageName}.mapper;
|
||||
|
||||
import ${packageName}.domain.${ClassName};
|
||||
import ${packageName}.domain.vo.${ClassName}Vo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* ${functionName}Mapper接口
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
public interface ${ClassName}Mapper extends BaseMapperPlus<${ClassName}, ${ClassName}Vo> {
|
||||
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
package ${packageName}.service;
|
||||
|
||||
import ${packageName}.domain.${ClassName};
|
||||
import ${packageName}.domain.vo.${ClassName}Vo;
|
||||
import ${packageName}.domain.bo.${ClassName}Bo;
|
||||
#if($table.crud)
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
#end
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ${functionName}Service接口
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
public interface I${ClassName}Service {
|
||||
|
||||
/**
|
||||
* 查询${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField} 主键
|
||||
* @return ${functionName}
|
||||
*/
|
||||
${ClassName}Vo queryById(${pkColumn.javaType} ${pkColumn.javaField});
|
||||
|
||||
#if($table.crud)
|
||||
/**
|
||||
* 分页查询${functionName}列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return ${functionName}分页列表
|
||||
*/
|
||||
TableDataInfo<${ClassName}Vo> queryPageList(${ClassName}Bo bo, PageQuery pageQuery);
|
||||
#end
|
||||
|
||||
/**
|
||||
* 查询符合条件的${functionName}列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return ${functionName}列表
|
||||
*/
|
||||
List<${ClassName}Vo> queryList(${ClassName}Bo bo);
|
||||
|
||||
/**
|
||||
* 新增${functionName}
|
||||
*
|
||||
* @param bo ${functionName}
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(${ClassName}Bo bo);
|
||||
|
||||
/**
|
||||
* 修改${functionName}
|
||||
*
|
||||
* @param bo ${functionName}
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(${ClassName}Bo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除${functionName}信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<${pkColumn.javaType}> ids, Boolean isValid);
|
||||
}
|
@@ -0,0 +1,160 @@
|
||||
package ${packageName}.service.impl;
|
||||
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
#if($table.crud)
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
#end
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ${packageName}.domain.bo.${ClassName}Bo;
|
||||
import ${packageName}.domain.vo.${ClassName}Vo;
|
||||
import ${packageName}.domain.${ClassName};
|
||||
import ${packageName}.mapper.${ClassName}Mapper;
|
||||
import ${packageName}.service.I${ClassName}Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* ${functionName}Service业务层处理
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class ${ClassName}ServiceImpl implements I${ClassName}Service {
|
||||
|
||||
private final ${ClassName}Mapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询${functionName}
|
||||
*
|
||||
* @param ${pkColumn.javaField} 主键
|
||||
* @return ${functionName}
|
||||
*/
|
||||
@Override
|
||||
public ${ClassName}Vo queryById(${pkColumn.javaType} ${pkColumn.javaField}){
|
||||
return baseMapper.selectVoById(${pkColumn.javaField});
|
||||
}
|
||||
|
||||
#if($table.crud)
|
||||
/**
|
||||
* 分页查询${functionName}列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return ${functionName}分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<${ClassName}Vo> queryPageList(${ClassName}Bo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<${ClassName}> lqw = buildQueryWrapper(bo);
|
||||
Page<${ClassName}Vo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
#end
|
||||
|
||||
/**
|
||||
* 查询符合条件的${functionName}列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return ${functionName}列表
|
||||
*/
|
||||
@Override
|
||||
public List<${ClassName}Vo> queryList(${ClassName}Bo bo) {
|
||||
LambdaQueryWrapper<${ClassName}> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<${ClassName}> buildQueryWrapper(${ClassName}Bo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<${ClassName}> lqw = Wrappers.lambdaQuery();
|
||||
#foreach($column in $columns)
|
||||
#if($column.query)
|
||||
#set($queryType=$column.queryType)
|
||||
#set($javaField=$column.javaField)
|
||||
#set($javaType=$column.javaType)
|
||||
#set($columnName=$column.columnName)
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#set($mpMethod=$column.queryType.toLowerCase())
|
||||
#if($queryType != 'BETWEEN')
|
||||
#if($javaType == 'String')
|
||||
#set($condition='StringUtils.isNotBlank(bo.get'+$AttrName+'())')
|
||||
#else
|
||||
#set($condition='bo.get'+$AttrName+'() != null')
|
||||
#end
|
||||
lqw.$mpMethod($condition, ${ClassName}::get$AttrName, bo.get$AttrName());
|
||||
#else
|
||||
lqw.between(params.get("begin$AttrName") != null && params.get("end$AttrName") != null,
|
||||
${ClassName}::get$AttrName ,params.get("begin$AttrName"), params.get("end$AttrName"));
|
||||
#end
|
||||
#end
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#if($column.isPk==1)
|
||||
lqw.orderByAsc(${ClassName}::get$AttrName);
|
||||
#end
|
||||
#end
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增${functionName}
|
||||
*
|
||||
* @param bo ${functionName}
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(${ClassName}Bo bo) {
|
||||
${ClassName} add = MapstructUtils.convert(bo, ${ClassName}.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
#set($pk=$pkColumn.javaField.substring(0,1).toUpperCase() + ${pkColumn.javaField.substring(1)})
|
||||
if (flag) {
|
||||
bo.set$pk(add.get$pk());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改${functionName}
|
||||
*
|
||||
* @param bo ${functionName}
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(${ClassName}Bo bo) {
|
||||
${ClassName} update = MapstructUtils.convert(bo, ${ClassName}.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(${ClassName} entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除${functionName}信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<${pkColumn.javaType}> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
package ${packageName}.domain.vo;
|
||||
|
||||
#foreach ($import in $importList)
|
||||
import ${import};
|
||||
#end
|
||||
import ${packageName}.domain.${ClassName};
|
||||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* ${functionName}视图对象 ${tableName}
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = ${ClassName}.class)
|
||||
public class ${ClassName}Vo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if($column.list)
|
||||
/**
|
||||
* $column.columnComment
|
||||
*/
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if(${column.dictType} && ${column.dictType} != '')
|
||||
@ExcelProperty(value = "${comment}", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(dictType = "${column.dictType}")
|
||||
#elseif($parentheseIndex != -1)
|
||||
@ExcelProperty(value = "${comment}", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "$column.readConverterExp()")
|
||||
#else
|
||||
@ExcelProperty(value = "${comment}")
|
||||
#end
|
||||
private $column.javaType $column.javaField;
|
||||
|
||||
#if($column.htmlType == "imageUpload")
|
||||
/**
|
||||
* ${column.columnComment}Url
|
||||
*/
|
||||
@Translation(type = TransConstant.OSS_ID_TO_URL, mapper = "${column.javaField}")
|
||||
private String ${column.javaField}Url;
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
-- 菜单 SQL
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(${table.menuIds[0]}, '${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 103, 1, sysdate, null, null, '${functionName}菜单');
|
||||
|
||||
-- 按钮 SQL
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(${table.menuIds[1]}, '${functionName}查询', ${table.menuIds[0]}, '1', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query', '#', 103, 1, sysdate, null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(${table.menuIds[2]}, '${functionName}新增', ${table.menuIds[0]}, '2', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:add', '#', 103, 1, sysdate, null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(${table.menuIds[3]}, '${functionName}修改', ${table.menuIds[0]}, '3', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:edit', '#', 103, 1, sysdate, null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(${table.menuIds[4]}, '${functionName}删除', ${table.menuIds[0]}, '4', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove', '#', 103, 1, sysdate, null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(${table.menuIds[5]}, '${functionName}导出', ${table.menuIds[0]}, '5', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export', '#', 103, 1, sysdate, null, null, '');
|
@@ -0,0 +1,20 @@
|
||||
-- 菜单 SQL
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(${table.menuIds[0]}, '${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 103, 1, now(), null, null, '${functionName}菜单');
|
||||
|
||||
-- 按钮 SQL
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(${table.menuIds[1]}, '${functionName}查询', ${table.menuIds[0]}, '1', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query', '#', 103, 1, now(), null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(${table.menuIds[2]}, '${functionName}新增', ${table.menuIds[0]}, '2', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:add', '#', 103, 1, now(), null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(${table.menuIds[3]}, '${functionName}修改', ${table.menuIds[0]}, '3', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:edit', '#', 103, 1, now(), null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(${table.menuIds[4]}, '${functionName}删除', ${table.menuIds[0]}, '4', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove', '#', 103, 1, now(), null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(${table.menuIds[5]}, '${functionName}导出', ${table.menuIds[0]}, '5', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export', '#', 103, 1, now(), null, null, '');
|
||||
|
19
ruoyi-modules/ruoyi-gen/src/main/resources/vm/sql/sql.vm
Normal file
19
ruoyi-modules/ruoyi-gen/src/main/resources/vm/sql/sql.vm
Normal file
@@ -0,0 +1,19 @@
|
||||
-- 菜单 SQL
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(${table.menuIds[0]}, '${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 103, 1, sysdate(), null, null, '${functionName}菜单');
|
||||
|
||||
-- 按钮 SQL
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(${table.menuIds[1]}, '${functionName}查询', ${table.menuIds[0]}, '1', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(${table.menuIds[2]}, '${functionName}新增', ${table.menuIds[0]}, '2', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:add', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(${table.menuIds[3]}, '${functionName}修改', ${table.menuIds[0]}, '3', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:edit', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(${table.menuIds[4]}, '${functionName}删除', ${table.menuIds[0]}, '4', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove', '#', 103, 1, sysdate(), null, null, '');
|
||||
|
||||
insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark)
|
||||
values(${table.menuIds[5]}, '${functionName}导出', ${table.menuIds[0]}, '5', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export', '#', 103, 1, sysdate(), null, null, '');
|
63
ruoyi-modules/ruoyi-gen/src/main/resources/vm/ts/api.ts.vm
Normal file
63
ruoyi-modules/ruoyi-gen/src/main/resources/vm/ts/api.ts.vm
Normal file
@@ -0,0 +1,63 @@
|
||||
import request from '@/utils/request';
|
||||
import { AxiosPromise } from 'axios';
|
||||
import { ${BusinessName}VO, ${BusinessName}Form, ${BusinessName}Query } from '@/api/${moduleName}/${businessName}/types';
|
||||
|
||||
/**
|
||||
* 查询${functionName}列表
|
||||
* @param query
|
||||
* @returns {*}
|
||||
*/
|
||||
|
||||
export const list${BusinessName} = (query?: ${BusinessName}Query): AxiosPromise<${BusinessName}VO[]> => {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 查询${functionName}详细
|
||||
* @param ${pkColumn.javaField}
|
||||
*/
|
||||
export const get${BusinessName} = (${pkColumn.javaField}: string | number): AxiosPromise<${BusinessName}VO> => {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
|
||||
method: 'get'
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 新增${functionName}
|
||||
* @param data
|
||||
*/
|
||||
export const add${BusinessName} = (data: ${BusinessName}Form) => {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}',
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 修改${functionName}
|
||||
* @param data
|
||||
*/
|
||||
export const update${BusinessName} = (data: ${BusinessName}Form) => {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}',
|
||||
method: 'put',
|
||||
data: data
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除${functionName}
|
||||
* @param ${pkColumn.javaField}
|
||||
*/
|
||||
export const del${BusinessName} = (${pkColumn.javaField}: string | number | Array<string | number>) => {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
|
||||
method: 'delete'
|
||||
});
|
||||
};
|
64
ruoyi-modules/ruoyi-gen/src/main/resources/vm/ts/types.ts.vm
Normal file
64
ruoyi-modules/ruoyi-gen/src/main/resources/vm/ts/types.ts.vm
Normal file
@@ -0,0 +1,64 @@
|
||||
export interface ${BusinessName}VO {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.list)
|
||||
/**
|
||||
* $column.columnComment
|
||||
*/
|
||||
$column.javaField:#if($column.javaField.indexOf("id") != -1 || $column.javaField.indexOf("Id") != -1) string | number;
|
||||
#elseif($column.javaType == 'Long' || $column.javaType == 'Integer' || $column.javaType == 'Double' || $column.javaType == 'Float' || $column.javaType == 'BigDecimal') number;
|
||||
#elseif($column.javaType == 'Boolean') boolean;
|
||||
#else string;
|
||||
#end
|
||||
#if($column.htmlType == "imageUpload")
|
||||
/**
|
||||
* ${column.columnComment}Url
|
||||
*/
|
||||
${column.javaField}Url: string;
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#if ($table.tree)
|
||||
/**
|
||||
* 子对象
|
||||
*/
|
||||
children: ${BusinessName}VO[];
|
||||
#end
|
||||
}
|
||||
|
||||
export interface ${BusinessName}Form extends BaseEntity {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.insert || $column.edit)
|
||||
/**
|
||||
* $column.columnComment
|
||||
*/
|
||||
$column.javaField?:#if($column.javaField.indexOf("id") != -1 || $column.javaField.indexOf("Id") != -1) string | number;
|
||||
#elseif($column.javaType == 'Long' || $column.javaType == 'Integer' || $column.javaType == 'Double' || $column.javaType == 'Float' || $column.javaType == 'BigDecimal') number;
|
||||
#elseif($column.javaType == 'Boolean') boolean;
|
||||
#else string;
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
|
||||
export interface ${BusinessName}Query #if(!${treeCode})extends PageQuery #end{
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if($column.query)
|
||||
/**
|
||||
* $column.columnComment
|
||||
*/
|
||||
$column.javaField?:#if($column.javaField.indexOf("id") != -1 || $column.javaField.indexOf("Id") != -1) string | number;
|
||||
#elseif($column.javaType == 'Long' || $column.javaType == 'Integer' || $column.javaType == 'Double' || $column.javaType == 'Float' || $column.javaType == 'BigDecimal') number;
|
||||
#elseif($column.javaType == 'Boolean') boolean;
|
||||
#else string;
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
/**
|
||||
* 日期范围参数
|
||||
*/
|
||||
params?: any;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -0,0 +1,69 @@
|
||||
import type { ${BusinessName}VO, ${BusinessName}Form, ${BusinessName}Query } from './model';
|
||||
|
||||
import type { ID, IDS } from '#/api/common';
|
||||
#if($tplCategory != 'tree')
|
||||
import type { PageResult } from '#/api/common';
|
||||
#end
|
||||
|
||||
import { commonExport } from '#/api/helper';
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
/**
|
||||
* 查询${functionName}列表
|
||||
* @param params
|
||||
* @returns ${functionName}列表
|
||||
*/
|
||||
export function ${businessName}List(params?: ${BusinessName}Query) {
|
||||
#if($tplCategory != 'tree')
|
||||
return requestClient.get<PageResult<${BusinessName}VO>>('/${moduleName}/${businessName}/list', { params });
|
||||
#else
|
||||
return requestClient.get<${BusinessName}VO[]>(`/${moduleName}/${businessName}/list`, { params });
|
||||
#end
|
||||
}
|
||||
|
||||
#if($tplCategory != 'tree')
|
||||
/**
|
||||
* 导出${functionName}列表
|
||||
* @param params
|
||||
* @returns ${functionName}列表
|
||||
*/
|
||||
export function ${businessName}Export(params?: ${BusinessName}Query) {
|
||||
return commonExport('/${moduleName}/${businessName}/export', params ?? {});
|
||||
}
|
||||
#end
|
||||
|
||||
/**
|
||||
* 查询${functionName}详情
|
||||
* @param ${pkColumn.javaField} id
|
||||
* @returns ${functionName}详情
|
||||
*/
|
||||
export function ${businessName}Info(${pkColumn.javaField}: ID) {
|
||||
return requestClient.get<${BusinessName}VO>(`/${moduleName}/${businessName}/${${pkColumn.javaField}}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增${functionName}
|
||||
* @param data
|
||||
* @returns void
|
||||
*/
|
||||
export function ${businessName}Add(data: ${BusinessName}Form) {
|
||||
return requestClient.postWithMsg<void>('/${moduleName}/${businessName}', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新${functionName}
|
||||
* @param data
|
||||
* @returns void
|
||||
*/
|
||||
export function ${businessName}Update(data: ${BusinessName}Form) {
|
||||
return requestClient.putWithMsg<void>('/${moduleName}/${businessName}', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除${functionName}
|
||||
* @param ${pkColumn.javaField} id
|
||||
* @returns void
|
||||
*/
|
||||
export function ${businessName}Remove(${pkColumn.javaField}: ID | IDS) {
|
||||
return requestClient.deleteWithMsg<void>(`/${moduleName}/${businessName}/${${pkColumn.javaField}}`);
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
import type { PageQuery, BaseEntity } from '#/api/common';
|
||||
|
||||
export interface ${BusinessName}VO {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.list)
|
||||
/**
|
||||
* $column.columnComment
|
||||
*/
|
||||
$column.javaField:#if($column.javaField.indexOf("id") != -1 || $column.javaField.indexOf("Id") != -1) string | number;
|
||||
#elseif($column.javaType == 'Long' || $column.javaType == 'Integer' || $column.javaType == 'Double' || $column.javaType == 'Float' || $column.javaType == 'BigDecimal') number;
|
||||
#elseif($column.javaType == 'Boolean') boolean;
|
||||
#else string;
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#if ($table.tree)
|
||||
/**
|
||||
* 子对象
|
||||
*/
|
||||
children: ${BusinessName}VO[];
|
||||
#end
|
||||
}
|
||||
|
||||
export interface ${BusinessName}Form extends BaseEntity {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.insert || $column.edit)
|
||||
/**
|
||||
* $column.columnComment
|
||||
*/
|
||||
$column.javaField?:#if($column.javaField.indexOf("id") != -1 || $column.javaField.indexOf("Id") != -1) string | number;
|
||||
#elseif($column.javaType == 'Long' || $column.javaType == 'Integer' || $column.javaType == 'Double' || $column.javaType == 'Float' || $column.javaType == 'BigDecimal') number;
|
||||
#elseif($column.javaType == 'Boolean') boolean;
|
||||
#else string;
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
|
||||
export interface ${BusinessName}Query #if(!${treeCode})extends PageQuery #end{
|
||||
#foreach ($column in $columns)
|
||||
#if($column.query)
|
||||
/**
|
||||
* $column.columnComment
|
||||
*/
|
||||
$column.javaField?:#if($column.javaField.indexOf("id") != -1 || $column.javaField.indexOf("Id") != -1) string | number;
|
||||
#elseif($column.javaType == 'Long' || $column.javaType == 'Integer' || $column.javaType == 'Double' || $column.javaType == 'Float' || $column.javaType == 'BigDecimal') number;
|
||||
#elseif($column.javaType == 'Boolean') boolean;
|
||||
#else string;
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
/**
|
||||
* 日期范围参数
|
||||
*/
|
||||
params?: any;
|
||||
}
|
@@ -0,0 +1,215 @@
|
||||
import type { FormSchemaGetter } from '#/adapter/form';
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
|
||||
#if(${dicts} != '')
|
||||
import { getDictOptions } from '#/utils/dict';
|
||||
import { renderDict } from '#/utils/render';
|
||||
#end
|
||||
|
||||
export const querySchema: FormSchemaGetter = () => [
|
||||
#foreach($column in $columns)
|
||||
#if($column.query)
|
||||
#if($column.dictType)
|
||||
#set($dictType=$column.dictType)
|
||||
#else
|
||||
#set($dictType="")
|
||||
#end
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if($column.htmlType == "input")
|
||||
#set($component="Input")
|
||||
#elseif($column.htmlType == "textarea")
|
||||
#set($component="Textarea")
|
||||
#elseif($column.htmlType == "select")
|
||||
#set($component="Select")
|
||||
#elseif($column.htmlType == "radio")
|
||||
#set($component="RadioGroup")
|
||||
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
||||
#set($component="DatePicker")
|
||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($component="RangePicker")
|
||||
#else
|
||||
#set($component="Input")
|
||||
#end
|
||||
{
|
||||
component: '${component}',
|
||||
#if($component == "Select" || $component == "RadioGroup")
|
||||
componentProps: {
|
||||
#if($dictType != "")
|
||||
// 可选从DictEnum中获取 DictEnum.${dictType.toUpperCase()} 便于维护
|
||||
options: getDictOptions('$dictType'),
|
||||
#end
|
||||
#if($component == "RadioGroup")
|
||||
buttonStyle: 'solid',
|
||||
optionType: 'button',
|
||||
#end
|
||||
},
|
||||
#elseif($component == "DatePicker" || $component == "RangePicker")
|
||||
componentProps: {
|
||||
showTime: true,
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||
},
|
||||
#end
|
||||
fieldName: '${column.javaField}',
|
||||
label: '${comment}',
|
||||
},
|
||||
#end
|
||||
#end
|
||||
];
|
||||
|
||||
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
|
||||
// export const columns: () => VxeGridProps['columns'] = () => [
|
||||
export const columns: VxeGridProps['columns'] = [
|
||||
#if($tplCategory != 'tree')
|
||||
{ type: 'checkbox', width: 60 },
|
||||
#end
|
||||
#foreach($column in $columns)
|
||||
#if($column.list)
|
||||
#if($column.dictType)
|
||||
#set($dictType=$column.dictType)
|
||||
#else
|
||||
#set($dictType="")
|
||||
#end
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
{
|
||||
title: '${comment}',
|
||||
field: '${column.javaField}',
|
||||
#if( $foreach.count == 1 && $tplCategory == 'tree')
|
||||
treeNode: true,
|
||||
#end
|
||||
#if($dictType != "")
|
||||
slots: {
|
||||
default: ({ row }) => {
|
||||
// 可选从DictEnum中获取 DictEnum.${dictType.toUpperCase()} 便于维护
|
||||
return renderDict(row.${column.javaField}, '$dictType');
|
||||
},
|
||||
},
|
||||
#end
|
||||
},
|
||||
#end
|
||||
#end
|
||||
{
|
||||
field: 'action',
|
||||
fixed: 'right',
|
||||
slots: { default: 'action' },
|
||||
title: '操作',
|
||||
width: 180,
|
||||
},
|
||||
];
|
||||
|
||||
#if($formComponent == "useForm")
|
||||
export const ${popupComponent}Schema: FormSchemaGetter = () => [
|
||||
#foreach($column in $columns)
|
||||
#if($column.edit)
|
||||
#if($column.dictType)
|
||||
#set($dictType=$column.dictType)
|
||||
#else
|
||||
#set($dictType="")
|
||||
#end
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if($column.htmlType == "input")
|
||||
#set($component="Input")
|
||||
#elseif($column.htmlType == "textarea")
|
||||
#set($component="Textarea")
|
||||
#elseif($column.htmlType == "select")
|
||||
#set($component="Select")
|
||||
#elseif($column.htmlType == "radio")
|
||||
#set($component="RadioGroup")
|
||||
#elseif($column.htmlType == "checkbox")
|
||||
#set($component="Checkbox")
|
||||
#elseif($column.htmlType == "imageUpload")
|
||||
#set($component="ImageUpload")
|
||||
#elseif($column.htmlType == "fileUpload")
|
||||
#set($component="FileUpload")
|
||||
#elseif($column.htmlType == "editor")
|
||||
#set($component="RichTextarea")
|
||||
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
||||
#set($component="DatePicker")
|
||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($component="RangePicker")
|
||||
#else
|
||||
#set($component="Input")
|
||||
#end
|
||||
#if($column.required && $column.pk == false)
|
||||
#set($required='true')
|
||||
#else
|
||||
#set($required='false')
|
||||
#end
|
||||
{
|
||||
label: '${comment}',
|
||||
fieldName: '${column.javaField}',
|
||||
#if("" != $treeParentCode && $column.javaField == $treeParentCode)
|
||||
component: 'TreeSelect',
|
||||
#else
|
||||
component: '${component}',
|
||||
#end
|
||||
#if($component == "DatePicker" || $component == "RangePicker")
|
||||
componentProps: {
|
||||
showTime: true,
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||
},
|
||||
#elseif($component == "ImageUpload")
|
||||
componentProps: {
|
||||
// accept: 'image/*', // 可选拓展名或者mime类型 ,拼接
|
||||
// maxCount: 1, // 最大上传文件数 默认为1 为1会绑定为string而非string[]类型
|
||||
},
|
||||
#elseif($component == "FileUpload")
|
||||
/**
|
||||
* 注意这里获取为数组 需要自行定义回显/提交
|
||||
* 文件上传还在demo阶段 可能有重大改动!
|
||||
*/
|
||||
componentProps: {
|
||||
// accept: 'application/pdf', // 可选拓展名或者mime类型 ,拼接
|
||||
// maxCount: 1, // 最大上传文件数 默认为1 为1会绑定为string而非string[]类型
|
||||
},
|
||||
#elseif($component == "RichTextarea")
|
||||
componentProps: {
|
||||
// disabled: false, // 是否只读
|
||||
// height: 400 // 高度 默认400
|
||||
},
|
||||
#elseif($component == "Select" || $component == "RadioGroup" || $component == "Checkbox")
|
||||
componentProps: {
|
||||
#if($dictType != "")
|
||||
// 可选从DictEnum中获取 DictEnum.${dictType.toUpperCase()} 便于维护
|
||||
options: getDictOptions('$dictType'),
|
||||
#end
|
||||
#if($component == "RadioGroup")
|
||||
buttonStyle: 'solid',
|
||||
optionType: 'button',
|
||||
#end
|
||||
},
|
||||
#end
|
||||
#if(${column.pk})
|
||||
dependencies: {
|
||||
show: () => false,
|
||||
triggerFields: [''],
|
||||
},
|
||||
#end
|
||||
#if($required == 'true' && $column.pk == false)
|
||||
#if($component == "Select" || $component == "RadioGroup" || $component == "Checkbox")
|
||||
rules: 'selectRequired',
|
||||
#else
|
||||
rules: 'required',
|
||||
#end
|
||||
#end
|
||||
},
|
||||
#end
|
||||
#end
|
||||
];
|
||||
#end
|
@@ -0,0 +1,182 @@
|
||||
<script setup lang="ts">
|
||||
import type { Recordable } from '@vben/types';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { Page, useVben${PopupComponent}, type VbenFormProps } from '@vben/common-ui';
|
||||
import { getVxePopupContainer } from '@vben/utils';
|
||||
|
||||
import { Modal, Popconfirm, Space } from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import {
|
||||
useVbenVxeGrid,
|
||||
vxeCheckboxChecked,
|
||||
type VxeGridProps
|
||||
} from '#/adapter/vxe-table';
|
||||
|
||||
import {
|
||||
${businessName}Export,
|
||||
${businessName}List,
|
||||
${businessName}Remove,
|
||||
} from '#/api/${moduleName}/${businessName}';
|
||||
import type { ${BusinessName}Form } from '#/api/${moduleName}/${businessName}/model';
|
||||
import { commonDownloadExcel } from '#/utils/file/download';
|
||||
|
||||
import ${businessName}${PopupComponent} from './${businessName}-${popupComponent}.vue';
|
||||
import { columns, querySchema } from './data';
|
||||
|
||||
const formOptions: VbenFormProps = {
|
||||
commonConfig: {
|
||||
labelWidth: 80,
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
schema: querySchema(),
|
||||
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
|
||||
// 处理区间选择器RangePicker时间格式 将一个字段映射为两个字段 搜索/导出会用到
|
||||
// 不需要直接删除
|
||||
// fieldMappingTime: [
|
||||
// [
|
||||
// 'createTime',
|
||||
// ['params[beginTime]', 'params[endTime]'],
|
||||
// ['YYYY-MM-DD 00:00:00', 'YYYY-MM-DD 23:59:59'],
|
||||
// ],
|
||||
// ],
|
||||
};
|
||||
|
||||
const gridOptions: VxeGridProps = {
|
||||
checkboxConfig: {
|
||||
// 高亮
|
||||
highlight: true,
|
||||
// 翻页时保留选中状态
|
||||
reserve: true,
|
||||
// 点击行选中
|
||||
// trigger: 'row',
|
||||
},
|
||||
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
|
||||
// columns: columns(),
|
||||
columns,
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
pagerConfig: {},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues = {}) => {
|
||||
return await ${businessName}List({
|
||||
pageNum: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: '${pkColumn.javaField}',
|
||||
},
|
||||
// 表格全局唯一表示 保存列配置需要用到
|
||||
id: '${moduleName}-${businessName}-index'
|
||||
};
|
||||
|
||||
const [BasicTable, tableApi] = useVbenVxeGrid({
|
||||
formOptions,
|
||||
gridOptions,
|
||||
});
|
||||
|
||||
const [${BusinessName}${PopupComponent}, ${popupComponent}Api] = useVben${PopupComponent}({
|
||||
connectedComponent: ${businessName}${PopupComponent},
|
||||
});
|
||||
|
||||
function handleAdd() {
|
||||
${popupComponent}Api.setData({});
|
||||
${popupComponent}Api.open();
|
||||
}
|
||||
|
||||
async function handleEdit(row: Required<${BusinessName}Form>) {
|
||||
${popupComponent}Api.setData({ id: row.${pkColumn.javaField} });
|
||||
${popupComponent}Api.open();
|
||||
}
|
||||
|
||||
async function handleDelete(row: Required<${BusinessName}Form>) {
|
||||
await ${businessName}Remove(row.${pkColumn.javaField});
|
||||
await tableApi.query();
|
||||
}
|
||||
|
||||
function handleMultiDelete() {
|
||||
const rows = tableApi.grid.getCheckboxRecords();
|
||||
const ids = rows.map((row: Required<${BusinessName}Form>) => row.${pkColumn.javaField});
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
okType: 'danger',
|
||||
content: `确认删除选中的${ids.length}条记录吗?`,
|
||||
onOk: async () => {
|
||||
await ${businessName}Remove(ids);
|
||||
await tableApi.query();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function handleDownloadExcel() {
|
||||
commonDownloadExcel(${businessName}Export, '${functionName}数据', tableApi.formApi.form.values, {
|
||||
fieldMappingTime: formOptions.fieldMappingTime,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page :auto-content-height="true">
|
||||
<BasicTable table-title="${functionName}列表">
|
||||
<template #toolbar-tools>
|
||||
<Space>
|
||||
<a-button
|
||||
v-access:code="['${permissionPrefix}:export']"
|
||||
@click="handleDownloadExcel"
|
||||
>
|
||||
{{ $t('pages.common.export') }}
|
||||
</a-button>
|
||||
<a-button
|
||||
:disabled="!vxeCheckboxChecked(tableApi)"
|
||||
danger
|
||||
type="primary"
|
||||
v-access:code="['${permissionPrefix}:remove']"
|
||||
@click="handleMultiDelete">
|
||||
{{ $t('pages.common.delete') }}
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
v-access:code="['${permissionPrefix}:add']"
|
||||
@click="handleAdd"
|
||||
>
|
||||
{{ $t('pages.common.add') }}
|
||||
</a-button>
|
||||
</Space>
|
||||
</template>
|
||||
<template #action="{ row }">
|
||||
<Space>
|
||||
<ghost-button
|
||||
v-access:code="['${permissionPrefix}:edit']"
|
||||
@click.stop="handleEdit(row)"
|
||||
>
|
||||
{{ $t('pages.common.edit') }}
|
||||
</ghost-button>
|
||||
<Popconfirm
|
||||
:get-popup-container="getVxePopupContainer"
|
||||
placement="left"
|
||||
title="确认删除?"
|
||||
@confirm="handleDelete(row)"
|
||||
>
|
||||
<ghost-button
|
||||
danger
|
||||
v-access:code="['${permissionPrefix}:remove']"
|
||||
@click.stop=""
|
||||
>
|
||||
{{ $t('pages.common.delete') }}
|
||||
</ghost-button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<${BusinessName}${PopupComponent} @reload="tableApi.query()" />
|
||||
</Page>
|
||||
</template>
|
@@ -0,0 +1,152 @@
|
||||
<script setup lang="ts">
|
||||
import type { Recordable } from '@vben/types';
|
||||
|
||||
import { nextTick } from 'vue';
|
||||
|
||||
import { Page, useVben${PopupComponent}, type VbenFormProps } from '@vben/common-ui';
|
||||
import { getVxePopupContainer } from '@vben/utils';
|
||||
|
||||
import { Popconfirm, Space } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid, type VxeGridProps } from '#/adapter/vxe-table';
|
||||
import { ${businessName}List, ${businessName}Remove } from '#/api/${moduleName}/${businessName}';
|
||||
import type { ${BusinessName}Form } from '#/api/${moduleName}/${businessName}/model';
|
||||
|
||||
import { columns, querySchema } from './data';
|
||||
import ${businessName}${PopupComponent} from './${businessName}-${popupComponent}.vue';
|
||||
|
||||
const formOptions: VbenFormProps = {
|
||||
commonConfig: {
|
||||
labelWidth: 80,
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
schema: querySchema(),
|
||||
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
|
||||
};
|
||||
|
||||
const gridOptions: VxeGridProps = {
|
||||
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
|
||||
// columns: columns(),
|
||||
columns,
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
pagerConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async (_, formValues = {}) => {
|
||||
const resp = await ${businessName}List({
|
||||
...formValues,
|
||||
});
|
||||
return { rows: resp };
|
||||
},
|
||||
// 默认请求接口后展开全部 不需要可以删除这段
|
||||
querySuccess: () => {
|
||||
nextTick(() => {
|
||||
expandAll();
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: '${pkColumn.javaField}',
|
||||
},
|
||||
/**
|
||||
* 虚拟滚动开关 默认关闭
|
||||
* 数据量小可以选择关闭
|
||||
* 如果遇到样式问题(空白、错位 滚动等)可以选择关闭虚拟滚动
|
||||
*/
|
||||
scrollY: {
|
||||
enabled: false,
|
||||
gt: 0,
|
||||
},
|
||||
treeConfig: {
|
||||
parentField: '${treeParentCode}',
|
||||
rowField: '${treeCode}',
|
||||
// 自动转换为tree 由vxe处理 无需手动转换
|
||||
transform: true,
|
||||
},
|
||||
// 表格全局唯一表示 保存列配置需要用到
|
||||
id: '${moduleName}-${businessName}-index'
|
||||
};
|
||||
|
||||
const [BasicTable, tableApi] = useVbenVxeGrid({ formOptions, gridOptions });
|
||||
const [${BusinessName}${PopupComponent}, ${popupComponent}Api] = useVben${PopupComponent}({
|
||||
connectedComponent: ${businessName}${PopupComponent},
|
||||
});
|
||||
|
||||
function handleAdd() {
|
||||
${popupComponent}Api.setData({});
|
||||
${popupComponent}Api.open();
|
||||
}
|
||||
|
||||
async function handleEdit(row: Required<${BusinessName}Form>) {
|
||||
${popupComponent}Api.setData({ id: row.${pkColumn.javaField} });
|
||||
${popupComponent}Api.open();
|
||||
}
|
||||
|
||||
async function handleDelete(row: Required<${BusinessName}Form>) {
|
||||
await ${businessName}Remove(row.${pkColumn.javaField});
|
||||
await tableApi.query();
|
||||
}
|
||||
|
||||
function expandAll() {
|
||||
tableApi.grid?.setAllTreeExpand(true);
|
||||
}
|
||||
|
||||
function collapseAll() {
|
||||
tableApi.grid?.setAllTreeExpand(false);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page :auto-content-height="true">
|
||||
<BasicTable table-title="${functionName}列表">
|
||||
<template #toolbar-tools>
|
||||
<Space>
|
||||
<a-button @click="collapseAll">
|
||||
{{ $t('pages.common.collapse') }}
|
||||
</a-button>
|
||||
<a-button @click="expandAll">
|
||||
{{ $t('pages.common.expand') }}
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
v-access:code="['${permissionPrefix}:add']"
|
||||
@click="handleAdd"
|
||||
>
|
||||
{{ $t('pages.common.add') }}
|
||||
</a-button>
|
||||
</Space>
|
||||
</template>
|
||||
<template #action="{ row }">
|
||||
<Space>
|
||||
<ghost-button
|
||||
v-access:code="['${permissionPrefix}:edit']"
|
||||
@click.stop="handleEdit(row)"
|
||||
>
|
||||
{{ $t('pages.common.edit') }}
|
||||
</ghost-button>
|
||||
<Popconfirm
|
||||
:get-popup-container="getVxePopupContainer"
|
||||
placement="left"
|
||||
title="确认删除?"
|
||||
@confirm="handleDelete(row)"
|
||||
>
|
||||
<ghost-button
|
||||
danger
|
||||
v-access:code="['${permissionPrefix}:remove']"
|
||||
@click.stop=""
|
||||
>
|
||||
{{ $t('pages.common.delete') }}
|
||||
</ghost-button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<${BusinessName}${PopupComponent} @reload="tableApi.query()" />
|
||||
</Page>
|
||||
</template>
|
@@ -0,0 +1,373 @@
|
||||
#if($formComponent == "useForm")
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVben${PopupComponent} } from '@vben/common-ui';
|
||||
import { $t } from '@vben/locales';
|
||||
import { cloneDeep } from '@vben/utils';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { ${businessName}Add, ${businessName}Info, ${businessName}Update } from '#/api/${moduleName}/${businessName}';
|
||||
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
|
||||
|
||||
import { ${popupComponent}Schema } from './data';
|
||||
|
||||
const emit = defineEmits<{ reload: [] }>();
|
||||
|
||||
const isUpdate = ref(false);
|
||||
const title = computed(() => {
|
||||
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add');
|
||||
});
|
||||
|
||||
const [BasicForm, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
// 默认占满两列
|
||||
formItemClass: 'col-span-2',
|
||||
// 默认label宽度 px
|
||||
labelWidth: 80,
|
||||
// 通用配置项 会影响到所有表单项
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
}
|
||||
},
|
||||
schema: ${popupComponent}Schema(),
|
||||
showDefaultActions: false,
|
||||
wrapperClass: 'grid-cols-2',
|
||||
});
|
||||
|
||||
const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
|
||||
{
|
||||
initializedGetter: defaultFormValueGetter(formApi),
|
||||
currentGetter: defaultFormValueGetter(formApi),
|
||||
},
|
||||
);
|
||||
|
||||
const [Basic${PopupComponent}, ${popupComponent}Api] = useVben${PopupComponent}({
|
||||
// 在这里更改宽度
|
||||
class: 'w-[550px]',
|
||||
fullscreenButton: false,
|
||||
onBeforeClose,
|
||||
onClosed: handleClosed,
|
||||
onConfirm: handleConfirm,
|
||||
onOpenChange: async (isOpen) => {
|
||||
if (!isOpen) {
|
||||
return null;
|
||||
}
|
||||
${popupComponent}Api.${popupComponent}Loading(true);
|
||||
|
||||
const { id } = ${popupComponent}Api.getData() as { id?: number | string };
|
||||
isUpdate.value = !!id;
|
||||
|
||||
if (isUpdate.value && id) {
|
||||
const record = await ${businessName}Info(id);
|
||||
await formApi.setValues(record);
|
||||
}
|
||||
await markInitialized();
|
||||
|
||||
${popupComponent}Api.${popupComponent}Loading(false);
|
||||
},
|
||||
});
|
||||
|
||||
async function handleConfirm() {
|
||||
try {
|
||||
${popupComponent}Api.lock(true);
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
|
||||
const data = cloneDeep(await formApi.getValues());
|
||||
await (isUpdate.value ? ${businessName}Update(data) : ${businessName}Add(data));
|
||||
resetInitialized();
|
||||
emit('reload');
|
||||
${popupComponent}Api.close();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
${popupComponent}Api.lock(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleClosed() {
|
||||
await formApi.resetForm();
|
||||
resetInitialized();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Basic${PopupComponent} :title="title">
|
||||
<BasicForm />
|
||||
</Basic${PopupComponent}>
|
||||
</template>
|
||||
#else
|
||||
<!--
|
||||
使用antd原生Form生成 详细用法参考ant-design-vue Form组件文档
|
||||
vscode默认配置文件会自动格式化/移除未使用依赖
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import type { RuleObject } from 'ant-design-vue/es/form';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { Input, Textarea, Select, RadioGroup, CheckboxGroup, DatePicker, Form, FormItem } from 'ant-design-vue';
|
||||
import { ImageUpload, FileUpload } from '#/components/upload';
|
||||
import { Tinymce } from '#/components/tinymce';
|
||||
import { getPopupContainer } from '@vben/utils';
|
||||
import { pick } from 'lodash-es';
|
||||
|
||||
#if(${dicts} != '')
|
||||
import { getDictOptions } from '#/utils/dict';
|
||||
#end
|
||||
|
||||
import { useVben${PopupComponent} } from '@vben/common-ui';
|
||||
import { $t } from '@vben/locales';
|
||||
import { cloneDeep } from '@vben/utils';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { ${businessName}Add, ${businessName}Info, ${businessName}Update } from '#/api/${moduleName}/${businessName}';
|
||||
import type { ${BusinessName}Form } from '#/api/${moduleName}/${businessName}/model';
|
||||
import { useBeforeCloseDiff } from '#/utils/popup';
|
||||
|
||||
const emit = defineEmits<{ reload: [] }>();
|
||||
|
||||
const isUpdate = ref(false);
|
||||
const title = computed(() => {
|
||||
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add');
|
||||
});
|
||||
|
||||
/**
|
||||
* 定义默认值 用于reset
|
||||
*/
|
||||
const defaultValues: Partial<${BusinessName}Form> = {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.insert || $column.edit)
|
||||
#if($column.htmlType == "checkbox")
|
||||
$column.javaField: []#if($foreach.count != $columns.size()),#end
|
||||
#else
|
||||
$column.javaField: undefined#if($foreach.count != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单数据ref
|
||||
*/
|
||||
const formData = ref(defaultValues);
|
||||
|
||||
type AntdFormRules<T> = Partial<Record<keyof T, RuleObject[]>> & {
|
||||
[key: string]: RuleObject[];
|
||||
};
|
||||
/**
|
||||
* 表单校验规则
|
||||
*/
|
||||
const formRules = ref<AntdFormRules<${BusinessName}Form>>({
|
||||
#foreach ($column in $columns)
|
||||
#if($column.insert || $column.edit)
|
||||
#if($column.required && $column.pk == false)
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
$column.javaField: [
|
||||
{ required: true, message: "$comment不能为空" }
|
||||
]#if($foreach.count != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
});
|
||||
|
||||
/**
|
||||
* useForm解构出表单方法
|
||||
*/
|
||||
const { validate, validateInfos, resetFields } = Form.useForm(
|
||||
formData,
|
||||
formRules,
|
||||
);
|
||||
|
||||
function customFormValueGetter() {
|
||||
return JSON.stringify(formData.value);
|
||||
}
|
||||
|
||||
const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
|
||||
{
|
||||
initializedGetter: customFormValueGetter,
|
||||
currentGetter: customFormValueGetter,
|
||||
},
|
||||
);
|
||||
|
||||
const [Basic${PopupComponent}, ${popupComponent}Api] = useVben${PopupComponent}({
|
||||
class: 'w-[550px]',
|
||||
fullscreenButton: false,
|
||||
onBeforeClose,
|
||||
onClosed: handleClosed,
|
||||
onConfirm: handleConfirm,
|
||||
onOpenChange: async (isOpen) => {
|
||||
if (!isOpen) {
|
||||
return null;
|
||||
}
|
||||
${popupComponent}Api.${popupComponent}Loading(true);
|
||||
|
||||
const { id } = ${popupComponent}Api.getData() as { id?: number | string };
|
||||
isUpdate.value = !!id;
|
||||
|
||||
if (isUpdate.value && id) {
|
||||
const record = await ${businessName}Info(id);
|
||||
// 只赋值存在的字段
|
||||
const filterRecord = pick(record, Object.keys(defaultValues));
|
||||
formData.value = filterRecord;
|
||||
}
|
||||
await markInitialized();
|
||||
|
||||
${popupComponent}Api.${popupComponent}Loading(false);
|
||||
},
|
||||
});
|
||||
|
||||
async function handleConfirm() {
|
||||
try {
|
||||
${popupComponent}Api.lock(true);
|
||||
await validate();
|
||||
// 可能会做数据处理 使用cloneDeep深拷贝
|
||||
const data = cloneDeep(formData.value);
|
||||
await (isUpdate.value ? ${businessName}Update(data) : ${businessName}Add(data));
|
||||
resetInitialized();
|
||||
emit('reload');
|
||||
${popupComponent}Api.close();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
${popupComponent}Api.lock(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleClosed() {
|
||||
formData.value = defaultValues;
|
||||
resetFields();
|
||||
resetInitialized();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Basic${PopupComponent} :title="title">
|
||||
<Form :label-col="{ span: 4 }">
|
||||
#foreach($column in $columns)
|
||||
#set($field=$column.javaField)
|
||||
#if(($column.insert || $column.edit) && !$column.pk)
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#set($dictType=$column.dictType)
|
||||
#if($column.htmlType == "input")
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<Input v-model:value="formData.${field}" :placeholder="$t('ui.formRules.required')" />
|
||||
</FormItem>
|
||||
#elseif($column.htmlType == "imageUpload")
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<!-- props参考apps/web-antd/src/components/upload/src/props.d.ts -->
|
||||
<!-- maxCount为1(默认)时只允许上传一个文件 会自动绑定为string而非string[] -->
|
||||
<ImageUpload :max-count="1" v-model:value="formData.${field}" />
|
||||
</FormItem>
|
||||
#elseif($column.htmlType == "fileUpload")
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<!-- props参考apps/web-antd/src/components/upload/src/props.d.ts -->
|
||||
<!-- maxCount为1(默认)时只允许上传一个文件 会自动绑定为string而非string[] -->
|
||||
<FileUpload :max-count="1" v-model:value="formData.${field}" />
|
||||
</FormItem>
|
||||
#elseif($column.htmlType == "editor")
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<Tinymce
|
||||
:disabled="false"
|
||||
v-model="formData.${field}"
|
||||
/>
|
||||
</FormItem>
|
||||
#elseif($column.htmlType == "select" && "" != $dictType)
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<Select
|
||||
v-model:value="formData.${field}"
|
||||
#if($column.javaType == "Integer" || $column.javaType == "Long")
|
||||
:options="getDictOptions('$dictType', true)"
|
||||
#else
|
||||
:options="getDictOptions('$dictType')"
|
||||
#end
|
||||
:getPopupContainer="getPopupContainer"
|
||||
:placeholder="$t('ui.formRules.selectRequired')"
|
||||
/>
|
||||
</FormItem>
|
||||
#elseif($column.htmlType == "select" && "" == $dictType)
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<Select
|
||||
v-model:value="formData.${field}"
|
||||
:options="[]"
|
||||
:getPopupContainer="getPopupContainer"
|
||||
:placeholder="$t('ui.formRules.selectRequired')"
|
||||
/>
|
||||
</FormItem>
|
||||
#elseif($column.htmlType == "checkbox" && "" != $dictType)
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<CheckboxGroup
|
||||
v-model:value="formData.${field}"
|
||||
#if($column.javaType == "Integer" || $column.javaType == "Long")
|
||||
:options="getDictOptions('$dictType', true)"
|
||||
#else
|
||||
:options="getDictOptions('$dictType')"
|
||||
#end
|
||||
/>
|
||||
</FormItem>
|
||||
#elseif($column.htmlType == "checkbox" && "" == $dictType)
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<CheckboxGroup
|
||||
v-model:value="formData.${field}"
|
||||
:options="[]"
|
||||
/>
|
||||
</FormItem>
|
||||
#elseif($column.htmlType == "radio" && "" != $dictType)
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<RadioGroup
|
||||
option-type="button"
|
||||
button-style="solid"
|
||||
v-model:value="formData.${field}"
|
||||
#if($column.javaType == "Integer" || $column.javaType == "Long")
|
||||
:options="getDictOptions('$dictType', true)"
|
||||
#else
|
||||
:options="getDictOptions('$dictType')"
|
||||
#end
|
||||
/>
|
||||
</FormItem>
|
||||
#elseif($column.htmlType == "radio" && "" == $dictType)
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<RadioGroup
|
||||
option-type="button"
|
||||
button-style="solid"
|
||||
v-model:value="formData.${field}"
|
||||
:options="[]"
|
||||
/>
|
||||
</FormItem>
|
||||
#elseif($column.htmlType == "datetime")
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<!-- 需要自行调整参数 -->
|
||||
<DatePicker
|
||||
v-model:value="formData.${field}"
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
/>
|
||||
</FormItem>
|
||||
#elseif($column.htmlType == "textarea")
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<Textarea
|
||||
v-model:value="formData.${field}"
|
||||
:placeholder="$t('ui.formRules.required')"
|
||||
:rows="4"
|
||||
/>
|
||||
</FormItem>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
</Form>
|
||||
</Basic${PopupComponent}>
|
||||
</template>
|
||||
#end
|
||||
|
@@ -0,0 +1,408 @@
|
||||
#if($formComponent == "useForm")
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVben${PopupComponent} } from '@vben/common-ui';
|
||||
import { $t } from '@vben/locales';
|
||||
import { cloneDeep, getPopupContainer, listToTree } from '@vben/utils';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { ${businessName}Add, ${businessName}Info, ${businessName}List, ${businessName}Update } from '#/api/${moduleName}/${businessName}';
|
||||
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
|
||||
|
||||
import { ${popupComponent}Schema } from './data';
|
||||
|
||||
const emit = defineEmits<{ reload: [] }>();
|
||||
|
||||
const isUpdate = ref(false);
|
||||
const title = computed(() => {
|
||||
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add');
|
||||
});
|
||||
|
||||
const [BasicForm, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
// 默认占满两列
|
||||
formItemClass: 'col-span-2',
|
||||
// 默认label宽度 px
|
||||
labelWidth: 80,
|
||||
// 通用配置项 会影响到所有表单项
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
}
|
||||
},
|
||||
schema: ${popupComponent}Schema(),
|
||||
showDefaultActions: false,
|
||||
wrapperClass: 'grid-cols-2',
|
||||
});
|
||||
|
||||
async function setup${BusinessName}Select() {
|
||||
const listData = await ${businessName}List();
|
||||
const treeData = listToTree(listData, { id: '${treeCode}', pid: '${treeParentCode}' });
|
||||
formApi.updateSchema([{
|
||||
fieldName: '${treeParentCode}',
|
||||
componentProps: {
|
||||
treeData,
|
||||
treeLine: { showLeafIcon: false },
|
||||
fieldNames: { label: '${treeName}', value: '${treeCode}' },
|
||||
treeDefaultExpandAll: true,
|
||||
getPopupContainer,
|
||||
},
|
||||
}]);
|
||||
}
|
||||
|
||||
const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
|
||||
{
|
||||
initializedGetter: defaultFormValueGetter(formApi),
|
||||
currentGetter: defaultFormValueGetter(formApi),
|
||||
},
|
||||
);
|
||||
|
||||
const [Basic${PopupComponent}, ${popupComponent}Api] = useVben${PopupComponent}({
|
||||
// 在这里更改宽度
|
||||
class: 'w-[550px]',
|
||||
fullscreenButton: false,
|
||||
onBeforeClose,
|
||||
onClosed: handleClosed,
|
||||
onConfirm: handleConfirm,
|
||||
onOpenChange: async (isOpen) => {
|
||||
if (!isOpen) {
|
||||
return null;
|
||||
}
|
||||
${popupComponent}Api.${popupComponent}Loading(true);
|
||||
|
||||
const { id } = ${popupComponent}Api.getData() as { id?: number | string };
|
||||
isUpdate.value = !!id;
|
||||
|
||||
if (isUpdate.value && id) {
|
||||
const record = await ${businessName}Info(id);
|
||||
await formApi.setValues(record);
|
||||
}
|
||||
await setup${BusinessName}Select();
|
||||
await markInitialized();
|
||||
|
||||
${popupComponent}Api.${popupComponent}Loading(false);
|
||||
},
|
||||
});
|
||||
|
||||
async function handleConfirm() {
|
||||
try {
|
||||
${popupComponent}Api.lock(true);
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
|
||||
const data = cloneDeep(await formApi.getValues());
|
||||
await (isUpdate.value ? ${businessName}Update(data) : ${businessName}Add(data));
|
||||
resetInitialized();
|
||||
emit('reload');
|
||||
${popupComponent}Api.close();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
${popupComponent}Api.lock(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleClosed() {
|
||||
await formApi.resetForm();
|
||||
resetInitialized();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Basic${PopupComponent} :title="title">
|
||||
<BasicForm />
|
||||
</Basic${PopupComponent}>
|
||||
</template>
|
||||
#else
|
||||
<!--
|
||||
使用antd原生Form生成 详细用法参考ant-design-vue Form组件文档
|
||||
vscode默认配置文件会自动格式化/移除未使用依赖
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import type { RuleObject } from 'ant-design-vue/es/form';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { Input, Textarea, Select, RadioGroup, CheckboxGroup, DatePicker, Form, FormItem, TreeSelect } from 'ant-design-vue';
|
||||
import { ImageUpload, FileUpload } from '#/components/upload';
|
||||
import { Tinymce } from '#/components/tinymce';
|
||||
import { getPopupContainer } from '@vben/utils';
|
||||
import { pick } from 'lodash-es';
|
||||
|
||||
#if(${dicts} != '')
|
||||
import { getDictOptions } from '#/utils/dict';
|
||||
#end
|
||||
|
||||
import { useVben${PopupComponent} } from '@vben/common-ui';
|
||||
import { $t } from '@vben/locales';
|
||||
import { cloneDeep, listToTree } from '@vben/utils';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { ${businessName}Add, ${businessName}Info, ${businessName}List, ${businessName}Update } from '#/api/${moduleName}/${businessName}';
|
||||
import type { ${BusinessName}Form } from '#/api/${moduleName}/${businessName}/model';
|
||||
import { useBeforeCloseDiff } from '#/utils/popup';
|
||||
|
||||
const emit = defineEmits<{ reload: [] }>();
|
||||
|
||||
const isUpdate = ref(false);
|
||||
const title = computed(() => {
|
||||
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add');
|
||||
});
|
||||
|
||||
/**
|
||||
* 定义默认值 用于reset
|
||||
*/
|
||||
const defaultValues: Partial<${BusinessName}Form> = {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.insert || $column.edit)
|
||||
#if($column.htmlType == "checkbox")
|
||||
$column.javaField: []#if($foreach.count != $columns.size()),#end
|
||||
#else
|
||||
$column.javaField: undefined#if($foreach.count != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单数据ref
|
||||
*/
|
||||
const formData = ref(defaultValues);
|
||||
|
||||
type AntdFormRules<T> = Partial<Record<keyof T, RuleObject[]>> & {
|
||||
[key: string]: RuleObject[];
|
||||
};
|
||||
/**
|
||||
* 表单校验规则
|
||||
*/
|
||||
const formRules = ref<AntdFormRules<${BusinessName}Form>>({
|
||||
#foreach ($column in $columns)
|
||||
#if($column.insert || $column.edit)
|
||||
#if($column.required && $column.pk == false)
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
$column.javaField: [
|
||||
{ required: true, message: "$comment不能为空" }
|
||||
]#if($foreach.count != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
});
|
||||
|
||||
/**
|
||||
* useForm解构出表单方法
|
||||
*/
|
||||
const { validate, validateInfos, resetFields } = Form.useForm(
|
||||
formData,
|
||||
formRules,
|
||||
);
|
||||
|
||||
function customFormValueGetter() {
|
||||
return JSON.stringify(formData.value);
|
||||
}
|
||||
|
||||
const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
|
||||
{
|
||||
initializedGetter: customFormValueGetter,
|
||||
currentGetter: customFormValueGetter,
|
||||
},
|
||||
);
|
||||
|
||||
const treeData = ref<any[]>([]);
|
||||
async function setup${BusinessName}Select() {
|
||||
const listData = await ${businessName}List();
|
||||
treeData.value = listToTree(listData, { id: '${treeCode}', pid: '${treeParentCode}' });
|
||||
}
|
||||
|
||||
const [Basic${PopupComponent}, ${popupComponent}Api] = useVben${PopupComponent}({
|
||||
class: 'w-[550px]',
|
||||
fullscreenButton: false,
|
||||
onBeforeClose,
|
||||
onClosed: handleClosed,
|
||||
onConfirm: handleConfirm,
|
||||
onOpenChange: async (isOpen) => {
|
||||
if (!isOpen) {
|
||||
return null;
|
||||
}
|
||||
${popupComponent}Api.${popupComponent}Loading(true);
|
||||
|
||||
const { id } = ${popupComponent}Api.getData() as { id?: number | string };
|
||||
isUpdate.value = !!id;
|
||||
|
||||
if (isUpdate.value && id) {
|
||||
const record = await ${businessName}Info(id);
|
||||
// 只赋值存在的字段
|
||||
const filterRecord = pick(record, Object.keys(defaultValues));
|
||||
formData.value = filterRecord;
|
||||
}
|
||||
await setup${BusinessName}Select();
|
||||
await markInitialized();
|
||||
|
||||
${popupComponent}Api.${popupComponent}Loading(false);
|
||||
},
|
||||
});
|
||||
|
||||
async function handleConfirm() {
|
||||
try {
|
||||
${popupComponent}Api.lock(true);
|
||||
await validate();
|
||||
// 可能会做数据处理 使用cloneDeep深拷贝
|
||||
const data = cloneDeep(formData.value);
|
||||
await (isUpdate.value ? ${businessName}Update(data) : ${businessName}Add(data));
|
||||
resetInitialized();
|
||||
emit('reload');
|
||||
await handleCancel();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
${popupComponent}Api.lock(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleClosed() {
|
||||
formData.value = defaultValues;
|
||||
resetFields();
|
||||
resetInitialized();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Basic${PopupComponent} :title="title">
|
||||
<Form :label-col="{ span: 4 }">
|
||||
#foreach($column in $columns)
|
||||
#set($field=$column.javaField)
|
||||
#if(($column.insert || $column.edit) && !$column.pk)
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#set($dictType=$column.dictType)
|
||||
#if("" != $treeParentCode && $column.javaField == $treeParentCode)
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<TreeSelect
|
||||
v-model:value="formData.${treeParentCode}"
|
||||
:treeData="treeData"
|
||||
:tree-line="{ showLeafIcon: false }"
|
||||
:treeDefaultExpandAll="true"
|
||||
:fieldNames="{ label: '${treeName}', value: '${treeCode}' }"
|
||||
:placeholder="$t('ui.formRules.selectRequired')"
|
||||
:getPopupContainer="getPopupContainer"
|
||||
/>
|
||||
</FormItem>
|
||||
#elseif($column.htmlType == "input")
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<Input v-model:value="formData.${field}" :placeholder="$t('ui.formRules.required')" />
|
||||
</FormItem>
|
||||
#elseif($column.htmlType == "imageUpload")
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<!-- props参考apps/web-antd/src/components/upload/src/image-upload.vue 25行 -->
|
||||
<!-- maxNumber为1(默认)时只允许上传一个文件 会自动绑定为string而非string[] -->
|
||||
<!-- resultField默认为url 可选ossId -->
|
||||
<ImageUpload resultField="ossId" :max-number="1" v-model:value="formData.${field}" />
|
||||
</FormItem>
|
||||
#elseif($column.htmlType == "fileUpload")
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<!-- props参考apps/web-antd/src/components/upload/src/file-upload.vue 25行 -->
|
||||
<!-- resultField默认为url 可选ossId -->
|
||||
<FileUpload resultField="ossId" :max-number="1" v-model:value="formData.${field}" />
|
||||
</FormItem>
|
||||
#elseif($column.htmlType == "editor")
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<Tinymce
|
||||
:options="{ readonly: false }"
|
||||
v-model="formData.${field}"
|
||||
/>
|
||||
</FormItem>
|
||||
#elseif($column.htmlType == "select" && "" != $dictType)
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<Select
|
||||
v-model:value="formData.${field}"
|
||||
#if($column.javaType == "Integer" || $column.javaType == "Long")
|
||||
:options="getDictOptions('$dictType', true)"
|
||||
#else
|
||||
:options="getDictOptions('$dictType')"
|
||||
#end
|
||||
:getPopupContainer="getPopupContainer"
|
||||
:placeholder="$t('ui.formRules.selectRequired')"
|
||||
/>
|
||||
</FormItem>
|
||||
#elseif($column.htmlType == "select" && "" == $dictType)
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<Select
|
||||
v-model:value="formData.${field}"
|
||||
:options="[]"
|
||||
:getPopupContainer="getPopupContainer"
|
||||
:placeholder="$t('ui.formRules.selectRequired')"
|
||||
/>
|
||||
</FormItem>
|
||||
#elseif($column.htmlType == "checkbox" && "" != $dictType)
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<CheckboxGroup
|
||||
v-model:value="formData.${field}"
|
||||
#if($column.javaType == "Integer" || $column.javaType == "Long")
|
||||
:options="getDictOptions('$dictType', true)"
|
||||
#else
|
||||
:options="getDictOptions('$dictType')"
|
||||
#end
|
||||
/>
|
||||
</FormItem>
|
||||
#elseif($column.htmlType == "checkbox" && "" == $dictType)
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<CheckboxGroup
|
||||
v-model:value="formData.${field}"
|
||||
:options="[]"
|
||||
/>
|
||||
</FormItem>
|
||||
#elseif($column.htmlType == "radio" && "" != $dictType)
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<RadioGroup
|
||||
option-type="button"
|
||||
button-style="solid"
|
||||
v-model:value="formData.${field}"
|
||||
#if($column.javaType == "Integer" || $column.javaType == "Long")
|
||||
:options="getDictOptions('$dictType', true)"
|
||||
#else
|
||||
:options="getDictOptions('$dictType')"
|
||||
#end
|
||||
/>
|
||||
</FormItem>
|
||||
#elseif($column.htmlType == "radio" && "" == $dictType)
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<RadioGroup
|
||||
option-type="button"
|
||||
button-style="solid"
|
||||
v-model:value="formData.${field}"
|
||||
:options="[]"
|
||||
/>
|
||||
</FormItem>
|
||||
#elseif($column.htmlType == "datetime")
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<!-- 需要自行调整参数 -->
|
||||
<DatePicker
|
||||
v-model:value="formData.${field}"
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
/>
|
||||
</FormItem>
|
||||
#elseif($column.htmlType == "textarea")
|
||||
<FormItem label="${comment}" v-bind="validateInfos.${field}">
|
||||
<Textarea
|
||||
v-model:value="formData.${field}"
|
||||
:placeholder="$t('ui.formRules.required')"
|
||||
:rows="4"
|
||||
/>
|
||||
</FormItem>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
</Form>
|
||||
</Basic${PopupComponent}>
|
||||
</template>
|
||||
#end
|
@@ -0,0 +1,499 @@
|
||||
<template>
|
||||
<div class="p-2">
|
||||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||
<div v-show="showSearch" class="mb-[10px]">
|
||||
<el-card shadow="hover">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
#foreach($column in $columns)
|
||||
#if($column.query)
|
||||
#set($dictType=$column.dictType)
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if($column.htmlType == "input" || $column.htmlType == "textarea")
|
||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||
<el-input v-model="queryParams.${column.javaField}" placeholder="请输入${comment}" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
|
||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
|
||||
<el-option v-for="dict in ${dictType}" :key="dict.value" :label="dict.label" :value="dict.value"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
|
||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable>
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||
<el-date-picker clearable
|
||||
v-model="queryParams.${column.javaField}"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="选择${comment}"
|
||||
/>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
<el-form-item label="${comment}" style="width: 308px">
|
||||
<el-date-picker
|
||||
v-model="dateRange${AttrName}"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]"
|
||||
/>
|
||||
</el-form-item>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd()" v-hasPermi="['${moduleName}:${businessName}:add']">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="info" plain icon="Sort" @click="handleToggleExpandAll">展开/折叠</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
<el-table
|
||||
ref="${businessName}TableRef"
|
||||
v-loading="loading"
|
||||
:data="${businessName}List"
|
||||
row-key="${treeCode}"
|
||||
border
|
||||
:default-expand-all="isExpandAll"
|
||||
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
||||
>
|
||||
#foreach($column in $columns)
|
||||
#set($javaField=$column.javaField)
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if($column.pk)
|
||||
#elseif($column.list && $column.htmlType == "datetime")
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
#elseif($column.list && $column.htmlType == "imageUpload")
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}Url" width="100">
|
||||
<template #default="scope">
|
||||
<image-preview :src="scope.row.${javaField}Url" :width="50" :height="50"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
#elseif($column.list && $column.dictType && "" != $column.dictType)
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}">
|
||||
<template #default="scope">
|
||||
#if($column.htmlType == "checkbox")
|
||||
<dict-tag :options="${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/>
|
||||
#else
|
||||
<dict-tag :options="${column.dictType}" :value="scope.row.${javaField}"/>
|
||||
#end
|
||||
</template>
|
||||
</el-table-column>
|
||||
#elseif($column.list && "" != $javaField)
|
||||
#if(${foreach.index} == 1)
|
||||
<el-table-column label="${comment}" prop="${javaField}" />
|
||||
#else
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="修改" placement="top">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${moduleName}:${businessName}:edit']" />
|
||||
</el-tooltip>
|
||||
<el-tooltip content="新增" placement="top">
|
||||
<el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['${moduleName}:${businessName}:add']" />
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top">
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${moduleName}:${businessName}:remove']" />
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
<!-- 添加或修改${functionName}对话框 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||
<el-form ref="${businessName}FormRef" :model="form" :rules="rules" label-width="80px">
|
||||
#foreach($column in $columns)
|
||||
#set($field=$column.javaField)
|
||||
#if(($column.insert || $column.edit) && !$column.pk)
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#set($dictType=$column.dictType)
|
||||
#if("" != $treeParentCode && $column.javaField == $treeParentCode)
|
||||
<el-form-item label="${comment}" prop="${treeParentCode}">
|
||||
<el-tree-select
|
||||
v-model="form.${treeParentCode}"
|
||||
:data="${businessName}Options"
|
||||
:props="{ value: '${treeCode}', label: '${treeName}', children: 'children' }"
|
||||
value-key="${treeCode}"
|
||||
placeholder="请选择${comment}"
|
||||
check-strictly
|
||||
/>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "input")
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "imageUpload")
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<image-upload v-model="form.${field}"/>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "fileUpload")
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<file-upload v-model="form.${field}"/>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "editor")
|
||||
<el-form-item label="${comment}">
|
||||
<editor v-model="form.${field}" :min-height="192"/>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "select" && "" != $dictType)
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
||||
<el-option
|
||||
v-for="dict in ${dictType}"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
#if($column.javaType == "Integer" || $column.javaType == "Long")
|
||||
:value="parseInt(dict.value)"
|
||||
#else
|
||||
:value="dict.value"
|
||||
#end
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "select" && $dictType)
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "checkbox" && "" != $dictType)
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-checkbox-group v-model="form.${field}">
|
||||
<el-checkbox
|
||||
v-for="dict in ${dictType}"
|
||||
:key="dict.value"
|
||||
:label="dict.value">
|
||||
{{dict.label}}
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "checkbox" && $dictType)
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-checkbox-group v-model="form.${field}">
|
||||
<el-checkbox>请选择字典生成</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "radio" && "" != $dictType)
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-radio-group v-model="form.${field}">
|
||||
<el-radio
|
||||
v-for="dict in ${dictType}"
|
||||
:key="dict.value"
|
||||
#if($column.javaType == "Integer" || $column.javaType == "Long")
|
||||
:value="parseInt(dict.value)"
|
||||
#else
|
||||
:value="dict.value"
|
||||
#end
|
||||
>{{dict.label}}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "radio" && $dictType)
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-radio-group v-model="form.${field}">
|
||||
<el-radio value="1">请选择字典生成</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "datetime")
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-date-picker clearable
|
||||
v-model="form.${field}"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
placeholder="选择${comment}"
|
||||
/>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "textarea")
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-input v-model="form.${field}" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="${BusinessName}" lang="ts">
|
||||
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}";
|
||||
import { ${BusinessName}VO, ${BusinessName}Query, ${BusinessName}Form } from '@/api/${moduleName}/${businessName}/types';
|
||||
|
||||
type ${BusinessName}Option = {
|
||||
${treeCode}: number;
|
||||
${treeName}: string;
|
||||
children?: ${BusinessName}Option[];
|
||||
}
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;;
|
||||
|
||||
#if(${dicts} != '')
|
||||
#set($dictsNoSymbol=$dicts.replace("'", ""))
|
||||
const { ${dictsNoSymbol} } = toRefs<any>(proxy?.useDict(${dicts}));
|
||||
#end
|
||||
|
||||
const ${businessName}List = ref<${BusinessName}VO[]>([]);
|
||||
const ${businessName}Options = ref<${BusinessName}Option[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const showSearch = ref(true);
|
||||
const isExpandAll = ref(true);
|
||||
const loading = ref(false);
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const ${businessName}FormRef = ref<ElFormInstance>();
|
||||
const ${businessName}TableRef = ref<ElTableInstance>()
|
||||
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
const dateRange${AttrName} = ref<[DateModelType, DateModelType]>(['', '']);
|
||||
#end
|
||||
#end
|
||||
|
||||
const initFormData: ${BusinessName}Form = {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.insert || $column.edit)
|
||||
#if($column.htmlType == "checkbox")
|
||||
$column.javaField: []#if($foreach.count != $columns.size()),#end
|
||||
#else
|
||||
$column.javaField: undefined#if($foreach.count != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
|
||||
const data = reactive<PageData<${BusinessName}Form, ${BusinessName}Query>>({
|
||||
form: {...initFormData},
|
||||
queryParams: {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.query)
|
||||
#if($column.htmlType != "datetime" || $column.queryType != "BETWEEN")
|
||||
$column.javaField: undefined,
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
params: {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.query)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
$column.javaField: undefined#if($foreach.count != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
},
|
||||
rules: {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.insert || $column.edit)
|
||||
#if($column.required)
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
$column.javaField: [
|
||||
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end }
|
||||
]#if($foreach.count != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询${functionName}列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
queryParams.value.params = {};
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
proxy?.addDateRange(queryParams.value, dateRange${AttrName}.value, '${AttrName}');
|
||||
#end
|
||||
#end
|
||||
const res = await list${BusinessName}(queryParams.value);
|
||||
const data = proxy?.handleTree<${BusinessName}VO>(res.data, "${treeCode}", "${treeParentCode}");
|
||||
if (data) {
|
||||
${businessName}List.value = data;
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询${functionName}下拉树结构 */
|
||||
const getTreeselect = async () => {
|
||||
const res = await list${BusinessName}();
|
||||
${businessName}Options.value = [];
|
||||
const data: ${BusinessName}Option = { ${treeCode}: 0, ${treeName}: '顶级节点', children: [] };
|
||||
data.children = proxy?.handleTree<${BusinessName}Option>(res.data, "${treeCode}", "${treeParentCode}");
|
||||
${businessName}Options.value.push(data);
|
||||
}
|
||||
|
||||
// 取消按钮
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
}
|
||||
|
||||
// 表单重置
|
||||
const reset = () => {
|
||||
form.value = {...initFormData}
|
||||
${businessName}FormRef.value?.resetFields();
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
getList();
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
dateRange${AttrName}.value = ['', ''];
|
||||
#end
|
||||
#end
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
}
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = (row?: ${BusinessName}VO) => {
|
||||
reset();
|
||||
getTreeselect();
|
||||
if (row != null && row.${treeCode}) {
|
||||
form.value.${treeParentCode} = row.${treeCode};
|
||||
} else {
|
||||
form.value.${treeParentCode} = 0;
|
||||
}
|
||||
dialog.visible = true;
|
||||
dialog.title = "添加${functionName}";
|
||||
}
|
||||
|
||||
/** 展开/折叠操作 */
|
||||
const handleToggleExpandAll = () => {
|
||||
isExpandAll.value = !isExpandAll.value;
|
||||
toggleExpandAll(${businessName}List.value, isExpandAll.value)
|
||||
}
|
||||
|
||||
/** 展开/折叠操作 */
|
||||
const toggleExpandAll = (data: ${BusinessName}VO[], status: boolean) => {
|
||||
data.forEach((item) => {
|
||||
${businessName}TableRef.value?.toggleRowExpansion(item, status)
|
||||
if (item.children && item.children.length > 0) toggleExpandAll(item.children, status)
|
||||
})
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row: ${BusinessName}VO) => {
|
||||
reset();
|
||||
await getTreeselect();
|
||||
if (row != null) {
|
||||
form.value.${treeParentCode} = row.${treeParentCode};
|
||||
}
|
||||
const res = await get${BusinessName}(row.${pkColumn.javaField});
|
||||
Object.assign(form.value, res.data);
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "checkbox")
|
||||
form.value.$column.javaField = form.value.${column.javaField}.split(",");
|
||||
#end
|
||||
#end
|
||||
dialog.visible = true;
|
||||
dialog.title = "修改${functionName}";
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
${businessName}FormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "checkbox")
|
||||
form.value.$column.javaField = form.value.${column.javaField}.join(",");
|
||||
#end
|
||||
#end
|
||||
if (form.value.${pkColumn.javaField}) {
|
||||
await update${BusinessName}(form.value).finally(() => buttonLoading.value = false);
|
||||
} else {
|
||||
await add${BusinessName}(form.value).finally(() => buttonLoading.value = false);
|
||||
}
|
||||
proxy?.#[[$modal]]#.msgSuccess("操作成功");
|
||||
dialog.visible = false;
|
||||
getList();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row: ${BusinessName}VO) => {
|
||||
await proxy?.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + row.${pkColumn.javaField} + '"的数据项?');
|
||||
loading.value = true;
|
||||
await del${BusinessName}(row.${pkColumn.javaField}).finally(() => loading.value = false);
|
||||
await getList();
|
||||
proxy?.#[[$modal]]#.msgSuccess("删除成功");
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
459
ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/index.vue.vm
Normal file
459
ruoyi-modules/ruoyi-gen/src/main/resources/vm/vue/index.vue.vm
Normal file
@@ -0,0 +1,459 @@
|
||||
<template>
|
||||
<div class="p-2">
|
||||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||
<div v-show="showSearch" class="mb-[10px]">
|
||||
<el-card shadow="hover">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
||||
#foreach($column in $columns)
|
||||
#if($column.query)
|
||||
#set($dictType=$column.dictType)
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if($column.htmlType == "input" || $column.htmlType == "textarea")
|
||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||
<el-input v-model="queryParams.${column.javaField}" placeholder="请输入${comment}" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
|
||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable >
|
||||
<el-option v-for="dict in ${dictType}" :key="dict.value" :label="dict.label" :value="dict.value"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
|
||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable >
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||
<el-date-picker clearable
|
||||
v-model="queryParams.${column.javaField}"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="请选择${comment}"
|
||||
/>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
<el-form-item label="${comment}" style="width: 308px">
|
||||
<el-date-picker
|
||||
v-model="dateRange${AttrName}"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]"
|
||||
/>
|
||||
</el-form-item>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['${moduleName}:${businessName}:add']">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['${moduleName}:${businessName}:edit']">修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['${moduleName}:${businessName}:remove']">删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['${moduleName}:${businessName}:export']">导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" border :data="${businessName}List" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
#foreach($column in $columns)
|
||||
#set($javaField=$column.javaField)
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if($column.pk)
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" v-if="${column.list}" />
|
||||
#elseif($column.list && $column.htmlType == "datetime")
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
#elseif($column.list && $column.htmlType == "imageUpload")
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}Url" width="100">
|
||||
<template #default="scope">
|
||||
<image-preview :src="scope.row.${javaField}Url" :width="50" :height="50"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
#elseif($column.list && $column.dictType && "" != $column.dictType)
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}">
|
||||
<template #default="scope">
|
||||
#if($column.htmlType == "checkbox")
|
||||
<dict-tag :options="${column.dictType}" :value="scope.row.${javaField} ? scope.row.${javaField}.split(',') : []"/>
|
||||
#else
|
||||
<dict-tag :options="${column.dictType}" :value="scope.row.${javaField}"/>
|
||||
#end
|
||||
</template>
|
||||
</el-table-column>
|
||||
#elseif($column.list && "" != $javaField)
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||
#end
|
||||
#end
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="修改" placement="top">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${moduleName}:${businessName}:edit']"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top">
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${moduleName}:${businessName}:remove']"></el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
</el-card>
|
||||
<!-- 添加或修改${functionName}对话框 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||
<el-form ref="${businessName}FormRef" :model="form" :rules="rules" label-width="80px">
|
||||
#foreach($column in $columns)
|
||||
#set($field=$column.javaField)
|
||||
#if(($column.insert || $column.edit) && !$column.pk)
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#set($dictType=$column.dictType)
|
||||
#if($column.htmlType == "input")
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "imageUpload")
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<image-upload v-model="form.${field}"/>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "fileUpload")
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<file-upload v-model="form.${field}"/>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "editor")
|
||||
<el-form-item label="${comment}">
|
||||
<editor v-model="form.${field}" :min-height="192"/>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "select" && "" != $dictType)
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
||||
<el-option
|
||||
v-for="dict in ${dictType}"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
#if($column.javaType == "Integer" || $column.javaType == "Long")
|
||||
:value="parseInt(dict.value)"
|
||||
#else
|
||||
:value="dict.value"
|
||||
#end
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "select" && $dictType)
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "checkbox" && "" != $dictType)
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-checkbox-group v-model="form.${field}">
|
||||
<el-checkbox
|
||||
v-for="dict in ${dictType}"
|
||||
:key="dict.value"
|
||||
:label="dict.value">
|
||||
{{dict.label}}
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "checkbox" && $dictType)
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-checkbox-group v-model="form.${field}">
|
||||
<el-checkbox>请选择字典生成</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "radio" && "" != $dictType)
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-radio-group v-model="form.${field}">
|
||||
<el-radio
|
||||
v-for="dict in ${dictType}"
|
||||
:key="dict.value"
|
||||
#if($column.javaType == "Integer" || $column.javaType == "Long")
|
||||
:value="parseInt(dict.value)"
|
||||
#else
|
||||
:value="dict.value"
|
||||
#end
|
||||
>{{dict.label}}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "radio" && $dictType)
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-radio-group v-model="form.${field}">
|
||||
<el-radio value="1">请选择字典生成</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "datetime")
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-date-picker clearable
|
||||
v-model="form.${field}"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
placeholder="请选择${comment}">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "textarea")
|
||||
<el-form-item label="${comment}" prop="${field}">
|
||||
<el-input v-model="form.${field}" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="${BusinessName}" lang="ts">
|
||||
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from '@/api/${moduleName}/${businessName}';
|
||||
import { ${BusinessName}VO, ${BusinessName}Query, ${BusinessName}Form } from '@/api/${moduleName}/${businessName}/types';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
#if(${dicts} != '')
|
||||
#set($dictsNoSymbol=$dicts.replace("'", ""))
|
||||
const { ${dictsNoSymbol} } = toRefs<any>(proxy?.useDict(${dicts}));
|
||||
#end
|
||||
|
||||
const ${businessName}List = ref<${BusinessName}VO[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref<Array<string | number>>([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
const dateRange${AttrName} = ref<[DateModelType, DateModelType]>(['', '']);
|
||||
#end
|
||||
#end
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const ${businessName}FormRef = ref<ElFormInstance>();
|
||||
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const initFormData: ${BusinessName}Form = {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.insert || $column.edit)
|
||||
#if($column.htmlType == "checkbox")
|
||||
$column.javaField: []#if($foreach.count != $columns.size()),#end
|
||||
#else
|
||||
$column.javaField: undefined#if($foreach.count != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
const data = reactive<PageData<${BusinessName}Form, ${BusinessName}Query>>({
|
||||
form: {...initFormData},
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
#foreach ($column in $columns)
|
||||
#if($column.query)
|
||||
#if($column.htmlType != "datetime" || $column.queryType != "BETWEEN")
|
||||
$column.javaField: undefined,
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
params: {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.query)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
$column.javaField: undefined#if($foreach.count != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
},
|
||||
rules: {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.insert || $column.edit)
|
||||
#if($column.required)
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
$column.javaField: [
|
||||
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end }
|
||||
]#if($foreach.count != $columns.size()),#end
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
/** 查询${functionName}列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
queryParams.value.params = {};
|
||||
#break
|
||||
#end
|
||||
#end
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
proxy?.addDateRange(queryParams.value, dateRange${AttrName}.value, '${AttrName}');
|
||||
#end
|
||||
#end
|
||||
const res = await list${BusinessName}(queryParams.value);
|
||||
${businessName}List.value = res.rows;
|
||||
total.value = res.total;
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
}
|
||||
|
||||
/** 表单重置 */
|
||||
const reset = () => {
|
||||
form.value = {...initFormData};
|
||||
${businessName}FormRef.value?.resetFields();
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
dateRange${AttrName}.value = ['', ''];
|
||||
#end
|
||||
#end
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
}
|
||||
|
||||
/** 多选框选中数据 */
|
||||
const handleSelectionChange = (selection: ${BusinessName}VO[]) => {
|
||||
ids.value = selection.map(item => item.${pkColumn.javaField});
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
}
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = () => {
|
||||
reset();
|
||||
dialog.visible = true;
|
||||
dialog.title = "添加${functionName}";
|
||||
}
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row?: ${BusinessName}VO) => {
|
||||
reset();
|
||||
const _${pkColumn.javaField} = row?.${pkColumn.javaField} || ids.value[0]
|
||||
const res = await get${BusinessName}(_${pkColumn.javaField});
|
||||
Object.assign(form.value, res.data);
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "checkbox")
|
||||
form.value.$column.javaField = form.value.${column.javaField}.split(",");
|
||||
#end
|
||||
#end
|
||||
dialog.visible = true;
|
||||
dialog.title = "修改${functionName}";
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
${businessName}FormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "checkbox")
|
||||
form.value.$column.javaField = form.value.${column.javaField}.join(",");
|
||||
#end
|
||||
#end
|
||||
if (form.value.${pkColumn.javaField}) {
|
||||
await update${BusinessName}(form.value).finally(() => buttonLoading.value = false);
|
||||
} else {
|
||||
await add${BusinessName}(form.value).finally(() => buttonLoading.value = false);
|
||||
}
|
||||
proxy?.#[[$modal]]#.msgSuccess("操作成功");
|
||||
dialog.visible = false;
|
||||
await getList();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row?: ${BusinessName}VO) => {
|
||||
const _${pkColumn.javaField}s = row?.${pkColumn.javaField} || ids.value;
|
||||
await proxy?.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + _${pkColumn.javaField}s + '"的数据项?').finally(() => loading.value = false);
|
||||
await del${BusinessName}(_${pkColumn.javaField}s);
|
||||
proxy?.#[[$modal]]#.msgSuccess("删除成功");
|
||||
await getList();
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = () => {
|
||||
proxy?.download('${moduleName}/${businessName}/export', {
|
||||
...queryParams.value
|
||||
}, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
@@ -0,0 +1,7 @@
|
||||
<?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="${packageName}.mapper.${ClassName}Mapper">
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user