You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
806 B
27 lines
806 B
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];
|
|
});
|
|
};
|