UserSelector.vue
1.63 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
<template>
<div @click="showDialog">
<el-input
v-model="fullnames"
:title="fullnames"
placeholder="请选择人员"
readonly
suffix-icon="icon-account"
style="width:350px;"
>
<!-- <el-button slot="append" @click="showDialog()" icon="icon-account"></el-button> -->
</el-input>
<ht-user-dialog
ref="eipUserDialog"
@on-confirm="onConfirm"
:single="single"
:currentSelectUsers="currentSelectUsers"
:appendToBody="true"
/>
</div>
</template>
<script>
import eipUserDialog from "@/components/dialog/EipUserDialog.vue";
export default {
name: "user-selector",
components: { eipUserDialog },
props: {
value: Array | String,
single: {
type: Boolean,
default: false
}
},
data() {
return {};
},
computed: {
fullnames: function(val) {
let temp = [];
if (this.value && this.value.constructor == Array) {
this.value.forEach(item => {
temp.push(item.fullname);
});
}
return temp.join(",");
},
currentSelectUsers(){
return this.value.constructor === Array ? this.value : []
}
},
methods: {
showDialog() {
this.$refs.eipUserDialog.showDialog(this.value);
},
onConfirm(selection) {
let result = [];
if (selection) {
selection.forEach(item => {
let obj = {
id: item.id,
account: item.account,
fullname: item.fullname
};
result.push(obj);
});
}
// this.fullnames = fullnames.join(",");
this.$emit("input", result);
}
}
};
</script>