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

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

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

Loading…
Cancel
Save