FlowVarSelector.vue
7.6 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>
<div :style="'display: inline-block;' + (type == '3' ? 'width:100%;' : '')">
<el-popover v-if="type != '2'" placement="bottom-start" v-model="visible">
<ht-tree
:style="
'max-height:400px;;overflow: auto;' +
(type == '1' ? 'width:300px' : '')
"
v-if="visible"
:data="data"
node-key="id"
:expand-on-click-node="false"
:props="defaultProps"
support-filter
default-expand-all
@node-click="handleNodeClick"
></ht-tree>
<el-button :size="size || 'small'" v-if="type != '3'" slot="reference"
>选择变量
<i class="expanded el-tree-node__expand-icon el-icon-caret-right"></i
></el-button>
<el-input
:size="size || 'small'"
v-if="type == '3'"
style="width: 100%;"
slot="reference"
v-model="value"
placeholder="选择变量"
:readonly="true"
/>
</el-popover>
<ht-tree
v-if="type == '2'"
style="height:100%;width:300px;overflow: auto;"
:data="data"
node-key="id"
:expand-on-click-node="false"
:props="defaultProps"
support-filter
default-expand-all
@node-click="handleNodeClick"
:highlight-current="true"
></ht-tree>
</div>
</template>
<script>
import req from '@/request.js'
import {mapState} from 'vuex'
import FlowNodeCusersSelector from '@/components/flow/FlowNodeCusersSelector.vue'
import utils from '@/hotent-ui-util.js'
export default {
props: [
'defId',
'nodeId',
'type',
'value',
'removeSub',
'includeBpmConstants',
'isBpmForm',
'varData',
'appendVarData',
'isMore',
'size',
'isNewFlow',
'isSubOrSunTable'
], //type 1,流程其它设置,2,流程人员规则设置
components: {FlowNodeCusersSelector},
data() {
return {
visible: false,
dialogVisible: false,
data: [],
defaultProps: {
children: 'children',
label: 'desc'
},
thisDefId: ''
}
},
computed: mapState({
defConfigData: state => state.flow.defConfigData
}),
watch: {
data: {
handler(val) {
},
immediate: true,
deep: true
}
},
methods: {
handleNodeClick(selection, node, nodeCompent) {
console.log('selection, node: ', selection, node);
if (selection && selection.children && selection.children.length > 0) {
return
}
const isMainTable =
selection.path && selection.path.split('.').length === 1
if (this.isNewFlow && this.isSubOrSunTable && isMainTable) {
return this.$message.warning(
'主流程字段为子表或孙表时新流程字段不允许选择主表字段'
)
}
this.visible = false
this.handleValue(node, selection)
this.$emit('node-click', selection, node)
},
handleValue(node, selection) {
var keyStr = node.data.name
var parentNode = node.parent
let nodeType = parentNode.data.nodeType
var boDefAlias = parentNode.data.boDefAlias
var typeMoth =
node.data.dataType == 'number' ? '.getDouble' : '.getString'
if (node.data.nodeType != 'var') {
while (parentNode && !boDefAlias) {
let pParentNode = parentNode.parent
if (!pParentNode) {
break
}
parentNode = pParentNode
boDefAlias = pParentNode.data.boDefAlias
}
}
// 子表情况做提示
if (node.data.nodeType == 'sub') {
keyStr =
boDefAlias +
".getSubByKey('" +
node.data.name +
"') /* 获取子表,return List<BoData> */"
} // 主表bo
else if (parentNode.data.nodeType == 'main') {
if (this.type == '1') {
keyStr = boDefAlias + '.' + node.data.name
} else if (this.type == '2') {
keyStr = boDefAlias + '.' + node.data.name
} else {
keyStr =
boDefAlias +
typeMoth +
'("' +
node.data.name +
'") /*数据类型:' +
node.data.dataType +
'*/'
}
} else if (parentNode.nodeType == 'sub') {
var mainTableName = boDefAlias
keyStr =
mainTableName +
'.getSubByKey("' +
parentNode.name +
'") /*获取子表数据 ,返回数据:return List<BoData> 。子表字段:' +
node.name +
', 请根据实际情况处理子表数据的获取*/'
} else if (node.data.nodeType == 'var') {
keyStr = node.data.name
}
if (this.type == '1') {
keyStr = '{' + node.data.desc + ':' + keyStr + '}'
} else if (this.type == '3') {
keyStr =
node.data.desc +
'【' +
node.data.path +
'.' +
node.data.name +
'】-' +
node.data.dataType
}
node.data.pathValue = keyStr
selection.pathValue = keyStr
console.log('keyStr: ', keyStr);
this.$emit('input', keyStr)
}
},
mounted() {
if (this.varData) {
this.data = this.varData
this.$emit('getData', this.data, this.isNewFlow)
return
}
this.utils = utils
let this_ = this
this.thisDefId = this.defId
if (!this.thisDefId && this.defConfigData && this.defConfigData.initData) {
this.thisDefId = this.defConfigData.initData.bpmDefinition.defId
}
let isRemoveSub = this.removeSub
if (isRemoveSub !== false) {
isRemoveSub = true
}
let includeBpmConst = this.includeBpmConstants
if (includeBpmConst !== false) {
includeBpmConst = true
}
let bpmForm = this.isBpmForm
if (bpmForm !== false) {
bpmForm = true
}
req
.post(window.context.bpmModel + '/flow/node/v1/varTree', {
defId: this.thisDefId,
nodeId: this.nodeId,
includeBpmConstants: includeBpmConst,
removeSub: isRemoveSub,
bpmForm: bpmForm
})
.then(response => {
if (this_.type == '1') {
for (const d of response.data) {
if (d.desc == '流程变量' && d.nodeType == 'root') {
d.children.push({
desc: '流程标题',
name: 'title',
nodeType: 'var'
})
d.children.push({
desc: '发起时间',
name: 'startDate',
nodeType: 'var'
})
if (this.isMore) {
d.children.push({
desc: '流程名称',
name: 'flowName',
nodeType: 'var'
})
}
}
}
}
this_.data = response.data
if (this_.appendVarData) {
this_.data.push(this_.appendVarData)
}
this.$emit('getData', this.data, this.isNewFlow)
})
}
}
</script>
<style scoped>
div >>> .el-dialog__body {
padding: 10px;
}
.table > thead > tr > th,
.table > thead > th,
.table > tbody > tr > th,
.table > tfoot > tr > th,
.table > thead > tr > td,
.table > tbody > tr > td,
.table > tfoot > tr > td {
border-top: 1px solid #e7eaec;
border-left: 1px solid #e7eaec;
line-height: 1.42857;
padding: 8px;
vertical-align: middle;
}
.table {
border-bottom: 1px solid #e7eaec;
border-right: 1px solid #e7eaec;
}
.table >>> .el-button {
padding: 6px 8px;
margin-left: 0px;
margin-right: 5px;
}
div >>> .el-tabs__content {
height: 450px;
overflow: auto;
}
::v-deep .el-tree-node__expand-icon {
color: #333333;
}
::v-deep .el-tree-node__expand-icon.is-leaf {
color: transparent !important;
}
</style>