1 Star 0 Fork 3.8K

github-mysync/Admin.NET

forked from zuohuaijun/Admin.NET 
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
UserSelect.vue 1.60 KB
一键复制 编辑 原始数据 按行查看 历史
Jerry 提交于 2022-03-11 15:42 +08:00 . 删除 console.log
<template>
<a-select
:mode="model"
showSearch
:value="selectValue"
:filter-option="false"
:placeholder="placeholder"
:not-found-content="fetching ? undefined : null"
@search="fetchUser"
@change="handleChange"
>
<a-spin v-if="fetching" slot="notFoundContent" size="small" />
<a-select-option v-for="d in data" :key="d.value">
{{ d.text }}
</a-select-option>
</a-select>
</template>
<script>
import debounce from 'lodash/debounce'
import { getUserPage } from '@/api/modular/system/userManage'
export default {
name: 'UserSelect',
props: {
placeholder: {
type: String
},
value: {
type: String
},
multiple: {
type: Boolean,
default: false
}
},
data() {
const multiple = this.multiple
this.fetchUser = debounce(this.fetchUser, 800)
return {
data: [],
fetching: false,
selectValue: multiple ? [] : undefined,
model: multiple ? 'multiple' : 'default'
}
},
methods: {
fetchUser(key) {
this.data = []
this.fetching = true
const params = {
pageNo: 1,
pageSize: 10,
searchValue: key
}
this.userFetching = true
getUserPage(params).then((res) => {
this.data = res.data.rows.map(user => ({
text: `${user.name} ${user.account}`,
value: user.id
}))
}).finally(() => {
this.fetching = false
})
},
handleChange(value) {
Object.assign(this, {
selectValue: value,
fetching: false
})
this.$emit('change', value)
}
}
}
</script>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/github-mysync/Admin.NET.git
git@gitee.com:github-mysync/Admin.NET.git
github-mysync
Admin.NET
Admin.NET
master

搜索帮助