Commit 7f17b731 authored by Babin Egor's avatar Babin Egor

fild-file vue updated

parent 8f5a8e14
......@@ -12,7 +12,7 @@ Vue.component('app-waste-utilisation-order-form', {
type: Array
},
docs: {
type: Object
type: FileList
}
},
data: function () {
......@@ -116,8 +116,8 @@ Vue.component('app-waste-utilisation-order-form', {
initValue: {
value: '0'
},
serverUrl: '/',
//serverUrl: 'https://r52.ru/',
//serverUrl: '/',
serverUrl: 'https://r52.ru/',
}
},
created() {
......@@ -135,7 +135,7 @@ Vue.component('app-waste-utilisation-order-form', {
},
wAmount: '',
wUnit: {},
wDocs: [],
wDocs: {},
wAddress: {
region: {
id: null,
......@@ -179,8 +179,8 @@ Vue.component('app-waste-utilisation-order-form', {
},
mounted() {
this.wasteMainGroupsLoad();
this.wasteGroupsLoad();
this.fiasInit();
},
......@@ -188,12 +188,16 @@ Vue.component('app-waste-utilisation-order-form', {
// Открываем кнопку "сохранить"
formFilledRight() {
return true;
/*
return (!this.objEmty(this.localRecord.wGroup)) &&
(this.localRecord.wAmount !== '') &&
(this.localRecord.wAddress.region.name !== '') &&
(this.localRecord.wAddress.city.name !== '') &&
(this.localRecord.wAddress.street.name !== '') &&
(this.localRecord.wAddress.building.name !== '');
*/
},
// следим на ссылкой на группы отходов
......@@ -210,8 +214,6 @@ Vue.component('app-waste-utilisation-order-form', {
let classSel = this.wDangerClassSelect.options;
//alert(classSel);
if (classSel) {
return 'col-md-9';
} else {
......@@ -235,6 +237,7 @@ Vue.component('app-waste-utilisation-order-form', {
methods: {
// проверяем пустой ли объект
objEmty(obj) {
return Object.keys(obj).length === 0
},
......@@ -344,8 +347,6 @@ Vue.component('app-waste-utilisation-order-form', {
.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){
......@@ -354,20 +355,27 @@ Vue.component('app-waste-utilisation-order-form', {
}
}
//this.$set(this.wMainGroupSelect, 'options', groupsArr);
this.wMainGroupSelect.options = groupsArr;
this.dateFromGroup();
this.$set(this.wMainGroupSelect, 'options', groupsArr);
this.wasteGroupsLoad();
})
},
// Подгрузка селектора группы отходов
wasteGroupsLoad() {
wasteGroupsLoad(enevt = false) {
if (enevt) {
this.localRecord.wGroup = {};
this.localRecord.wDangerClass = {};
this.localRecord.wUnit = {};
this.localRecord.wAmount = "";
}
axios
.get(this.wasteGroupUrl)
.then(response => response.data)
.then(options => {
this.initValue.value = !this.isEditing ? this.initValue.value : this.localRecord.wGroup.value;
let groupsArr = [];
for(var k in options){
......@@ -376,58 +384,71 @@ Vue.component('app-waste-utilisation-order-form', {
}
}
//this.$set(this.wGroupSelect, 'options', groupsArr);
this.$set(this.wGroupSelect, 'options', groupsArr);
this.wGroupSelect.options = groupsArr;
this.dateFromGroup();
this.dataFromGroup(options);
})
},
dateFromMainGroup() {
this.wasteGroupsLoad();
},
// обновляем класс опасности и ед изм.
dataFromGroup(classUnitsOptions = 0, event = 0) {
if (event) {
this.localRecord.wDangerClass = {};
this.localRecord.wUnit = {};
this.localRecord.wAmount = "";
}
if (classUnitsOptions) {
for(var k in classUnitsOptions){
if (this.localRecord.wGroup["value"] !== undefined){
if (classUnitsOptions[k]["group"]["value"] == this.localRecord.wGroup["value"]){
this.$set(this.wDangerClassSelect, 'options', classUnitsOptions[k]["class"]);
this.$set(this.wUnitSelect, 'options', classUnitsOptions[k]["price_units"]);
}
} else {
this.$set(this.wDangerClassSelect, 'options', {});
this.$set(this.wUnitSelect, 'options', {});
}
}
} else {
dateFromGroup() {
axios
.get(this.wasteGroupUrl)
.then(response => response.data)
.then(options => {
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"]){
//this.$set(this.wDangerClassSelect, 'options', options[k]["class"]);
//this.$set(this.wUnitSelect, 'options', options[k]["price_units"]);
this.wDangerClassSelect.options = options[k]["class"];
this.wUnitSelect.options = options[k]["price_units"];
this.$set(this.wDangerClassSelect, 'options', options[k]["class"]);
this.$set(this.wUnitSelect, 'options', options[k]["price_units"]);
}
} else {
//this.$set(this.wDangerClassSelect, 'options', {});
//this.$set(this.wUnitSelect, 'options', {});
this.$set(this.wDangerClassSelect, 'options', {});
this.$set(this.wUnitSelect, 'options', {});
}
}
})
}
},
// считаем цену из селекта
priceFromSelect() {
axios
.get(this.wasteGroupUrl)
.then(response => response.data)
.then(options => {
this.initValue.value = !this.isEditing ? this.initValue.value : this.localRecord.wGroup.value;
for(var k in options){
if (options[k]["group"]["value"] == this.localRecord.wGroup["value"]){
//this.$set(this.wDangerClassSelect, 'options', options[k]["class"]);
//this.$set(this.wUnitSelect, 'options', options[k]["price_units"]);
this.wDangerClassSelect.options = options[k]["class"];
this.wUnitSelect.options = options[k]["price_units"];
this.$set(this.wDangerClassSelect, 'options', options[k]["class"]);
this.$set(this.wUnitSelect, 'options', options[k]["price_units"]);
options[k]["price_units"].forEach(element => {
if (element["value"] == this.localRecord.wUnit["value"]){
......@@ -440,6 +461,7 @@ Vue.component('app-waste-utilisation-order-form', {
this.delivCost();
},
// смотри за изменением чек-бокса транспортировки
isTransport() {
if (this.localRecord.isTransport.value) {
this.localRecord.isTransport.value = false;
......@@ -450,6 +472,8 @@ Vue.component('app-waste-utilisation-order-form', {
}
},
// смотрим за измененем чек-бокса доставки
isAddress() {
if (this.localRecord.isAddress.value) {
this.localRecord.isAddress.value = false;
......@@ -495,11 +519,9 @@ Vue.component('app-waste-utilisation-order-form', {
this.localRecord.wGroup = {};
this.localRecord.wDangerClass = {};
this.localRecord.wUnit = {};
this.localRecord.wFKKO = {};
this.localRecord.wAmount = "";
this.wasteMainGroupsLoad();
this.wasteGroupsLoad();
},
clickOnAddToApplicationFormBtn() {
......@@ -520,7 +542,27 @@ Vue.component('app-waste-utilisation-order-form', {
// При изменении списка файлов
updateDocs(e) {
this.localRecord.wDocs = this.$children["4"].localFiles;
/*
var files = e.target.files || e.dataTransfer.files;
if (!files.length) {
alert("err!");
return false;
}
console.log(files);
alert(1);
//this.localRecord.wDocs = this.$children["4"].localFiles;
*/
},
filesSetChanges() {
alert(1);
},
},
......@@ -538,7 +580,7 @@ Vue.component('app-waste-utilisation-order-form', {
<!-- Debug --->
<div class="debug"
style="position: absolute; right: -270px;top: 20px; background-color:#fff; z-index:1; width: 400px; height: 1500px; padding: 10px; border: 1px solid #999;">
style="position: absolute; right: -270px;top: 20px; background-color:#fff; z-index:10000; width: 400px; height: 1500px; padding: 10px; border: 1px solid #999;">
<pre>
{{ localRecord }}
</pre>
......@@ -564,7 +606,7 @@ Vue.component('app-waste-utilisation-order-form', {
<field-select
v-bind="wMainGroupSelect"
:init="localRecord.wMainGroup"
@change="(localRecord.wMainGroup = $event, dateFromMainGroup())"
@change="(localRecord.wMainGroup = $event, wasteGroupsLoad($event))"
>
</field-select>
</div>
......@@ -576,7 +618,7 @@ Vue.component('app-waste-utilisation-order-form', {
<field-select
v-bind="wGroupSelect"
:init="localRecord.wGroup"
@change="(localRecord.wGroup = $event, dateFromGroup())"
@change="(localRecord.wGroup = $event, dataFromGroup(false, $event))"
>
</field-select>
</div>
......@@ -650,6 +692,7 @@ Vue.component('app-waste-utilisation-order-form', {
<field-file
:text="fieldFileAttrs.text"
:attrs="fieldFileAttrs.attrs"
:value="localRecord.wAmount"
:files="localRecord.wDocs"
@filesSetChanges="updateDocs"
>
......
......@@ -32,15 +32,19 @@ Vue.component('field-file',{
type: Object
},
files: {
type: Array
type: FileList
},
value: {
type: String
}
},
data: function () {
return {
localFiles: this.files.slice()
localFiles: this.files.slice(),
}
},
methods: {
onInputFileChange(e) {
// если не выбрали файл и нажали отмену, то ничего не делать
......@@ -52,17 +56,25 @@ Vue.component('field-file',{
// очищаем input, т.к. файл мы сохранили
e.target.value = '';
this.files = this.localFiles;
},
addFiles(files) {
// Поправильному, прежде чем добавлять файлы нужно проверить не добавленны ли они ранее
this.localFiles = this.localFiles.concat(files);
// console.log(this.localFiles);
this.$emit('filesSetChanges',files)
this.files = this.localFiles;
},
removeFile(index) {
this.localFiles.splice(index, 1);
this.$emit('filesSetChanges',this.localFiles)
this.files = this.localFiles;
}
},
// watch: {
......@@ -74,6 +86,9 @@ Vue.component('field-file',{
template: `
<div class="field-file" ref="fieldFile">
{{ files }}
{{ localValue }}
<field-file-item-wrap
v-for="(file, index) in localFiles"
:key="index"
......
......@@ -68,7 +68,6 @@ Vue.component('field-select', {
},
template: `
<div class="field-select">
<div class="field-select__name" v-if="title">
{{ title }}
<span v-if="attrs.required"
......
......@@ -139,6 +139,12 @@
display: none;
}
/*
#choices--waste-group-item-choice-1 {
display: none;
}
*/
&__input {
border: none;
// border: 1px solid #ccc;
......
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