mirror of https://gitee.com/xiaonuobase/snowy
【修复】xn-page-select组件无法及时更新双向绑定value数据的值的问题。
【优化】xn-page-select组件支持搜索框搜索--调用后端数据搜索。pull/223/head
parent
831a1ef55d
commit
cf2d20014e
|
@ -8,7 +8,10 @@
|
||||||
:placeholder="props.placeholder"
|
:placeholder="props.placeholder"
|
||||||
:allow-clear="props.allowClear"
|
:allow-clear="props.allowClear"
|
||||||
:disabled="props.disabled"
|
:disabled="props.disabled"
|
||||||
|
:showSearch="props.showSearch"
|
||||||
|
:filterOption="!props.showSearch"
|
||||||
@change="handleChange"
|
@change="handleChange"
|
||||||
|
@search="handleSearch"
|
||||||
@popupScroll="handlePopupScroll"
|
@popupScroll="handlePopupScroll"
|
||||||
/>
|
/>
|
||||||
</a-spin>
|
</a-spin>
|
||||||
|
@ -21,7 +24,7 @@
|
||||||
const initParams = ref({})
|
const initParams = ref({})
|
||||||
const options = ref([])
|
const options = ref([])
|
||||||
const spinning = ref(false)
|
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({
|
const props = defineProps({
|
||||||
value: {
|
value: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -45,6 +48,14 @@
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: () => false
|
default: () => false
|
||||||
},
|
},
|
||||||
|
showSearch: {
|
||||||
|
type: Boolean,
|
||||||
|
default: () => false
|
||||||
|
},
|
||||||
|
searchKeyName: {
|
||||||
|
type: String,
|
||||||
|
default: () => ''
|
||||||
|
},
|
||||||
disabled: {
|
disabled: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: () => false
|
default: () => false
|
||||||
|
@ -99,10 +110,24 @@
|
||||||
// change
|
// change
|
||||||
const handleChange = (value, array) => {
|
const handleChange = (value, array) => {
|
||||||
modelValue.value = value
|
modelValue.value = value
|
||||||
// 触发change事件
|
if (value == null && props.showSearch){
|
||||||
emit('change', value, array)
|
//被清空,重置查询条件
|
||||||
|
initParams.value[props.searchKeyName] = value;
|
||||||
|
}
|
||||||
// 更新数据
|
// 更新数据
|
||||||
emit('update:value', 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) => {
|
const handlePopupScroll = (e) => {
|
||||||
|
|
Loading…
Reference in New Issue