Files
dvcp_v2_webapp/project/xiushan/components/AiUserPicker.vue

59 lines
1.3 KiB
Vue
Raw Normal View History

2022-03-22 20:26:57 +08:00
<template>
<section class="AiUserPicker">
2022-03-22 22:32:04 +08:00
<el-select size="small" :value="value" placeholder="选择人员" clearable @change="handleSelect" v-bind="$attrs"
2022-03-22 20:26:57 +08:00
filterable>
2022-03-22 21:11:18 +08:00
<el-option v-for="row in list" :key="row.id" :value="row.id" :label="row[label]"/>
2022-03-22 20:26:57 +08:00
</el-select>
</section>
</template>
<script>
export default {
name: "AiUserPicker",
model: {
prop: "value",
event: "select"
},
props: {
value: {default: ""},
instance: Function,
2022-08-29 10:58:48 +08:00
action: {default: "/app/appportaluser/list"},
2022-03-22 21:11:18 +08:00
params: {default: () => ({})},
2022-03-22 22:32:04 +08:00
label: {default: "phone"},
name: {default: ""}
2022-03-22 20:26:57 +08:00
},
data() {
return {
list: []
}
},
methods: {
getUsers() {
let {action, params} = this
this.instance?.post(action, null, {params: {...params, size: 9999}}).then(res => {
if (res?.data) {
this.list = res.data.records
}
})
2022-03-22 22:32:04 +08:00
},
handleSelect(v) {
let list = this.list.filter(e => [v].flat().includes(e.id))
this.$emit('select', v)
this.$emit("update:name", list?.map(e => e[this.label])?.toString() || "")
this.$emit("list", list)
2022-03-22 20:26:57 +08:00
}
},
created() {
this.getUsers()
}
}
</script>
<style lang="scss" scoped>
.AiUserPicker {
2022-03-22 21:11:18 +08:00
.el-select {
2022-03-22 20:57:09 +08:00
width: 100%;
}
2022-03-22 20:26:57 +08:00
}
</style>