提交 | 用户 | 时间
|
3e359e
|
1 |
<template> |
H |
2 |
<doc-alert title="流程设计器(BPMN)" url="https://doc.iocoder.cn/bpm/model-designer-dingding/" /> |
|
3 |
<doc-alert |
|
4 |
title="流程设计器(钉钉、飞书)" |
|
5 |
url="https://doc.iocoder.cn/bpm/model-designer-bpmn/" |
|
6 |
/> |
|
7 |
<doc-alert title="选择审批人、发起人自选" url="https://doc.iocoder.cn/bpm/assignee/" /> |
|
8 |
<doc-alert title="会签、或签、依次审批" url="https://doc.iocoder.cn/bpm/multi-instance/" /> |
|
9 |
|
|
10 |
<ContentWrap> |
|
11 |
<!-- 搜索工作栏 --> |
|
12 |
<el-form |
|
13 |
class="-mb-15px" |
|
14 |
:model="queryParams" |
|
15 |
ref="queryFormRef" |
|
16 |
:inline="true" |
|
17 |
label-width="68px" |
|
18 |
> |
|
19 |
<el-form-item label="流程标识" prop="key"> |
|
20 |
<el-input |
|
21 |
v-model="queryParams.key" |
|
22 |
placeholder="请输入流程标识" |
|
23 |
clearable |
|
24 |
@keyup.enter="handleQuery" |
|
25 |
class="!w-240px" |
|
26 |
/> |
|
27 |
</el-form-item> |
|
28 |
<el-form-item label="流程名称" prop="name"> |
|
29 |
<el-input |
|
30 |
v-model="queryParams.name" |
|
31 |
placeholder="请输入流程名称" |
|
32 |
clearable |
|
33 |
@keyup.enter="handleQuery" |
|
34 |
class="!w-240px" |
|
35 |
/> |
|
36 |
</el-form-item> |
|
37 |
<el-form-item label="流程分类" prop="category"> |
|
38 |
<el-select |
|
39 |
v-model="queryParams.category" |
|
40 |
placeholder="请选择流程分类" |
|
41 |
clearable |
|
42 |
class="!w-240px" |
|
43 |
> |
|
44 |
<el-option |
|
45 |
v-for="category in categoryList" |
|
46 |
:key="category.code" |
|
47 |
:label="category.name" |
|
48 |
:value="category.code" |
|
49 |
/> |
|
50 |
</el-select> |
|
51 |
</el-form-item> |
|
52 |
<el-form-item> |
|
53 |
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> |
|
54 |
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button> |
|
55 |
<el-button |
|
56 |
type="primary" |
|
57 |
plain |
|
58 |
@click="openForm('create')" |
|
59 |
v-hasPermi="['bpm:model:create']" |
|
60 |
> |
|
61 |
<Icon icon="ep:plus" class="mr-5px" /> 新建 |
|
62 |
</el-button> |
|
63 |
</el-form-item> |
|
64 |
</el-form> |
|
65 |
</ContentWrap> |
|
66 |
|
|
67 |
<!-- 列表 --> |
|
68 |
<ContentWrap> |
|
69 |
<el-table v-loading="loading" :data="list"> |
|
70 |
<el-table-column label="流程名称" align="center" prop="name" min-width="200" /> |
|
71 |
<el-table-column label="流程图标" align="center" prop="icon" min-width="100"> |
|
72 |
<template #default="scope"> |
|
73 |
<el-image :src="scope.row.icon" class="h-32px w-32px" /> |
|
74 |
</template> |
|
75 |
</el-table-column> |
|
76 |
<el-table-column label="可见范围" align="center" prop="startUserIds" min-width="100"> |
|
77 |
<template #default="scope"> |
|
78 |
<el-text v-if="!scope.row.startUsers || scope.row.startUsers.length === 0"> |
|
79 |
全部可见 |
|
80 |
</el-text> |
|
81 |
<el-text v-else-if="scope.row.startUsers.length == 1"> |
|
82 |
{{ scope.row.startUsers[0].nickname }} |
|
83 |
</el-text> |
|
84 |
<el-text v-else> |
|
85 |
<el-tooltip |
|
86 |
class="box-item" |
|
87 |
effect="dark" |
|
88 |
placement="top" |
|
89 |
:content="scope.row.startUsers.map((user: any) => user.nickname).join('、')" |
|
90 |
> |
|
91 |
{{ scope.row.startUsers[0].nickname }}等 {{ scope.row.startUsers.length }} 人可见 |
|
92 |
</el-tooltip> |
|
93 |
</el-text> |
|
94 |
</template> |
|
95 |
</el-table-column> |
|
96 |
<el-table-column label="流程分类" align="center" prop="categoryName" min-width="100" /> |
|
97 |
<el-table-column label="表单信息" align="center" prop="formType" min-width="200"> |
|
98 |
<template #default="scope"> |
|
99 |
<el-button |
|
100 |
v-if="scope.row.formType === 10" |
|
101 |
type="primary" |
|
102 |
link |
|
103 |
@click="handleFormDetail(scope.row)" |
|
104 |
> |
|
105 |
<span>{{ scope.row.formName }}</span> |
|
106 |
</el-button> |
|
107 |
<el-button |
|
108 |
v-else-if="scope.row.formType === 20" |
|
109 |
type="primary" |
|
110 |
link |
|
111 |
@click="handleFormDetail(scope.row)" |
|
112 |
> |
|
113 |
<span>{{ scope.row.formCustomCreatePath }}</span> |
|
114 |
</el-button> |
|
115 |
<label v-else>暂无表单</label> |
|
116 |
</template> |
|
117 |
</el-table-column> |
|
118 |
<el-table-column label="最后发布" align="center" prop="deploymentTime" min-width="250"> |
|
119 |
<template #default="scope"> |
|
120 |
<span v-if="scope.row.processDefinition"> |
|
121 |
{{ formatDate(scope.row.processDefinition.deploymentTime) }} |
|
122 |
</span> |
|
123 |
<el-tag v-if="scope.row.processDefinition" class="ml-10px"> |
|
124 |
v{{ scope.row.processDefinition.version }} |
|
125 |
</el-tag> |
|
126 |
<el-tag v-else type="warning">未部署</el-tag> |
|
127 |
<el-tag |
|
128 |
v-if="scope.row.processDefinition?.suspensionState === 2" |
|
129 |
type="warning" |
|
130 |
class="ml-10px" |
|
131 |
> |
|
132 |
已停用 |
|
133 |
</el-tag> |
|
134 |
</template> |
|
135 |
</el-table-column> |
|
136 |
<el-table-column label="操作" align="center" width="200" fixed="right"> |
|
137 |
<template #default="scope"> |
|
138 |
<el-button |
|
139 |
link |
|
140 |
type="primary" |
|
141 |
@click="openForm('update', scope.row.id)" |
|
142 |
v-hasPermi="['bpm:model:update']" |
|
143 |
:disabled="!isManagerUser(scope.row)" |
|
144 |
> |
|
145 |
修改 |
|
146 |
</el-button> |
|
147 |
<el-button |
|
148 |
link |
|
149 |
class="!ml-5px" |
|
150 |
type="primary" |
|
151 |
@click="handleDesign(scope.row)" |
|
152 |
v-hasPermi="['bpm:model:update']" |
|
153 |
:disabled="!isManagerUser(scope.row)" |
|
154 |
> |
|
155 |
设计 |
|
156 |
</el-button> |
|
157 |
<el-button |
|
158 |
link |
|
159 |
class="!ml-5px" |
|
160 |
type="primary" |
|
161 |
@click="handleDeploy(scope.row)" |
|
162 |
v-hasPermi="['bpm:model:deploy']" |
|
163 |
:disabled="!isManagerUser(scope.row)" |
|
164 |
> |
|
165 |
发布 |
|
166 |
</el-button> |
|
167 |
<el-dropdown |
|
168 |
class="!align-middle ml-5px" |
|
169 |
@command="(command) => handleCommand(command, scope.row)" |
|
170 |
v-hasPermi="['bpm:process-definition:query', 'bpm:model:update', 'bpm:model:delete']" |
|
171 |
> |
|
172 |
<el-button type="primary" link>更多</el-button> |
|
173 |
<template #dropdown> |
|
174 |
<el-dropdown-menu> |
|
175 |
<el-dropdown-item |
|
176 |
command="handleDefinitionList" |
|
177 |
v-if="checkPermi(['bpm:process-definition:query'])" |
|
178 |
> |
|
179 |
历史 |
|
180 |
</el-dropdown-item> |
|
181 |
<el-dropdown-item |
|
182 |
command="handleChangeState" |
|
183 |
v-if="checkPermi(['bpm:model:update']) && scope.row.processDefinition" |
|
184 |
:disabled="!isManagerUser(scope.row)" |
|
185 |
> |
|
186 |
{{ scope.row.processDefinition.suspensionState === 1 ? '停用' : '启用' }} |
|
187 |
</el-dropdown-item> |
|
188 |
<el-dropdown-item |
|
189 |
type="danger" |
|
190 |
command="handleDelete" |
|
191 |
v-if="checkPermi(['bpm:model:delete'])" |
|
192 |
:disabled="!isManagerUser(scope.row)" |
|
193 |
> |
|
194 |
删除 |
|
195 |
</el-dropdown-item> |
|
196 |
</el-dropdown-menu> |
|
197 |
</template> |
|
198 |
</el-dropdown> |
|
199 |
</template> |
|
200 |
</el-table-column> |
|
201 |
</el-table> |
|
202 |
<!-- 分页 --> |
|
203 |
<Pagination |
|
204 |
:total="total" |
|
205 |
v-model:page="queryParams.pageNo" |
|
206 |
v-model:limit="queryParams.pageSize" |
|
207 |
@pagination="getList" |
|
208 |
/> |
|
209 |
</ContentWrap> |
|
210 |
|
|
211 |
<!-- 表单弹窗:添加/修改流程 --> |
|
212 |
<ModelForm ref="formRef" @success="getList" /> |
|
213 |
|
|
214 |
<!-- 弹窗:表单详情 --> |
|
215 |
<Dialog title="表单详情" v-model="formDetailVisible" width="800"> |
|
216 |
<form-create :rule="formDetailPreview.rule" :option="formDetailPreview.option" /> |
|
217 |
</Dialog> |
|
218 |
</template> |
|
219 |
|
|
220 |
<script lang="ts" setup> |
|
221 |
import { formatDate } from '@/utils/formatTime' |
|
222 |
import * as ModelApi from '@/api/bpm/model' |
|
223 |
import * as FormApi from '@/api/bpm/form' |
|
224 |
import ModelForm from './ModelForm.vue' |
|
225 |
import { setConfAndFields2 } from '@/utils/formCreate' |
|
226 |
import { CategoryApi } from '@/api/bpm/category' |
|
227 |
import { BpmModelType } from '@/utils/constants' |
|
228 |
import { checkPermi } from '@/utils/permission' |
|
229 |
import { useUserStoreWithOut } from '@/store/modules/user' |
|
230 |
|
|
231 |
defineOptions({ name: 'BpmModel' }) |
|
232 |
|
|
233 |
const message = useMessage() // 消息弹窗 |
|
234 |
const { t } = useI18n() // 国际化 |
|
235 |
const { push } = useRouter() // 路由 |
|
236 |
const userStore = useUserStoreWithOut() // 用户信息缓存 |
|
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.getModelList(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 handleCommand = (command: string, row: any) => { |
|
277 |
switch (command) { |
|
278 |
case 'handleDefinitionList': |
|
279 |
handleDefinitionList(row) |
|
280 |
break |
|
281 |
case 'handleDelete': |
|
282 |
handleDelete(row) |
|
283 |
break |
|
284 |
case 'handleChangeState': |
|
285 |
handleChangeState(row) |
|
286 |
break |
|
287 |
default: |
|
288 |
break |
|
289 |
} |
|
290 |
} |
|
291 |
|
|
292 |
/** 添加/修改操作 */ |
|
293 |
const formRef = ref() |
|
294 |
const openForm = (type: string, id?: number) => { |
|
295 |
formRef.value.open(type, id) |
|
296 |
} |
|
297 |
|
|
298 |
/** 删除按钮操作 */ |
|
299 |
const handleDelete = async (row: any) => { |
|
300 |
try { |
|
301 |
// 删除的二次确认 |
|
302 |
await message.delConfirm() |
|
303 |
// 发起删除 |
|
304 |
await ModelApi.deleteModel(row.id) |
|
305 |
message.success(t('common.delSuccess')) |
|
306 |
// 刷新列表 |
|
307 |
await getList() |
|
308 |
} catch {} |
|
309 |
} |
|
310 |
|
|
311 |
/** 更新状态操作 */ |
|
312 |
const handleChangeState = async (row: any) => { |
|
313 |
const state = row.processDefinition.suspensionState |
|
314 |
const newState = state === 1 ? 2 : 1 |
|
315 |
try { |
|
316 |
// 修改状态的二次确认 |
|
317 |
const id = row.id |
|
318 |
debugger |
|
319 |
const statusState = state === 1 ? '停用' : '启用' |
|
320 |
const content = '是否确认' + statusState + '流程名字为"' + row.name + '"的数据项?' |
|
321 |
await message.confirm(content) |
|
322 |
// 发起修改状态 |
|
323 |
await ModelApi.updateModelState(id, newState) |
|
324 |
message.success(statusState + '成功') |
|
325 |
// 刷新列表 |
|
326 |
await getList() |
|
327 |
} catch {} |
|
328 |
} |
|
329 |
|
|
330 |
/** 设计流程 */ |
|
331 |
const handleDesign = (row: any) => { |
|
332 |
if (row.type == BpmModelType.BPMN) { |
|
333 |
push({ |
|
334 |
name: 'BpmModelEditor', |
|
335 |
query: { |
|
336 |
modelId: row.id |
|
337 |
} |
|
338 |
}) |
|
339 |
} else { |
|
340 |
push({ |
|
341 |
name: 'SimpleModelDesign', |
|
342 |
query: { |
|
343 |
modelId: row.id |
|
344 |
} |
|
345 |
}) |
|
346 |
} |
|
347 |
} |
|
348 |
|
|
349 |
/** 发布流程 */ |
|
350 |
const handleDeploy = async (row: any) => { |
|
351 |
try { |
|
352 |
// 删除的二次确认 |
|
353 |
await message.confirm('是否部署该流程!!') |
|
354 |
// 发起部署 |
|
355 |
await ModelApi.deployModel(row.id) |
|
356 |
message.success(t('部署成功')) |
|
357 |
// 刷新列表 |
|
358 |
await getList() |
|
359 |
} catch {} |
|
360 |
} |
|
361 |
|
|
362 |
/** 跳转到指定流程定义列表 */ |
|
363 |
const handleDefinitionList = (row) => { |
|
364 |
push({ |
|
365 |
name: 'BpmProcessDefinition', |
|
366 |
query: { |
|
367 |
key: row.key |
|
368 |
} |
|
369 |
}) |
|
370 |
} |
|
371 |
|
|
372 |
/** 流程表单的详情按钮操作 */ |
|
373 |
const formDetailVisible = ref(false) |
|
374 |
const formDetailPreview = ref({ |
|
375 |
rule: [], |
|
376 |
option: {} |
|
377 |
}) |
|
378 |
const handleFormDetail = async (row: any) => { |
|
379 |
if (row.formType == 10) { |
|
380 |
// 设置表单 |
|
381 |
const data = await FormApi.getForm(row.formId) |
|
382 |
setConfAndFields2(formDetailPreview, data.conf, data.fields) |
|
383 |
// 弹窗打开 |
|
384 |
formDetailVisible.value = true |
|
385 |
} else { |
|
386 |
await push({ |
|
387 |
path: row.formCustomCreatePath |
|
388 |
}) |
|
389 |
} |
|
390 |
} |
|
391 |
|
|
392 |
/** 判断是否可以操作 */ |
|
393 |
const isManagerUser = (row: any) => { |
|
394 |
const userId = userStore.getUser.id |
|
395 |
return row.managerUserIds && row.managerUserIds.includes(userId) |
|
396 |
} |
|
397 |
|
|
398 |
/** 初始化 **/ |
|
399 |
onMounted(async () => { |
|
400 |
await getList() |
|
401 |
// 查询流程分类列表 |
|
402 |
categoryList.value = await CategoryApi.getCategorySimpleList() |
|
403 |
}) |
|
404 |
</script> |