84 lines
2.2 KiB
Vue
84 lines
2.2 KiB
Vue
<template>
|
|
<div>
|
|
<v-select
|
|
v-model="range"
|
|
:clearable="false"
|
|
label="label"
|
|
:options='rangesDatas'
|
|
:filterable="true"
|
|
@input="checkRange">
|
|
</v-select>
|
|
<input type="hidden" v-model="range.id" name="range_id" />
|
|
<v-select
|
|
v-model="subrange"
|
|
:clearable="false"
|
|
label="name"
|
|
:options='subrangesDatas'
|
|
:filterable="true"
|
|
:disabled="this.range.has_subranges === 0">
|
|
</v-select>
|
|
<input type="hidden" v-model="subrange.id" name="sub_range_id" />
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import { defineComponent } from "vue";
|
|
|
|
export default defineComponent({
|
|
mounted() {
|
|
this.range = JSON.parse(this.dbRange);
|
|
this.range.label = this.range.name + ' - ' + this.range.type;
|
|
this.subrange = JSON.parse(this.dbSubrange);
|
|
if(!this.range) {
|
|
this.range = {
|
|
name: null,
|
|
id: null,
|
|
type: null,
|
|
}
|
|
}
|
|
if(!this.subrange) {
|
|
this.subrange = {
|
|
name: null,
|
|
id: 0,
|
|
}
|
|
}
|
|
this.rangesDatas = JSON.parse(this.ranges);
|
|
this.rangesDatas.forEach((item,index) => {
|
|
//TODO Ramener le vrai label de l'enum Type
|
|
item.label = item.name + ' - ' + (item.type == 0 ? 'Frais' : 'Gel');
|
|
});
|
|
this.subrangesDatas = JSON.parse(this.subranges);
|
|
this.subrangesDatas.unshift({
|
|
name: "<---Pas de Sous Gamme--->",
|
|
id: 0,
|
|
});
|
|
},
|
|
props: [
|
|
'ranges',
|
|
'subranges',
|
|
'dbRange',
|
|
'dbSubrange',
|
|
],
|
|
data() {
|
|
return {
|
|
rangesDatas: [],
|
|
subrangesDatas: [],
|
|
range: {
|
|
name: null,
|
|
id: 0
|
|
},
|
|
subrange: {
|
|
name: null,
|
|
id: 0
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
checkRange(value) {
|
|
if (value.has_subranges === 0) {
|
|
this.subrange = {name: null,id: 0}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
</script>
|