fixed AkauntingSelect.vue and AkauntingSelectRemote.vue files.

This commit is contained in:
Cüneyt Şentürk 2021-05-07 17:00:37 +03:00
parent dc6d53b649
commit aaafacf601
2 changed files with 135 additions and 91 deletions

View File

@ -269,7 +269,7 @@ export default {
type: String, type: String,
default: 'No Matchign Data', default: 'No Matchign Data',
description: "Selectbox search option not found item message" description: "Selectbox search option not found item message"
} },
}, },
data() { data() {
@ -294,70 +294,7 @@ export default {
}, },
created() { created() {
let created_options = (this.dynamicOptions) ? this.dynamicOptions : this.options; this.setSortOptions();
if (this.group) {
// Option set sort_option data
if (!Array.isArray(created_options)) {
for (const [index, options] of Object.entries(created_options)) {
let values = [];
for (const [key, value] of Object.entries(options)) {
values.push({
key: key,
value: value
});
}
this.sort_options.push({
key: index,
value: values
});
}
} else {
created_options.forEach(function (option, index) {
if (typeof(option) == 'string') {
this.sort_options.push({
index: index,
key: index.toString(),
value: option
});
} else {
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(created_options)) {
for (const [key, value] of Object.entries(created_options)) {
this.sort_options.push({
key: key,
value: value
});
}
} else {
created_options.forEach(function (option, index) {
if (typeof(option) == 'string') {
this.sort_options.push({
index: index,
key: index.toString(),
value: option
});
} else {
this.sort_options.push({
index: index,
key: option.id,
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
});
}
}, this);
}
}
}, },
computed: { computed: {
@ -418,6 +355,76 @@ export default {
} }
}, },
setSortOptions() {
// Reset sort_options
this.sort_options = [];
let created_options = (this.dynamicOptions) ? this.dynamicOptions : this.options;
if (this.group) {
// Option set sort_option data
if (!Array.isArray(created_options)) {
for (const [index, options] of Object.entries(created_options)) {
let values = [];
for (const [key, value] of Object.entries(options)) {
values.push({
key: key,
value: value
});
}
this.sort_options.push({
key: index,
value: values
});
}
} else {
created_options.forEach(function (option, index) {
if (typeof(option) == 'string') {
this.sort_options.push({
index: index,
key: index.toString(),
value: option
});
} else {
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(created_options)) {
for (const [key, value] of Object.entries(created_options)) {
this.sort_options.push({
key: key,
value: value
});
}
} else {
created_options.forEach(function (option, index) {
if (typeof(option) == 'string') {
this.sort_options.push({
index: index,
key: index.toString(),
value: option
});
} else {
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 controll added add new changed.. // This controll added add new changed..
if (typeof(this.selected) === 'object' && typeof(this.selected.type) !== 'undefined') { if (typeof(this.selected) === 'object' && typeof(this.selected.type) !== 'undefined') {
@ -541,6 +548,8 @@ export default {
}, },
onModal(value) { onModal(value) {
//this.setSortOptions();
let add_new = this.add_new; let add_new = this.add_new;
window.axios.get(this.add_new.path) window.axios.get(this.add_new.path)

View File

@ -88,7 +88,7 @@
</el-option> </el-option>
</el-option-group> </el-option-group>
<el-option v-if="!loading && addNew.status && options.length != 0 && sortOptions.length > 0" class="el-select__footer" :disabled="disabled" value=""> <el-option v-if="!loading && addNew.status && options.length != 0 && sortOptions.length > 0" class="el-select__footer" :disabled="disabled" value="">
<div @click="onAddItem"> <div @click="onAddItem">
<i class="fas fa-plus"></i> <i class="fas fa-plus"></i>
<span> <span>
@ -468,6 +468,9 @@ export default {
}, },
setSortOptions() { setSortOptions() {
// Reset sort_options
this.sort_options = [];
let created_options = (this.dynamicOptions) ? this.dynamicOptions : this.options; let created_options = (this.dynamicOptions) ? this.dynamicOptions : this.options;
if (this.group) { if (this.group) {
@ -490,11 +493,19 @@ export default {
} }
} else { } else {
created_options.forEach(function (option, index) { created_options.forEach(function (option, index) {
this.sort_options.push({ if (typeof(option) == 'string') {
index: index, this.sort_options.push({
key: option.id, index: index,
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name key: index.toString(),
}); value: option
});
} else {
this.sort_options.push({
index: index,
key: option.id,
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
});
}
}, this); }, this);
} }
} else { } else {
@ -508,11 +519,19 @@ export default {
} }
} else { } else {
created_options.forEach(function (option, index) { created_options.forEach(function (option, index) {
this.sort_options.push({ if (typeof(option) == 'string') {
index: index, this.sort_options.push({
key: option.id, index: index,
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name key: index.toString(),
}); value: option
});
} else {
this.sort_options.push({
index: index,
key: option.id,
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
});
}
}, this); }, this);
} }
} }
@ -531,7 +550,7 @@ export default {
// Option changed sort_option data // Option changed sort_option data
if (this.group) { if (this.group) {
this.sort_options.forEach(function (option_group, group_index) { this.sort_options.forEach(function (option_group, group_index) {
this.option_group.value.forEach(function (option, index) { option_group.value.forEach(function (option, index) {
if (this.multiple) { if (this.multiple) {
let indexs = []; let indexs = [];
let values = []; let values = [];
@ -539,7 +558,7 @@ export default {
let options = []; let options = [];
this.selected.forEach(function (selected_option_id, selected_index) { this.selected.forEach(function (selected_option_id, selected_index) {
if (option.value == selected_option_id) { if (option.key == selected_option_id) {
indexs.push(selected_index); indexs.push(selected_index);
values.push(option.id); values.push(option.id);
labels.push(option.value); labels.push(option.value);
@ -552,7 +571,7 @@ export default {
this.$emit('label', labels); this.$emit('label', labels);
this.$emit('option', options); this.$emit('option', options);
} else { } else {
if (option.value == this.selected) { if (option.key == this.selected) {
this.$emit('index', index); this.$emit('index', index);
this.$emit('value', option.id); this.$emit('value', option.id);
this.$emit('label', option.value); this.$emit('label', option.value);
@ -570,7 +589,7 @@ export default {
let options = []; let options = [];
this.selected.forEach(function (selected_option_id, selected_index) { this.selected.forEach(function (selected_option_id, selected_index) {
if (option.value == selected_option_id) { if (option.key == selected_option_id) {
indexs.push(selected_index); indexs.push(selected_index);
values.push(option.id); values.push(option.id);
labels.push(option.value); labels.push(option.value);
@ -583,7 +602,7 @@ export default {
this.$emit('label', labels); this.$emit('label', labels);
this.$emit('option', options); this.$emit('option', options);
} else { } else {
if (option.value == this.selected) { if (option.key == this.selected) {
this.$emit('index', index); this.$emit('index', index);
this.$emit('value', option.id); this.$emit('value', option.id);
this.$emit('label', option.value); this.$emit('label', option.value);
@ -982,11 +1001,19 @@ export default {
} }
} else { } else {
options.forEach(function (option, index) { options.forEach(function (option, index) {
this.sort_options.push({ if (typeof(option) == 'string') {
index: index, this.sort_options.push({
key: option.id, index: index,
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name key: index.toString(),
}); value: option
});
} else {
this.sort_options.push({
index: index,
key: option.id,
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
});
}
}, this); }, this);
} }
} else { } else {
@ -1000,11 +1027,19 @@ export default {
} }
} else { } else {
options.forEach(function (option, index) { options.forEach(function (option, index) {
this.sort_options.push({ if (typeof(option) == 'string') {
index: index, this.sort_options.push({
key: option.id, index: index,
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name key: index.toString(),
}); value: option
});
} else {
this.sort_options.push({
index: index,
key: option.id,
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
});
}
}, this); }, this);
} }
} }