1. 新增代码生成器支持生成时预设基础封装组件(查询、表格、列表、编辑弹窗)
2. 新增模块与 Server 新增脚本方法
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
<template>
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="100px"
|
||||
v-loading="formLoading"
|
||||
>
|
||||
<FormDialog
|
||||
ref="formDialogRef"
|
||||
:form-data="formData"
|
||||
:form-rules="formRules"
|
||||
:create-api="${simpleClassName}Api.create${simpleClassName}"
|
||||
:update-api="${simpleClassName}Api.update${simpleClassName}"
|
||||
:get-api="${simpleClassName}Api.get${simpleClassName}"
|
||||
create-title="新增${table.classComment}"
|
||||
update-title="修改${table.classComment}"
|
||||
@success="handleSuccess"
|
||||
>
|
||||
<template #form-items="{ formData }">
|
||||
#foreach($column in $columns)
|
||||
#if ($column.createOperation || $column.updateOperation)
|
||||
#set ($dictType = $column.dictType)
|
||||
@@ -48,6 +52,7 @@
|
||||
#elseif($column.htmlType == "fileUpload")## 文件上传
|
||||
<el-form-item label="${comment}" prop="${javaField}">
|
||||
<UploadFile v-model="formData.${javaField}" />
|
||||
</el-form-item>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "editor")## 文本编辑器
|
||||
<el-form-item label="${comment}" prop="${javaField}">
|
||||
@@ -116,35 +121,37 @@
|
||||
#end
|
||||
#end
|
||||
#if($isFileUpload && $isFileUpload == true)
|
||||
<el-form-item label="附件" prop="files">
|
||||
<UploadFile v-model="formData.files" />
|
||||
</el-form-item>
|
||||
<el-form-item label="附件" prop="files">
|
||||
<UploadFile v-model="formData.files" />
|
||||
</el-form-item>
|
||||
#end
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
## 特殊:主子表专属逻辑
|
||||
#if ( $table.templateType == 10 || $table.templateType == 12 )
|
||||
<!-- 子表的表单 -->
|
||||
<el-tabs v-model="subTabsName">
|
||||
#foreach ($subTable in $subTables)
|
||||
#set ($index = $foreach.count - 1)
|
||||
#set ($subClassNameVar = $subClassNameVars.get($index))
|
||||
#set ($subSimpleClassName = $subSimpleClassNames.get($index))
|
||||
#set ($subJoinColumn_strikeCase = $subJoinColumn_strikeCases.get($index))
|
||||
<el-tab-pane label="${subTable.classComment}" name="$subClassNameVar">
|
||||
<${subSimpleClassName}Form ref="${subClassNameVar}FormRef" :${subJoinColumn_strikeCase}="formData.id" />
|
||||
</el-tab-pane>
|
||||
#end
|
||||
</el-tabs>
|
||||
#end
|
||||
<template #footer>
|
||||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<template #footer="{ submit, cancel, loading }">
|
||||
<el-tabs v-model="subTabsName" style="margin-bottom: 20px;">
|
||||
#foreach ($subTable in $subTables)
|
||||
#set ($index = $foreach.count - 1)
|
||||
#set ($subClassNameVar = $subClassNameVars.get($index))
|
||||
#set ($subSimpleClassName = $subSimpleClassNames.get($index))
|
||||
#set ($subJoinColumn_strikeCase = $subJoinColumn_strikeCases.get($index))
|
||||
<el-tab-pane label="${subTable.classComment}" name="$subClassNameVar">
|
||||
<${subSimpleClassName}Form ref="${subClassNameVar}FormRef" :${subJoinColumn_strikeCase}="formData.id" />
|
||||
</el-tab-pane>
|
||||
#end
|
||||
</el-tabs>
|
||||
<el-button @click="submit" type="primary" :disabled="loading">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
#end
|
||||
</FormDialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { getIntDictOptions, getStrDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
import { ${simpleClassName}Api, ${simpleClassName}VO } from '@/api/${table.moduleName}/${table.businessName}'
|
||||
import FormDialog from '@/components/FormDialog/index.vue'
|
||||
## 特殊:树表专属逻辑
|
||||
#if ( $table.templateType == 2 )
|
||||
import { defaultProps, handleTree } from '@/utils/tree'
|
||||
@@ -162,10 +169,13 @@ defineOptions({ name: '${simpleClassName}Form' })
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const dialogTitle = ref('') // 弹窗的标题
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||
/** 成功事件 */
|
||||
const emit = defineEmits(['success'])
|
||||
|
||||
/** 组件引用 */
|
||||
const formDialogRef = ref()
|
||||
|
||||
/** 表单数据 */
|
||||
const formData = ref({
|
||||
#foreach ($column in $columns)
|
||||
#if ($column.createOperation || $column.updateOperation)
|
||||
@@ -180,6 +190,8 @@ const formData = ref({
|
||||
files: undefined
|
||||
#end
|
||||
})
|
||||
|
||||
/** 表单验证规则 */
|
||||
const formRules = reactive({
|
||||
#foreach ($column in $columns)
|
||||
#if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键
|
||||
@@ -188,6 +200,7 @@ const formRules = reactive({
|
||||
#end
|
||||
#end
|
||||
})
|
||||
|
||||
const formRef = ref() // 表单 Ref
|
||||
## 特殊:树表专属逻辑
|
||||
#if ( $table.templateType == 2 )
|
||||
@@ -205,97 +218,17 @@ const ${subClassNameVar}FormRef = ref()
|
||||
#end
|
||||
#end
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number) => {
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = t('action.' + type)
|
||||
formType.value = type
|
||||
resetForm()
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
formLoading.value = true
|
||||
try {
|
||||
formData.value = await ${simpleClassName}Api.get${simpleClassName}(id)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
## 特殊:树表专属逻辑
|
||||
#if ( $table.templateType == 2 )
|
||||
await get${simpleClassName}Tree()
|
||||
#end
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
await formRef.value.validate()
|
||||
## 特殊:主子表专属逻辑
|
||||
#if ( $table.templateType == 10 || $table.templateType == 12 )
|
||||
#if ( $subTables && $subTables.size() > 0 )
|
||||
// 校验子表单
|
||||
#foreach ($subTable in $subTables)
|
||||
#set ($index = $foreach.count - 1)
|
||||
#set ($subClassNameVar = $subClassNameVars.get($index))
|
||||
try {
|
||||
await ${subClassNameVar}FormRef.value.validate()
|
||||
} catch (e) {
|
||||
subTabsName.value = '${subClassNameVar}'
|
||||
return
|
||||
}
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as unknown as ${simpleClassName}VO
|
||||
## 特殊:主子表专属逻辑
|
||||
#if ( $table.templateType == 10 || $table.templateType == 12 )
|
||||
#if ( $subTables && $subTables.size() > 0 )
|
||||
// 拼接子表的数据
|
||||
#foreach ($subTable in $subTables)
|
||||
#set ($index = $foreach.count - 1)
|
||||
#set ($subClassNameVar = $subClassNameVars.get($index))
|
||||
data.${subClassNameVar}#if ( $subTable.subJoinMany)s#end = ${subClassNameVar}FormRef.value.getData()
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
if (formType.value === 'create') {
|
||||
await ${simpleClassName}Api.create${simpleClassName}(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
} else {
|
||||
await ${simpleClassName}Api.update${simpleClassName}(data)
|
||||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
/** 处理成功事件 */
|
||||
const handleSuccess = () => {
|
||||
emit('success')
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
#foreach ($column in $columns)
|
||||
#if ($column.createOperation || $column.updateOperation)
|
||||
#if ($column.htmlType == "checkbox")
|
||||
$column.javaField: [],
|
||||
#else
|
||||
$column.javaField: undefined,
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#if($isFileUpload && $isFileUpload == true)
|
||||
files: undefined
|
||||
#end
|
||||
/** 暴露组件方法 */
|
||||
defineExpose({
|
||||
open: (type: string, id?: number) => {
|
||||
formDialogRef.value?.open(type, id)
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
})
|
||||
## 特殊:树表专属逻辑
|
||||
#if ( $table.templateType == 2 )
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<!-- 搜索区域 -->
|
||||
<SearchForm
|
||||
v-model="queryParams"
|
||||
@search="handleQuery"
|
||||
@reset="resetQuery"
|
||||
>
|
||||
<template #search-items="{ form }">
|
||||
#foreach($column in $columns)
|
||||
#if ($column.listOperation)
|
||||
#set ($dictType = $column.dictType)
|
||||
@@ -26,7 +24,7 @@
|
||||
#if ($column.htmlType == "input")
|
||||
<el-form-item label="${comment}" prop="${javaField}">
|
||||
<el-input
|
||||
v-model="queryParams.${javaField}"
|
||||
v-model="form.${javaField}"
|
||||
placeholder="请输入${comment}"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
@@ -36,7 +34,7 @@
|
||||
#elseif ($column.htmlType == "select" || $column.htmlType == "radio")
|
||||
<el-form-item label="${comment}" prop="${javaField}">
|
||||
<el-select
|
||||
v-model="queryParams.${javaField}"
|
||||
v-model="form.${javaField}"
|
||||
placeholder="请选择${comment}"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
@@ -57,7 +55,7 @@
|
||||
#if ($column.listOperationCondition != "BETWEEN")## 非范围
|
||||
<el-form-item label="${comment}" prop="${javaField}">
|
||||
<el-date-picker
|
||||
v-model="queryParams.${javaField}"
|
||||
v-model="form.${javaField}"
|
||||
value-format="YYYY-MM-DD"
|
||||
type="date"
|
||||
placeholder="选择${comment}"
|
||||
@@ -68,7 +66,7 @@
|
||||
#else## 范围
|
||||
<el-form-item label="${comment}" prop="${javaField}">
|
||||
<el-date-picker
|
||||
v-model="queryParams.${javaField}"
|
||||
v-model="form.${javaField}"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
start-placeholder="开始日期"
|
||||
@@ -81,51 +79,50 @@
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
@click="openForm('create')"
|
||||
v-hasPermi="['${permissionPrefix}:create']"
|
||||
>
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
@click="handleExport"
|
||||
:loading="exportLoading"
|
||||
v-hasPermi="['${permissionPrefix}:export']"
|
||||
>
|
||||
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||
</el-button>
|
||||
</template>
|
||||
|
||||
<template #action-buttons>
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
@click="openForm('create')"
|
||||
v-hasPermi="['${permissionPrefix}:create']"
|
||||
>
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
@click="handleExport"
|
||||
:loading="exportLoading"
|
||||
v-hasPermi="['${permissionPrefix}:export']"
|
||||
>
|
||||
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||
</el-button>
|
||||
#if ( $table.templateType != 12 && $table.templateType != 11 && $table.templateType != 2 )
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
@click="handleBatchDelete"
|
||||
:disabled="selectRecords.length === 0"
|
||||
v-hasPermi="['template:demo-virtualized-table:delete']"
|
||||
>
|
||||
<Icon icon="ep:delete" class="mr-5px" /> 批量删除({{ selectRecords.length }})
|
||||
</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
@click="handleBatchDelete"
|
||||
:disabled="selectRecords.length === 0"
|
||||
v-hasPermi="['${permissionPrefix}:delete']"
|
||||
>
|
||||
<Icon icon="ep:delete" class="mr-5px" /> 批量删除({{ selectRecords.length }})
|
||||
</el-button>
|
||||
#end
|
||||
## 特殊:树表专属逻辑
|
||||
#if ( $table.templateType == 2 )
|
||||
<el-button type="danger" plain @click="toggleExpandAll">
|
||||
<Icon icon="ep:sort" class="mr-5px" /> 展开/折叠
|
||||
</el-button>
|
||||
<el-button type="danger" plain @click="toggleExpandAll">
|
||||
<Icon icon="ep:sort" class="mr-5px" /> 展开/折叠
|
||||
</el-button>
|
||||
#end
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
</template>
|
||||
</SearchForm>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
## 特殊:主子表专属逻辑
|
||||
<!-- 列表区域 -->
|
||||
#if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 )
|
||||
<!-- 特殊:主子表使用传统表格 -->
|
||||
<ContentWrap>
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="list"
|
||||
@@ -134,8 +131,9 @@
|
||||
highlight-current-row
|
||||
@current-change="handleCurrentChange"
|
||||
>
|
||||
## 特殊:树表专属逻辑
|
||||
#elseif ( $table.templateType == 2 )
|
||||
<!-- 特殊:树表使用传统表格 -->
|
||||
<ContentWrap>
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="list"
|
||||
@@ -145,9 +143,47 @@
|
||||
:default-expand-all="isExpandAll"
|
||||
v-if="refreshTable"
|
||||
>
|
||||
###else
|
||||
## <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||
#elseif ( $table.templateType == 12 && $subTables && $subTables.size() > 0 )
|
||||
<!-- 特殊:主子表展开使用传统表格 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||
#else
|
||||
<!-- 普通表格使用 DataTable 组件 -->
|
||||
<DataTable
|
||||
:data="list"
|
||||
:total="total"
|
||||
:loading="loading"
|
||||
:current-page="queryParams.pageNo"
|
||||
:page-size="queryParams.pageSize"
|
||||
:columns="tableColumns"
|
||||
@pagination="handlePagination"
|
||||
@selection-change="onSelectionChange"
|
||||
>
|
||||
<template #action="{ row }">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="openForm('update', row.id)"
|
||||
v-hasPermi="['${permissionPrefix}:update']"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(row.id)"
|
||||
v-hasPermi="['${permissionPrefix}:delete']"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
#if($isFileUpload && $isFileUpload == true)
|
||||
<el-button link @click="openBusinessFile(row.id)">附件</el-button>
|
||||
#end
|
||||
</template>
|
||||
</DataTable>
|
||||
#end
|
||||
## 特殊表格依然使用 element table
|
||||
#if ( $table.templateType == 12 || $table.templateType == 11 || $table.templateType == 2 )
|
||||
## 特殊:主子表专属逻辑
|
||||
#if ( $table.templateType == 12 && $subTables && $subTables.size() > 0 )
|
||||
<!-- 子表的列表 -->
|
||||
@@ -167,8 +203,6 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
#end
|
||||
## 特殊表格依然使用 element table
|
||||
#if ( $table.templateType == 12 || $table.templateType == 11 || $table.templateType == 2 )
|
||||
#foreach($column in $columns)
|
||||
#if ($column.listOperationResult)
|
||||
#set ($dictType=$column.dictType)
|
||||
@@ -218,36 +252,6 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
#else
|
||||
## 普通表格使用 Vxe table 支持大数据量渲染
|
||||
<vxe-grid
|
||||
ref="gridRef"
|
||||
v-bind="gridOptions"
|
||||
@checkbox-change="onCheckboxChange"
|
||||
>
|
||||
<template #action="{ row }">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="openForm('update', row.id)"
|
||||
v-hasPermi="['${permissionPrefix}:update']"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(row.id)"
|
||||
v-hasPermi="['${permissionPrefix}:delete']"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
#if($isFileUpload && $isFileUpload == true)
|
||||
<el-button link @click="openBusinessFile(row.id)">附件</el-button>
|
||||
#end
|
||||
</template>
|
||||
</vxe-grid>
|
||||
#end
|
||||
<!-- 分页 -->
|
||||
<Pagination
|
||||
:total="total"
|
||||
@@ -257,6 +261,7 @@
|
||||
:page-sizes="[10, 20, 50, 100, 200, 500, 700,5000, 10000]"
|
||||
/>
|
||||
</ContentWrap>
|
||||
#end
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<${simpleClassName}Form ref="formRef" @success="getList" />
|
||||
@@ -286,10 +291,16 @@ import { dateFormatter } from '@/utils/formatTime'
|
||||
#if ( $table.templateType == 2 )
|
||||
import { handleTree } from '@/utils/tree'
|
||||
#end
|
||||
#if ( $table.templateType != 12 && $table.templateType != 11 && $table.templateType != 2 )
|
||||
import { useVxeGrid } from '@/hooks/web/useVxeGrid'
|
||||
#end
|
||||
import download from '@/utils/download'
|
||||
import { ${simpleClassName}Api, ${simpleClassName}VO } from '@/api/${table.moduleName}/${table.businessName}'
|
||||
import ${simpleClassName}Form from './${simpleClassName}Form.vue'
|
||||
import SearchForm from '@/components/SearchForm/index.vue'
|
||||
#if ( $table.templateType != 12 && $table.templateType != 11 && $table.templateType != 2 )
|
||||
import DataTable from '@/components/DataTable/index.vue'
|
||||
#end
|
||||
## 特殊:主子表专属逻辑
|
||||
#if ( $table.templateType != 10 )
|
||||
#foreach ($subSimpleClassName in $subSimpleClassNames)
|
||||
@@ -319,7 +330,9 @@ const list = ref<${simpleClassName}VO[]>([]) // 列表的数据
|
||||
#if ( $table.templateType != 2 )
|
||||
const total = ref(0) // 列表的总页数
|
||||
#end
|
||||
#if ( $table.templateType == 12 || $table.templateType == 11 || $table.templateType == 2 )
|
||||
const gridRef = ref() // vxe-grid 的引用
|
||||
#end
|
||||
const selectRecords = ref<${simpleClassName}VO[]>([]) // 选中的记录
|
||||
const queryParams = reactive({
|
||||
## 特殊:树表专属逻辑(树不需要分页接口)
|
||||
@@ -338,10 +351,67 @@ const queryParams = reactive({
|
||||
#end
|
||||
#end
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
|
||||
#if ( $table.templateType != 12 && $table.templateType != 11 && $table.templateType != 2 )
|
||||
// 表格列配置
|
||||
const tableColumns = [
|
||||
#foreach($column in $columns)
|
||||
#if ($column.listOperationResult)
|
||||
#set ($dictType=$column.dictType)
|
||||
#set ($javaField = $column.javaField)
|
||||
#set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#set ($comment=$column.columnComment)
|
||||
#if ($column.javaType == "LocalDateTime")## 时间类型
|
||||
{
|
||||
field: '${javaField}',
|
||||
title: '${comment}',
|
||||
width: 180,
|
||||
align: 'center',
|
||||
formatter: ({ row, column, cellValue }) => cellValue ? dateFormatter(row, column, cellValue) : ''
|
||||
},
|
||||
#elseif($column.dictType && "" != $column.dictType)## 数据字典
|
||||
{
|
||||
field: '${javaField}',
|
||||
title: '${comment}',
|
||||
width: 120,
|
||||
align: 'center',
|
||||
formatter: ({ cellValue }) => {
|
||||
const dict = getStrDictOptions(DICT_TYPE.${dictType.toUpperCase()}).find(item => item.value === cellValue)
|
||||
return dict ? dict.label : cellValue
|
||||
}
|
||||
},
|
||||
#else
|
||||
{
|
||||
field: '${javaField}',
|
||||
title: '${comment}',
|
||||
minWidth: 120,
|
||||
align: 'center'
|
||||
},
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
{
|
||||
title: '操作',
|
||||
width: 200,
|
||||
align: 'center',
|
||||
fixed: 'right', // 固定在右侧
|
||||
slots: { default: 'action' }
|
||||
}
|
||||
]
|
||||
|
||||
/** DataTable 选择变化事件 */
|
||||
const onSelectionChange = (records: ${simpleClassName}VO[]) => {
|
||||
selectRecords.value = records
|
||||
}
|
||||
|
||||
/** 分页处理 */
|
||||
const handlePagination = ({ page, limit }: { page: number; limit: number }) => {
|
||||
queryParams.pageNo = page
|
||||
queryParams.pageSize = limit
|
||||
getList()
|
||||
}
|
||||
#else
|
||||
/** vxe-grid 复选框事件 */
|
||||
const onCheckboxChange = ({ records }) => {
|
||||
selectRecords.value = records
|
||||
@@ -424,14 +494,18 @@ const getList = async () => {
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
#if ( $table.templateType != 2 )
|
||||
queryParams.pageNo = 1
|
||||
#end
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value.resetFields()
|
||||
handleQuery()
|
||||
#if ( $table.templateType != 2 )
|
||||
queryParams.pageNo = 1
|
||||
#end
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 添加/修改操作 */
|
||||
@@ -467,7 +541,11 @@ const handleBatchDelete = async () => {
|
||||
await ${simpleClassName}Api.delete${simpleClassName}List(ids)
|
||||
message.success(t('common.delSuccess'))
|
||||
// 清空选中状态
|
||||
#if ( $table.templateType != 12 && $table.templateType != 11 && $table.templateType != 2 )
|
||||
// DataTable 组件会自动处理选中状态
|
||||
#else
|
||||
gridRef.value?.clearCheckboxRow()
|
||||
#end
|
||||
selectRecords.value = []
|
||||
// 刷新列表
|
||||
await getList()
|
||||
|
||||
Reference in New Issue
Block a user