InFeedFlowDotModal.vue
9.69 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
<template>
<a-modal
:visible="visible"
:maskClosable="false"
:confirmLoading="confirmLoading"
title='新增'
@ok="handleSubmit"
@cancel="handleCancel"
cancelText="关闭"
>
<a-form :form="form" :spinning="confirmLoading">
<a-form-item label="节点名称:" :labelCol="{xs: { span: 8 },sm: { span: 5 }}" :wrapperCol="wrapperCol">
<a-select
v-decorator="['name',{ rules: [{ required: true, message: '请选择节点名称' }] }]"
placeholder="请选择节点名称"
@change="handleSelectChangeName"
:disabled = 'disabledName'
>
<a-select-option
v-for="(item, index) in flowInfoList" :key="index" :value="item.name" :disabled="item.checked">
{{item.name}}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="节点序号:" :labelCol="{xs: { span: 8 },sm: { span: 5 }}" :wrapperCol="wrapperCol">
<a-select
v-decorator="['index',{ rules: [{ required: true, message: '请选择节点序号' }] }]"
placeholder="请选择节点序号"
@change="handleSelectChangeIndex"
:disabled = 'disabledName'
>
<a-select-option
v-for="(item, index) in flowInfoList" :key="index" :value="index+1" :disabled="item.checked">
{{index+1}}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="选择节点服务:" :labelCol="{xs: { span: 8 },sm: { span: 5 }}" :wrapperCol="wrapperCol">
<a-row v-decorator="[ 'data',{'initialValue':model.data}]" v-for="(item,index) in flowInfoList" :key="index">
<div v-if="(item.name == selectVal) && (item.nodeServices != null)">
<a-col v-for="(items,indexs) in item.nodeServices" :key="indexs">
<a-checkbox :value="items.name" :checked="items.checked || items.necessary" :disabled="items.disabled || items.necessary" @change="onChangeCheckbox(items)" >{{items.name}}</a-checkbox>
<a-row :gutter="24" v-if="(items.checked) && (items.data != null)">
<a-form-item label="决策类型:" :labelCol="{xs: { span: 8 },sm: { span: 6 }}" :wrapperCol="wrapperCol">
<a-select
v-decorator="['data',{'initialValue':model.data}]"
placeholder="请选择决策类型"
@change="handleSelectChangeType"
>
<a-select-option
v-for="(itemss, indexss) in items.data" :key="indexss" :value="indexss">
{{itemss}}
</a-select-option>
</a-select>
</a-form-item>
</a-row>
</a-col>
</div>
</a-row>
</a-form-item>
<a-form-item label="备注" :labelCol="{xs: { span: 8 },sm: { span: 6 }}" :wrapperCol="wrapperCol">
<a-textarea :rows="4" placeholder="最多输入60字" v-decorator="[ 'remark' ]" />
</a-form-item>
</a-form>
</a-modal>
</template>
<script>
import store from '@/store'
import pick from 'lodash.pick'
import {mapMutations,mapState} from 'vuex'
export default {
name: "PasswordModal",
data () {
return {
visible: false,
confirmLoading: false,
title: '',
flowNodeData:[], //
parentDotData: [],
childDotData:[], //个人节点名称->映射子项
nodeServices:[],
validatorRules:{
name: {
rules:[{
required: true,
message: '请输入节点名称'
}]
},
},
labelCol: {
xs: { span: 24 },
sm: { span: 8 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
},
emitDataCollect: [],
form: this.$form.createForm(this),
model: {},
personInfoEngineData:[],//决策引擎配置
value: [],
checked:false,
defaultChecked:false,
status:null,
//...
flowListData:[],//原始flow 数据
selectOptionsData:[],//select options数据
checkOptionsData:[],//check options数据
flowInfoList: [], //原始store中数据
selectVal:'',//节点选择后数据
disabledName:false
}
},
created() {
},
watch:{
'$store.state.flow.flowInfoList': function (newVal,oldVal) {
this.flowInfoList = newVal
}
},
methods: {
//处理编辑回显示节点process数据
handleFlowListData(data,orgin){
let arr = []
for(var idx = 0; idx < orgin.length; idx++) {
if(orgin[idx].code == data.code){
orgin[idx].checked = data.checked
orgin[idx].data = data.data
return orgin[idx]
}
}
},
//处理编辑回显示节点process数据
handleFlowListDataToList(data,orgin){
//先重置所有数据
var num = null
this.flowInfoList = this.handleResetCheckedData(orgin)
for(var idx in orgin){
if(orgin[idx].code == data.code){
num = idx
}
}
if(orgin[num].nodeServices){
for(var idx_1 in orgin[num].nodeServices){
if(data.nodeServices){
for(var idx_2 in data.nodeServices){
if(orgin[num].nodeServices[idx_1].code == data.nodeServices[idx_2].code){
orgin[num].nodeServices[idx_1].checked = true
}
}
}
}
}
return orgin
this.$forceUpdate();
},
//处理选中的数据
handleSelectFlowListData(data,orgin){//新数据,原数据
var arr = []
for(var idx = 0; idx < orgin.length; idx++) {
if(orgin[idx].name == data.name){
data.checked = true
data.code = orgin[idx].code
}
if(orgin[idx].nodeServices){
for(var idx1 = 0; idx1 < orgin[idx].nodeServices.length; idx1++) {
if(orgin[idx].nodeServices[idx1].checked){
arr.push(orgin[idx].nodeServices[idx1])
}
}
}
}
data.nodeServices = arr
return data
},
//处理 reset数据
handleResetCheckedData(orgin){
for(var idx = 0; idx < orgin.length; idx++) {
if(orgin[idx].checked){
delete orgin[idx].checked
}
if(orgin[idx].nodeServices){
for(var idx1 = 0; idx1 < orgin[idx].nodeServices.length; idx1++) {
if(orgin[idx].nodeServices[idx1].code == 'AGREEMENT_SIGNED' && orgin[idx].nodeServices[idx1].checked){
orgin[idx].nodeServices[idx1].flag = true
}
if(orgin[idx].nodeServices[idx1].code == 'AGREEMENT_SIGNED' && orgin[idx].nodeServices[idx1].flag){
for(var idx_1 = 0; idx_1 < orgin.length; idx_1++) {
if(orgin[idx_1].nodeServices){
for(var idx_2 = 0, _nodeServices = orgin[idx_1].nodeServices; idx_2 < _nodeServices.length; idx_2++) {
if(orgin[idx_1].nodeServices[idx_2].code == 'AGREEMENT_SIGNED'){
orgin[idx_1].nodeServices[idx_2].disabled = true
}
}
}
}
orgin[idx].nodeServices[idx1].disabled = false
}
if(orgin[idx].nodeServices[idx1].checked){
delete orgin[idx].nodeServices[idx1].checked
}
}
}
}
return orgin
},
handleSelectChangeName(val) {
this.selectVal = val
},
//select 选择框选择内容
handleSelectChangeIndex(val) {
},
handleSelectChangeType(){
},
onChangeCheckbox(e){
e.checked = !e.checked
this.$forceUpdate();
},
edit (record,val) {
this.status = 1
this.model = record;
this.disabledName = true
this.selectVal = record.name
this.form.resetFields();
this.visible = true;
this.$nextTick(() => {
this.flowListData = this.handleFlowListDataToList(record,val)
this.form.setFieldsValue(pick(record,'name','index','remark'));
});
},
add (val) {
//新增时候拿到原始flowList数据
this.status = 0
this.model = {};
this.disabledName = false
this.form.resetFields();
//将选中的数据重置
this.flowInfoList = this.handleResetCheckedData(val)
this.visible = true;
this.$nextTick(() => {
this.form.setFieldsValue();
});
},
close () {
this.$emit('close');
this.visible = false;
this.disableSubmit = false;
this.checkedRole = [];
},
handleSubmit () {
// 触发表单验证
this.form.validateFields((err, values) => {
if (!err) {
this.confirmLoading = true;
let formData = this.handleSelectFlowListData(values,this.flowInfoList)
// console.log(formData)
this.$emit('ok', formData,this.status);
this.confirmLoading = false;
this.close();
this.reset()
}
})
},
handleCancel () {
this.close()
},
reset(){
this.selectVal = ''
}
}
}
</script>
<style scoped>
</style>