agreeButton.js
8.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
//同意审批按钮时用户任务加签
const ADD_SIGN_ACTION_MAP = {
oppose: 'opposeTrans',
agree: 'agreeTrans',
}
//任务状态
const TASK_STATUS_ARRAY = [
'APPROVELINEING',
'APPROVELINEED',
'SIGNSEQUENCEING',
'SIGNSEQUENCEED',
'SIGNLINEING',
'SIGNLINEED',
]
import {
getAfterJumpNodesByDefId,
getNextExecutor,
} from '@/api/process'
import { validObject } from '@/utils'
import { mapMutations, mapState } from 'vuex'
export default {
data() {
return {
jumpNodes: {},
selectConfig: {},
isShowSelectPath: false,
jumpType: ''
}
},
computed: {
...mapState('signature', ['signatureStatus']),
//自动签章字段
signatureField() {
return this.getNodeProperties()?.signatureField
},
// 签章是否免密
secretFree() {
return this.getNodeProperties()?.secretFree
},
//是否显示签章密码输入框
isShowSignature() {
if (this.signatureField) {
return !this.secretFree && this.currentAlias === 'agree'
} else {
return false
}
},
isFree() {
return this.$route.query.type === 'free'
},
excludeStatus() {
return !TASK_STATUS_ARRAY.includes(this.bpmTask.status)
},
},
methods: {
...mapMutations('signature', [
'setSignatureConfig',
'setSignatureStatus',
'initSignatureConfig',
]),
//配置了签章
handleSignature() {
//修改签章配置前先初始化配置信息
this.initSignatureConfig()
const { signatureCover, secretFree } = this.getNodeProperties()
const signatureConfig = {
field: this.signatureField, //自动签章字段
isCover: signatureCover, //自动签章时是否覆盖
secretFree: secretFree, //自动签章时是否免密
password: this.form.signaturePassword,
}
this.setSignatureConfig(signatureConfig)
this.setSignatureStatus('start')
},
getNodeProperties() {
let currentNodeProperties = {}
const nodeProperties = this.curNodeDef?.nodeProperties || []
if (nodeProperties && nodeProperties.length) {
const { nodeProperties, localProperties } = this.curNodeDef
currentNodeProperties = nodeProperties[0] || localProperties
}
return currentNodeProperties
},
//用户任务加签设置action
setAddSignAction() {
if (this.curNodeDef.type === 'USERTASK' && this.bpmTask.parentId !== '0') {
this.addSignAction = ADD_SIGN_ACTION_MAP[this.currentAlias]
}
},
//选择路径跳转
selectPathJumpDialogBefore() {
this.getApprovalOpinionByInstIdAndTaskId()
this.setAddSignAction()
const { choiceExcutor, jumpType } = this.getNodeProperties()
this.jumpType = jumpType
if ((choiceExcutor || jumpType || this.isFree) && this.excludeStatus) {
const params = {
defId: this.bpmTask.procDefId,
instId: this.instId,
type: jumpType || '',
}
this.getAfterJumpNodes(params)
} else {
const isGetNextExecutor =
this.currentAlias === 'agree' && this.bpmTask.status === 'SIGNSEQUENCEED'
isGetNextExecutor
? this.getSequenceSignNextExecutor() : this.showApprovalAction = true
}
},
openCurrentDialogByJumpNodes() {
this.showApprovalAction = true
if (this.isFree) {
this.jumpType = 'free'
}
this.setSelectConfigVal()
if (this.jumpType === 'free' && this.selectConfig.choiceExcutor === 'free') {
const data = {
selectNodeId: '',
selectNodeName: '',
nodeUsers: this.getNodeUserList() || []
}
this.getCurrentSelected(data)
}
},
//获取顺序签署下一步执行人
getSequenceSignNextExecutor() {
getNextExecutor(this.taskId, (res) => {
if (!res.data) return
if (res.data.state && res.data.value) {
this.$dialog.confirm(
`下一步执行人为:${res.data?.value?.name},您确定要继续?`,
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
)
.then(() => {
this.showApprovalAction = true
})
.catch(() => {
this.showApprovalAction = false
})
}
})
},
//获取跳转节点
getAfterJumpNodes(params) {
const requestParams = {
taskId: this.taskId || '',
alias: this.currentAlias,
data: Base64.encode(JSON.stringify(this.data)),
...params,
}
getAfterJumpNodesByDefId(requestParams).then((res) => {
this.jumpNodes = res
this.selectConfig = res
this.nodeList = res?.afterNodes
this.openCurrentDialogByJumpNodes()
})
},
setSelectConfigVal() {
if (this.isFree) {
this.selectConfig = {
...this.selectConfig,
jumpType: this.jumpType,
choiceExcutor: this.jumpType,
}
this.nodeList = this.selectConfig.afterNodes
}
const { afterNodes } = this.selectConfig
if (afterNodes?.length === 1) {
this.form.selectNodeId = afterNodes[0].nodeId
this.selectNodeName = afterNodes[0].nodeName
}
// 如果是自由选择,默认带出候选人,然后在再基于候选人进行调整(删减或增加)
if (
afterNodes?.length > 0 &&
this.selectConfig.choiceExcutor &&
this.selectConfig.choiceExcutor != 'candidate'
) {
this.selectConfig.afterNodes = afterNodes.map((item) => {
return {
...item,
selectUsers: this.getValueByKey(item.excutorList, 'name'),
id: this.getValueByKey(item.excutorList, 'id'),
}
})
this.nodeList = this.selectConfig.afterNodes
}
},
getValueByKey(array, key) {
let value = ''
if (array && array.length > 0) {
value = array.map((it) => it[key]).join(',')
}
return value
},
//审批同意,选择路径跳转 自由跳转,提交参数
getSubmitData() {
let data = {
formType: this.data?.businessKey ? 'frame' : 'inner',
defId: this.bpmTask.procDefId || this.startParams.defId,
proInstId: this.instId || '',
agentLeaderId: this.leaderId || 0,
isSendNodeUsers: '1',
destination: this.form.selectNodeId || '',
...this.getEffectiveValue(),
}
if (this.jumpType) {
data.jumpType = this.jumpType === 'select' ? 'select' : 'free'
}
return data
},
getEffectiveValue() {
const data = {
urgentStateValue: this.$storage.get('urgentStateValue'),
nodeUsers: JSON.stringify(this.getNodeUserList()) || this.selectedNodeAndUser?.nodeUsers,
startOrgId: '',//TODO:获取组织id
}
return validObject(data)
},
getNodeUserList() {
let nodeUsers = []
if (this.selectConfig?.choiceExcutor === 'candidate') {
nodeUsers = this.getCandidateList()
} else {
nodeUsers = this.getNodeUsers()
}
return nodeUsers.length > 0 ? nodeUsers : []
},
getCandidateList() {
let candidateList = []
this.selectConfig?.afterNodes?.map((item) => {
if (item.selectUserIds?.length > 0) {
const excutorList = item.excutorList
const selectUsers = excutorList?.filter((it) => {
return item.selectUserIds.includes(it.id)
})
candidateList.push({ nodeId: item.nodeId, executors: selectUsers })
}
})
return candidateList
},
getNodeUsers() {
let nodeUsers = []
this.selectConfig?.afterNodes?.map((node) => {
const currentSelectedUserList = node.selectUsers?.split(',')
const selectedUserIds = node.id?.split(',')
if (currentSelectedUserList?.length > 0) {
const selectUsers = currentSelectedUserList?.map((user, index) => {
return {
id: selectedUserIds[index],
name: user,
type: 'user',
}
})?.filter(it => it.id)
if (selectUsers && selectUsers.length) {
nodeUsers.push({ nodeId: node.nodeId, executors: selectUsers })
}
}
})
return nodeUsers
},
}
}