szh-new
张同海 5 months ago
parent bc48099518
commit 3efecd0dff

@ -6,6 +6,7 @@
:showSearch="true"
@dropdown-visible-change="handleFetch"
@change="handleChange"
:optionLabelProp="props.showName ? 'showName' : 'label'"
>
<template v-for="item in Object.keys($slots)" #[item]="data">
<slot :name="item" v-bind="data || {}"></slot>
@ -52,13 +53,14 @@
type: Array,
default: () => {
return []
}
},
},
// api params
params: propTypes.any.def({}),
// support xxx.xxx.xx
resultField: propTypes.string.def(''),
labelField: propTypes.string.def('label'),
showName: propTypes.string.def(''),
valueField: propTypes.string.def('value'),
immediate: propTypes.bool.def(true),
alwaysLoad: propTypes.bool.def(false),
@ -83,13 +85,13 @@
prev.push({
...omit(next, [labelField, valueField]),
label: next[labelField],
showName: props.showName ? next[props.showName] : '',
value: numberToString ? `${value}` : value,
})
}
return prev
}, [] as OptionsItem[])
})
watchEffect(() => {
props.immediate && !props.alwaysLoad && fetch()
})
@ -158,7 +160,7 @@
emitData.value = args
}
return { state, attrs, getOptions, loading, t, handleFetch, handleChange }
return { state, attrs, getOptions, loading, t, handleFetch, handleChange, props }
},
})
</script>

@ -354,6 +354,7 @@ export const basicInfoFormSchema: FormSchema[] = [
})
},
labelField: 'name',
showName: 'shortName',
valueField: 'id',
filterOption: (input: string, option: any) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0

Loading…
Cancel
Save