mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-05 05:29:01 +08:00
27 lines
806 B
TypeScript
27 lines
806 B
TypeScript
|
import type { Ref } from 'vue';
|
||
|
import { computed } from 'vue';
|
||
|
import type { SingleValueType, DefaultOptionType, InternalFieldNames } from '../Cascader';
|
||
|
import { toPathOptions } from '../utils/treeUtil';
|
||
|
|
||
|
export default (
|
||
|
options: Ref<DefaultOptionType[]>,
|
||
|
fieldNames: Ref<InternalFieldNames>,
|
||
|
rawValues: Ref<SingleValueType[]>,
|
||
|
) => {
|
||
|
return computed(() => {
|
||
|
const missingValues: SingleValueType[] = [];
|
||
|
const existsValues: SingleValueType[] = [];
|
||
|
|
||
|
rawValues.value.forEach(valueCell => {
|
||
|
const pathOptions = toPathOptions(valueCell, options.value, fieldNames.value);
|
||
|
if (pathOptions.every(opt => opt.option)) {
|
||
|
existsValues.push(valueCell);
|
||
|
} else {
|
||
|
missingValues.push(valueCell);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
return [existsValues, missingValues];
|
||
|
});
|
||
|
};
|