提交 | 用户 | 时间
|
e7c126
|
1 |
#set ($subTable = $subTables.get($subIndex))##当前表 |
H |
2 |
#set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组 |
|
3 |
#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 |
|
4 |
#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex)) |
|
5 |
#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 |
|
6 |
#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 |
|
7 |
<template> |
|
8 |
<!-- 列表 --> |
|
9 |
<ContentWrap> |
|
10 |
#if ($table.templateType == 11) |
|
11 |
<el-button |
|
12 |
type="primary" |
|
13 |
plain |
|
14 |
@click="openForm('create')" |
|
15 |
v-hasPermi="['${permissionPrefix}:create']" |
|
16 |
> |
|
17 |
<Icon icon="ep:plus" class="mr-5px" /> 新增 |
|
18 |
</el-button> |
|
19 |
#end |
|
20 |
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true"> |
|
21 |
#foreach($column in $subColumns) |
|
22 |
#if ($column.listOperationResult) |
|
23 |
#set ($dictType=$column.dictType) |
|
24 |
#set ($javaField = $column.javaField) |
|
25 |
#set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
|
26 |
#set ($comment=$column.columnComment) |
|
27 |
#if ( $column.id == $subJoinColumn.id) ## 特殊:忽略主子表的 join 字段,不用填写 |
|
28 |
#elseif ($column.javaType == "LocalDateTime")## 时间类型 |
|
29 |
<el-table-column |
|
30 |
label="${comment}" |
|
31 |
align="center" |
|
32 |
prop="${javaField}" |
|
33 |
:formatter="dateFormatter" |
|
34 |
width="180px" |
|
35 |
/> |
|
36 |
#elseif($column.dictType && "" != $column.dictType)## 数据字典 |
|
37 |
<el-table-column label="${comment}" align="center" prop="${javaField}"> |
|
38 |
<template #default="scope"> |
|
39 |
<dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.${column.javaField}" /> |
|
40 |
</template> |
|
41 |
</el-table-column> |
|
42 |
#else |
|
43 |
<el-table-column label="${comment}" align="center" prop="${javaField}" /> |
|
44 |
#end |
|
45 |
#end |
|
46 |
#end |
|
47 |
#if ($table.templateType == 11) |
|
48 |
<el-table-column label="操作" align="center"> |
|
49 |
<template #default="scope"> |
|
50 |
<el-button |
|
51 |
link |
|
52 |
type="primary" |
|
53 |
@click="openForm('update', scope.row.id)" |
|
54 |
v-hasPermi="['${permissionPrefix}:update']" |
|
55 |
> |
|
56 |
编辑 |
|
57 |
</el-button> |
|
58 |
<el-button |
|
59 |
link |
|
60 |
type="danger" |
|
61 |
@click="handleDelete(scope.row.id)" |
|
62 |
v-hasPermi="['${permissionPrefix}:delete']" |
|
63 |
> |
|
64 |
删除 |
|
65 |
</el-button> |
|
66 |
</template> |
|
67 |
</el-table-column> |
|
68 |
#end |
|
69 |
</el-table> |
|
70 |
#if ($table.templateType == 11) |
|
71 |
<!-- 分页 --> |
|
72 |
<Pagination |
|
73 |
:total="total" |
|
74 |
v-model:page="queryParams.pageNo" |
|
75 |
v-model:limit="queryParams.pageSize" |
|
76 |
@pagination="getList" |
|
77 |
/> |
|
78 |
#end |
|
79 |
</ContentWrap> |
|
80 |
#if ($table.templateType == 11) |
|
81 |
<!-- 表单弹窗:添加/修改 --> |
|
82 |
<${subSimpleClassName}Form ref="formRef" @success="getList" /> |
|
83 |
#end |
|
84 |
</template> |
|
85 |
<script setup lang="ts"> |
|
86 |
import { getIntDictOptions, getStrDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict' |
|
87 |
import { dateFormatter } from '@/utils/formatTime' |
|
88 |
import { ${simpleClassName}Api } from '@/api/${table.moduleName}/${table.businessName}' |
|
89 |
#if ($table.templateType == 11) |
|
90 |
import ${subSimpleClassName}Form from './${subSimpleClassName}Form.vue' |
|
91 |
#end |
|
92 |
|
|
93 |
const { t } = useI18n() // 国际化 |
|
94 |
const message = useMessage() // 消息弹窗 |
|
95 |
|
|
96 |
const props = defineProps<{ |
|
97 |
${subJoinColumn.javaField}?: number // ${subJoinColumn.columnComment}(主表的关联字段) |
|
98 |
}>() |
|
99 |
const loading = ref(false) // 列表的加载中 |
|
100 |
const list = ref([]) // 列表的数据 |
|
101 |
#if ($table.templateType == 11) |
|
102 |
const total = ref(0) // 列表的总页数 |
|
103 |
const queryParams = reactive({ |
|
104 |
pageNo: 1, |
|
105 |
pageSize: 10, |
|
106 |
${subJoinColumn.javaField}: undefined as unknown |
|
107 |
}) |
|
108 |
|
|
109 |
/** 监听主表的关联字段的变化,加载对应的子表数据 */ |
|
110 |
watch( |
|
111 |
() => props.${subJoinColumn.javaField}, |
|
112 |
(val: number) => { |
|
113 |
if (!val) { |
|
114 |
return |
|
115 |
} |
|
116 |
queryParams.${subJoinColumn.javaField} = val |
|
117 |
handleQuery() |
|
118 |
}, |
|
119 |
{ immediate: true, deep: true } |
|
120 |
) |
|
121 |
#end |
|
122 |
|
|
123 |
/** 查询列表 */ |
|
124 |
const getList = async () => { |
|
125 |
loading.value = true |
|
126 |
try { |
|
127 |
#if ($table.templateType == 11) |
|
128 |
const data = await ${simpleClassName}Api.get${subSimpleClassName}Page(queryParams) |
|
129 |
list.value = data.list |
|
130 |
total.value = data.total |
|
131 |
#else |
|
132 |
#if ( $subTable.subJoinMany ) |
|
133 |
list.value = await ${simpleClassName}Api.get${subSimpleClassName}ListBy${SubJoinColumnName}(props.${subJoinColumn.javaField}) |
|
134 |
#else |
|
135 |
const data = await ${simpleClassName}Api.get${subSimpleClassName}By${SubJoinColumnName}(props.${subJoinColumn.javaField}) |
|
136 |
if (!data) { |
|
137 |
return |
|
138 |
} |
|
139 |
list.value.push(data) |
|
140 |
#end |
|
141 |
#end |
|
142 |
} finally { |
|
143 |
loading.value = false |
|
144 |
} |
|
145 |
} |
|
146 |
|
|
147 |
/** 搜索按钮操作 */ |
|
148 |
const handleQuery = () => { |
|
149 |
queryParams.pageNo = 1 |
|
150 |
getList() |
|
151 |
} |
|
152 |
#if ($table.templateType == 11) |
|
153 |
|
|
154 |
/** 添加/修改操作 */ |
|
155 |
const formRef = ref() |
|
156 |
const openForm = (type: string, id?: number) => { |
|
157 |
if (!props.${subJoinColumn.javaField}) { |
|
158 |
message.error('请选择一个${table.classComment}') |
|
159 |
return |
|
160 |
} |
|
161 |
formRef.value.open(type, id, props.${subJoinColumn.javaField}) |
|
162 |
} |
|
163 |
|
|
164 |
/** 删除按钮操作 */ |
|
165 |
const handleDelete = async (id: number) => { |
|
166 |
try { |
|
167 |
// 删除的二次确认 |
|
168 |
await message.delConfirm() |
|
169 |
// 发起删除 |
|
170 |
await ${simpleClassName}Api.delete${subSimpleClassName}(id) |
|
171 |
message.success(t('common.delSuccess')) |
|
172 |
// 刷新列表 |
|
173 |
await getList() |
|
174 |
} catch {} |
|
175 |
} |
|
176 |
#end |
|
177 |
#if ($table.templateType != 11) |
|
178 |
|
|
179 |
/** 初始化 **/ |
|
180 |
onMounted(() => { |
|
181 |
getList() |
|
182 |
}) |
|
183 |
#end |
|
184 |
</script> |