【修复】xn-page-select组件无法及时更新双向绑定value数据的值的问题。

【优化】xn-page-select组件支持搜索框搜索--调用后端数据搜索。
pull/223/head
张耕碧 2024-06-27 18:31:44 +08:00
parent 831a1ef55d
commit cf2d20014e
1 changed files with 28 additions and 3 deletions

View File

@ -8,7 +8,10 @@
:placeholder="props.placeholder"
:allow-clear="props.allowClear"
:disabled="props.disabled"
:showSearch="props.showSearch"
:filterOption="!props.showSearch"
@change="handleChange"
@search="handleSearch"
@popupScroll="handlePopupScroll"
/>
</a-spin>
@ -21,7 +24,7 @@
const initParams = ref({})
const options = ref([])
const spinning = ref(false)
const emit = defineEmits({ change: null, 'update:value': null })
const emit = defineEmits({ change: null, 'update:value': null, search:null })
const props = defineProps({
value: {
type: String,
@ -45,6 +48,14 @@
type: Boolean,
default: () => false
},
showSearch: {
type: Boolean,
default: () => false
},
searchKeyName: {
type: String,
default: () => ''
},
disabled: {
type: Boolean,
default: () => false
@ -99,10 +110,24 @@
// change
const handleChange = (value, array) => {
modelValue.value = value
// change
emit('change', value, array)
if (value == null && props.showSearch){
//
initParams.value[props.searchKeyName] = value;
}
//
emit('update:value', value)
// change
emit('change', value, array)
}
// search
const handleSearch = (searchValue) => {
let _params = {current: 1};
if (props.searchKeyName && props.searchKeyName !== ''){
_params[props.searchKeyName] = searchValue;
onPage({ ...initParams.value, ..._params});
}
// search
emit('search', searchValue)
}
//
const handlePopupScroll = (e) => {