mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-10-30 02:57:09 +08:00
feat: 新增 continew-admin-plugins 插件模块,代码生成迁移到插件模块,为后续插件化改造铺垫
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package ${packageName}.${subPackageName};
|
||||
|
||||
import top.continew.starter.extension.crud.enums.Api;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
|
||||
import top.continew.starter.extension.crud.controller.BaseController;
|
||||
import ${packageName}.model.query.${classNamePrefix}Query;
|
||||
import ${packageName}.model.req.${classNamePrefix}Req;
|
||||
import ${packageName}.model.resp.${classNamePrefix}DetailResp;
|
||||
import ${packageName}.model.resp.${classNamePrefix}Resp;
|
||||
import ${packageName}.service.${classNamePrefix}Service;
|
||||
|
||||
/**
|
||||
* ${businessName}管理 API
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Tag(name = "${businessName}管理 API")
|
||||
@RestController
|
||||
@CrudRequestMapping(value = "/${apiModuleName}/${apiName}", api = {Api.PAGE, Api.GET, Api.ADD, Api.UPDATE, Api.DELETE, Api.EXPORT})
|
||||
public class ${className} extends BaseController<${classNamePrefix}Service, ${classNamePrefix}Resp, ${classNamePrefix}DetailResp, ${classNamePrefix}Query, ${classNamePrefix}Req> {}
|
||||
@@ -0,0 +1,44 @@
|
||||
package ${packageName}.${subPackageName};
|
||||
|
||||
import java.io.Serial;
|
||||
<#if hasLocalDateTime>
|
||||
import java.time.LocalDateTime;
|
||||
</#if>
|
||||
<#if hasBigDecimal>
|
||||
import java.math.BigDecimal;
|
||||
</#if>
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
|
||||
import top.continew.starter.extension.crud.model.resp.BaseDetailResp;
|
||||
|
||||
/**
|
||||
* ${businessName}详情信息
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@Schema(description = "${businessName}详情信息")
|
||||
public class ${className} extends BaseDetailResp {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
<#if fieldConfigs??>
|
||||
<#list fieldConfigs as fieldConfig>
|
||||
|
||||
/**
|
||||
* ${fieldConfig.comment}
|
||||
*/
|
||||
@Schema(description = "${fieldConfig.comment}")
|
||||
@ExcelProperty(value = "${fieldConfig.comment}")
|
||||
private ${fieldConfig.fieldType} ${fieldConfig.fieldName};
|
||||
</#list>
|
||||
</#if>
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package ${packageName}.${subPackageName};
|
||||
|
||||
import java.io.Serial;
|
||||
<#if hasLocalDateTime>
|
||||
import java.time.LocalDateTime;
|
||||
</#if>
|
||||
<#if hasBigDecimal>
|
||||
import java.math.BigDecimal;
|
||||
</#if>
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import top.continew.starter.extension.crud.model.entity.BaseDO;
|
||||
|
||||
/**
|
||||
* ${businessName}实体
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Data
|
||||
@TableName("${tableName}")
|
||||
public class ${className} extends BaseDO {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
<#if fieldConfigs??>
|
||||
<#list fieldConfigs as fieldConfig>
|
||||
|
||||
/**
|
||||
* ${fieldConfig.comment}
|
||||
*/
|
||||
private ${fieldConfig.fieldType} ${fieldConfig.fieldName};
|
||||
</#list>
|
||||
</#if>
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package ${packageName}.${subPackageName};
|
||||
|
||||
import top.continew.starter.data.mybatis.plus.base.BaseMapper;
|
||||
import ${packageName}.model.entity.${classNamePrefix}DO;
|
||||
|
||||
/**
|
||||
* ${businessName} Mapper
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
public interface ${className} extends BaseMapper<${classNamePrefix}DO> {}
|
||||
@@ -0,0 +1,51 @@
|
||||
package ${packageName}.${subPackageName};
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
<#if hasLocalDateTime>
|
||||
import java.time.LocalDateTime;
|
||||
</#if>
|
||||
<#if hasBigDecimal>
|
||||
import java.math.BigDecimal;
|
||||
</#if>
|
||||
<#if hasListQueryField>
|
||||
import java.util.List;
|
||||
</#if>
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import top.continew.starter.data.core.annotation.Query;
|
||||
import top.continew.starter.data.core.enums.QueryType;
|
||||
|
||||
/**
|
||||
* ${businessName}查询条件
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "${businessName}查询条件")
|
||||
public class ${className} implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
<#if fieldConfigs??>
|
||||
<#list fieldConfigs as fieldConfig>
|
||||
<#if fieldConfig.showInQuery>
|
||||
|
||||
/**
|
||||
* ${fieldConfig.comment}
|
||||
*/
|
||||
@Schema(description = "${fieldConfig.comment}")
|
||||
@Query(type = QueryType.${fieldConfig.queryType})
|
||||
<#if fieldConfig.queryType = 'IN' || fieldConfig.queryType = 'NOT_IN' || fieldConfig.queryType = 'BETWEEN'>
|
||||
private List<${fieldConfig.fieldType}> ${fieldConfig.fieldName};
|
||||
<#else>
|
||||
private ${fieldConfig.fieldType} ${fieldConfig.fieldName};
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package ${packageName}.${subPackageName};
|
||||
|
||||
import java.io.Serial;
|
||||
<#if hasLocalDateTime>
|
||||
import java.time.LocalDateTime;
|
||||
</#if>
|
||||
<#if hasBigDecimal>
|
||||
import java.math.BigDecimal;
|
||||
</#if>
|
||||
|
||||
<#if hasRequiredField>
|
||||
import jakarta.validation.constraints.*;
|
||||
</#if>
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import top.continew.starter.extension.crud.model.req.BaseReq;
|
||||
|
||||
/**
|
||||
* 创建或修改${businessName}信息
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "创建或修改${businessName}信息")
|
||||
public class ${className} extends BaseReq {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
<#if fieldConfigs??>
|
||||
<#list fieldConfigs as fieldConfig>
|
||||
<#if fieldConfig.showInForm>
|
||||
|
||||
/**
|
||||
* ${fieldConfig.comment}
|
||||
*/
|
||||
@Schema(description = "${fieldConfig.comment}")
|
||||
<#if fieldConfig.isRequired>
|
||||
<#if fieldConfig.fieldType = 'String'>
|
||||
@NotBlank(message = "${fieldConfig.comment}不能为空")
|
||||
<#else>
|
||||
@NotNull(message = "${fieldConfig.comment}不能为空")
|
||||
</#if>
|
||||
</#if>
|
||||
<#if fieldConfig.fieldType = 'String' && fieldConfig.columnSize??>
|
||||
@Length(max = ${fieldConfig.columnSize}, message = "${fieldConfig.comment}长度不能超过 {max} 个字符")
|
||||
</#if>
|
||||
private ${fieldConfig.fieldType} ${fieldConfig.fieldName};
|
||||
</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package ${packageName}.${subPackageName};
|
||||
|
||||
import java.io.Serial;
|
||||
<#if hasLocalDateTime>
|
||||
import java.time.LocalDateTime;
|
||||
</#if>
|
||||
<#if hasBigDecimal>
|
||||
import java.math.BigDecimal;
|
||||
</#if>
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import top.continew.starter.extension.crud.model.resp.BaseResp;
|
||||
|
||||
/**
|
||||
* ${businessName}信息
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "${businessName}信息")
|
||||
public class ${className} extends BaseResp {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
<#if fieldConfigs??>
|
||||
<#list fieldConfigs as fieldConfig>
|
||||
<#if fieldConfig.showInList>
|
||||
|
||||
/**
|
||||
* ${fieldConfig.comment}
|
||||
*/
|
||||
@Schema(description = "${fieldConfig.comment}")
|
||||
private ${fieldConfig.fieldType} ${fieldConfig.fieldName};
|
||||
</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package ${packageName}.${subPackageName};
|
||||
|
||||
import top.continew.starter.extension.crud.service.BaseService;
|
||||
import ${packageName}.model.query.${classNamePrefix}Query;
|
||||
import ${packageName}.model.req.${classNamePrefix}Req;
|
||||
import ${packageName}.model.resp.${classNamePrefix}DetailResp;
|
||||
import ${packageName}.model.resp.${classNamePrefix}Resp;
|
||||
|
||||
/**
|
||||
* ${businessName}业务接口
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
public interface ${className} extends BaseService<${classNamePrefix}Resp, ${classNamePrefix}DetailResp, ${classNamePrefix}Query, ${classNamePrefix}Req> {}
|
||||
@@ -0,0 +1,24 @@
|
||||
package ${packageName}.${subPackageName};
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import top.continew.starter.extension.crud.service.impl.BaseServiceImpl;
|
||||
import ${packageName}.mapper.${classNamePrefix}Mapper;
|
||||
import ${packageName}.model.entity.${classNamePrefix}DO;
|
||||
import ${packageName}.model.query.${classNamePrefix}Query;
|
||||
import ${packageName}.model.req.${classNamePrefix}Req;
|
||||
import ${packageName}.model.resp.${classNamePrefix}DetailResp;
|
||||
import ${packageName}.model.resp.${classNamePrefix}Resp;
|
||||
import ${packageName}.service.${classNamePrefix}Service;
|
||||
|
||||
/**
|
||||
* ${businessName}业务实现
|
||||
*
|
||||
* @author ${author}
|
||||
* @since ${date}
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ${className} extends BaseServiceImpl<${classNamePrefix}Mapper, ${classNamePrefix}DO, ${classNamePrefix}Resp, ${classNamePrefix}DetailResp, ${classNamePrefix}Query, ${classNamePrefix}Req> implements ${classNamePrefix}Service {}
|
||||
@@ -0,0 +1,136 @@
|
||||
<template>
|
||||
<a-modal
|
||||
v-model:visible="visible"
|
||||
:title="title"
|
||||
:mask-closable="false"
|
||||
:esc-to-close="false"
|
||||
:modal-style="{ maxWidth: '520px' }"
|
||||
width="90%"
|
||||
@before-ok="save"
|
||||
@close="reset"
|
||||
>
|
||||
<GiForm ref="formRef" v-model="form" :options="options" :columns="columns" />
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import { get${classNamePrefix}, add${classNamePrefix}, update${classNamePrefix} } from '@/apis/${apiModuleName}/${apiName}'
|
||||
import { type Columns, GiForm, type Options } from '@/components/GiForm'
|
||||
import { useForm } from '@/hooks'
|
||||
import { useDict } from '@/hooks/app'
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'save-success'): void
|
||||
}>()
|
||||
|
||||
const dataId = ref('')
|
||||
const isUpdate = computed(() => !!dataId.value)
|
||||
const title = computed(() => (isUpdate.value ? '修改${businessName}' : '新增${businessName}'))
|
||||
const formRef = ref<InstanceType<typeof GiForm>>()
|
||||
|
||||
<#list fieldConfigs as fieldConfig>
|
||||
<#if fieldConfig.showInForm>
|
||||
<#-- SELECT/RADIO/CHECK_BOX/TREE_SELECT控件从服务器端获取数据 -->
|
||||
<#if fieldConfig.formType = 'SELECT' || fieldConfig.formType = 'RADIO'
|
||||
|| fieldConfig.formType = 'CHECK_BOX' || fieldConfig.formType = 'TREE_SELECT'>
|
||||
const { ${fieldConfig.columnName}_enum } = useDict('${fieldConfig.columnName}_enum')
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
|
||||
const options: Options = {
|
||||
form: {},
|
||||
col: { xs: 24, sm: 24, md: 24, lg: 24, xl: 24, xxl: 24 },
|
||||
btns: { hide: true }
|
||||
}
|
||||
|
||||
const columns: Columns = [
|
||||
<#list fieldConfigs as fieldConfig>
|
||||
<#if fieldConfig.showInForm>
|
||||
{
|
||||
label: '${fieldConfig.comment}',
|
||||
field: '${fieldConfig.fieldName}',
|
||||
<#if fieldConfig.formType = 'INPUT'>
|
||||
type: 'input',
|
||||
<#elseif fieldConfig.formType = 'TEXT_AREA'>
|
||||
type: 'textarea',
|
||||
<#elseif fieldConfig.formType = 'DATE'>
|
||||
type: 'date-picker',
|
||||
<#elseif fieldConfig.formType = 'DATE_TIME'>
|
||||
type: 'time-picker',
|
||||
<#elseif fieldConfig.formType = 'INPUT_NUMBER'>
|
||||
type: 'input-number',
|
||||
<#elseif fieldConfig.formType = 'INPUT_PASSWORD'>
|
||||
type: 'input-password',
|
||||
<#elseif fieldConfig.formType = 'SWITCH'>
|
||||
type: 'switch',
|
||||
<#elseif fieldConfig.formType = 'CHECK_BOX'>
|
||||
type: 'check-group',
|
||||
options: ${fieldConfig.columnName}_enum,
|
||||
<#elseif fieldConfig.formType = 'TREE_SELECT'>
|
||||
type: 'tree-select',
|
||||
data: '${fieldConfig.columnName}_enum',
|
||||
<#elseif fieldConfig.formType = 'SELECT'>
|
||||
type: 'select',
|
||||
options: ${fieldConfig.columnName}_enum,
|
||||
<#elseif fieldConfig.formType = 'RADIO'>
|
||||
type: 'radio-group',
|
||||
options: ${fieldConfig.columnName}_enum,
|
||||
</#if>
|
||||
<#if fieldConfig.isRequired>
|
||||
rules: [{ required: true, message: '请输入${fieldConfig.comment}' }]
|
||||
</#if>
|
||||
},
|
||||
</#if>
|
||||
</#list>
|
||||
]
|
||||
|
||||
const { form, resetForm } = useForm({
|
||||
// todo 待补充
|
||||
})
|
||||
|
||||
// 重置
|
||||
const reset = () => {
|
||||
formRef.value?.formRef?.resetFields()
|
||||
resetForm()
|
||||
}
|
||||
|
||||
const visible = ref(false)
|
||||
// 新增
|
||||
const onAdd = () => {
|
||||
reset()
|
||||
dataId.value = ''
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
// 修改
|
||||
const onUpdate = async (id: string) => {
|
||||
reset()
|
||||
dataId.value = id
|
||||
const res = await get${classNamePrefix}(id)
|
||||
Object.assign(form, res.data)
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
// 保存
|
||||
const save = async () => {
|
||||
try {
|
||||
const isInvalid = await formRef.value?.formRef?.validate()
|
||||
if (isInvalid) return false
|
||||
if (isUpdate.value) {
|
||||
await update${classNamePrefix}(form, dataId.value)
|
||||
Message.success('修改成功')
|
||||
} else {
|
||||
await add${classNamePrefix}(form)
|
||||
Message.success('新增成功')
|
||||
}
|
||||
emit('save-success')
|
||||
return true
|
||||
} catch (error) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ onAdd, onUpdate })
|
||||
</script>
|
||||
@@ -0,0 +1,41 @@
|
||||
<template>
|
||||
<a-drawer v-model:visible="visible" title="${businessName}详情" :width="width >= 580 ? 580 : '100%'" :footer="false">
|
||||
<a-descriptions :column="2" size="large" class="general-description">
|
||||
<#list fieldConfigs as fieldConfig>
|
||||
<a-descriptions-item label="${fieldConfig.comment}">{{ dataDetail?.${fieldConfig.fieldName} }}</a-descriptions-item>
|
||||
<#if fieldConfig.fieldName = 'createUser'>
|
||||
<a-descriptions-item label="创建人">{{ dataDetail?.createUserString }}</a-descriptions-item>
|
||||
<#elseif fieldConfig.fieldName = 'updateUser'>
|
||||
<a-descriptions-item label="修改人">{{ dataDetail?.updateUserString }}</a-descriptions-item>
|
||||
</#if>
|
||||
</#list>
|
||||
</a-descriptions>
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { useWindowSize } from '@vueuse/core'
|
||||
import { type ${classNamePrefix}DetailResp, get${classNamePrefix} } from '@/apis/${apiModuleName}/${apiName}'
|
||||
|
||||
const { width } = useWindowSize()
|
||||
|
||||
const visible = ref(false)
|
||||
const dataId = ref('')
|
||||
const dataDetail = ref<${classNamePrefix}DetailResp>()
|
||||
// 查询详情
|
||||
const getDataDetail = async () => {
|
||||
const res = await get${classNamePrefix}(dataId.value)
|
||||
dataDetail.value = res.data
|
||||
}
|
||||
|
||||
// 打开详情
|
||||
const onDetail = async (id: string) => {
|
||||
dataId.value = id
|
||||
await getDataDetail()
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
defineExpose({ onDetail })
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,65 @@
|
||||
import http from '@/utils/http'
|
||||
|
||||
const BASE_URL = '/${apiModuleName}/${apiName}'
|
||||
|
||||
export interface ${classNamePrefix}Resp {
|
||||
<#if fieldConfigs??>
|
||||
<#list fieldConfigs as fieldConfig>
|
||||
<#if fieldConfig.showInList>
|
||||
${fieldConfig.fieldName}: string
|
||||
</#if>
|
||||
</#list>
|
||||
createUserString: string
|
||||
updateUserString: string
|
||||
</#if>
|
||||
}
|
||||
export interface ${classNamePrefix}DetailResp {
|
||||
<#if fieldConfigs??>
|
||||
<#list fieldConfigs as fieldConfig>
|
||||
${fieldConfig.fieldName}: string
|
||||
</#list>
|
||||
createUserString: string
|
||||
updateUserString: string
|
||||
</#if>
|
||||
}
|
||||
export interface ${classNamePrefix}Query {
|
||||
<#if fieldConfigs??>
|
||||
<#list fieldConfigs as fieldConfig>
|
||||
<#if fieldConfig.showInQuery>
|
||||
${fieldConfig.fieldName}: string
|
||||
</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
sort: Array<string>
|
||||
}
|
||||
export interface ${classNamePrefix}PageQuery extends ${classNamePrefix}Query, PageQuery {}
|
||||
|
||||
/** @desc 查询${businessName}列表 */
|
||||
export function list${classNamePrefix}(query: ${classNamePrefix}PageQuery) {
|
||||
return http.get<PageRes<${classNamePrefix}Resp[]>>(`${'$'}{BASE_URL}`, query)
|
||||
}
|
||||
|
||||
/** @desc 查询${businessName}详情 */
|
||||
export function get${classNamePrefix}(id: string) {
|
||||
return http.get<${classNamePrefix}DetailResp>(`${'$'}{BASE_URL}/${'$'}{id}`)
|
||||
}
|
||||
|
||||
/** @desc 新增${businessName} */
|
||||
export function add${classNamePrefix}(data: any) {
|
||||
return http.post(`${'$'}{BASE_URL}`, data)
|
||||
}
|
||||
|
||||
/** @desc 修改${businessName} */
|
||||
export function update${classNamePrefix}(data: any, id: string) {
|
||||
return http.put(`${'$'}{BASE_URL}/${'$'}{id}`, data)
|
||||
}
|
||||
|
||||
/** @desc 删除${businessName} */
|
||||
export function delete${classNamePrefix}(id: string) {
|
||||
return http.del(`${'$'}{BASE_URL}/${'$'}{id}`)
|
||||
}
|
||||
|
||||
/** @desc 导出${businessName} */
|
||||
export function export${classNamePrefix}(query: ${classNamePrefix}Query) {
|
||||
return http.download<any>(`${'$'}{BASE_URL}/export`, query)
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
<template>
|
||||
<div class="table-page">
|
||||
<GiTable
|
||||
row-key="id"
|
||||
title="${businessName}管理"
|
||||
:data="dataList"
|
||||
:columns="columns"
|
||||
:loading="loading"
|
||||
:scroll="{ x: '100%', y: '100%', minWidth: 1000 }"
|
||||
:pagination="pagination"
|
||||
:disabled-tools="['size']"
|
||||
:disabled-column-keys="['name']"
|
||||
@refresh="search"
|
||||
>
|
||||
<template #custom-left>
|
||||
<#list fieldConfigs as fieldConfig>
|
||||
<#if fieldConfig.showInQuery>
|
||||
<#if fieldConfig.formType == "SELECT"><#-- 下拉框 -->
|
||||
<a-select
|
||||
v-model="queryForm.${fieldConfig.fieldName}"
|
||||
:options="${fieldConfig.columnName}_enum"
|
||||
placeholder="请选择${fieldConfig.comment}"
|
||||
allow-clear
|
||||
style="width: 150px"
|
||||
@change="search"
|
||||
/>
|
||||
<#elseif fieldConfig.formType == "RADIO"><#-- 单选框 -->
|
||||
<a-radio-group v-model="queryForm.${fieldConfig.fieldName}" :options="${fieldConfig.columnName}_enum" @change="search"/>
|
||||
<#elseif fieldConfig.formType == "DATE"><#-- 日期框 -->
|
||||
<#if fieldConfig.queryType == "BETWEEN">
|
||||
<a-range-picker
|
||||
v-model="queryForm.${fieldConfig.fieldName}"
|
||||
:placeholder="['请选择开始${fieldConfig.comment}','请选择结束${fieldConfig.comment}']"
|
||||
format="YYYY-MM-DD"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<#else>
|
||||
<a-date-picker
|
||||
v-model="queryForm.${fieldConfig.fieldName}"
|
||||
placeholder="请选择${fieldConfig.comment}"
|
||||
format="YYYY-MM-DD"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</#if>
|
||||
|
||||
<#elseif fieldConfig.formType == "DATE_TIME"><#-- 日期时间框 -->
|
||||
<#if fieldConfig.queryType == "BETWEEN">
|
||||
<a-range-picker
|
||||
v-model="queryForm.${fieldConfig.fieldName}"
|
||||
:placeholder="['请选择开始${fieldConfig.comment}','请选择结束${fieldConfig.comment}']"
|
||||
show-time
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<#else>
|
||||
<a-date-picker
|
||||
v-model="queryForm.${fieldConfig.fieldName}"
|
||||
placeholder="请选择${fieldConfig.comment}"
|
||||
show-time
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</#if>
|
||||
<#else>
|
||||
<a-input v-model="queryForm.${fieldConfig.fieldName}" placeholder="请输入${fieldConfig.comment}" allow-clear @change="search">
|
||||
<template #prefix><icon-search /></template>
|
||||
</a-input>
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
<a-button @click="reset">重置</a-button>
|
||||
</template>
|
||||
<template #custom-right>
|
||||
<a-button v-permission="['${apiModuleName}:${apiName}:add']" type="primary" @click="onAdd">
|
||||
<template #icon><icon-plus /></template>
|
||||
<span>新增</span>
|
||||
</a-button>
|
||||
<a-tooltip content="导出">
|
||||
<a-button v-permission="['${apiModuleName}:${apiName}:export']" class="gi_hover_btn-border" @click="onExport">
|
||||
<template #icon>
|
||||
<icon-download />
|
||||
</template>
|
||||
</a-button>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template #name="{ record }">
|
||||
<a-link @click="onDetail(record)">{{ record.name }}</a-link>
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<a-space>
|
||||
<a-link v-permission="['${apiModuleName}:${apiName}:update']" @click="onUpdate(record)">修改</a-link>
|
||||
<a-link
|
||||
v-permission="['${apiModuleName}:${apiName}:delete']"
|
||||
status="danger"
|
||||
:disabled="record.disabled"
|
||||
@click="onDelete(record)"
|
||||
>
|
||||
删除
|
||||
</a-link>
|
||||
</a-space>
|
||||
</template>
|
||||
</GiTable>
|
||||
|
||||
<${classNamePrefix}AddModal ref="${classNamePrefix}AddModalRef" @save-success="search" />
|
||||
<${classNamePrefix}DetailDrawer ref="${classNamePrefix}DetailDrawerRef" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import ${classNamePrefix}AddModal from './${classNamePrefix}AddModal.vue'
|
||||
import ${classNamePrefix}DetailDrawer from './${classNamePrefix}DetailDrawer.vue'
|
||||
import { type ${classNamePrefix}Resp, type ${classNamePrefix}Query, delete${classNamePrefix}, export${classNamePrefix}, list${classNamePrefix} } from '@/apis/${apiModuleName}/${apiName}'
|
||||
import type { TableInstanceColumns } from '@/components/GiTable/type'
|
||||
import { useDownload, useTable } from '@/hooks'
|
||||
import { isMobile } from '@/utils'
|
||||
import has from '@/utils/has'
|
||||
import { useDict } from '@/hooks/app'
|
||||
|
||||
defineOptions({ name: '${classNamePrefix}' })
|
||||
|
||||
const queryForm = reactive<${classNamePrefix}Query>({
|
||||
<#list fieldConfigs as fieldConfig>
|
||||
<#if fieldConfig.showInQuery>
|
||||
${fieldConfig.fieldName}: undefined,
|
||||
</#if>
|
||||
</#list>
|
||||
sort: ['createTime,desc']
|
||||
})
|
||||
|
||||
<#list fieldConfigs as fieldConfig>
|
||||
<#if fieldConfig.showInQuery>
|
||||
<#if fieldConfig.formType == "SELECT" || fieldConfig.formType == "RADIO">
|
||||
const { ${fieldConfig.columnName}_enum } = useDict('${fieldConfig.columnName}_enum')
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
|
||||
const {
|
||||
tableData: dataList,
|
||||
loading,
|
||||
pagination,
|
||||
search,
|
||||
handleDelete
|
||||
} = useTable((page) => list${classNamePrefix}({ ...queryForm, ...page }), { immediate: true })
|
||||
|
||||
const columns: TableInstanceColumns[] = [
|
||||
<#if fieldConfigs??>
|
||||
<#list fieldConfigs as fieldConfig>
|
||||
<#if fieldConfig.showInList>
|
||||
{ title: '${fieldConfig.comment}', dataIndex: '${fieldConfig.fieldName}', slotName: '${fieldConfig.fieldName}' },
|
||||
</#if>
|
||||
</#list>
|
||||
</#if>
|
||||
{
|
||||
title: '操作',
|
||||
slotName: 'action',
|
||||
width: 130,
|
||||
align: 'center',
|
||||
fixed: !isMobile() ? 'right' : undefined,
|
||||
show: has.hasPermOr(['${apiModuleName}:${apiName}:update', '${apiModuleName}:${apiName}:delete'])
|
||||
}
|
||||
]
|
||||
|
||||
// 重置
|
||||
const reset = () => {
|
||||
<#list fieldConfigs as fieldConfig>
|
||||
<#if fieldConfig.showInQuery>
|
||||
queryForm.${fieldConfig.fieldName} = undefined
|
||||
</#if>
|
||||
</#list>
|
||||
search()
|
||||
}
|
||||
|
||||
// 删除
|
||||
const onDelete = (item: ${classNamePrefix}Resp) => {
|
||||
return handleDelete(() => delete${classNamePrefix}(item.id), {
|
||||
content: `是否确定删除该条数据?`,
|
||||
showModal: true
|
||||
})
|
||||
}
|
||||
|
||||
// 导出
|
||||
const onExport = () => {
|
||||
useDownload(() => export${classNamePrefix}(queryForm))
|
||||
}
|
||||
|
||||
const ${classNamePrefix}AddModalRef = ref<InstanceType<typeof ${classNamePrefix}AddModal>>()
|
||||
// 新增
|
||||
const onAdd = () => {
|
||||
${classNamePrefix}AddModalRef.value?.onAdd()
|
||||
}
|
||||
|
||||
// 修改
|
||||
const onUpdate = (item: ${classNamePrefix}Resp) => {
|
||||
${classNamePrefix}AddModalRef.value?.onUpdate(item.id)
|
||||
}
|
||||
|
||||
const ${classNamePrefix}DetailDrawerRef = ref<InstanceType<typeof ${classNamePrefix}DetailDrawer>>()
|
||||
// 详情
|
||||
const onDetail = (item: ${classNamePrefix}Resp) => {
|
||||
${classNamePrefix}DetailDrawerRef.value?.onDetail(item.id)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
Reference in New Issue
Block a user