Commit 7555f666 authored by Babin Egor's avatar Babin Egor

update vue order form

parent 8beabd44
......@@ -29,37 +29,24 @@ Vue.component('app-waste-utilisation-order-form', {
settings: {
searchEnabled: true,
shouldSort: false,
noChoicesText: 'Пусто',
noResultsText: 'Ничего не найдено',
noChoicesText: 'Пусто',
noResultsText: 'Ничего не найдено',
},
helptext: ''
},
wGroupSelect2: {
wMainGroupSelect: {
title: 'Вид отходов',
attrs: {
name: 'waste-group',
id: 'waste-group',
required: true
},
options: [
{
option: "1",
label: "прочие отходы"
},
{
option: "1",
label: "отходы металла, стекла, дерева, текстиля"
},
{
option: "1",
label: "Промышленные стоки"
}
],
options: [],
settings: {
searchEnabled: true,
shouldSort: false,
noChoicesText: 'Пусто',
noResultsText: 'Ничего не найдено',
noChoicesText: 'Пусто',
noResultsText: 'Ничего не найдено',
},
helptext: ''
},
......@@ -129,6 +116,7 @@ Vue.component('app-waste-utilisation-order-form', {
name: 'communal',
caption: 'Сбор коммунальных отходов',
},
wMainGroup: {},
wGroup: {},
wDangerClass: {},
wFKKO: {
......@@ -187,12 +175,18 @@ Vue.component('app-waste-utilisation-order-form', {
//console.log("Режим создания новой записи")
}
// Подгружаем группы отходов
this.wasteMainGroupsLoad();
this.wasteGroupsLoad();
this.fiasInit();
},
computed: {
wasteGroupUrl() {
return '/api/type/' + this.localRecord.wType.name
return 'https://r52.ru/api/type/' + this.localRecord.wType.name
},
wasteMainGroupUrl(){
return 'https://r52.ru/api/mainType/' + this.localRecord.wType.name
},
// Открываем кнопку "сохранить"
formFilledRight() {
......@@ -206,6 +200,7 @@ Vue.component('app-waste-utilisation-order-form', {
},
methods: {
// Вводи кода отхода вручную
codeUp(){
this.localRecord.wGroup = {};
......@@ -242,6 +237,7 @@ Vue.component('app-waste-utilisation-order-form', {
return Object.keys(obj).length === 0
},
// КЛАДР
fiasInit() {
let $this = this;
......@@ -337,6 +333,30 @@ Vue.component('app-waste-utilisation-order-form', {
// Отключаем проверку введённых данных для строений
// $building.fias('verify', false);
},
// Подгрузка селектора гнлавных групп отходов
wasteMainGroupsLoad(){
axios
.get(this.wasteMainGroupUrl)
.then(response => response.data)
.then(options => {
// новый бланк/старый
this.initValue.value = !this.isEditing ? this.initValue.value : this.localRecord.wMainGroup.value;
let groupsArr = [];
for(var k in options){
if (options[k]["group"]) {
groupsArr.push(options[k]["group"]);
}
}
this.$set(this.wMainGroupSelect, 'options', groupsArr);
this.dateFromGroup();
})
},
// Подгрузка селектора группы отходов
wasteGroupsLoad() {
axios
.get(this.wasteGroupUrl)
......@@ -355,15 +375,16 @@ Vue.component('app-waste-utilisation-order-form', {
this.$set(this.wGroupSelect, 'options', groupsArr);
this.dateFromGroup();
})
},
dateFromMainGroup() {
},
dateFromGroup() {
axios
.get(this.wasteGroupUrl)
.then(response => response.data)
.then(options => {
this.initValue.value = !this.isEditing ?
this.initValue.value :
this.localRecord.wGroup.value;
this.initValue.value = !this.isEditing ? this.initValue.value : this.localRecord.wGroup.value;
for(var k in options){
if (this.localRecord.wGroup["value"] !== undefined){
if (options[k]["group"]["value"] == this.localRecord.wGroup["value"]){
......@@ -439,10 +460,10 @@ Vue.component('app-waste-utilisation-order-form', {
amount: this.localRecord.wAmount,
group: this.localRecord.wGroup["value"]
},
url: "/api/transport/getPrice/"
url: "https://r52.ru/api/transport/getPrice/"
}).then(response => response.data)
.then(options => {
this.localRecord.wTransportCost["value"] = parseFloat(options["price"]).toFixed(2);
this.localRecord.wTransportCost["value"] = parseFloat(options["price"]).toFixed(2);
});
}
......@@ -451,12 +472,15 @@ Vue.component('app-waste-utilisation-order-form', {
this.localRecord.wType = e;
this.localRecord.wMainGroup = {}
this.localRecord.wGroup = {};
this.localRecord.wDangerClass = {};
this.localRecord.wUnit = {};
this.localRecord.wFKKO = {};
this.localRecord.wAmount = "";
this.wasteMainGroupsLoad();
this.wasteGroupsLoad();
},
......@@ -491,7 +515,7 @@ Vue.component('app-waste-utilisation-order-form', {
</waste-filter>
</div>
<!-- Debug --->
<div style="display: none; position: absolute; right: -130px;top: 0px; background-color:#fff; z-index:1000; width: 400px; height: 1000px; padding: 10px; border: 1px solid #999;">
<div style="position: absolute; right: -130px;top: 0px; background-color:#fff; z-index:1000; width: 400px; height: 1000px; padding: 10px; border: 1px solid #999;">
<pre>
{{ localRecord }}
</pre>
......@@ -531,10 +555,10 @@ Vue.component('app-waste-utilisation-order-form', {
<div class="block_orange-b">
<!-- Вид отхода. Список -->
<field-select
v-bind="wGroupSelect2"
:init="localRecord.wGroup"
@change="localRecord.wGroup = $event"
@change="dateFromGroup"
v-bind="wMainGroupSelect"
:init="localRecord.wMainGroup"
@change="localRecord.wMainGroup = $event"
@change="dateFromMainGroup"
>
</field-select>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment