DynamicControlDialog.vue
9.52 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="配置动态规则"
width="1280px"
append-to-body
top="8vh"
:visible.sync="selectQueryDialog"
v-if="selectQueryDialog"
:close-on-click-modal="false"
custom-class="dynamic-control-dia"
>
<el-button
icon="el-icon-plus"
style="margin-bottom: 5px;"
@click="addNewItem"
>添加规则</el-button
>
<table class="form-table" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr class="linkageTable-tr">
<td width="200px;">监听值</td>
<td width="170">条件</td>
<td width="170">字段类型</td>
<td width="170">具体值</td>
<td width="170">变换字段</td>
<td width="170">影响策略</td>
<td width="100px">操作</td>
</tr>
<tr v-for="(column, index) in tableList" :key="index">
<td width="200px;">
<ht-select
:filterable="true"
clearable
v-model="column.watchPath"
:options="mainBoFields"
:props="{key: 'name', value: 'desc'}"
style="width: 100%;"
>
<template slot-scope="{options}">
<el-option-group
v-for="(group, idenxOptions) in options"
:key="idenxOptions"
:label="group.desc"
>
<el-option
v-for="item in group.children"
:key="item.id"
:label="item.desc"
:value="'data.' + item.path + '.' + item.name"
></el-option>
</el-option-group>
</template>
</ht-select>
</td>
<td colspan="5">
<table
cellspacing="0"
cellpadding="0"
border="0"
style="width: 100%"
>
<tr v-for="(effects, index1) in column.effect" :key="index1">
<!-- 条件 -->
<td
width="150"
style="padding-right: 10px;padding-bottom: 10px;"
>
<ht-select
v-model="effects.condition"
:options="conditionOption"
clearable
style="width: 100%"
/>
</td>
<!-- 字段类型 -->
<td
width="160"
style="padding-right: 10px;padding-bottom: 10px;"
>
<ht-select
v-model="effects.fieldType"
:options="typeOption"
clearable
style="width: 100%"
/>
</td>
<!-- 具体值 -->
<td
width="160"
style="padding-right: 10px;padding-bottom: 10px;"
>
<!-- 固定值时自己输入 -->
<ht-input
v-if="effects.fieldType == 'fixed'"
v-model="effects.fixedValue"
style="width: 100%"
></ht-input>
<ht-select
v-else
:filterable="true"
clearable
v-model="effects.varValue"
:options="mainBoFields"
:props="{key: 'name', value: 'desc'}"
style="width: 100%;"
>
<template slot-scope="{options}">
<el-option-group
v-for="(group, idenxOptions) in options"
:key="idenxOptions"
:label="group.desc"
>
<el-option
v-for="item in group.children"
:key="item.id"
:label="item.desc"
:value="'data.' + item.path + '.' + item.name"
></el-option>
</el-option-group>
</template>
</ht-select>
</td>
<!-- 变换字段 -->
<td
width="160"
style="padding-right: 10px;padding-bottom: 10px;"
>
<ht-select
v-model="effects.changeField"
:options="mainBoFields"
clearable
:filterable="true"
:props="{key: 'name', value: 'desc'}"
style="width: 100%;"
>
<template slot-scope="{options}">
<el-option-group
v-for="(group, idenxOptions) in options"
:key="idenxOptions"
:label="group.desc"
>
<el-option
v-for="item in group.children"
:key="item.id"
:label="item.desc"
:value="getEffectsTarget(group, item)"
></el-option>
</el-option-group>
</template>
</ht-select>
</td>
<!-- 影响策略 -->
<td style="padding-bottom: 10px;">
<ht-select
v-model="effects.effectResult"
:options="effectsOption"
style="width: 100%;"
/>
</td>
<td
width="40px"
style="text-align: center;padding-bottom: 10px;"
>
<el-button
type="text"
icon="el-icon-delete"
@click="column.effect.splice(index1, 1)"
></el-button>
</td>
</tr>
</table>
</td>
<td width="100px">
<div style="display: flex; justify-content: center">
<el-button
class="btn-padding"
style="margin-left: 5px"
icon="el-icon-plus"
@click="addEffectObj(column.effect)"
></el-button>
<el-button
icon="el-icon-document-copy"
class="btn-padding"
@click="copyEffect(column)"
></el-button>
<el-button
icon="el-icon-delete"
class="btn-padding"
@click="tableList.remove(column)"
></el-button>
</div>
</td>
</tr>
</tbody>
</table>
<div slot="footer" class="dialog-footer">
<el-button @click="selectQueryDialog = false">取消</el-button>
<el-button type="primary" @click="confirm" size="small">确定</el-button>
</div>
</el-dialog>
</template>
<script>
export default {
name: 'DynamicControlDialog',
components: {},
data() {
return {
effectsOption: [
// {key: 'w', value: '显示'},
{key: 'n', value: '隐藏'},
{key: 'b', value: '必填'},
{key: 'r', value: '只读'}
],
conditionOption: [
{key: '==', value: '等于'},
{key: '!=', value: '不等于'},
{key: '>', value: '大于'},
{key: '<', value: '小于'},
{key: '>=', value: '大于等于'},
{key: '<=', value: '小于等于'}
],
typeOption: [
{key: 'fixed', value: '固定值'},
{key: 'variable', value: '变量'}
],
effectObj: {
condition: '==', // 条件
fieldType: 'fixed', // 固定值fixed 变量variable
changeField: '', // 变换字段
fixedValue: '', // 固定值
varValue: '', // 动态值时要取值的字段
effectResult: 'n' // 变换策略
},
tableList: [], // 规则数据
selectQueryDialog: false
}
},
props: ['mainBoFields', 'formData'],
methods: {
getEffectsTarget(group, item) {
let groupName = group.name === 'noAttrField' ? item.tableName : group.name
return groupName + '.' + item.name
},
copyEffect(column) {
this.tableList.push(JSON.parse(JSON.stringify(column)))
},
addEffectObj(effect) {
let cloneObj = JSON.parse(JSON.stringify(this.effectObj))
effect.push(cloneObj)
},
addNewItem() {
this.tableList.push({
watchPath: '',
effect: [
{
condition: '==', // 条件
fieldType: 'fixed', // 固定值fixed 变量variable
fixedValue: '', // 固定值
varValue: '', // 动态值时要取值的字段
changeField: '', // 变换字段
effectResult: 'n' // 变换策略
}
]
})
},
showDialog(data) {
if (data && data.globalDynamicControl) {
this.tableList = JSON.parse(data.globalDynamicControl)
} else {
this.tableList = []
}
this.selectQueryDialog = true
},
confirm() {
this.$emit('confirm-dynamic', JSON.stringify(this.tableList))
// let formSetting = JSON.parse(this.formData.formSetting)
// formSetting.dynamicControl = this.tableList
// this.formData.formSetting = JSON.stringify(formSetting)
this.selectQueryDialog = false
}
}
}
</script>
<style lang="scss" scoped>
::v-deep .dynamic-control-dia {
.el-dialog__body {
max-height: 600px;
overflow-y: auto;
}
}
</style>