Skip to content

Commit 5286ad1

Browse files
committed
BPM:新增【流程实例】菜单,用于全部流程实例的查询
1 parent ee12e69 commit 5286ad1

File tree

4 files changed

+300
-22
lines changed

4 files changed

+300
-22
lines changed

src/api/bpm/processInstance/index.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,32 @@ export type ProcessInstanceCopyVO = {
3131
reason: string
3232
}
3333

34-
export const getMyProcessInstancePage = async (params) => {
34+
export const getProcessInstanceMyPage = async (params: any) => {
3535
return await request.get({ url: '/bpm/process-instance/my-page', params })
3636
}
3737

38+
export const getProcessInstanceManagerPage = async (params: any) => {
39+
return await request.get({ url: '/bpm/process-instance/manager-page', params })
40+
}
41+
3842
export const createProcessInstance = async (data) => {
3943
return await request.post({ url: '/bpm/process-instance/create', data: data })
4044
}
4145

42-
export const cancelProcessInstance = async (id: number, reason: string) => {
46+
export const cancelProcessInstanceByStartUser = async (id: number, reason: string) => {
47+
const data = {
48+
id: id,
49+
reason: reason
50+
}
51+
return await request.delete({ url: '/bpm/process-instance/cancel-by-start-user', data: data })
52+
}
53+
54+
export const cancelProcessInstanceByAdmin = async (id: number, reason: string) => {
4355
const data = {
4456
id: id,
4557
reason: reason
4658
}
47-
return await request.delete({ url: '/bpm/process-instance/cancel', data: data })
59+
return await request.delete({ url: '/bpm/process-instance/cancel-by-admin', data: data })
4860
}
4961

5062
export const getProcessInstance = async (id: string) => {

src/views/bpm/oa/leave/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ const cancelLeave = async (row) => {
226226
inputErrorMessage: '取消原因不能为空'
227227
})
228228
// 发起取消
229-
await ProcessInstanceApi.cancelProcessInstance(row.id, value)
229+
await ProcessInstanceApi.cancelProcessInstanceByStartUser(row.id, value)
230230
message.success('取消成功')
231231
// 刷新列表
232232
await getList()

src/views/bpm/processInstance/index.vue

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
/>
5959
</el-select>
6060
</el-form-item>
61-
<el-form-item label="提交时间" prop="createTime">
61+
<el-form-item label="发起时间" prop="createTime">
6262
<el-date-picker
6363
v-model="queryParams.createTime"
6464
value-format="YYYY-MM-DD HH:mm:ss"
@@ -87,23 +87,21 @@
8787
<!-- 列表 -->
8888
<ContentWrap>
8989
<el-table v-loading="loading" :data="list">
90-
<el-table-column label="流程编号" align="center" prop="id" width="300px" />
91-
<el-table-column label="流程名称" align="center" prop="name" />
92-
<el-table-column label="流程分类" align="center" prop="categoryName" />
93-
<el-table-column label="当前审批任务" align="center" prop="tasks">
94-
<template #default="scope">
95-
<el-button type="primary" v-for="task in scope.row.tasks" :key="task.id" link>
96-
<span>{{ task.name }}</span>
97-
</el-button>
98-
</template>
99-
</el-table-column>
100-
<el-table-column label="流程" prop="status">
90+
<el-table-column label="流程名称" align="center" prop="name" min-width="200px" fixed="left" />
91+
<el-table-column
92+
label="流程分类"
93+
align="center"
94+
prop="categoryName"
95+
min-width="100"
96+
fixed="left"
97+
/>
98+
<el-table-column label="流程状态" prop="status" width="120">
10199
<template #default="scope">
102100
<dict-tag :type="DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS" :value="scope.row.status" />
103101
</template>
104102
</el-table-column>
105103
<el-table-column
106-
label="提交时间"
104+
label="发起时间"
107105
align="center"
108106
prop="startTime"
109107
width="180"
@@ -116,7 +114,20 @@
116114
width="180"
117115
:formatter="dateFormatter"
118116
/>
119-
<el-table-column label="操作" align="center">
117+
<el-table-column align="center" label="耗时" prop="durationInMillis" width="120">
118+
<template #default="scope">
119+
{{ scope.row.durationInMillis > 0 ? formatPast2(scope.row.durationInMillis) : '-' }}
120+
</template>
121+
</el-table-column>
122+
<el-table-column label="当前审批任务" align="center" prop="tasks" min-width="120px">
123+
<template #default="scope">
124+
<el-button type="primary" v-for="task in scope.row.tasks" :key="task.id" link>
125+
<span>{{ task.name }}</span>
126+
</el-button>
127+
</template>
128+
</el-table-column>
129+
<el-table-column label="流程编号" align="center" prop="id" min-width="320px" />
130+
<el-table-column label="操作" align="center" fixed="right" width="180">
120131
<template #default="scope">
121132
<el-button
122133
link
@@ -152,12 +163,12 @@
152163
</template>
153164
<script lang="ts" setup>
154165
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
155-
import { dateFormatter } from '@/utils/formatTime'
166+
import { dateFormatter, formatPast2 } from '@/utils/formatTime'
156167
import { ElMessageBox } from 'element-plus'
157168
import * as ProcessInstanceApi from '@/api/bpm/processInstance'
158169
import { CategoryApi } from '@/api/bpm/category'
159170
160-
defineOptions({ name: 'BpmProcessInstance' })
171+
defineOptions({ name: 'BpmProcessInstanceMy' })
161172
162173
const router = useRouter() // 路由
163174
const message = useMessage() // 消息弹窗
@@ -182,7 +193,7 @@ const categoryList = ref([]) // 流程分类列表
182193
const getList = async () => {
183194
loading.value = true
184195
try {
185-
const data = await ProcessInstanceApi.getMyProcessInstancePage(queryParams)
196+
const data = await ProcessInstanceApi.getProcessInstanceMyPage(queryParams)
186197
list.value = data.list
187198
total.value = data.total
188199
} finally {
@@ -230,7 +241,7 @@ const handleCancel = async (row) => {
230241
inputErrorMessage: '取消原因不能为空'
231242
})
232243
// 发起取消
233-
await ProcessInstanceApi.cancelProcessInstance(row.id, value)
244+
await ProcessInstanceApi.cancelProcessInstanceByStartUser(row.id, value)
234245
message.success('取消成功')
235246
// 刷新列表
236247
await getList()
Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
<template>
2+
<doc-alert title="工作流手册" url="https://doc.iocoder.cn/bpm/" />
3+
4+
<ContentWrap>
5+
<!-- 搜索工作栏 -->
6+
<el-form
7+
class="-mb-15px"
8+
:model="queryParams"
9+
ref="queryFormRef"
10+
:inline="true"
11+
label-width="68px"
12+
>
13+
<el-form-item label="发起人" prop="startUserId">
14+
<el-select v-model="queryParams.startUserId" placeholder="请选择发起人" class="!w-240px">
15+
<el-option
16+
v-for="user in userList"
17+
:key="user.id"
18+
:label="user.nickname"
19+
:value="user.id"
20+
/>
21+
</el-select>
22+
</el-form-item>
23+
<el-form-item label="流程名称" prop="name">
24+
<el-input
25+
v-model="queryParams.name"
26+
placeholder="请输入流程名称"
27+
clearable
28+
@keyup.enter="handleQuery"
29+
class="!w-240px"
30+
/>
31+
</el-form-item>
32+
<el-form-item label="所属流程" prop="processDefinitionId">
33+
<el-input
34+
v-model="queryParams.processDefinitionId"
35+
placeholder="请输入流程定义的编号"
36+
clearable
37+
@keyup.enter="handleQuery"
38+
class="!w-240px"
39+
/>
40+
</el-form-item>
41+
<el-form-item label="流程分类" prop="category">
42+
<el-select
43+
v-model="queryParams.category"
44+
placeholder="请选择流程分类"
45+
clearable
46+
class="!w-240px"
47+
>
48+
<el-option
49+
v-for="category in categoryList"
50+
:key="category.code"
51+
:label="category.name"
52+
:value="category.code"
53+
/>
54+
</el-select>
55+
</el-form-item>
56+
<el-form-item label="流程状态" prop="status">
57+
<el-select
58+
v-model="queryParams.status"
59+
placeholder="请选择流程状态"
60+
clearable
61+
class="!w-240px"
62+
>
63+
<el-option
64+
v-for="dict in getIntDictOptions(DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS)"
65+
:key="dict.value"
66+
:label="dict.label"
67+
:value="dict.value"
68+
/>
69+
</el-select>
70+
</el-form-item>
71+
<el-form-item label="发起时间" prop="createTime">
72+
<el-date-picker
73+
v-model="queryParams.createTime"
74+
value-format="YYYY-MM-DD HH:mm:ss"
75+
type="daterange"
76+
start-placeholder="开始日期"
77+
end-placeholder="结束日期"
78+
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
79+
class="!w-220px"
80+
/>
81+
</el-form-item>
82+
</el-form>
83+
</ContentWrap>
84+
85+
<!-- 列表 -->
86+
<ContentWrap>
87+
<el-table v-loading="loading" :data="list">
88+
<el-table-column label="流程名称" align="center" prop="name" min-width="200px" fixed="left" />
89+
<el-table-column
90+
label="流程分类"
91+
align="center"
92+
prop="categoryName"
93+
min-width="100"
94+
fixed="left"
95+
/>
96+
<el-table-column label="流程发起人" align="center" prop="startUser.nickname" width="120" />
97+
<el-table-column label="发起部门" align="center" prop="startUser.deptName" width="120" />
98+
<el-table-column label="流程状态" prop="status" width="120">
99+
<template #default="scope">
100+
<dict-tag :type="DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS" :value="scope.row.status" />
101+
</template>
102+
</el-table-column>
103+
<el-table-column
104+
label="发起时间"
105+
align="center"
106+
prop="startTime"
107+
width="180"
108+
:formatter="dateFormatter"
109+
/>
110+
<el-table-column
111+
label="结束时间"
112+
align="center"
113+
prop="endTime"
114+
width="180"
115+
:formatter="dateFormatter"
116+
/>
117+
<el-table-column align="center" label="耗时" prop="durationInMillis" width="120">
118+
<template #default="scope">
119+
{{ scope.row.durationInMillis > 0 ? formatPast2(scope.row.durationInMillis) : '-' }}
120+
</template>
121+
</el-table-column>
122+
<el-table-column label="当前审批任务" align="center" prop="tasks" min-width="120px">
123+
<template #default="scope">
124+
<el-button type="primary" v-for="task in scope.row.tasks" :key="task.id" link>
125+
<span>{{ task.name }}</span>
126+
</el-button>
127+
</template>
128+
</el-table-column>
129+
<el-table-column label="流程编号" align="center" prop="id" min-width="320px" />
130+
<el-table-column label="操作" align="center" fixed="right" width="180">
131+
<template #default="scope">
132+
<el-button
133+
link
134+
type="primary"
135+
v-hasPermi="['bpm:process-instance:cancel']"
136+
@click="handleDetail(scope.row)"
137+
>
138+
详情
139+
</el-button>
140+
<el-button
141+
link
142+
type="primary"
143+
v-if="scope.row.status === 1"
144+
v-hasPermi="['bpm:process-instance:query']"
145+
@click="handleCancel(scope.row)"
146+
>
147+
取消
148+
</el-button>
149+
</template>
150+
</el-table-column>
151+
</el-table>
152+
<!-- 分页 -->
153+
<Pagination
154+
:total="total"
155+
v-model:page="queryParams.pageNo"
156+
v-model:limit="queryParams.pageSize"
157+
@pagination="getList"
158+
/>
159+
</ContentWrap>
160+
</template>
161+
<script lang="ts" setup>
162+
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
163+
import { dateFormatter, formatPast2 } from '@/utils/formatTime'
164+
import { ElMessageBox } from 'element-plus'
165+
import * as ProcessInstanceApi from '@/api/bpm/processInstance'
166+
import { CategoryApi } from '@/api/bpm/category'
167+
import * as UserApi from '@/api/system/user'
168+
import { cancelProcessInstanceByAdmin } from '@/api/bpm/processInstance'
169+
170+
// 它是【我的流程】的差异是,该菜单可以看全部的流程实例
171+
defineOptions({ name: 'BpmProcessInstanceManager' })
172+
173+
const router = useRouter() // 路由
174+
const message = useMessage() // 消息弹窗
175+
const { t } = useI18n() // 国际化
176+
177+
const loading = ref(true) // 列表的加载中
178+
const total = ref(0) // 列表的总页数
179+
const list = ref([]) // 列表的数据
180+
const queryParams = reactive({
181+
pageNo: 1,
182+
pageSize: 10,
183+
startUserId: undefined,
184+
name: '',
185+
processDefinitionId: undefined,
186+
category: undefined,
187+
status: undefined,
188+
createTime: []
189+
})
190+
const queryFormRef = ref() // 搜索的表单
191+
const categoryList = ref([]) // 流程分类列表
192+
const userList = ref<any[]>([]) // 用户列表
193+
194+
/** 查询列表 */
195+
const getList = async () => {
196+
loading.value = true
197+
try {
198+
const data = await ProcessInstanceApi.getProcessInstanceManagerPage(queryParams)
199+
list.value = data.list
200+
total.value = data.total
201+
} finally {
202+
loading.value = false
203+
}
204+
}
205+
206+
/** 搜索按钮操作 */
207+
const handleQuery = () => {
208+
queryParams.pageNo = 1
209+
getList()
210+
}
211+
212+
/** 重置按钮操作 */
213+
const resetQuery = () => {
214+
queryFormRef.value.resetFields()
215+
handleQuery()
216+
}
217+
218+
/** 查看详情 */
219+
const handleDetail = (row) => {
220+
router.push({
221+
name: 'BpmProcessInstanceDetail',
222+
query: {
223+
id: row.id
224+
}
225+
})
226+
}
227+
228+
/** 取消按钮操作 */
229+
const handleCancel = async (row) => {
230+
// 二次确认
231+
const { value } = await ElMessageBox.prompt('请输入取消原因', '取消流程', {
232+
confirmButtonText: t('common.ok'),
233+
cancelButtonText: t('common.cancel'),
234+
inputPattern: /^[\s\S]*.*\S[\s\S]*$/, // 判断非空,且非空格
235+
inputErrorMessage: '取消原因不能为空'
236+
})
237+
// 发起取消
238+
await ProcessInstanceApi.cancelProcessInstanceByAdmin(row.id, value)
239+
message.success('取消成功')
240+
// 刷新列表
241+
await getList()
242+
}
243+
244+
/** 激活时 **/
245+
onActivated(() => {
246+
getList()
247+
})
248+
249+
/** 初始化 **/
250+
onMounted(async () => {
251+
await getList()
252+
categoryList.value = await CategoryApi.getCategorySimpleList()
253+
userList.value = await UserApi.getSimpleUserList()
254+
})
255+
</script>

0 commit comments

Comments
 (0)