CopySetting.vue
8.07 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
288
289
290
291
292
<template>
<el-dialog
title="流程复制配置"
:visible.sync="dialogVisible"
width="70%"
:append-to-body="true"
@opened="opened"
@closed="closed"
:destory-on-close="true"
>
<el-container>
<el-main>
<el-row>
<el-cascader
:options="options"
clearable
filterable
:show-all-levels="false"
:props="props"
@change="handleSelectNode"
v-model="selectVal"
ref="cascader"
popper-class="train-tree-cascader"
>
</el-cascader>
</el-row>
<el-row v-for="(ent, index) in copyConfig" :key="index">
<el-card
shadow="always"
:body-style="{padding: '20px'}"
style="margin-top: 10px"
>
<div slot="header">
<span>{{ ent.desc }}</span>
<el-button
type="text"
size="default"
icon="el-icon-close"
@click="deleteConf(index, ent)"
style="float: right; padding: 3px 0"
></el-button>
<el-tooltip placement="top" effect="dark">
<div slot="content">
黑名单模式下,复制时忽略选中的字段<br />
白名单模式下,只会复制选中的字段<br />
注意:复制之后生成的数据都会被初始赋值所覆盖
</div>
<el-select
v-model="ent.model"
style="float: right; width: 90px; padding-right: 20px"
size="mini"
@change="changeModel(ent)"
>
<el-option value="b" label="黑名单"></el-option>
<el-option value="w" label="白名单"></el-option>
</el-select>
</el-tooltip>
<el-tooltip placement="top" effect="dark">
<div slot="content">
未设置时默认启用<br />
选择停用,复制时将忽略该子表的数据<br />
停用子表时,孙表的数据也将会丢弃<br />
</div>
<el-select
v-model="ent.enable"
v-if="ent.type != 'main'"
style="float: right; padding-right: 20px; width: 105px"
size="mini"
>
<el-option :value="true" label="启用复制"></el-option>
<el-option :value="false" label="停用复制"></el-option>
</el-select>
</el-tooltip>
</div>
<div v-if="ent.enable">
<el-select
:multiple="true"
v-model="ent.value"
style="width: 100%"
>
<el-option
v-for="(attr, index2) in optionsMap[ent.name]"
:key="index2"
:label="attr.label"
:value="attr.value"
></el-option>
</el-select>
</div>
</el-card>
</el-row>
</el-main>
</el-container>
<span slot="footer">
<el-button type="default" @click="cancel">取消</el-button>
<el-button type="primary" @click="confirm">确定</el-button>
</span>
</el-dialog>
</template>
<script>
export default {
data() {
return {
dialogVisible: false,
options: [],
props: {
lazy: true,
expandTrigger: 'click',
multiple: false,
checkStrictly: false,
lazyLoad: this.lazyLoad
},
boDefList: [],
boEntList: [],
copyConfig: [],
optionsMap: {},
formKey: '',
selectVal: ''
}
},
props: ['defId'],
methods: {
confirm() {
this.$emit('confirm', this.copyConfig)
this.dialogVisible = false
},
cancel() {
this.dialogVisible = false
},
showDialog(copySetting) {
if (copySetting) {
this.copyConfig = JSON.parse(copySetting)
}
//通过流程定义ID获取全局表单
this.$http
.get(
`${window.context.bpmModel}/flow/node/v1/getGlobalForm?defId=${this.defId}&type=pc`
)
.then(resp => {
this.formKey = resp.data.formKey
this.dialogVisible = true
})
},
handleSelectNode(param) {
if (
this.copyConfig.some(conf => {
return conf.id == param[1]
})
) {
this.$message.warning(`该实体已存在`)
return
}
let ent = this.boEntList.filter(item => {
return item.id == param[1]
})[0]
if (!ent) {
return
}
let configItem = {
desc: ent.desc,
name: ent.name,
id: ent.id,
value: [],
model: 'b',
enable: true,
defId: param[0],
type: ent.type
}
this.$http
.get(
`${window.context.form}/bo/def/v1/getBoAttrByEntId?boEntId=${param[1]}`
)
.then(resp => {
if (this.optionsMap[ent.name]) {
this.optionsMap[ent.name].splice(0)
} else {
this.$set(this.optionsMap, ent.name, new Array())
}
resp.data.forEach(item => {
this.optionsMap[ent.name].push({
label: item.desc,
value: item.name
})
})
this.copyConfig.push(configItem)
})
},
opened() {
this.selectVal = ''
this.copyConfig.forEach(conf => {
this.$http
.get(
`${window.context.form}/bo/def/v1/getBoAttrByEntId?boEntId=${conf.id}`
)
.then(resp => {
if (this.optionsMap[conf.name]) {
this.optionsMap[conf.name].splice(0)
} else {
this.$set(this.optionsMap, conf.name, new Array())
}
resp.data.forEach(attr => {
this.optionsMap[conf.name].push({
label: attr.desc,
value: attr.name
})
})
})
})
},
closed() {
this.options.splice(0)
},
lazyLoad(node, resolve) {
let this_ = this
if (node.level == 0) {
let formKey = this.formKey
this_.$http
.get(
`${window.context.form}/form/formServiceController/v1/getFormBoLists?formKey=${formKey}`
)
.then(resp => {
let nodes = []
resp.data.forEach(boDef => {
if (
!this_.boDefList.some(item => {
return item.id == boDef.id
})
) {
this_.boDefList.push(boDef)
}
nodes.push({
label: boDef.description,
value: boDef.id
})
})
resolve(nodes)
})
} else if (node.level == 1) {
//获取boEnt列表
let boDefId = node.data.value
this_.$http
.get(
`${window.context.form}/bo/def/v1/getEntListByDefId?boDefId=${boDefId}`
)
.then(resp => {
let nodes = []
resp.data.forEach(item => {
if (
!this_.boEntList.some(ent => {
return ent.id == item.id
})
) {
this_.boEntList.push(item)
}
let desc = item.desc
if (item.type == 'main') {
desc += '(主表)'
}
nodes.push({
label: desc,
value: item.id,
leaf: true
})
})
resolve(nodes)
})
} else {
resolve(null)
}
},
deleteConf(index, ent) {
delete this.optionsMap[ent.name]
this.copyConfig.splice(index, 1)
},
changeModel(ent) {
if (ent.value) {
ent.value = []
}
}
}
}
</script>
<style lang="scss" scoped></style>
<style lang="scss">
.train-tree-cascader {
.el-cascader-menu__wrap {
height: auto;
}
}
</style>