FlowNodeReuseDialog.vue
8.47 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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
<template>
<el-dialog
width="930px"
title="配置复用"
v-if="dialogVisibleSetting"
:visible.sync="dialogVisibleSetting"
:before-close="close"
:close-on-click-modal="false"
append-to-body
:destroy-on-close="true"
custom-class="flow-node-reuse-dialog"
>
<el-form data-vv-scope="resuseSettingSave" v-form ref="Setingform">
<ht-form-item label="来源节点" label-width="100px" align="left">
<ht-select
v-model="sourceNode"
:options="nodes"
filterable
:props="{key: 'nodeId', value: 'label'}"
:validate="{required: true}"
></ht-select>
<span style="color: #e55555; margin-left: 20px"
>注意:请先保存源节点的配置,再进行复用操作。
</span>
</ht-form-item>
<ht-form-item label="复用节点" label-width="100px" align="left">
<ht-select
:multiple="true"
collapse-tags
v-model="targetNodes"
:options="nodes"
filterable
:props="{key: 'nodeId', value: 'label'}"
:validate="{required: true}"
></ht-select>
<span style="color: #e55555; margin-left: 20px"
>注意:节点原有的配置将会被覆盖!
</span>
</ht-form-item>
<ht-form-item label="复用配置" label-width="100px" align="left">
<ht-checkbox
v-model="type"
:options="typeOptions"
:validate="{required: true}"
class="type-checkbox"
@change="typeChange"
></ht-checkbox>
</ht-form-item>
<ht-form-item label="功能说明" label-width="100px" align="left">
<span class="item-explain">
当流程节点配置信息基本相似时,可以使用配置复用功能快速复用其他节点的配置信息。
</span>
</ht-form-item>
</el-form>
<div class="bottom-btn">
<el-button @click="close()">取消</el-button>
<el-button type="primary" @click="save()">马上生效</el-button>
</div>
</el-dialog>
</template>
<script>
import flow from '@/api/flow.js'
import utils from '@/hotent-ui-util.js'
export default {
name: 'FlowNodeReuseDialog',
components: {},
props: {
defConfigData: {
type: Object,
},
topDefKey: {
type: String,
},
},
data() {
return {
dialogVisibleSetting: false,
sourceNode: null,
targetNodes: null,
type: '',
typeOptions: [
{key: 'nodeForm', value: '节点表单', disabled: false},
{key: 'nodeUser', value: '节点审批人', disabled: false},
{key: 'nodeReadUser', value: '节点传阅人', disabled: false},
{key: 'nodeProperties', value: '节点属性', disabled: false},
{key: 'nodeBtn', value: '节点按钮', disabled: false},
{key: 'all', value: '全部配置信息'},
],
}
},
computed: {
nodes: function () {
let arr = []
this.defConfigData &&
this.defConfigData.nodeSetData &&
this.defConfigData.nodeSetData.nodes &&
this.defConfigData.nodeSetData.nodes.forEach((node) => {
node.label = `${node.name}(${node.nodeId})`
if (node.type !== 'start') {
arr.push(node)
}
})
return arr
},
targetNodeArr: function () {
return this.targetNodes ? this.targetNodes.split(',') : []
},
},
methods: {
showDialog() {
//重新初始化全部的 data数据
Object.assign(this.$data, this.$options.data())
this.dialogVisibleSetting = true
},
close() {
this.dialogVisibleSetting = false
},
typeChange(m, n) {
let type = this.type
if (this.type.indexOf('all') != -1) {
this.type = 'all'
this.switchOptsDisabled(true)
} else {
this.switchOptsDisabled(false)
}
},
switchOptsDisabled(value = false) {
this.typeOptions.forEach((e) => {
if (e.hasOwnProperty('disabled')) {
e.disabled = value
}
})
},
save() {
utils
.validateForm(this, 'resuseSettingSave')
.then((r) => {
this.$confirm(`将覆盖更新所有目标节点,确定进行此操作吗 ?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
this.doSave()
this.type = ''
this.sourceNode = null
})
.catch(() => {})
})
.catch(() => {})
},
doSave() {
let pcForm = this.defConfigData.nodeSetData.bpmDefSetting.nodeForms.find(
(obj) => obj.nodeId == this.sourceNode && obj.formType == 'pc'
)
let param = {
sourceNodeId: this.sourceNode,
defId: this.defConfigData.initData.bpmDefLayout.defId, //流程定义ID
defKey: this.defConfigData.initData.bpmDefinition.defKey, //流程定义key
targetNodeIds: this.targetNodeArr,
scope: this.type.split(','),
}
// 入参中如果定义了topDefKey(top不为LOCAL_)则不会复制信息 去掉:topDefKey: this.topDefKey,
if (pcForm.formValue) {
param.pcFormKey = pcForm.formValue
}
flow.copyNodeConf(param).then((resp) => {
if (resp.state) {
this.$message.success(resp.message || '复制成功')
this.$emit('confirm', null)
this.dialogVisibleSetting = false
}
})
// //节点表单
// if (this.type.indexOf('nodeForm') != -1) {
// this.copyNodeForm()
// }
// //节点审批人
// if (this.type.indexOf('nodeUser') != -1) {
// this.copyNodeUser()
// }
// //节点传阅人
// if (this.type.indexOf('nodeReadUser') != -1) {
// this.copyNodeReadUser()
// }
// //节点属性
// if (this.type.indexOf('nodeProperties') != -1) {
// this.copyNodeProperties()
// }
// //节点按钮
// if (this.type.indexOf('nodeBtn') != -1) {
// this.copyNodeBtn()
// }
},
//节点表单复制
copyNodeForm() {
this.targetNodeArr.forEach((nodeId) => {
let newObj = JSON.parse(
JSON.stringify(
this.defConfigData.nodeSetData.bpmDefSetting.formMap[
this.sourceNode
]
)
)
newObj.nodeId = nodeId
//pc表单
let pcForm = {['nodeSetData.bpmDefSetting.formMap.' + nodeId]: newObj}
this.$store.dispatch('flow/updateConfig', pcForm)
//手机表单
newObj = JSON.parse(
JSON.stringify(
this.defConfigData.nodeSetData.bpmDefSetting.mobileFormMap[
this.sourceNode
]
)
)
newObj.nodeId = nodeId
let mbForm = {
['nodeSetData.bpmDefSetting.mobileFormMap.' + nodeId]: newObj,
}
this.$store.dispatch('flow/updateConfig', mbForm)
})
},
copyNodeUser() {
this.targetNodeArr.forEach((nodeId) => {
let newObj = JSON.parse(
JSON.stringify(
this.defConfigData.nodeSetData.nodeUserMap[this.sourceNode]
)
)
let path = 'nodeSetData.nodeUserMap.' + nodeId
this.$store.dispatch('flow/updateConfig', {[path]: newObj})
})
},
copyNodeReadUser() {
this.targetNodeArr.forEach((nodeId) => {
let newObj = JSON.parse(
JSON.stringify(
this.defConfigData.nodeSetData.nodeReadUserMap[this.sourceNode]
)
)
let path = 'nodeSetData.nodeReadUserMap.' + nodeId
this.$store.dispatch('flow/updateConfig', {[path]: newObj})
})
},
copyNodeProperties() {
this.targetNodeArr.forEach((nodeId) => {
let path = 'nodeSetData.bpmDefSetting.nodePropertieMap.' + nodeId
let newObj = JSON.parse(
JSON.stringify(
this.defConfigData.nodeSetData.bpmDefSetting.nodePropertieMap[
this.sourceNode
]
)
)
newObj.nodeId = nodeId
this.$store.dispatch('flow/updateConfig', {[path]: newObj})
})
},
copyNodeBtn() {
this.targetNodeArr.forEach((nodeId) => {})
},
},
mounted() {
this.$validator = this.$root.$validator
},
}
</script>
<style lang="scss" scoped>
::v-deep .flow-node-reuse-dialog {
.el-dialog__body {
padding: 30px 48px;
}
.bottom-btn {
margin-top: 40px;
text-align: right;
}
.item-explain {
color: #333;
}
}
.type-checkbox {
width: 100% !important;
}
</style>