Skip to content

Commit 2d16816

Browse files
committed
【工作流】- 对接新获取表单字段权限接口
1 parent 27d24cd commit 2d16816

File tree

7 files changed

+82
-21
lines changed

7 files changed

+82
-21
lines changed

src/api/bpm/processInstance/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ export const getProcessInstanceCopyPage = async (params: any) => {
8787
return await request.get({ url: '/bpm/process-instance/copy/page', params })
8888
}
8989

90+
// 获取审批详情
9091
export const getApprovalDetail = async (processInstanceId?:string, processDefinitionId?:string) => {
9192
const param = processInstanceId ? '?processInstanceId='+ processInstanceId : '?processDefinitionId='+ processDefinitionId
9293
return await request.get({ url: 'bpm/process-instance/get-approval-detail'+ param })
9394
}
95+
96+
// 获取表单字段权限
97+
export const getFormFieldsPermission = async (params: any) => {
98+
return await request.get({ url: '/bpm/process-instance/get-form-fields-permission', params })
99+
}

src/router/modules/remaining.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,14 @@ const remainingRouter: AppRouteRecordRaw[] = [
300300
canTo: true,
301301
title: '流程详情',
302302
activeMenu: '/bpm/task/my'
303-
}
303+
},
304+
props: route => (
305+
{
306+
id: route.query.id,
307+
taskId: route.query.taskId,
308+
activityId: route.query.activityId
309+
}
310+
)
304311
},
305312
{
306313
path: 'oa/leave/create',

src/views/bpm/processInstance/detail/ProcessInstanceTimeline.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ const getApprovalDetail = async () => {
178178
props.processInstanceId,
179179
props.processDefinitionId
180180
)
181-
console.log('approveNodes is []', data)
182181
approveNodes.value = data.approveNodes
183182
}
184183

src/views/bpm/processInstance/detail/index_new.vue

Lines changed: 56 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@
8888
<el-tab-pane label="流转评论" name="comment"> 流转评论 </el-tab-pane>
8989
</el-tabs>
9090

91-
<div class=" b-t-solid border-t-1px border-[var(--el-border-color)]" v-if="activeTab === 'form'">
91+
<div
92+
class="b-t-solid border-t-1px border-[var(--el-border-color)]"
93+
v-if="activeTab === 'form'"
94+
>
9295
<!-- 操作栏按钮 -->
9396
<ProcessInstanceOperationButton
9497
ref="operationButtonRef"
@@ -115,15 +118,18 @@ import ProcessInstanceOperationButton from './ProcessInstanceOperationButton.vue
115118
import ProcessInstanceTimeline from './ProcessInstanceTimeline.vue'
116119
import { registerComponent } from '@/utils/routerHelper'
117120
import * as UserApi from '@/api/system/user'
121+
import { FieldPermissionType } from '@/components/SimpleProcessDesignerV2/src/consts'
118122
import audit1 from '@/assets/svgs/bpm/audit1.svg'
119123
import audit2 from '@/assets/svgs/bpm/audit2.svg'
120124
import audit3 from '@/assets/svgs/bpm/audit3.svg'
121125
122126
defineOptions({ name: 'BpmProcessInstanceDetail' })
123-
124-
const { query } = useRoute() // 查询参数
127+
const props = defineProps<{
128+
id: string // 流程实例的编号
129+
taskId?: string // 任务编号
130+
activityId?: string //流程活动编号,用于抄送查看
131+
}>()
125132
const message = useMessage() // 消息弹窗
126-
const id = query.id as unknown as string // 流程实例的编号
127133
const processInstanceLoading = ref(false) // 流程实例的加载中
128134
const processInstance = ref<any>({}) // 流程实例
129135
const operationButtonRef = ref()
@@ -157,7 +163,7 @@ const BusinessFormComponent = ref<any>(null) // 异步组件
157163
const getProcessInstance = async () => {
158164
try {
159165
processInstanceLoading.value = true
160-
const data = await ProcessInstanceApi.getProcessInstance(id)
166+
const data = await ProcessInstanceApi.getProcessInstance(props.id)
161167
if (!data) {
162168
message.error('查询不到流程信息!')
163169
return
@@ -167,6 +173,15 @@ const getProcessInstance = async () => {
167173
// 设置表单信息
168174
const processDefinition = data.processDefinition
169175
if (processDefinition.formType === 10) {
176+
// 获取表单字段权限
177+
let fieldsPermission = undefined
178+
if (props.taskId || props.activityId) {
179+
fieldsPermission = await ProcessInstanceApi.getFormFieldsPermission({
180+
processInstanceId: props.id,
181+
taskId: props.taskId,
182+
activityId: props.activityId
183+
})
184+
}
170185
setConfAndFields2(
171186
detailForm,
172187
processDefinition.formConf,
@@ -177,6 +192,11 @@ const getProcessInstance = async () => {
177192
fApi.value?.btn.show(false)
178193
fApi.value?.resetBtn.show(false)
179194
fApi.value?.disabled(true)
195+
if (fieldsPermission) {
196+
Object.keys(fieldsPermission).forEach((item) => {
197+
setFieldPermission(item, fieldsPermission[item])
198+
})
199+
}
180200
})
181201
} else {
182202
// 注意:data.processDefinition.formCustomViewPath 是组件的全路径,例如说:/crm/contract/detail/index.vue
@@ -190,12 +210,27 @@ const getProcessInstance = async () => {
190210
}
191211
}
192212
213+
/**
214+
* 设置表单权限
215+
*/
216+
const setFieldPermission = (field: string, permission: string) => {
217+
if (permission === FieldPermissionType.READ) {
218+
fApi.value?.disabled(true, field)
219+
}
220+
if (permission === FieldPermissionType.WRITE) {
221+
fApi.value?.disabled(false, field)
222+
}
223+
if (permission === FieldPermissionType.NONE) {
224+
fApi.value?.hidden(true, field)
225+
}
226+
}
227+
193228
/** 加载任务列表 */
194229
const getTaskList = async () => {
195230
try {
196231
// 获得未取消的任务
197232
tasksLoad.value = true
198-
const data = await TaskApi.getTaskListByProcessInstanceId(id)
233+
const data = await TaskApi.getTaskListByProcessInstanceId(props.id)
199234
tasks.value = []
200235
// 1.1 移除已取消的审批
201236
data.forEach((task) => {
@@ -238,19 +273,29 @@ onMounted(async () => {
238273
</script>
239274

240275
<style lang="scss" scoped>
241-
$wrap-padding-height: 30px ;
276+
$wrap-padding-height: 30px;
242277
$wrap-margin-height: 15px;
243278
$button-height: 51px;
244279
$process-header-height: 194px;
245280
246281
.processInstance-wrap-main {
247-
height: calc(100vh - var(--top-tool-height) - var(--tags-view-height) - var(--app-footer-height) - 45px);
248-
max-height: calc(100vh - var(--top-tool-height) - var(--tags-view-height) - var(--app-footer-height) - 45px);
282+
height: calc(
283+
100vh - var(--top-tool-height) - var(--tags-view-height) - var(--app-footer-height) - 45px
284+
);
285+
max-height: calc(
286+
100vh - var(--top-tool-height) - var(--tags-view-height) - var(--app-footer-height) - 45px
287+
);
249288
overflow: auto;
250289
251290
.form-scoll-area {
252-
height: calc(100vh - var(--top-tool-height) - var(--tags-view-height) - var(--app-footer-height) - 45px - $process-header-height - 40px);
253-
max-height: calc(100vh - var(--top-tool-height) - var(--tags-view-height) - var(--app-footer-height) - 45px - $process-header-height - 40px);
291+
height: calc(
292+
100vh - var(--top-tool-height) - var(--tags-view-height) - var(--app-footer-height) - 45px -
293+
$process-header-height - 40px
294+
);
295+
max-height: calc(
296+
100vh - var(--top-tool-height) - var(--tags-view-height) - var(--app-footer-height) - 45px -
297+
$process-header-height - 40px
298+
);
254299
overflow: auto;
255300
}
256301
}
@@ -260,7 +305,4 @@ $process-header-height: 194px;
260305
border: none;
261306
}
262307
}
263-
264-
265-
266308
</style>

src/views/bpm/task/copy/index.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,16 @@ const getList = async () => {
111111
112112
/** 处理审批按钮 */
113113
const handleAudit = (row: any) => {
114+
const query = {
115+
id: row.processInstanceId,
116+
activityId: undefined
117+
}
118+
if (row.activityId) {
119+
query.activityId = row.activityId
120+
}
114121
push({
115122
name: 'BpmProcessInstanceDetail',
116-
query: {
117-
id: row.processInstanceId
118-
}
123+
query: query
119124
})
120125
}
121126

src/views/bpm/task/done/index.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ const handleAudit = (row: any) => {
158158
push({
159159
name: 'BpmProcessInstanceDetail',
160160
query: {
161-
id: row.processInstance.id
161+
id: row.processInstance.id,
162+
taskId: row.id
162163
}
163164
})
164165
}

src/views/bpm/task/todo/index.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ const handleAudit = (row: any) => {
140140
push({
141141
name: 'BpmProcessInstanceDetail',
142142
query: {
143-
id: row.processInstance.id
143+
id: row.processInstance.id,
144+
taskId: row.id
144145
}
145146
})
146147
}

0 commit comments

Comments
 (0)