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', { ...@@ -29,37 +29,24 @@ Vue.component('app-waste-utilisation-order-form', {
settings: { settings: {
searchEnabled: true, searchEnabled: true,
shouldSort: false, shouldSort: false,
noChoicesText: 'Пусто', noChoicesText: 'Пусто',
noResultsText: 'Ничего не найдено', noResultsText: 'Ничего не найдено',
}, },
helptext: '' helptext: ''
}, },
wGroupSelect2: { wMainGroupSelect: {
title: 'Вид отходов', title: 'Вид отходов',
attrs: { attrs: {
name: 'waste-group', name: 'waste-group',
id: 'waste-group', id: 'waste-group',
required: true required: true
}, },
options: [ options: [],
{
option: "1",
label: "прочие отходы"
},
{
option: "1",
label: "отходы металла, стекла, дерева, текстиля"
},
{
option: "1",
label: "Промышленные стоки"
}
],
settings: { settings: {
searchEnabled: true, searchEnabled: true,
shouldSort: false, shouldSort: false,
noChoicesText: 'Пусто', noChoicesText: 'Пусто',
noResultsText: 'Ничего не найдено', noResultsText: 'Ничего не найдено',
}, },
helptext: '' helptext: ''
}, },
...@@ -129,6 +116,7 @@ Vue.component('app-waste-utilisation-order-form', { ...@@ -129,6 +116,7 @@ Vue.component('app-waste-utilisation-order-form', {
name: 'communal', name: 'communal',
caption: 'Сбор коммунальных отходов', caption: 'Сбор коммунальных отходов',
}, },
wMainGroup: {},
wGroup: {}, wGroup: {},
wDangerClass: {}, wDangerClass: {},
wFKKO: { wFKKO: {
...@@ -187,12 +175,18 @@ Vue.component('app-waste-utilisation-order-form', { ...@@ -187,12 +175,18 @@ Vue.component('app-waste-utilisation-order-form', {
//console.log("Режим создания новой записи") //console.log("Режим создания новой записи")
} }
// Подгружаем группы отходов
this.wasteMainGroupsLoad();
this.wasteGroupsLoad(); this.wasteGroupsLoad();
this.fiasInit(); this.fiasInit();
}, },
computed: { computed: {
wasteGroupUrl() { 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() { formFilledRight() {
...@@ -206,6 +200,7 @@ Vue.component('app-waste-utilisation-order-form', { ...@@ -206,6 +200,7 @@ Vue.component('app-waste-utilisation-order-form', {
}, },
methods: { methods: {
// Вводи кода отхода вручную
codeUp(){ codeUp(){
this.localRecord.wGroup = {}; this.localRecord.wGroup = {};
...@@ -242,6 +237,7 @@ Vue.component('app-waste-utilisation-order-form', { ...@@ -242,6 +237,7 @@ Vue.component('app-waste-utilisation-order-form', {
return Object.keys(obj).length === 0 return Object.keys(obj).length === 0
}, },
// КЛАДР
fiasInit() { fiasInit() {
let $this = this; let $this = this;
...@@ -337,6 +333,30 @@ Vue.component('app-waste-utilisation-order-form', { ...@@ -337,6 +333,30 @@ Vue.component('app-waste-utilisation-order-form', {
// Отключаем проверку введённых данных для строений // Отключаем проверку введённых данных для строений
// $building.fias('verify', false); // $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() { wasteGroupsLoad() {
axios axios
.get(this.wasteGroupUrl) .get(this.wasteGroupUrl)
...@@ -355,15 +375,16 @@ Vue.component('app-waste-utilisation-order-form', { ...@@ -355,15 +375,16 @@ Vue.component('app-waste-utilisation-order-form', {
this.$set(this.wGroupSelect, 'options', groupsArr); this.$set(this.wGroupSelect, 'options', groupsArr);
this.dateFromGroup(); this.dateFromGroup();
}) })
},
dateFromMainGroup() {
}, },
dateFromGroup() { dateFromGroup() {
axios axios
.get(this.wasteGroupUrl) .get(this.wasteGroupUrl)
.then(response => response.data) .then(response => response.data)
.then(options => { .then(options => {
this.initValue.value = !this.isEditing ? this.initValue.value = !this.isEditing ? this.initValue.value : this.localRecord.wGroup.value;
this.initValue.value :
this.localRecord.wGroup.value;
for(var k in options){ for(var k in options){
if (this.localRecord.wGroup["value"] !== undefined){ if (this.localRecord.wGroup["value"] !== undefined){
if (options[k]["group"]["value"] == this.localRecord.wGroup["value"]){ if (options[k]["group"]["value"] == this.localRecord.wGroup["value"]){
...@@ -439,10 +460,10 @@ Vue.component('app-waste-utilisation-order-form', { ...@@ -439,10 +460,10 @@ Vue.component('app-waste-utilisation-order-form', {
amount: this.localRecord.wAmount, amount: this.localRecord.wAmount,
group: this.localRecord.wGroup["value"] group: this.localRecord.wGroup["value"]
}, },
url: "/api/transport/getPrice/" url: "https://r52.ru/api/transport/getPrice/"
}).then(response => response.data) }).then(response => response.data)
.then(options => { .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', { ...@@ -451,12 +472,15 @@ Vue.component('app-waste-utilisation-order-form', {
this.localRecord.wType = e; this.localRecord.wType = e;
this.localRecord.wMainGroup = {}
this.localRecord.wGroup = {}; this.localRecord.wGroup = {};
this.localRecord.wDangerClass = {}; this.localRecord.wDangerClass = {};
this.localRecord.wUnit = {}; this.localRecord.wUnit = {};
this.localRecord.wFKKO = {}; this.localRecord.wFKKO = {};
this.localRecord.wAmount = ""; this.localRecord.wAmount = "";
this.wasteMainGroupsLoad();
this.wasteGroupsLoad(); this.wasteGroupsLoad();
}, },
...@@ -491,7 +515,7 @@ Vue.component('app-waste-utilisation-order-form', { ...@@ -491,7 +515,7 @@ Vue.component('app-waste-utilisation-order-form', {
</waste-filter> </waste-filter>
</div> </div>
<!-- Debug ---> <!-- 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> <pre>
{{ localRecord }} {{ localRecord }}
</pre> </pre>
...@@ -531,10 +555,10 @@ Vue.component('app-waste-utilisation-order-form', { ...@@ -531,10 +555,10 @@ Vue.component('app-waste-utilisation-order-form', {
<div class="block_orange-b"> <div class="block_orange-b">
<!-- Вид отхода. Список --> <!-- Вид отхода. Список -->
<field-select <field-select
v-bind="wGroupSelect2" v-bind="wMainGroupSelect"
:init="localRecord.wGroup" :init="localRecord.wMainGroup"
@change="localRecord.wGroup = $event" @change="localRecord.wMainGroup = $event"
@change="dateFromGroup" @change="dateFromMainGroup"
> >
</field-select> </field-select>
</div> </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