refs select remote file
This commit is contained in:
parent
c31c097e19
commit
870db531fe
@ -280,7 +280,7 @@ export default {
|
|||||||
|
|
||||||
model: {
|
model: {
|
||||||
type: [String, Number, Array, Object],
|
type: [String, Number, Array, Object],
|
||||||
default: null,
|
default: '',
|
||||||
description: "Selectbox selected model"
|
description: "Selectbox selected model"
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -386,23 +386,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
// Option set sort_option data
|
this.setSortOptions();
|
||||||
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);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
@ -451,6 +435,26 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
setSortOptions() {
|
||||||
|
// 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);
|
||||||
|
|
||||||
@ -485,18 +489,23 @@ export default {
|
|||||||
if (query !== '') {
|
if (query !== '') {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
|
||||||
if (!this.remoteAction) {
|
let path = this.remoteAction;
|
||||||
this.remoteAction = url + '/common/items/autocomplete';
|
|
||||||
|
if (!path) {
|
||||||
|
path = url + '/common/items/autocomplete';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (path.search('/?') !== -1) {
|
||||||
|
path += '?search=' + query;
|
||||||
|
} else {
|
||||||
|
path += '&search=' + query;
|
||||||
|
}
|
||||||
|
|
||||||
|
path += '¤cy_code=' + this.currencyCode;
|
||||||
|
|
||||||
window.axios({
|
window.axios({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: this.remoteAction,
|
url: path,
|
||||||
params: {
|
|
||||||
type: this.remoteType,
|
|
||||||
query: query,
|
|
||||||
currency_code: this.currencyCode,
|
|
||||||
},
|
|
||||||
headers: {
|
headers: {
|
||||||
'X-CSRF-TOKEN': window.Laravel.csrfToken,
|
'X-CSRF-TOKEN': window.Laravel.csrfToken,
|
||||||
'X-Requested-With': 'XMLHttpRequest',
|
'X-Requested-With': 'XMLHttpRequest',
|
||||||
@ -507,9 +516,18 @@ export default {
|
|||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
|
||||||
if (response.data.data) {
|
if (response.data.data) {
|
||||||
this.selectOptions = response.data.data;
|
let data = response.data.data;
|
||||||
|
|
||||||
|
this.sort_options = [];
|
||||||
|
|
||||||
|
data.forEach(function (option) {
|
||||||
|
this.sort_options.push({
|
||||||
|
key: option.id.toString(),
|
||||||
|
value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name
|
||||||
|
});
|
||||||
|
}, this);
|
||||||
} else {
|
} else {
|
||||||
this.selectOptions = [];
|
this.sortOptions = [];
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
@ -518,7 +536,7 @@ export default {
|
|||||||
// always executed
|
// always executed
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.selectOptions = this.options;
|
this.setSortOptions();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
<akaunting-select-remote
|
<akaunting-select-remote
|
||||||
class="{{ $col }}{{ isset($attributes['required']) ? ' required' : '' }}{{ isset($attributes['disabled']) ? ' disabled' : '' }}"
|
class="{{ $col }}{{ isset($attributes['required']) ? ' required' : '' }}{{ isset($attributes['disabled']) ? ' disabled' : '' }}"
|
||||||
|
|
||||||
|
id="form-select-{{ $name }}"
|
||||||
|
|
||||||
@if (!empty($attributes['v-error']))
|
@if (!empty($attributes['v-error']))
|
||||||
:form-classes="[{'has-error': {{ $attributes['v-error'] }} }]"
|
:form-classes="[{'has-error': {{ $attributes['v-error'] }} }]"
|
||||||
@else
|
@else
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
<akaunting-select-remote
|
<akaunting-select-remote
|
||||||
class="{{ $col }}{{ isset($attributes['required']) ? ' required' : '' }}{{ isset($attributes['disabled']) ? ' disabled' : '' }}"
|
class="{{ $col }}{{ isset($attributes['required']) ? ' required' : '' }}{{ isset($attributes['disabled']) ? ' disabled' : '' }}"
|
||||||
|
|
||||||
|
id="form-select-{{ $name }}"
|
||||||
|
|
||||||
@if (!empty($attributes['v-error']))
|
@if (!empty($attributes['v-error']))
|
||||||
:form-classes="[{'has-error': {{ $attributes['v-error'] }} }]"
|
:form-classes="[{'has-error': {{ $attributes['v-error'] }} }]"
|
||||||
@else
|
@else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user