提交 | 用户 | 时间
|
9ec4bd
|
1 |
<template> |
1e8d99
|
2 |
<el-row :gutter="20"> |
潘 |
3 |
<!-- 左侧树 --> |
|
4 |
<el-col :span="4" :xs="24"> |
|
5 |
<ContentWrap class="h-1/1"> |
|
6 |
<el-tree |
|
7 |
style="max-width: 600px" |
|
8 |
:data="treeData" |
|
9 |
:props="treeProps" |
|
10 |
default-expand-all |
|
11 |
highlight-current |
|
12 |
@node-click="handleNodeClick" |
9ec4bd
|
13 |
/> |
1e8d99
|
14 |
</ContentWrap> |
潘 |
15 |
</el-col> |
|
16 |
<el-col :span="20" :xs="24"> |
|
17 |
<!-- 搜索工作栏 --> |
|
18 |
<ContentWrap> |
|
19 |
<el-form |
|
20 |
class="-mb-15px" |
|
21 |
:model="queryParams" |
|
22 |
ref="queryFormRef" |
|
23 |
:inline="true" |
|
24 |
label-width="68px" |
|
25 |
> |
|
26 |
<el-form-item label="模型名称" prop="pyName"> |
|
27 |
<el-input |
|
28 |
v-model="queryParams.pyName" |
|
29 |
placeholder="请输入模型名称" |
|
30 |
clearable |
|
31 |
class="!w-240px" |
|
32 |
/> |
|
33 |
</el-form-item> |
|
34 |
<el-form-item> |
|
35 |
<el-button @click="handleQuery"> |
|
36 |
<Icon icon="ep:search" class="mr-5px"/> |
|
37 |
搜索 |
9ec4bd
|
38 |
</el-button> |
1e8d99
|
39 |
<el-button @click="resetQuery"> |
潘 |
40 |
<Icon icon="ep:refresh" class="mr-5px"/> |
|
41 |
重置 |
|
42 |
</el-button> |
|
43 |
<div class="ml-12px"> |
|
44 |
<router-link :to="'/file/form'"> |
|
45 |
<el-button type="primary" plain v-hasPermi="['mpk:file:create']"> |
|
46 |
<Icon icon="ep:plus" class="mr-5px"/>新增</el-button> |
|
47 |
</router-link> |
9ec4bd
|
48 |
</div> |
潘 |
49 |
|
1e8d99
|
50 |
</el-form-item> |
潘 |
51 |
</el-form> |
|
52 |
</ContentWrap> |
|
53 |
|
|
54 |
<!-- 列表 --> |
|
55 |
<ContentWrap> |
|
56 |
<el-table |
|
57 |
v-loading="loading" |
|
58 |
:data="list" |
|
59 |
row-key="id" |
|
60 |
> |
7599ca
|
61 |
<el-table-column prop="pyChineseName" label="模型名称" header-align="center" align="center" min-width="100" /> |
1e8d99
|
62 |
<el-table-column prop="pyName" label="模型文件" header-align="center" align="center" min-width="300"/> |
潘 |
63 |
<el-table-column prop="pyType" label="模型类型" :formatter="(r,c,v) => getDictLabel(DICT_TYPE.MODEL_TYPE,v)"/> |
|
64 |
<el-table-column prop="menuName" label="所属菜单" min-width="120px"/> |
|
65 |
<el-table-column prop="groupName" label="所属组" min-width="120px"/> |
|
66 |
<el-table-column prop="remark" label="备注" min-width="100px"/> |
|
67 |
<el-table-column prop="createDate" label="创建时间" :formatter="dateFormatter" width="180px"/> |
|
68 |
<el-table-column label="操作" align="center" width="200px"> |
|
69 |
<template #default="scope"> |
|
70 |
<div class="flex items-center justify-center"> |
|
71 |
<router-link :to="'/file/form/' + scope.row.id"> |
|
72 |
<el-button type="primary" link v-hasPermi="['mpk:file:update']"> |
|
73 |
<Icon icon="ep:edit"/>修改 |
|
74 |
</el-button> |
|
75 |
</router-link> |
|
76 |
<el-button link type="danger" @click="handleDelete(scope.row.id)" v-hasPermi="['mpk:file:delete']"> |
|
77 |
<Icon icon="ep:delete"/>删除 |
|
78 |
</el-button> |
|
79 |
<div class="pl-12px"> |
|
80 |
<el-dropdown @command="(command) => handleCommand(command, scope.row)" trigger="click"> |
|
81 |
<el-button type="primary" link> |
|
82 |
<Icon icon="ep:d-arrow-right" /> 更多 |
|
83 |
</el-button> |
|
84 |
<template #dropdown> |
|
85 |
<el-dropdown-menu> |
|
86 |
<el-dropdown-item |
|
87 |
command="generatorCode" |
|
88 |
> |
|
89 |
生成代码 |
|
90 |
</el-dropdown-item> |
|
91 |
<el-dropdown-item |
|
92 |
command="generatorHistory" |
|
93 |
> |
|
94 |
生成历史 |
|
95 |
</el-dropdown-item> |
|
96 |
<el-dropdown-item |
|
97 |
command="mpkRunDialog" |
|
98 |
> |
|
99 |
运行 |
|
100 |
</el-dropdown-item> |
|
101 |
</el-dropdown-menu> |
|
102 |
</template> |
|
103 |
</el-dropdown> |
|
104 |
</div> |
|
105 |
</div> |
|
106 |
</template> |
|
107 |
</el-table-column> |
|
108 |
</el-table> |
|
109 |
<!-- 分页 --> |
|
110 |
<Pagination |
b45bad
|
111 |
v-model:limit="queryParams.limit" |
1e8d99
|
112 |
v-model:page="queryParams.page" |
潘 |
113 |
:total="total" |
|
114 |
@pagination="getList" |
|
115 |
/> |
|
116 |
</ContentWrap> |
|
117 |
|
|
118 |
<MpkGenerator ref="mpkGenerator"/> |
|
119 |
<GeneratorCodeHistory ref="generatorCodeHistory"/> |
|
120 |
<MpkRun ref="mpkRun"/> |
|
121 |
</el-col> |
|
122 |
</el-row> |
9ec4bd
|
123 |
</template> |
潘 |
124 |
<script lang="ts" setup> |
|
125 |
import {dateFormatter} from '@/utils/formatTime' |
aff5c9
|
126 |
import * as MpkApi from '@/api/model/mpk/mpk' |
1e8d99
|
127 |
import * as MpkMenuApi from '@/api/model/mpk/menu' |
9ec4bd
|
128 |
import MpkGenerator from './MpkGenerator.vue' |
潘 |
129 |
import GeneratorCodeHistory from './MpkGeneratorHistory.vue' |
|
130 |
import MpkRun from './MpkRun.vue' |
|
131 |
import { DICT_TYPE, getDictLabel } from '@/utils/dict' |
1e8d99
|
132 |
import {ElTree} from "element-plus"; |
9ec4bd
|
133 |
|
潘 |
134 |
defineOptions({name: 'MpkFile'}) |
|
135 |
|
|
136 |
const message = useMessage() // 消息弹窗 |
|
137 |
const {t} = useI18n() // 国际化 |
1e8d99
|
138 |
|
潘 |
139 |
const treeProps = { |
|
140 |
children: 'children', |
|
141 |
label: 'label', |
|
142 |
} |
9ec4bd
|
143 |
|
潘 |
144 |
const loading = ref(true) // 列表的加载中 |
|
145 |
const total = ref(0) // 列表的总页数 |
|
146 |
const list = ref([]) // 字典表格数据 |
|
147 |
const queryParams = reactive({ |
|
148 |
page: 1, |
b45bad
|
149 |
limit: 10, |
1e8d99
|
150 |
pyName: '', |
潘 |
151 |
label: '' |
9ec4bd
|
152 |
}) |
潘 |
153 |
const queryFormRef = ref() // 搜索的表单 |
1e8d99
|
154 |
const treeData = ref([]) |
9ec4bd
|
155 |
|
潘 |
156 |
const getList = async () => { |
|
157 |
loading.value = true |
|
158 |
try { |
|
159 |
const data = await MpkApi.getPage(queryParams) |
|
160 |
list.value = data.list |
|
161 |
total.value = data.total |
|
162 |
} finally { |
|
163 |
loading.value = false |
|
164 |
} |
1e8d99
|
165 |
} |
潘 |
166 |
|
|
167 |
const getTree = async () => { |
|
168 |
const data = await MpkMenuApi.getTree() |
|
169 |
treeData.value = data |
9ec4bd
|
170 |
} |
潘 |
171 |
|
|
172 |
/** 操作分发 */ |
|
173 |
const handleCommand = (command: string, row) => { |
|
174 |
switch (command) { |
|
175 |
case 'generatorCode': |
|
176 |
generatorCode(row.id,row.pyName) |
|
177 |
break |
|
178 |
case 'generatorHistory': |
|
179 |
generatorHistory(row.id) |
|
180 |
break |
|
181 |
case 'mpkRunDialog': |
|
182 |
mpkRunDialog(row) |
|
183 |
break |
|
184 |
default: |
|
185 |
break |
|
186 |
} |
|
187 |
} |
|
188 |
|
|
189 |
const mpkGenerator = ref(); |
|
190 |
const generatorCode = (id,pyName) => { |
|
191 |
mpkGenerator.value.open(id,pyName); |
|
192 |
} |
|
193 |
|
|
194 |
const generatorCodeHistory = ref(); |
|
195 |
const generatorHistory = (id) => { |
|
196 |
generatorCodeHistory.value.open(id); |
|
197 |
} |
|
198 |
|
|
199 |
const mpkRun = ref(); |
|
200 |
const mpkRunDialog = (row) => { |
|
201 |
mpkRun.value.open(row); |
|
202 |
} |
|
203 |
|
|
204 |
/** 搜索按钮操作 */ |
|
205 |
const handleQuery = () => { |
|
206 |
getList() |
|
207 |
} |
|
208 |
|
|
209 |
/** 重置按钮操作 */ |
|
210 |
const resetQuery = () => { |
|
211 |
queryParams.page = 1 |
|
212 |
queryFormRef.value.resetFields() |
|
213 |
handleQuery() |
|
214 |
} |
|
215 |
|
|
216 |
/** 删除按钮操作 */ |
|
217 |
const handleDelete = async (id: number) => { |
|
218 |
try { |
|
219 |
// 删除的二次确认 |
|
220 |
await message.delConfirm() |
|
221 |
// 发起删除 |
|
222 |
await MpkApi.deleteMpk(id) |
|
223 |
message.success(t('common.delSuccess')) |
|
224 |
// 刷新列表 |
|
225 |
await getList() |
|
226 |
} catch { |
|
227 |
} |
|
228 |
} |
|
229 |
|
1e8d99
|
230 |
const handleNodeClick = (data: Tree) => { |
潘 |
231 |
queryParams.label = data.label |
|
232 |
getList() |
|
233 |
} |
|
234 |
|
9ec4bd
|
235 |
onActivated((to) => { |
潘 |
236 |
getList() |
1e8d99
|
237 |
getTree() |
9ec4bd
|
238 |
}) |
潘 |
239 |
|
|
240 |
/** 初始化 **/ |
|
241 |
onMounted(async () => { |
|
242 |
await getList() |
1e8d99
|
243 |
await getTree() |
9ec4bd
|
244 |
}) |
潘 |
245 |
</script> |