SelectGroup.vue
2.96 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
<template>
<div>
<el-form-item label="群发客户群" required prop="type">
<el-radio-group v-model="form.type" @change="clearData" :disabled="isDetail">
<el-radio :label="0">全部群</el-radio>
<el-radio :label="1">部分群</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item v-if="form.type == 1">
<div>
<div class="item-magin aic">
<div class="item-name" v-if="!isDetail">
<!-- <span style="color: red;">*</span> -->
选择群主:
</div>
<el-button
v-if="!isDetail"
type="primary"
size="mini"
class="mr10"
icon="el-icon-circle-plus-outline"
plain
@click="onSelectCustomerGroup"
>
{{ form.userIds ? '编辑' : '选择' }}群主
</el-button>
<el-tag v-for="item in selectCustomerGroupList" :key="item.userId">{{ item.name }}</el-tag>
</div>
</div>
</el-form-item>
<SelectWeUser
:visible.sync="dialogVisibleSelectCustomerGroup"
title="选择群主"
destroyOnClose
:defaultValues="selectCustomerGroupList"
@success="submitSelectCustomerGroup"
></SelectWeUser>
</div>
</template>
<script>
export default {
name: 'select-group',
data() {
return {
form: {
type: 0
},
selectCustomerGroupList: [],
dialogVisibleSelectCustomerGroup: false
}
},
props: {
dataObj: {
type: Object,
default: null
},
isDetail: {
type: Boolean,
default: false
}
},
watch: {
dataObj: {
handler(val, old) {
if (val) {
this.form = val
this.setData()
}
},
deep: true,
immediate: true
}
},
methods: {
setData() {
if (this.form.userIds) {
this.selectCustomerGroupList = []
let arr = this.form.userIds.split(',')
let obj = {}
arr.forEach((dd) => {
obj = {
userId: dd,
name: this.form.users[dd]
}
this.selectCustomerGroupList.push(obj)
})
}
},
clearData(type) {
if (type == 0) {
this.selectCustomerGroupList = []
this.form.userIds = ''
this.changeFn()
}
},
onSelectCustomerGroup() {
this.dialogVisibleSelectCustomerGroup = true
},
submitSelectCustomerGroup(users) {
this.selectCustomerGroupList = users
this.form.userIds = users
.map((dd) => {
return dd.userId
})
.join(',')
let obj = {}
users.forEach((ff) => {
obj[ff.userId] = ff.name
})
this.form.users = obj
this.changeFn()
},
changeFn() {
this.$emit('update', this.form)
}
}
}
</script>
<style scoped></style>