|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<div class="table-box">
|
|
|
- <ProTable ref="proTable" :columns="columns" row-key="${pkColumn.javaField}" :request-api="list${BusinessName}Api" :init-param="initParam" :data-callback="dataCallback">
|
|
|
+ <ProTable ref="proTable" :columns="columns" row-key="${pkColumn.javaField}" :request-api="list${BusinessName}Api" >
|
|
|
<!-- 表格 header 按钮 -->
|
|
|
<template #tableHeader="scope">
|
|
|
<el-button type="primary" v-auth="['${moduleName}:${businessName}:add']" :icon="CirclePlus" @click="openDialog(1, '${functionName}新增')">
|
|
@@ -69,8 +69,8 @@
|
|
|
add${BusinessName}Api,
|
|
|
update${BusinessName}Api,
|
|
|
importTemplateApi,
|
|
|
- importDataApi,
|
|
|
- exportApi,
|
|
|
+ import${BusinessName}DataApi,
|
|
|
+ export${BusinessName}Api,
|
|
|
get${BusinessName}Api
|
|
|
} from '@/api/modules/${moduleName}/${businessName}'
|
|
|
#if(${dicts} != '')
|
|
@@ -80,29 +80,15 @@
|
|
|
// ProTable 实例
|
|
|
const proTable = ref<ProTableInstance>()
|
|
|
|
|
|
- // 如果表格需要初始化请求参数,直接定义传给 ProTable (之后每次请求都会自动带上该参数,此参数更改之后也会一直带上,改变此参数会自动刷新表格数据)
|
|
|
- const initParam = reactive({ type: 1 })
|
|
|
-
|
|
|
- // dataCallback 是对于返回的表格数据做处理,如果你后台返回的数据不是 list && total && pageNum && pageSize 这些字段,可以在这里进行处理成这些字段
|
|
|
- const dataCallback = (data: any) => {
|
|
|
- const page = proTable.value!.pageable
|
|
|
- return {
|
|
|
- list: data.data,
|
|
|
- total: data.total,
|
|
|
- pageNum: page.pageNum,
|
|
|
- pageSize: page.pageSize
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
// 删除${functionName}信息
|
|
|
const delete${BusinessName} = async (params: any) => {
|
|
|
- await useHandleData(del${BusinessName}Api, { id: [params.${pkColumn.javaField}] }, `删除【${params.id}】${functionName}`)
|
|
|
+ await useHandleData(del${BusinessName}Api, params.${pkColumn.javaField}, `删除【params.${pkColumn.javaField}】${functionName}`)
|
|
|
proTable.value?.getTableList()
|
|
|
}
|
|
|
|
|
|
// 批量删除${functionName}信息
|
|
|
- const batchDelete = async (id: string[]) => {
|
|
|
- await useHandleData(del${BusinessName}Api, { id }, '删除所选${functionName}信息')
|
|
|
+ const batchDelete = async (ids: string[]) => {
|
|
|
+ await useHandleData(del${BusinessName}Api, ids, '删除所选${functionName}信息')
|
|
|
proTable.value?.clearSelection()
|
|
|
proTable.value?.getTableList()
|
|
|
}
|
|
@@ -110,7 +96,7 @@
|
|
|
// 导出${functionName}列表
|
|
|
const downloadFile = async () => {
|
|
|
ElMessageBox.confirm('确认导出${functionName}数据?', '温馨提示', { type: 'warning' }).then(() =>
|
|
|
- useDownload(exportApi, '${functionName}列表', proTable.value?.searchParam)
|
|
|
+ useDownload(export${BusinessName}Api, '${functionName}列表', proTable.value?.searchParam)
|
|
|
)
|
|
|
}
|
|
|
|
|
@@ -120,7 +106,7 @@
|
|
|
const params = {
|
|
|
title: '${functionName}',
|
|
|
tempApi: importTemplateApi,
|
|
|
- importApi: importDataApi,
|
|
|
+ importApi: import${BusinessName}DataApi,
|
|
|
getTableList: proTable.value?.getTableList
|
|
|
}
|
|
|
dialogRef.value?.acceptParams(params)
|
|
@@ -134,12 +120,12 @@
|
|
|
res = await get${BusinessName}Api(row?.${pkColumn.javaField} || null)
|
|
|
}
|
|
|
// 重置表单
|
|
|
- setFieldList()
|
|
|
+ setFormItems()
|
|
|
const params = {
|
|
|
title,
|
|
|
width: 580,
|
|
|
isEdit: type !== 3,
|
|
|
- fieldList: fieldList,
|
|
|
+ fieldList: formItems,
|
|
|
model: type == 1 ? {} : res.data,
|
|
|
api: type == 1 ? add${BusinessName}Api : update${BusinessName}Api,
|
|
|
getTableList: proTable.value?.getTableList
|
|
@@ -204,9 +190,9 @@
|
|
|
{ prop: 'operation', label: '操作', width: 230, fixed: 'right' }
|
|
|
])
|
|
|
// 表单配置项
|
|
|
- let fieldList: Form.FieldItem[] = []
|
|
|
- const setFieldList = () => {
|
|
|
- fieldList = [
|
|
|
+ let formItems: ProForm.ItemsOptions[] = []
|
|
|
+ const setFormItems = () => {
|
|
|
+ formItems = [
|
|
|
#foreach($column in $columns)
|
|
|
#set($field=$column.javaField)
|
|
|
#if($column.insert && !$column.pk)
|
|
@@ -221,51 +207,51 @@
|
|
|
#if($column.htmlType == "input")
|
|
|
{
|
|
|
label: '${comment}',
|
|
|
- field: '${field}',
|
|
|
+ prop: '${field}',
|
|
|
#if($column.required)
|
|
|
rules: [{required: true, message: '${comment}不能为空', trigger: 'blur'}],
|
|
|
#else
|
|
|
#end
|
|
|
- placeholder: '请输入${comment}'
|
|
|
+ compOptions: {
|
|
|
+ placeholder: '请输入${comment}'
|
|
|
+ }
|
|
|
},
|
|
|
#elseif($column.htmlType == "select" && "" != $dictType)
|
|
|
{
|
|
|
label: '${comment}',
|
|
|
- field: '${field}',
|
|
|
- enum: () => getDictsApi('$dictType'),
|
|
|
- type: 'select',
|
|
|
+ prop: '${field}',
|
|
|
#if($column.required)
|
|
|
rules: [{required: true, message: '${comment}不能为空', trigger: 'change'}],
|
|
|
#else
|
|
|
#end
|
|
|
- options: {
|
|
|
+ compOptions: {
|
|
|
+ elTagName: 'select',
|
|
|
labelKey: 'dictLabel',
|
|
|
- valueKey: 'dictValue'
|
|
|
- },
|
|
|
- placeholder: '请选择${comment}'
|
|
|
+ valueKey: 'dictValue',
|
|
|
+ enum: () => getDictsApi('$dictType'),
|
|
|
+ placeholder: '请选择${comment}'
|
|
|
+ }
|
|
|
},
|
|
|
#elseif($column.htmlType == "checkbox" && "" != $dictType)
|
|
|
{
|
|
|
label: '${comment}',
|
|
|
- field: '${field}',
|
|
|
- enum: () => getDictsApi('$dictType'),
|
|
|
- type: 'checkbox',
|
|
|
+ prop: '${field}',
|
|
|
#if($column.required)
|
|
|
rules: [{required: true, message: '${comment}不能为空', trigger: 'change'}],
|
|
|
#else
|
|
|
#end
|
|
|
- options: {
|
|
|
+ compOptions: {
|
|
|
+ elTagName: 'checkbox-group',
|
|
|
labelKey: 'dictLabel',
|
|
|
- valueKey: 'dictValue'
|
|
|
- },
|
|
|
- placeholder: '请选择${comment}'
|
|
|
+ valueKey: 'dictValue',
|
|
|
+ enum: () => getDictsApi('$dictType'),
|
|
|
+ placeholder: '请选择${comment}'
|
|
|
+ }
|
|
|
},
|
|
|
#elseif($column.htmlType == "radio" && "" != $dictType)
|
|
|
{
|
|
|
label: '${comment}',
|
|
|
- field: '${field}',
|
|
|
- enum: () => getDictsApi('$dictType'),
|
|
|
- type: 'radio',
|
|
|
+ prop: '${field}',
|
|
|
#if($column.required)
|
|
|
rules: [{required: true, message: '${comment}不能为空', trigger: 'change'}],
|
|
|
#else
|
|
@@ -274,39 +260,53 @@
|
|
|
labelKey: 'dictLabel',
|
|
|
valueKey: 'dictValue'
|
|
|
},
|
|
|
- placeholder: '请选择${comment}'
|
|
|
+ compOptions: {
|
|
|
+ elTagName: 'radio-group',
|
|
|
+ labelKey: 'dictLabel',
|
|
|
+ valueKey: 'dictValue',
|
|
|
+ enum: () => getDictsApi('$dictType'),
|
|
|
+ placeholder: '请选择${comment}'
|
|
|
+ }
|
|
|
},
|
|
|
#elseif($column.htmlType == "datetime")
|
|
|
{
|
|
|
label: '${comment}',
|
|
|
- field: '${field}',
|
|
|
- type: 'date-picker',
|
|
|
+ prop: '${field}',
|
|
|
#if($column.required)
|
|
|
rules: [{required: true, message: '${comment}不能为空', trigger: 'change'}],
|
|
|
#else
|
|
|
#end
|
|
|
- placeholder: '请选择${comment}'
|
|
|
+ compOptions: {
|
|
|
+ elTagName: 'date-picker',
|
|
|
+ type: 'date',
|
|
|
+ placeholder: '请选择${comment}'
|
|
|
+ }
|
|
|
},
|
|
|
#elseif($column.htmlType == "textarea")
|
|
|
{
|
|
|
label: '${comment}',
|
|
|
- field: '${field}',
|
|
|
- type: 'textarea',
|
|
|
+ prop: '${field}',
|
|
|
#if($column.required)
|
|
|
rules: [{required: true, message: '${comment}不能为空', trigger: 'blur'}],
|
|
|
#else
|
|
|
#end
|
|
|
- placeholder: '请输入内容'
|
|
|
+ compOptions: {
|
|
|
+ type: 'textarea',
|
|
|
+ clearable: true,
|
|
|
+ placeholder: '请输入内容'
|
|
|
+ }
|
|
|
},
|
|
|
#else
|
|
|
{
|
|
|
label: '${comment}',
|
|
|
- field: '${field}',
|
|
|
+ prop: '${field}',
|
|
|
#if($column.required)
|
|
|
rules: [{required: true, message: '${comment}不能为空', trigger: 'blur'}],
|
|
|
#else
|
|
|
#end
|
|
|
- placeholder: '请输入${comment}'
|
|
|
+ compOptions: {
|
|
|
+ placeholder: '请输入${comment}'
|
|
|
+ }
|
|
|
},
|
|
|
#end
|
|
|
#end
|