提交 | 用户 | 时间
|
820397
|
1 |
<template> |
H |
2 |
<ContentWrap> |
|
3 |
<!-- 搜索工作栏 --> |
|
4 |
<el-form |
|
5 |
class="-mb-15px" |
|
6 |
:model="queryParams" |
|
7 |
ref="queryFormRef" |
|
8 |
:inline="true" |
|
9 |
label-width="68px" |
|
10 |
> |
|
11 |
<el-form-item label="流程标识" prop="key"> |
|
12 |
<el-input |
|
13 |
v-model="queryParams.key" |
|
14 |
placeholder="请输入流程标识" |
|
15 |
clearable |
|
16 |
@keyup.enter="handleQuery" |
|
17 |
class="!w-240px" |
|
18 |
/> |
|
19 |
</el-form-item> |
|
20 |
<el-form-item label="流程名称" prop="name"> |
|
21 |
<el-input |
|
22 |
v-model="queryParams.name" |
|
23 |
placeholder="请输入流程名称" |
|
24 |
clearable |
|
25 |
@keyup.enter="handleQuery" |
|
26 |
class="!w-240px" |
|
27 |
/> |
|
28 |
</el-form-item> |
|
29 |
<el-form-item label="流程分类" prop="category"> |
|
30 |
<el-select |
|
31 |
v-model="queryParams.category" |
|
32 |
placeholder="请选择流程分类" |
|
33 |
clearable |
|
34 |
class="!w-240px" |
|
35 |
> |
|
36 |
<el-option |
|
37 |
v-for="category in categoryList" |
|
38 |
:key="category.code" |
|
39 |
:label="category.name" |
|
40 |
:value="category.code" |
|
41 |
/> |
|
42 |
</el-select> |
|
43 |
</el-form-item> |
|
44 |
<el-form-item> |
|
45 |
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> |
|
46 |
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button> |
|
47 |
<el-button |
|
48 |
type="primary" |
|
49 |
plain |
|
50 |
@click="openForm('create')" |
|
51 |
v-hasPermi="['bpm:model:create']" |
|
52 |
> |
|
53 |
<Icon icon="ep:plus" class="mr-5px" /> 新建流程 |
|
54 |
</el-button> |
|
55 |
<el-button type="success" plain @click="openImportForm" v-hasPermi="['bpm:model:import']"> |
|
56 |
<Icon icon="ep:upload" class="mr-5px" /> 导入流程 |
|
57 |
</el-button> |
|
58 |
</el-form-item> |
|
59 |
</el-form> |
|
60 |
</ContentWrap> |
|
61 |
|
|
62 |
<!-- 列表 --> |
|
63 |
<ContentWrap> |
|
64 |
<el-table v-loading="loading" :data="list"> |
|
65 |
<el-table-column label="流程标识" align="center" prop="key" width="200" /> |
|
66 |
<el-table-column label="流程名称" align="center" prop="name" width="200"> |
|
67 |
<template #default="scope"> |
|
68 |
<el-button type="primary" link @click="handleBpmnDetail(scope.row)"> |
|
69 |
<span>{{ scope.row.name }}</span> |
|
70 |
</el-button> |
|
71 |
</template> |
|
72 |
</el-table-column> |
|
73 |
<el-table-column label="流程图标" align="center" prop="icon" width="100"> |
|
74 |
<template #default="scope"> |
|
75 |
<el-image :src="scope.row.icon" class="w-32px h-32px" /> |
|
76 |
</template> |
|
77 |
</el-table-column> |
|
78 |
<el-table-column label="流程分类" align="center" prop="categoryName" width="100" /> |
|
79 |
<el-table-column label="表单信息" align="center" prop="formType" width="200"> |
|
80 |
<template #default="scope"> |
|
81 |
<el-button |
|
82 |
v-if="scope.row.formType === 10" |
|
83 |
type="primary" |
|
84 |
link |
|
85 |
@click="handleFormDetail(scope.row)" |
|
86 |
> |
|
87 |
<span>{{ scope.row.formName }}</span> |
|
88 |
</el-button> |
|
89 |
<el-button |
|
90 |
v-else-if="scope.row.formType === 20" |
|
91 |
type="primary" |
|
92 |
link |
|
93 |
@click="handleFormDetail(scope.row)" |
|
94 |
> |
|
95 |
<span>{{ scope.row.formCustomCreatePath }}</span> |
|
96 |
</el-button> |
|
97 |
<label v-else>暂无表单</label> |
|
98 |
</template> |
|
99 |
</el-table-column> |
|
100 |
<el-table-column |
|
101 |
label="创建时间" |
|
102 |
align="center" |
|
103 |
prop="createTime" |
|
104 |
width="180" |
|
105 |
:formatter="dateFormatter" |
|
106 |
/> |
|
107 |
<el-table-column label="最新部署的流程定义" align="center"> |
|
108 |
<el-table-column |
|
109 |
label="流程版本" |
|
110 |
align="center" |
|
111 |
prop="processDefinition.version" |
|
112 |
width="100" |
|
113 |
> |
|
114 |
<template #default="scope"> |
|
115 |
<el-tag v-if="scope.row.processDefinition"> |
|
116 |
v{{ scope.row.processDefinition.version }} |
|
117 |
</el-tag> |
|
118 |
<el-tag v-else type="warning">未部署</el-tag> |
|
119 |
</template> |
|
120 |
</el-table-column> |
|
121 |
<el-table-column |
|
122 |
label="激活状态" |
|
123 |
align="center" |
|
124 |
prop="processDefinition.version" |
|
125 |
width="85" |
|
126 |
> |
|
127 |
<template #default="scope"> |
|
128 |
<el-switch |
|
129 |
v-if="scope.row.processDefinition" |
|
130 |
v-model="scope.row.processDefinition.suspensionState" |
|
131 |
:active-value="1" |
|
132 |
:inactive-value="2" |
|
133 |
@change="handleChangeState(scope.row)" |
|
134 |
/> |
|
135 |
</template> |
|
136 |
</el-table-column> |
|
137 |
<el-table-column label="部署时间" align="center" prop="deploymentTime" width="180"> |
|
138 |
<template #default="scope"> |
|
139 |
<span v-if="scope.row.processDefinition"> |
|
140 |
{{ formatDate(scope.row.processDefinition.deploymentTime) }} |
|
141 |
</span> |
|
142 |
</template> |
|
143 |
</el-table-column> |
|
144 |
</el-table-column> |
|
145 |
<el-table-column label="操作" align="center" width="240" fixed="right"> |
|
146 |
<template #default="scope"> |
|
147 |
<el-button |
|
148 |
link |
|
149 |
type="primary" |
|
150 |
@click="openForm('update', scope.row.id)" |
|
151 |
v-hasPermi="['bpm:model:update']" |
|
152 |
> |
|
153 |
修改流程 |
|
154 |
</el-button> |
|
155 |
<el-button |
|
156 |
link |
|
157 |
type="primary" |
|
158 |
@click="handleDesign(scope.row)" |
|
159 |
v-hasPermi="['bpm:model:update']" |
|
160 |
> |
|
161 |
设计流程 |
|
162 |
</el-button> |
|
163 |
<el-button |
|
164 |
link |
|
165 |
type="primary" |
|
166 |
@click="handleDeploy(scope.row)" |
|
167 |
v-hasPermi="['bpm:model:deploy']" |
|
168 |
> |
|
169 |
发布流程 |
|
170 |
</el-button> |
|
171 |
<el-button |
|
172 |
link |
|
173 |
type="primary" |
|
174 |
v-hasPermi="['bpm:process-definition:query']" |
|
175 |
@click="handleDefinitionList(scope.row)" |
|
176 |
> |
|
177 |
流程定义 |
|
178 |
</el-button> |
|
179 |
<el-button |
|
180 |
link |
|
181 |
type="danger" |
|
182 |
@click="handleDelete(scope.row.id)" |
|
183 |
v-hasPermi="['bpm:model:delete']" |
|
184 |
> |
|
185 |
删除 |
|
186 |
</el-button> |
|
187 |
</template> |
|
188 |
</el-table-column> |
|
189 |
</el-table> |
|
190 |
<!-- 分页 --> |
|
191 |
<Pagination |
|
192 |
:total="total" |
|
193 |
v-model:page="queryParams.pageNo" |
|
194 |
v-model:limit="queryParams.pageSize" |
|
195 |
@pagination="getList" |
|
196 |
/> |
|
197 |
</ContentWrap> |
|
198 |
|
|
199 |
<!-- 表单弹窗:添加/修改流程 --> |
|
200 |
<ModelForm ref="formRef" @success="getList" /> |
|
201 |
|
|
202 |
<!-- 表单弹窗:导入流程 --> |
|
203 |
<ModelImportForm ref="importFormRef" @success="getList" /> |
|
204 |
|
|
205 |
<!-- 弹窗:表单详情 --> |
|
206 |
<Dialog title="表单详情" v-model="formDetailVisible" width="800"> |
|
207 |
<form-create :rule="formDetailPreview.rule" :option="formDetailPreview.option" /> |
|
208 |
</Dialog> |
|
209 |
|
|
210 |
<!-- 弹窗:流程模型图的预览 --> |
|
211 |
<Dialog title="流程图" v-model="bpmnDetailVisible" width="800"> |
|
212 |
<MyProcessViewer |
|
213 |
key="designer" |
|
214 |
v-model="bpmnXML" |
|
215 |
:value="bpmnXML as any" |
|
216 |
v-bind="bpmnControlForm" |
|
217 |
:prefix="bpmnControlForm.prefix" |
|
218 |
/> |
|
219 |
</Dialog> |
|
220 |
</template> |
|
221 |
|
|
222 |
<script lang="ts" setup> |
|
223 |
import { dateFormatter, formatDate } from '@/utils/formatTime' |
|
224 |
import { MyProcessViewer } from '@/components/bpmnProcessDesigner/package' |
|
225 |
import * as ModelApi from '@/api/bpm/model' |
|
226 |
import * as FormApi from '@/api/bpm/form' |
|
227 |
import ModelForm from './ModelForm.vue' |
|
228 |
import ModelImportForm from '@/views/bpm/model/ModelImportForm.vue' |
|
229 |
import { setConfAndFields2 } from '@/utils/formCreate' |
|
230 |
import { CategoryApi } from '@/api/bpm/category' |
|
231 |
|
|
232 |
defineOptions({ name: 'BpmModel' }) |
|
233 |
|
|
234 |
const message = useMessage() // 消息弹窗 |
|
235 |
const { t } = useI18n() // 国际化 |
|
236 |
const { push } = useRouter() // 路由 |
|
237 |
|
|
238 |
const loading = ref(true) // 列表的加载中 |
|
239 |
const total = ref(0) // 列表的总页数 |
|
240 |
const list = ref([]) // 列表的数据 |
|
241 |
const queryParams = reactive({ |
|
242 |
pageNo: 1, |
|
243 |
pageSize: 10, |
|
244 |
key: undefined, |
|
245 |
name: undefined, |
|
246 |
category: undefined |
|
247 |
}) |
|
248 |
const queryFormRef = ref() // 搜索的表单 |
|
249 |
const categoryList = ref([]) // 流程分类列表 |
|
250 |
|
|
251 |
/** 查询列表 */ |
|
252 |
const getList = async () => { |
|
253 |
loading.value = true |
|
254 |
try { |
|
255 |
const data = await ModelApi.getModelPage(queryParams) |
|
256 |
list.value = data.list |
|
257 |
total.value = data.total |
|
258 |
} finally { |
|
259 |
loading.value = false |
|
260 |
} |
|
261 |
} |
|
262 |
|
|
263 |
/** 搜索按钮操作 */ |
|
264 |
const handleQuery = () => { |
|
265 |
queryParams.pageNo = 1 |
|
266 |
getList() |
|
267 |
} |
|
268 |
|
|
269 |
/** 重置按钮操作 */ |
|
270 |
const resetQuery = () => { |
|
271 |
queryFormRef.value.resetFields() |
|
272 |
handleQuery() |
|
273 |
} |
|
274 |
|
|
275 |
/** 添加/修改操作 */ |
|
276 |
const formRef = ref() |
|
277 |
const openForm = (type: string, id?: number) => { |
|
278 |
formRef.value.open(type, id) |
|
279 |
} |
|
280 |
|
|
281 |
/** 添加/修改操作 */ |
|
282 |
const importFormRef = ref() |
|
283 |
const openImportForm = () => { |
|
284 |
importFormRef.value.open() |
|
285 |
} |
|
286 |
|
|
287 |
/** 删除按钮操作 */ |
|
288 |
const handleDelete = async (id: number) => { |
|
289 |
try { |
|
290 |
// 删除的二次确认 |
|
291 |
await message.delConfirm() |
|
292 |
// 发起删除 |
|
293 |
await ModelApi.deleteModel(id) |
|
294 |
message.success(t('common.delSuccess')) |
|
295 |
// 刷新列表 |
|
296 |
await getList() |
|
297 |
} catch {} |
|
298 |
} |
|
299 |
|
|
300 |
/** 更新状态操作 */ |
|
301 |
const handleChangeState = async (row) => { |
|
302 |
const state = row.processDefinition.suspensionState |
|
303 |
try { |
|
304 |
// 修改状态的二次确认 |
|
305 |
const id = row.id |
|
306 |
const statusState = state === 1 ? '激活' : '挂起' |
|
307 |
const content = '是否确认' + statusState + '流程名字为"' + row.name + '"的数据项?' |
|
308 |
await message.confirm(content) |
|
309 |
// 发起修改状态 |
|
310 |
await ModelApi.updateModelState(id, state) |
|
311 |
// 刷新列表 |
|
312 |
await getList() |
|
313 |
} catch { |
|
314 |
// 取消后,进行恢复按钮 |
|
315 |
row.processDefinition.suspensionState = state === 1 ? 2 : 1 |
|
316 |
} |
|
317 |
} |
|
318 |
|
|
319 |
/** 设计流程 */ |
|
320 |
const handleDesign = (row) => { |
|
321 |
push({ |
|
322 |
name: 'BpmModelEditor', |
|
323 |
query: { |
|
324 |
modelId: row.id |
|
325 |
} |
|
326 |
}) |
|
327 |
} |
|
328 |
|
|
329 |
/** 发布流程 */ |
|
330 |
const handleDeploy = async (row) => { |
|
331 |
try { |
|
332 |
// 删除的二次确认 |
|
333 |
await message.confirm('是否部署该流程!!') |
|
334 |
// 发起部署 |
|
335 |
await ModelApi.deployModel(row.id) |
|
336 |
message.success(t('部署成功')) |
|
337 |
// 刷新列表 |
|
338 |
await getList() |
|
339 |
} catch {} |
|
340 |
} |
|
341 |
|
|
342 |
/** 跳转到指定流程定义列表 */ |
|
343 |
const handleDefinitionList = (row) => { |
|
344 |
push({ |
|
345 |
name: 'BpmProcessDefinition', |
|
346 |
query: { |
|
347 |
key: row.key |
|
348 |
} |
|
349 |
}) |
|
350 |
} |
|
351 |
|
|
352 |
/** 流程表单的详情按钮操作 */ |
|
353 |
const formDetailVisible = ref(false) |
|
354 |
const formDetailPreview = ref({ |
|
355 |
rule: [], |
|
356 |
option: {} |
|
357 |
}) |
|
358 |
const handleFormDetail = async (row) => { |
|
359 |
if (row.formType == 10) { |
|
360 |
// 设置表单 |
|
361 |
const data = await FormApi.getForm(row.formId) |
|
362 |
setConfAndFields2(formDetailPreview, data.conf, data.fields) |
|
363 |
// 弹窗打开 |
|
364 |
formDetailVisible.value = true |
|
365 |
} else { |
|
366 |
await push({ |
|
367 |
path: row.formCustomCreatePath |
|
368 |
}) |
|
369 |
} |
|
370 |
} |
|
371 |
|
|
372 |
/** 流程图的详情按钮操作 */ |
|
373 |
const bpmnDetailVisible = ref(false) |
|
374 |
const bpmnXML = ref(null) |
|
375 |
const bpmnControlForm = ref({ |
|
376 |
prefix: 'flowable' |
|
377 |
}) |
|
378 |
const handleBpmnDetail = async (row) => { |
|
379 |
const data = await ModelApi.getModel(row.id) |
|
380 |
bpmnXML.value = data.bpmnXml || '' |
|
381 |
bpmnDetailVisible.value = true |
|
382 |
} |
|
383 |
|
|
384 |
/** 初始化 **/ |
|
385 |
onMounted(async () => { |
|
386 |
await getList() |
|
387 |
// 查询流程分类列表 |
|
388 |
categoryList.value = await CategoryApi.getCategorySimpleList() |
|
389 |
}) |
|
390 |
</script> |