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