refs #5673 fix(vnSelectFilter): update options
gitea/salix-front/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2023-08-04 08:57:11 +02:00
parent 0cb925abc3
commit 35ac3afe81
2 changed files with 21 additions and 7 deletions

View File

@ -18,22 +18,24 @@ const $props = defineProps({
}); });
const updateValue = (newValue) => emit('update:modelValue', newValue); const updateValue = (newValue) => emit('update:modelValue', newValue);
const updateOptions = (newValue) => emit('update:options', newValue); const { modelValue, options, optionLabel } = toRefs($props);
const { modelValue } = toRefs($props);
function filterFn(val, update) { function filterFn(val, update) {
update( update(
() => { () => {
const needle = val.toLowerCase(); const needle = val.toLowerCase();
console.log($props.options);
// $props.options.value = options.value.filter( // $props.options.value = options.value.filter(
// (v) => v[$props.optionLabel.value].toLowerCase().indexOf(needle) > -1 // (v) => v[$props.optionLabel.value].toLowerCase().indexOf(needle) > -1
// ); // );
updateOptions( // updateOptions(
$props.options.filter( // $props.options.filter(
(v) => v[$props.optionLabel].toLowerCase().indexOf(needle) > -1 // (v) => v[$props.optionLabel].toLowerCase().indexOf(needle) > -1
) // )
// );
const filteredOptions = options.value.filter(
(v) => v[optionLabel.value].toLowerCase().indexOf(needle) > -1
); );
emit('update:options', filteredOptions);
}, },
(ref) => { (ref) => {
ref.setOptionIndex(-1); ref.setOptionIndex(-1);

View File

@ -147,6 +147,12 @@ const columns = computed(() => [
:label="col.label" :label="col.label"
v-model="row[col.model]" v-model="row[col.model]"
:options="col.options" :options="col.options"
@update:options="
(newOptions) => {
console.log(newOptions);
col.options = newOptions;
}
"
:option-value="col.optionValue" :option-value="col.optionValue"
:option-label="col.optionLabel" :option-label="col.optionLabel"
/> />
@ -166,6 +172,12 @@ const columns = computed(() => [
:label="col.label" :label="col.label"
v-model="props.row[col.model]" v-model="props.row[col.model]"
:options="col.options" :options="col.options"
@update:options="
(newOptions) => {
console.log(newOptions);
col.options = newOptions;
}
"
:option-value="col.optionValue" :option-value="col.optionValue"
:option-label="col.optionLabel" :option-label="col.optionLabel"
dense dense