FlowNodeUserConfig.vue
4.89 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
<template>
<div style="margin-top: -8px;" class="flow-node-user-config">
<div class="label-title">
{{title}}({{nodeId}})
<el-button icon="el-icon-circle-plus-outline" @click="setNodeUser()" type="text">新增</el-button>
</div>
<div class="alert-danger alert" v-if="!nodeUsers||nodeUsers.length==0"> 尚未配置节点人员,请添加人员设置</div>
<div v-for="(nodeCondition,$index) in nodeUsers" :key="$index" class="alert">
<div>
<el-tooltip
v-if="$index === 0"
class="item"
effect="dark"
content="批次顺序由上至下增大,第一批次无法获取到审批人时才会获取下一个批次审批人信息。"
placement="left"
>
<span class="control-label left-label">
<i class="el-icon-warning"></i>
</span>
</el-tooltip>
{{nodeCondition.description}}
</div>
<div>
<el-button icon="el-icon-edit-outline" @click="setNodeUser($index)" circle></el-button>
<el-button icon="el-icon-arrow-up" @click="ArrayTool(nodeUsers,$index,'up')" circle></el-button>
<el-button icon="el-icon-arrow-down" @click="ArrayTool(nodeUsers,$index)" circle></el-button>
<el-button icon="el-icon-delete" @click="nodeUsers.remove(nodeUsers[$index])" circle></el-button>
</div>
</div>
<FlowNodeUserCondition @nodeUserConditionConfirm="nodeUserConditionConfirm" ref="flowNodeUserCondition" />
</div>
</template>
<script>
import flow from "@/api/flow.js";
import req from "@/request.js";
import { mapState, mapActions } from "vuex";
const FlowNodeUserCondition = () => import("@/components/flow/FlowNodeUserCondition.vue");
import utils from "@/hotent-ui-util.js"
export default {
props: ["defId","title",'nodeId','defkey'],
components: {FlowNodeUserCondition },
data() {
return {
nodeUsers:[],
curSetIndex:'-1'
};
},
computed: mapState({
defConfigData:state => state.flow.defConfigData
}),
watch: {
nodeUsers: {
handler(newValue, oldValue) {
let path = 'nodeSetData.nodeUserMap.'+this.nodeId;
let obj = {};
obj[path] = newValue;
if (newValue) {
for (let index = 0; index < newValue.length; index++) {
newValue[index].groupNo = index+1;
}
}
this.$store.dispatch("flow/updateConfig",obj);
},
deep: true
}
},
methods: {
dialogCancel(){
},
nodeUserConditionConfirm(res){
if(res.calcs){
if (this.curSetIndex !='-1') {
this.nodeUsers.splice(this.curSetIndex,1,res);
} else {
this.nodeUsers.push(res);
}
}
},
ArrayTool(ary,idx,direct){
direct = direct || "down";
let part = ary[idx];
if (!part || (part.constructor !== Object && part.constructor !== Array)) {
return ary;
}
if (part.constructor === Object) {
part = [part];
}
if (direct == "up") {
part.forEach(m => {
let index = ary.indexOf(m, 1);
if (index > 0) {
let t=ary[index-1];
ary.splice(index - 1,1,ary[index]);
ary.splice(index,1,t);
}
});
} else if (direct == "down") {
for (var i = part.length - 1, m; (m = part[i--]);) {
let index = ary.indexOf(m, 0);
if (index > -1 && index < ary.length - 1) {
let t=ary[index+1];
ary.splice(index + 1,1,ary[index]);
ary.splice(index,1,t);
}
}
}
},
setNodeUser(index){
let conf ={nodeId:this.nodeId};
if (index || index ===0 ) {
this.curSetIndex = index;
conf.userRule = JSON.parse(JSON.stringify(this.nodeUsers[index]));
}else{
this.curSetIndex = -1;
}
this.$refs.flowNodeUserCondition.showDialog(conf);
},
},
created() {
this.utils = utils;
if(this.defConfigData.nodeSetData.nodeUserMap && this.defConfigData.nodeSetData.nodeUserMap[this.nodeId]){
this.nodeUsers = JSON.parse(JSON.stringify(this.defConfigData.nodeSetData.nodeUserMap[this.nodeId]));
}
}
};
</script>
<style lang="scss" scoped>
.flow-node-user-config {
.label-title {
color: #333;
font-weight: bold;
font-size: 14px;
margin-bottom: 10px;
button {
margin-left: 8px;
}
}
}
.alert {
display: flex;
align-items: center;
justify-content: space-between;
color: #409EFF;
background-color: #F6F6F6;
padding: 10px;
margin-bottom: 5px;
border-radius: 2px;
width: 100%;
}
.alert-danger {
color: #a94442;
background-color: #f2dede;
border-color: #ebccd1;
}
.alert ::v-deep .el-button {
padding: 6px 8px;
margin-left:0px;
margin-right:5px;
}
</style>