Commit ac82aa11 authored by Babin Egor's avatar Babin Egor

update forms

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