mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-16 06:16:46 +08:00
下拉列表框 名称帅选
This commit is contained in:
@@ -1,33 +1,18 @@
|
||||
<template>
|
||||
<a-select
|
||||
:getPopupContainer="
|
||||
(triggerNode) => {
|
||||
return triggerNode.parentNode || document.body;
|
||||
}
|
||||
"
|
||||
v-model:value="managerArray"
|
||||
:placeholder="placeholder"
|
||||
:filterOption="false"
|
||||
:options="isOpen?options:selectOptions"
|
||||
allowClear
|
||||
showSearch
|
||||
:disabled="disabled"
|
||||
@popupScroll="memberScroll"
|
||||
@search="searchMember"
|
||||
:open="isOpen"
|
||||
@change="change"
|
||||
@blur="blur"
|
||||
:show-arrow="false"
|
||||
style="width: 100%"
|
||||
>
|
||||
<a-select :getPopupContainer="(triggerNode) => {
|
||||
return triggerNode.parentNode || document.body;
|
||||
}
|
||||
" v-model:value="managerArray" :placeholder="placeholder" :filterOption="false"
|
||||
:options="isOpen ? options : selectOptions" allowClear showSearch :disabled="disabled" @popupScroll="memberScroll"
|
||||
@search="searchMember" :open="isOpen" @change="change" @blur="blur" :show-arrow="false" style="width: 100%">
|
||||
<template v-if="loading" #notFoundContent>
|
||||
<a-spin size="small"/>
|
||||
<a-spin size="small" />
|
||||
</template>
|
||||
</a-select>
|
||||
</template>
|
||||
<script setup>
|
||||
import {computed, defineEmits, defineProps, onMounted, ref, watch} from "vue";
|
||||
import {useThrottlePage} from "@/api/request";
|
||||
import { computed, defineEmits, defineProps, onMounted, ref, watch } from "vue";
|
||||
import { useThrottlePage } from "@/api/request";
|
||||
import { getTeacherList } from "@/api/Lecturer";
|
||||
const props = defineProps({
|
||||
value: {
|
||||
@@ -52,38 +37,39 @@ const props = defineProps({
|
||||
|
||||
const selectOptions = ref([])
|
||||
|
||||
const managerArray = computed(() => props.value === '' ? null : props.value)
|
||||
const managerArray = computed(() => props.value === '' ? null : props.value)
|
||||
|
||||
const emit = defineEmits({})
|
||||
|
||||
const isOpen = ref(false)
|
||||
function debounce(func, wait) {
|
||||
let timeout;
|
||||
return function(...args) {
|
||||
return function (...args) {
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(() => func.apply(this, args), wait);
|
||||
};
|
||||
}
|
||||
const memberParam = ref({name: '', pageNo:1, pageSize: 999,teacherType:2 ,status:1})
|
||||
const memberParam = ref({ name: '', pageNo: 1, pageSize: 999, teacherType: 2, status: 1 })
|
||||
|
||||
const userList = ref([])
|
||||
const loading = ref(false)
|
||||
const getOutTeacher = () => {
|
||||
getTeacherList(memberParam.value).then(res=>{
|
||||
if(res.data.code == 200){
|
||||
getTeacherList(memberParam.value).then(res => {
|
||||
if (res.data.code == 200) {
|
||||
userList.value = res.data.data.records
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
const options = computed(() => userList.value.map(e => ({
|
||||
|
||||
// label: e.name + '(' + e.userNo + ')' + e.organizationName,
|
||||
label:e.name+ '(' +e.supplier + ')',
|
||||
value: e.name,
|
||||
...e,
|
||||
audienceList: null
|
||||
})))
|
||||
const options = computed(() =>
|
||||
userList.value.map(e => ({
|
||||
// label: e.name + '(' + e.userNo + ')' + e.organizationName,
|
||||
label: e.name + '(' + e.supplier + ')',
|
||||
value: e.name,
|
||||
...e,
|
||||
audienceList: null
|
||||
})
|
||||
))
|
||||
|
||||
watch(props, init)
|
||||
|
||||
@@ -101,10 +87,10 @@ onMounted(() => {
|
||||
})
|
||||
|
||||
|
||||
const memberScroll = ({target: {scrollHeight, scrollTop, clientHeight}}) => {
|
||||
const memberScroll = ({ target: { scrollHeight, scrollTop, clientHeight } }) => {
|
||||
scrollHeight === (clientHeight + scrollTop) && memberParam.value.pageNo++
|
||||
};
|
||||
const debounceObject = debounce(getOutTeacher,1000)
|
||||
const debounceObject = debounce(getOutTeacher, 1000)
|
||||
//搜索学员
|
||||
const searchMember = (keyword) => {
|
||||
console.log('searchMember', keyword)
|
||||
@@ -112,7 +98,7 @@ const searchMember = (keyword) => {
|
||||
isOpen.value = true
|
||||
userList.value = []
|
||||
memberParam.value.pageNo = 1
|
||||
memberParam.value.teacherType=2
|
||||
memberParam.value.teacherType = 2
|
||||
memberParam.value.name = keyword
|
||||
console.log('searchMember', memberParam.value)
|
||||
debounceObject()
|
||||
@@ -122,19 +108,26 @@ function blur() {
|
||||
isOpen.value = false
|
||||
memberParam.value.name = ''
|
||||
memberParam.value.pageNo = 1
|
||||
memberParam.value.teacherType=2
|
||||
memberParam.value.teacherType = 2
|
||||
}
|
||||
|
||||
function change(e, l) {
|
||||
memberParam.value.name = ''
|
||||
memberParam.value.teacherType=2
|
||||
memberParam.value.teacherType = 2
|
||||
memberParam.value.pageNo = 1
|
||||
isOpen.value = false
|
||||
Array.isArray(l) && (selectOptions.value = l)
|
||||
Array.isArray(selectOptions.value) && emit('onChange', e, l)
|
||||
emit('update:name', l?.label)
|
||||
emit('update:value', l?.value)
|
||||
emit('update:mobile', l?.label)
|
||||
selectOptions.value.map(e => ({
|
||||
// label: e.name + '(' + e.userNo + ')' + e.organizationName,
|
||||
label: e.name + '(' + e.supplier + ')',
|
||||
value: e.name,
|
||||
...e,
|
||||
audienceList: null
|
||||
}));
|
||||
emit('update:name', l?.label)
|
||||
emit('update:value', l?.value)
|
||||
emit('update:mobile', l?.label)
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user