Commit ac82aa11 authored by Babin Egor's avatar Babin Egor

update forms

parent 7f17b731
...@@ -14,8 +14,6 @@ let config = { ...@@ -14,8 +14,6 @@ let config = {
"filter", "filter",
"app-registration", "app-registration",
"app-registration-form", "app-registration-form",
"app-ex-registration",
"app-ex-registration-form",
"app-waste-utilisation-order", "app-waste-utilisation-order",
"app-waste-utilisation-order-record", "app-waste-utilisation-order-record",
"app-waste-utilisation-order-form", "app-waste-utilisation-order-form",
......
...@@ -107,10 +107,22 @@ Vue.component('app-registration-form', { ...@@ -107,10 +107,22 @@ Vue.component('app-registration-form', {
personPassportIssuedDate: '', personPassportIssuedDate: '',
personPassportDepartmentCode: '', personPassportDepartmentCode: '',
personAddressRegion: '', personAddressRegion: {
personAddressCity: '', id: null,
personAddressStreet: '', name: ''
personAddressBuilding: '', },
personAddressCity: {
id: null,
name: ''
},
personAddressStreet: {
id: null,
name: ''
},
personAddressBuilding: {
id: null,
name: ''
},
personExtraDate: '', personExtraDate: '',
personExtraComment: '', personExtraComment: '',
...@@ -137,6 +149,24 @@ Vue.component('app-registration-form', { ...@@ -137,6 +149,24 @@ Vue.component('app-registration-form', {
name: '' name: ''
} }
}, },
wHomeAddress: {
region: {
id: null,
name: ''
},
city: {
id: null,
name: ''
},
street: {
id: null,
name: ''
},
building: {
id: null,
name: ''
},
},
}; };
this.transportGroupLoad(); this.transportGroupLoad();
...@@ -312,6 +342,9 @@ Vue.component('app-registration-form', { ...@@ -312,6 +342,9 @@ Vue.component('app-registration-form', {
deep: true deep: true
} }
}, },
mouted(){
this.fiasInit();
},
methods: { methods: {
selectTrans(e){ selectTrans(e){
...@@ -327,7 +360,6 @@ Vue.component('app-registration-form', { ...@@ -327,7 +360,6 @@ Vue.component('app-registration-form', {
this.wUnitAmounts[index].label = e.caption; this.wUnitAmounts[index].label = e.caption;
//alert(JSON.stringify(e)); //alert(JSON.stringify(e));
}, },
//https://r52.ru
transportGroupUrl(){ transportGroupUrl(){
return '/api/transport/getTypes/'; return '/api/transport/getTypes/';
}, },
...@@ -342,7 +374,6 @@ Vue.component('app-registration-form', { ...@@ -342,7 +374,6 @@ Vue.component('app-registration-form', {
this.wGroupSelect.options = options; this.wGroupSelect.options = options;
}) })
}, },
transportUnitsLoad(){ transportUnitsLoad(){
axios axios
.get(this.transportUnitsUrl(this.localRecord.wGroup.value)) .get(this.transportUnitsUrl(this.localRecord.wGroup.value))
...@@ -353,13 +384,17 @@ Vue.component('app-registration-form', { ...@@ -353,13 +384,17 @@ Vue.component('app-registration-form', {
//this.wUnitAmounts[0] = options[0]; //this.wUnitAmounts[0] = options[0];
}) })
}, },
fiasInit() { fiasInit() {
let $this = this; let $this = this;
$.fias.token = 'tiyhha6YHyNi6EfeyfrRrdrDQkyehf59'; $.fias.token = 'tiyhha6YHyNi6EfeyfrRrdrDQkyehf59';
$.fias.url = 'https://kladr-api.com/api.php'; $.fias.url = 'https://kladr-api.com/api.php';
let $container = $(this.$refs.address); let $container = $(this.$refs.address);
let $region = $container.find('[name="region"]'); let $region = $container.find('[name="region"]');
let $city = $container.find('[name="city"]');
let $street = $container.find('[name="street"]');
let $building = $container.find('[name="building"]');
$.fias.setDefault({ $.fias.setDefault({
parentInput: $container, parentInput: $container,
verify: true, verify: true,
...@@ -385,10 +420,18 @@ Vue.component('app-registration-form', { ...@@ -385,10 +420,18 @@ Vue.component('app-registration-form', {
if (obj) { if (obj) {
if (obj.parents) { if (obj.parents) {
$.fias.setValues(obj.parents, $container); $.fias.setValues(obj.parents, $container);
};
if ($this.currentStage == 0) {
$this.localRecord.wHomeAddress[obj.contentType].id = obj.id;
$this.localRecord.wHomeAddress[obj.contentType].name = obj.name;
} else {
$this.localRecord.wAddress[obj.contentType].id = obj.id;
$this.localRecord.wAddress[obj.contentType].name = obj.name;
} }
$this.localRecord.wAddress[obj.contentType].id = obj.id;
$this.localRecord.wAddress[obj.contentType].name = obj.name;
$input.parents('label').removeClass('field-text_error'); $input.parents('label').removeClass('field-text_error');
} else { } else {
$this.localRecord.wAddress[$input.attr('name')].id = null; $this.localRecord.wAddress[$input.attr('name')].id = null;
$this.localRecord.wAddress[$input.attr('name')].name = ''; $this.localRecord.wAddress[$input.attr('name')].name = '';
...@@ -399,6 +442,12 @@ Vue.component('app-registration-form', { ...@@ -399,6 +442,12 @@ Vue.component('app-registration-form', {
} }
}); });
$region.fias('type', $.fias.type.region); $region.fias('type', $.fias.type.region);
$city.fias('type', $.fias.type.city);
$street.fias('type', $.fias.type.street);
$building.fias('type', $.fias.type.building);
$city.fias('withParents', true);
$street.fias('withParents', true);
}, },
txtForRegButton() { txtForRegButton() {
...@@ -825,13 +874,14 @@ Vue.component('app-registration-form', { ...@@ -825,13 +874,14 @@ Vue.component('app-registration-form', {
<!-- Debug ---> <!-- Debug --->
<!--
<div style="display: none; position: fixed; right: 0;top: 0%; background-color:#fff; z-index:1000; width: 300px; padding: 10px; border: 1px solid #999;"> <div style="display: inerhit; position: fixed; right: 0;top: 0%; background-color:#fff; z-index:1000; width: 300px; padding: 10px; border: 1px solid #999;">
<pre> <pre>
{{ wUnitAmounts }} {{ localRecord.wHomeAddress }}
{{ fieldsVal[personType] }}
</pre> </pre>
</div> </div>
-->
<!-- end Debug ---> <!-- end Debug --->
...@@ -1285,7 +1335,8 @@ Vue.component('app-registration-form', { ...@@ -1285,7 +1335,8 @@ Vue.component('app-registration-form', {
<div class="hr"></div> <div class="hr"></div>
<div class="row"> <div class="row" v-if="wUnitsSelect.options.length">
<div class="offset-sm-2 col-sm-8 offset-md-3 col-md-6"> <div class="offset-sm-2 col-sm-8 offset-md-3 col-md-6">
<fieldset class="form__fieldset form__fieldset_address"> <fieldset class="form__fieldset form__fieldset_address">
<legend class="form__legend">Характеристики</legend> <legend class="form__legend">Характеристики</legend>
...@@ -1528,11 +1579,10 @@ Vue.component('app-registration-form', { ...@@ -1528,11 +1579,10 @@ Vue.component('app-registration-form', {
<label class="field-text"> <label class="field-text">
<span class="field-text__name">Дата выдачи <span style="color: red;">*</span></span> <span class="field-text__name">Дата выдачи <span style="color: red;">*</span></span>
<span class="field-text__input-wrap"> <span class="field-text__input-wrap">
<input type="text" <input type="date"
placeholder="Дата выдачи"
placeholder="Дата выдачи" class="field-text__input"
class="field-text__input" v-model="fieldsVal.natural.personPassportIssuedDate"
v-model="fieldsVal.natural.personPassportIssuedDate"
> >
</span> </span>
</label> </label>
...@@ -1558,17 +1608,20 @@ Vue.component('app-registration-form', { ...@@ -1558,17 +1608,20 @@ Vue.component('app-registration-form', {
<!-- Адрес --> <!-- Адрес -->
<div class="row"> <div class="row">
<div class="offset-sm-2 col-sm-8 offset-md-3 col-md-6"> <div class="offset-sm-2 col-sm-8 offset-md-3 col-md-6">
<fieldset class="form__fieldset"> <fieldset class="form__fieldset" ref="address">
<legend class="form__legend">Адрес</legend> <legend class="form__legend">Адрес</legend>
<div class="block_orange-b"> <div class="block_orange-b">
<label class="field-text"> <label class="field-text">
<span class="field-text__name">Область</span> <span class="field-text__name">Область</span>
<span class="field-text__input-wrap"> <span class="field-text__input-wrap">
<input type="text" <input
placeholder="Область" type="text"
class="field-text__input" name="region"
v-model="fieldsVal.natural.personAddressRegion" placeholder="Область"
class="field-text__input"
@click="fiasInit()"
v-model="localRecord.wHomeAddress.region.name"
> >
</span> </span>
</label> </label>
...@@ -1578,10 +1631,13 @@ Vue.component('app-registration-form', { ...@@ -1578,10 +1631,13 @@ Vue.component('app-registration-form', {
<label class="field-text"> <label class="field-text">
<span class="field-text__name">Населенный пункт</span> <span class="field-text__name">Населенный пункт</span>
<span class="field-text__input-wrap"> <span class="field-text__input-wrap">
<input type="text" <input
placeholder="Населенный пункт" type="text"
class="field-text__input" name="city"
v-model="fieldsVal.natural.personAddressCity" placeholder="Населенный пункт"
class="field-text__input"
@click="fiasInit()"
v-model="localRecord.wHomeAddress.city.name"
> >
</span> </span>
</label> </label>
...@@ -1592,9 +1648,11 @@ Vue.component('app-registration-form', { ...@@ -1592,9 +1648,11 @@ Vue.component('app-registration-form', {
<span class="field-text__name">Улица</span> <span class="field-text__name">Улица</span>
<span class="field-text__input-wrap"> <span class="field-text__input-wrap">
<input type="text" <input type="text"
placeholder="Улица" name="street"
class="field-text__input" placeholder="Улица"
v-model="fieldsVal.natural.personAddressStreet" class="field-text__input"
@click="fiasInit()"
v-model="localRecord.wHomeAddress.street.name"
> >
</span> </span>
</label> </label>
...@@ -1604,9 +1662,11 @@ Vue.component('app-registration-form', { ...@@ -1604,9 +1662,11 @@ Vue.component('app-registration-form', {
<span class="field-text__name">Дом</span> <span class="field-text__name">Дом</span>
<span class="field-text__input-wrap"> <span class="field-text__input-wrap">
<input type="text" <input type="text"
placeholder="Дом" @click="fiasInit()"
class="field-text__input" name="building"
v-model="fieldsVal.natural.personAddressBuilding" placeholder="Дом"
class="field-text__input"
v-model="localRecord.wHomeAddress.building.name"
> >
</span> </span>
</label> </label>
...@@ -1739,7 +1799,7 @@ Vue.component('app-registration-form', { ...@@ -1739,7 +1799,7 @@ Vue.component('app-registration-form', {
<div class="hr"></div> <div class="hr"></div>
<div class="row"> <div class="row" v-if="wUnitsSelect.options.length">
<div class="offset-sm-2 col-sm-8 offset-md-3 col-md-6"> <div class="offset-sm-2 col-sm-8 offset-md-3 col-md-6">
<fieldset class="form__fieldset form__fieldset_address"> <fieldset class="form__fieldset form__fieldset_address">
<legend class="form__legend">Характеристики</legend> <legend class="form__legend">Характеристики</legend>
......
...@@ -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: FileList type: Array
} }
}, },
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,8 @@ Vue.component('app-waste-utilisation-order-form', { ...@@ -135,7 +135,8 @@ Vue.component('app-waste-utilisation-order-form', {
}, },
wAmount: '', wAmount: '',
wUnit: {}, wUnit: {},
wDocs: {}, wDocs: [],
wDocsNames: [],
wAddress: { wAddress: {
region: { region: {
id: null, id: null,
...@@ -188,16 +189,14 @@ Vue.component('app-waste-utilisation-order-form', { ...@@ -188,16 +189,14 @@ Vue.component('app-waste-utilisation-order-form', {
// Открываем кнопку "сохранить" // Открываем кнопку "сохранить"
formFilledRight() { formFilledRight() {
//return true;
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 !== '');
*/
}, },
// следим на ссылкой на группы отходов // следим на ссылкой на группы отходов
...@@ -540,30 +539,34 @@ Vue.component('app-waste-utilisation-order-form', { ...@@ -540,30 +539,34 @@ Vue.component('app-waste-utilisation-order-form', {
this.$emit('clickOnDeleteFormBtn') this.$emit('clickOnDeleteFormBtn')
}, },
// При изменении списка файлов updateDocs(files){
updateDocs(e) { this.localRecord.wDocs = files;
var formData = new FormData();
/* let counter = 0;
var files = e.target.files || e.dataTransfer.files; this.localRecord.wDocsNames = [];
if (!files.length) { files.forEach(element => {
alert("err!"); if (element.name) {
return false; this.localRecord.wDocsNames.push(element.name);
} formData.append("userfile[" + counter +"]", element);
counter++;
}
console.log(files); });
alert(1); $.ajax({
url: 'files.php',
//this.localRecord.wDocs = this.$children["4"].localFiles; contentType: false, // важно - убираем форматирование данных по умолчанию
processData: false, // важно - убираем преобразование строк по умолчанию
*/ data: formData,
}, type: 'POST',
success: function (json) {
filesSetChanges() { if (json) {
alert(1); // тут что-то делаем с полученным результатом
}, }
}
});
}
}, },
template: ` template: `
...@@ -578,14 +581,14 @@ Vue.component('app-waste-utilisation-order-form', { ...@@ -578,14 +581,14 @@ Vue.component('app-waste-utilisation-order-form', {
</div> </div>
<!-- Debug ---> <!-- Debug --->
<!--
<div class="debug" <div class="debug"
style="position: absolute; right: -270px;top: 20px; background-color:#fff; z-index:10000; 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>
</div> </div>
-->
<!-- end Debug --> <!-- end Debug -->
<!-- Form --> <!-- Form -->
...@@ -692,7 +695,6 @@ Vue.component('app-waste-utilisation-order-form', { ...@@ -692,7 +695,6 @@ 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,21 +32,19 @@ Vue.component('field-file',{ ...@@ -32,21 +32,19 @@ Vue.component('field-file',{
type: Object type: Object
}, },
files: { files: {
type: FileList type: Array
},
value: {
type: String
} }
}, },
data: function () { data: function () {
return { return {
localFiles: this.files.slice(), localFiles: this.files.slice()
} }
}, },
methods: { methods: {
onInputFileChange(e) { onInputFileChange(e) {
this.localFiles = [];
// если не выбрали файл и нажали отмену, то ничего не делать // если не выбрали файл и нажали отмену, то ничего не делать
if (!e.target.files.length) { if (!e.target.files.length) {
return; return;
...@@ -57,24 +55,19 @@ Vue.component('field-file',{ ...@@ -57,24 +55,19 @@ Vue.component('field-file',{
e.target.value = ''; e.target.value = '';
this.files = this.localFiles; 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.files = this.localFiles; this.files = this.localFiles;
this.$emit('filesSetChanges',files);
}, },
removeFile(index) { removeFile(index) {
this.localFiles.splice(index, 1); this.localFiles.splice(index, 1);
this.$emit('filesSetChanges',this.localFiles)
this.files = this.localFiles; this.files = this.localFiles;
this.$emit('filesSetChanges',this.localFiles);
} }
}, },
// watch: { // watch: {
...@@ -86,9 +79,6 @@ Vue.component('field-file',{ ...@@ -86,9 +79,6 @@ 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"
...@@ -113,4 +103,4 @@ Vue.component('field-file',{ ...@@ -113,4 +103,4 @@ Vue.component('field-file',{
</div> </div>
` `
}) })
\ No newline at end of file
...@@ -196,12 +196,14 @@ block page ...@@ -196,12 +196,14 @@ block page
'', '',
'sm' 'sm'
) )
td td
+field-text({ +field-text({
title: '', title: '',
mods: 'sm', mods: 'sm',
attrs: { attrs: {
placeholder: 'Дата' type: 'date',
placeholder: 'Дата',
class: 'some-input'
} }
}) })
......
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