Select and multi select change option event with (key and value)
This commit is contained in:
parent
48d17ed098
commit
ff7cdb8d8b
@ -428,6 +428,71 @@ export default {
|
|||||||
this.$emit('interface', this.selected);
|
this.$emit('interface', this.selected);
|
||||||
|
|
||||||
this.$emit('change', this.selected);
|
this.$emit('change', this.selected);
|
||||||
|
|
||||||
|
// Option changed sort_option data
|
||||||
|
if (this.group) {
|
||||||
|
this.sort_options.forEach(function (option_group, group_index) {
|
||||||
|
this.option_group.value.forEach(function (option, index) {
|
||||||
|
if (this.multiple) {
|
||||||
|
let indexs = [];
|
||||||
|
let values = [];
|
||||||
|
let labels = [];
|
||||||
|
let options = [];
|
||||||
|
|
||||||
|
this.selected.forEach(function (selected_option_id, selected_index) {
|
||||||
|
if (option.value = this.selected) {
|
||||||
|
indexs.push(selected_index);
|
||||||
|
values.push(option.id);
|
||||||
|
labels.push(option.value);
|
||||||
|
options.push(option);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.$emit('index', indexs);
|
||||||
|
this.$emit('value', values);
|
||||||
|
this.$emit('label', labels);
|
||||||
|
this.$emit('option', options);
|
||||||
|
} else {
|
||||||
|
if (option.value = this.selected) {
|
||||||
|
this.$emit('index', index);
|
||||||
|
this.$emit('value', option.id);
|
||||||
|
this.$emit('label', option.value);
|
||||||
|
this.$emit('option', option);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
}, this);
|
||||||
|
} else {
|
||||||
|
this.sort_options.forEach(function (option, index) {
|
||||||
|
if (this.multiple) {
|
||||||
|
let indexs = [];
|
||||||
|
let values = [];
|
||||||
|
let labels = [];
|
||||||
|
let options = [];
|
||||||
|
|
||||||
|
this.selected.forEach(function (selected_option_id, selected_index) {
|
||||||
|
if (option.value = this.selected) {
|
||||||
|
indexs.push(selected_index);
|
||||||
|
values.push(option.id);
|
||||||
|
labels.push(option.value);
|
||||||
|
options.push(option);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.$emit('index', indexs);
|
||||||
|
this.$emit('value', values);
|
||||||
|
this.$emit('label', labels);
|
||||||
|
this.$emit('option', options);
|
||||||
|
} else {
|
||||||
|
if (option.value = this.selected) {
|
||||||
|
this.$emit('index', index);
|
||||||
|
this.$emit('value', option.id);
|
||||||
|
this.$emit('label', option.value);
|
||||||
|
this.$emit('option', option);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
visibleChange(event) {
|
visibleChange(event) {
|
||||||
|
@ -492,58 +492,123 @@ export default {
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
setSortOptions() {
|
setSortOptions() {
|
||||||
if (this.group) {
|
if (this.group) {
|
||||||
// Option set sort_option data
|
// Option set sort_option data
|
||||||
if (!Array.isArray(this.options)) {
|
if (!Array.isArray(this.options)) {
|
||||||
for (const [index, options] of Object.entries(this.options)) {
|
for (const [index, options] of Object.entries(this.options)) {
|
||||||
let values = [];
|
let values = [];
|
||||||
|
|
||||||
for (const [key, value] of Object.entries(options)) {
|
for (const [key, value] of Object.entries(options)) {
|
||||||
values.push({
|
values.push({
|
||||||
|
key: key,
|
||||||
|
value: value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.sort_options.push({
|
||||||
|
key: index,
|
||||||
|
value: values
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.options.forEach(function (option, index) {
|
||||||
|
this.sort_options.push({
|
||||||
|
index: index,
|
||||||
|
key: option.id,
|
||||||
|
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
|
||||||
|
});
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Option set sort_option data
|
||||||
|
if (!Array.isArray(this.options)) {
|
||||||
|
for (const [key, value] of Object.entries(this.options)) {
|
||||||
|
this.sort_options.push({
|
||||||
key: key,
|
key: key,
|
||||||
value: value
|
value: value
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
this.sort_options.push({
|
this.options.forEach(function (option, index) {
|
||||||
key: index,
|
this.sort_options.push({
|
||||||
value: values
|
index: index,
|
||||||
});
|
key: option.id,
|
||||||
|
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
|
||||||
|
});
|
||||||
|
}, this);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this.options.forEach(function (option, index) {
|
|
||||||
this.sort_options.push({
|
|
||||||
index: index,
|
|
||||||
key: option.id,
|
|
||||||
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
|
|
||||||
});
|
|
||||||
}, this);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// Option set sort_option data
|
|
||||||
if (!Array.isArray(this.options)) {
|
|
||||||
for (const [key, value] of Object.entries(this.options)) {
|
|
||||||
this.sort_options.push({
|
|
||||||
key: key,
|
|
||||||
value: value
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.options.forEach(function (option, index) {
|
|
||||||
this.sort_options.push({
|
|
||||||
index: index,
|
|
||||||
key: option.id,
|
|
||||||
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
|
|
||||||
});
|
|
||||||
}, this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
change() {
|
change() {
|
||||||
this.$emit('interface', this.selected);
|
this.$emit('interface', this.selected);
|
||||||
|
|
||||||
this.$emit('change', this.selected);
|
this.$emit('change', this.selected);
|
||||||
|
|
||||||
|
// Option changed sort_option data
|
||||||
|
if (this.group) {
|
||||||
|
this.sort_options.forEach(function (option_group, group_index) {
|
||||||
|
this.option_group.value.forEach(function (option, index) {
|
||||||
|
if (this.multiple) {
|
||||||
|
let indexs = [];
|
||||||
|
let values = [];
|
||||||
|
let labels = [];
|
||||||
|
let options = [];
|
||||||
|
|
||||||
|
this.selected.forEach(function (selected_option_id, selected_index) {
|
||||||
|
if (option.value = this.selected) {
|
||||||
|
indexs.push(selected_index);
|
||||||
|
values.push(option.id);
|
||||||
|
labels.push(option.value);
|
||||||
|
options.push(option);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.$emit('index', indexs);
|
||||||
|
this.$emit('value', values);
|
||||||
|
this.$emit('label', labels);
|
||||||
|
this.$emit('option', options);
|
||||||
|
} else {
|
||||||
|
if (option.value = this.selected) {
|
||||||
|
this.$emit('index', index);
|
||||||
|
this.$emit('value', option.id);
|
||||||
|
this.$emit('label', option.value);
|
||||||
|
this.$emit('option', option);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
}, this);
|
||||||
|
} else {
|
||||||
|
this.sort_options.forEach(function (option, index) {
|
||||||
|
if (this.multiple) {
|
||||||
|
let indexs = [];
|
||||||
|
let values = [];
|
||||||
|
let labels = [];
|
||||||
|
let options = [];
|
||||||
|
|
||||||
|
this.selected.forEach(function (selected_option_id, selected_index) {
|
||||||
|
if (option.value = this.selected) {
|
||||||
|
indexs.push(selected_index);
|
||||||
|
values.push(option.id);
|
||||||
|
labels.push(option.value);
|
||||||
|
options.push(option);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.$emit('index', indexs);
|
||||||
|
this.$emit('value', values);
|
||||||
|
this.$emit('label', labels);
|
||||||
|
this.$emit('option', options);
|
||||||
|
} else {
|
||||||
|
if (option.value = this.selected) {
|
||||||
|
this.$emit('index', index);
|
||||||
|
this.$emit('value', option.id);
|
||||||
|
this.$emit('label', option.value);
|
||||||
|
this.$emit('option', option);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
visibleChange(event) {
|
visibleChange(event) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user