Vue.config.devtools = true; var complexform = new Vue({ el: '#complex_form', components: { vuejsDatepicker: window.vuejsDatepicker }, data() { return { ru: vdp_translation_ru.js, is_show: false, is_show_result: false, errorMes: false, errorText: '', id: 0, errors: { 'name': false, 'addres': false }, OpenIndicator: { render: createElement => createElement('span', { class: { 'vueToggleSpan': true } }), }, types_complex: [{ 'code': 0, 'name': '' }], number: null, regions: [{ 'code': 0, 'name': '' }], region_id: 0, region_id_user: 0, regions_list: [], country: [], country_list: [], house_types: [], house_material: [], kladr_ids: null, region_kladr: null, region_label: null, complex: { id: 0, type: 'complex', name: '', address: [], address_line: '', rf_region_id: '', country_id: 171, rf_region_rayon: '', rayon_id: '', city: '', street: '', korpus: '', dom: '', litera: '', kladr_id: '', region_kladr_id: '', latitude: '', longitude: '', lines: [], deadline: [], builder_id: null, images: [], payment_types: [], contract_type: '', housing_class_id: null, first_floor: '', last_floor: '', number_apartments: '', ceiling_height: '', decoration_id: null, parking: 0, closed_area: 0, protected_area: 0, concierge: 0, house_type: null, house_material: null, infrastructure: { 'school': 0, 'kindergarten': 0, 'playgrounds': 0, 'sportsgrounds': 0, 'cafes': 0, 'shops': 0, 'beautysalons': 0, 'fitnessclub': 0, 'park': 0, 'trc': 0, 'commercialobjects': 0, }, metros: [{ 'id': null, 'subway_time': '', 'subway_type': null, 'metro_id' : '' }], dop: { domclick_id: null, title_desc: '', text_desc: '', title_desc_dop: '', text_desc_dop: '', url_video: '', type_video: null, UTP: [], UTP2: [], phone_op: '', phone_mobil_op: '', address_op: '', latitude_op: '', longitude_op: '', timezone_op: '', workdays_op: null, opentime_op: '', closetime_op: '' }, actions: [], }, metro_list: [], block_list: [], time_to_subway: [{ 'code': 1, 'name': 'пешком' }, { 'code': 2, 'name': 'на транспорте' }], check_blocks: false, block_id: 0, isInput: false, date_deadline: new Date(), format: "dd.MM.yyyy", mondayfirst: true, defaultDate: new Date(), mes_error_corpus: false, newCorpusName: '', newLineName: '', builders: [], builder_list: [], isInputBuilder: false, newBuilderName: '', newBuilderPhone: '', newBuilderLink: '', mes_error_builder: false, is_show_foto: false, images: [], swiper: null, swiper2: null, selectedFiles: [], progressUoload: [], classTypesFile: { 'img': 'far fa-file-image', 'png': 'far fa-file-image' }, isSelect: 0, paymentTypes: [], housingClass: [], decorations: [], types_video: [{ 'code': 'youtube', 'name': 'Youtube' }, { 'code': 'realtime', 'name': 'Realtime' }], isInputUTP: false, titleUTP: '', descUTP: '', imagesUTP: [], isInputUTP2: false, titleUTP2: '', descUTP2: '', imagesUTP2: [], status_corpus: [ { 'code': 1, 'name': 'Построен, но не сдан' }, { 'code': 2, 'name': 'Cдан в эксплуатацию' }, { 'code': 3, 'name': 'Cтроится' }, { 'code': 4, 'name': 'Построен и сдан' }, ], corpus_id: null, corpus_floors: null, corpus_floors_ready: null, corpus_fz_214: 0, corpus_status: null, workdays: ['Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота', 'Воскресенье'], } }, methods: { //Открытие open() { this.getBlocks(); this.get_builders(); this.getRegions(); this.getCountry(); this.getHouseTypes(); this.getHouseMaterial(); this.is_show = true; $('#complex_form .main-photo .photos').html(''); fileUploaderSettingsComplex(); $("body").addClass("lock"); $('.jw__add-popup').removeClass('is__show'); //this.get_photos_actions(); }, //Список типов комплекосов getTypesComplex() { axios.post('/ajax/vue_ajax/complex_axios.php', { request: 'get_types_complex', }, ) .then((response) => { var res = response.data; this.types_complex = res; }) .catch(function(error) { console.log(error); }); }, //Типы оплат getPaymentTypes() { axios.post('/ajax/vue_ajax/complex_axios.php', { request: 'get_payment_types', }, ) .then((response) => { var res = response.data; this.paymentTypes = res; }) .catch(function(error) { console.log(error); }); }, //Класс жилья getHousingClass() { axios.post('/ajax/vue_ajax/complex_axios.php', { request: 'get_housing_class', }, ) .then((response) => { var res = response.data; this.housingClass = res; }) .catch(function(error) { console.log(error); }); }, //Тип дома getHouseTypes() { axios.post('/ajax/vue_ajax/complex_axios.php', { request: 'get_house_types', }, ) .then((response) => { var res = response.data; this.house_types = res; }) .catch(function(error) { console.log(error); }); }, //Материал дома getHouseMaterial() { axios.post('/ajax/vue_ajax/complex_axios.php', { request: 'get_house_material', }, ) .then((response) => { var res = response.data; this.house_material = res; }) .catch(function(error) { console.log(error); }); }, //Отделка getDecorations() { axios.post('/ajax/vue_ajax/complex_axios.php', { request: 'get_decorations', }, ) .then((response) => { var res = response.data; this.decorations = res; }) .catch(function(error) { console.log(error); }); }, //Список регионов getRegions() { axios.post('/ajax/vue_ajax/complex_axios.php', { request: 'get_rf_regions', }, ) .then((response) => { console.log(response.data); var res = response.data; this.region_id = parseInt(res.region_id_user); this.region_id_user = parseInt(res.region_id_user); this.regions = res.regions; this.regions_list = res.regions_list; this.changeRegion(); }) .catch(function(error) { console.log(error); }); }, //Список стран getCountry() { axios.post('/ajax/vue_ajax/complex_axios.php', { request: 'get_country', }, ) .then((response) => { // console.log(response.data); var res = response.data; this.country = res.country; this.country_list = res.country_list; }) .catch(function(error) { console.log(error); }); }, //Выбор региона changeRegion() { this.complex.rf_region_id = this.region_id; this.region_kladr = this.regions_list[this.region_id].kladr; this.region_label = this.regions_list[this.region_id].label; this.kladr_ids = this.getConstraints(); this.getMetro(); daDataInitComplex(this.kladr_ids); if (typeof setCenterComplex == 'function') { setCenterComplex(); } }, //Выбор страны changeCountry() { if (this.complex.country_id != 171) { this.region_id = 0; daDataInitComplex([], this.country_list[this.complex.country_id].alpha2); setCenterComplex(); } else { this.region_id = this.region_id_user; this.changeRegion(); } }, join(arr /*, separator */ ) { var separator = arguments.length > 1 ? arguments[1] : ", "; return arr.filter(function(n) { return n }).join(separator); }, processAddress(address) { console.log(address); //let form = $('.adres2 .more-block'); if (address.area_type_full == "район") this.complex.rf_region_rayon = this.join([address.area, address.area_type], " ") else this.complex.rf_region_rayon = address.area; if (address.city_district) this.complex.rayon_id = address.city_district; else if (address.settlement && (!address.area && address.city)) this.complex.rayon_id = this.join([address.settlement_type, address.settlement], " "); if (address.settlement_type_full == "микрорайон") this.complex.rayon_id = this.join([address.settlement_type, address.settlement], " "); if (address.city === address.region && address.settlement) { this.complex.rayon_id = this.join([address.settlement_type, address.settlement], " "); } else { if (address.city) this.complex.city = address.city else this.complex.city = this.join([address.settlement_type, address.settlement], " "); } if (address.street_type_full == "шоссе" || address.street_type_full == "проезд" || address.street_type_full == "переулок") this.complex.street = this.join([address.street, address.street_type], " ") else this.complex.street = this.join([address.street_type, address.street], " ") if (address.house) this.complex.dom = address.house; else this.complex.dom = ''; if (address.block_type_full == "корпус") this.complex.korpus = address.block; else this.complex.korpus = ''; if (address.block_type_full == "литер" || address.block_type_full == "литера") this.complex.litera = address.block; else { this.complex.litera = ''; if (address.block_type_full == "строение") this.complex.litera = address.block; else this.complex.litera = ''; } /*let region; if (address.region) region = address.region; else if (address.city) region = address.city; if (region) { if (region === 'Омская') { $('select[name="id_rf_region"] option[data-label="омская область"]').prop('selected', true); } else { $('select[name="id_rf_region"] option[data-label*="' + region.toLowerCase() + '"]').prop('selected', true); } } else { $('select[name="id_rf_region"]').prop('selectedIndex', 0); }*/ this.complex.kladr_id = address.city_kladr_id; this.complex.region_kladr_id = address.region_kladr_id; let geo_lat = address.geo_lat; if (typeof geo_lat !== "undefined" && geo_lat) { this.complex.latitude = geo_lat.replace(/[^\.\d]/g, ''); } let geo_lon = address.geo_lon; if (typeof geo_lon !== "undefined" && geo_lon) { this.complex.longitude = geo_lon.replace(/[^\.\d]/g, ''); } this.complex.address_line = $('#address_complex').val(); }, // возвращает ограничение по КЛАДР региона для DaData getConstraints() { let ids = new Array(); if (this.region_kladr == 0 && this.region_label == 'москва и московская область') { ids.push({ locations: { kladr_id: "7700000000000" }, }); ids.push({ locations: { kladr_id: "5000000000000" }, }); } else if (this.region_kladr == 0 && this.region_label == 'санкт-петербург и ленинградская обл') { ids.push({ locations: { kladr_id: "7800000000000" }, }); ids.push({ locations: { kladr_id: "4700000000000" }, }); } else if (this.region_kladr == 0 && this.region_label == 'крым и севастополь') { ids.push({ locations: { kladr_id: "9100000000000" }, }); ids.push({ locations: { kladr_id: "9200000000000" }, }); } else { ids.push({ locations: { kladr_id: this.region_kladr.toString() }, }); } return ids; }, //Метро changeMetro() { }, getMetro() { return axios.post('/ajax/vue_ajax/complex_axios.php', { request: 'get_metro', region_id: this.region_id, }, ) .then((response) => { this.metro_list = response.data; }) .catch(function(error) { console.log(error); }); }, //ЖК Новостройки getBlocks() { if (this.isEmpty(this.block_list) || this.isEmpty(this.blocks)) { axios.post('/ajax/vue_ajax/complex_axios.php', { request: 'get_blocks', }, ) .then((response) => { var res = response.data; console.log(res); this.block_list = res.block_list; this.blocks = res.blocks; }) .catch(function(error) { console.log(error); }); } }, checkBlocks() { this.errors.name = false; if (this.block_id > 0) { this.complex.lines = this.blocks[this.block_id].lines; this.complex.lines = this.blocks[this.block_id].lines; this.complex.builder_id = this.blocks[this.block_id].builder_id; this.complex.name = this.blocks[this.block_id].name; } else { this.complex.lines = []; this.complex.builder_id = null; this.complex.name = ''; } this.getPhoto(); }, changeBlock() { this.complex.lines = []; this.complex.name = ''; this.block_id = 0; this.complex.images = []; }, //Список фото getPhoto() { if (this.block_id > 0) { axios.post('/ajax/vue_ajax/complex_axios.php', { request: 'get_photos', block_id: this.block_id, }, ) .then((response) => { var res = response.data; //console.log(res); $('#complex_form .main-photo .photos').html(''); if (!this.isEmpty(res)) { $('input[name="photoComplex"]').attr("data-fileuploader-files", JSON.stringify(res)); } fileUploaderSettingsComplex(); }) .catch(function(error) { console.log(error); }); } else { //this.complex.images = []; $('#complex_form .main-photo .photos').html(''); fileUploaderSettingsComplex(); } }, //Редактирование очереди editLineSave(idLine) { this.lineClose(idLine); }, lineClose(idLine) { $('.ui-tooltip').remove(); this.complex.lines[idLine].isEdit = false; this.complex.lines[idLine].isDiv = true; }, editLine(idLine) { $('.ui-tooltip').remove(); this.complex.lines[idLine].isEdit = true; this.complex.lines[idLine].isDiv = false; }, //Редактирование корпуса editCorpus(idLine, idCorpus) { $('.ui-tooltip').remove(); //console.log(this.complex.lines[idLine].corpuses[idCorpus]); this.complex.lines[idLine].corpuses[idCorpus].isEdit = true; this.complex.lines[idLine].corpuses[idCorpus].isDiv = false; this.complex.lines[idLine].corpuses[idCorpus].date = this.get_date(this.complex.lines[idLine].corpuses[idCorpus].deadline); }, corpusClose(idLine, idCorpus) { this.complex.lines[idLine].corpuses[idCorpus].isEdit = false; this.complex.lines[idLine].corpuses[idCorpus].isDiv = true; $('.ui-tooltip').remove(); }, inputClose(idLine) { this.complex.lines[idLine].isInput = false; this.defaultDate = new Date(); this.newCorpusName = ''; $('.ui-tooltip').remove(); }, inputLineClose() { this.isInput = false; this.newLineName = ''; $('.ui-tooltip').remove(); }, //Добавить очередь addLine() { if (this.isEmpty(this.newLineName)) { this.mes_error_corpus = true; } else { var res = { name: this.newLineName, isDiv: true, isEdit: false, corpuses: [], isInput: false, del: 0 } if (this.isEmpty(this.complex.lines)) { this.complex.lines = {}; } complexform.$set(complexform.complex.lines, parseInt(this.newLineName), res); this.inputLineClose(); } }, //Открыть добавление корпуса openCorpusIsInput(idLine) { this.defaultDate = new Date(); this.newCorpusName = ''; this.corpus_id = null; this.corpus_floors = null; this.corpus_floors_ready = null; this.corpus_fz_214 = 0; this.corpus_status = null; for (var idL in this.complex.lines) { this.complex.lines[idL].isInput = false; } this.complex.lines[idLine].isInput = true; $('.ui-tooltip').remove(); }, //Добавить корпус addCorpus(idLine) { if (this.isEmpty(this.newCorpusName)) { this.mes_error_corpus = true; } else { axios.post('/ajax/vue_ajax/complex_axios.php', { request: 'convert_corpus', deadline: this.defaultDate, corpus: this.newCorpusName, corpus_id: this.corpus_id, corpus_floors: this.corpus_floors, corpus_floors_ready: this.corpus_floors_ready, corpus_fz_214: this.corpus_fz_214, corpus_status: this.corpus_status, }, ) .then((response) => { var res = response.data; // complexform.$set(complexform.complex.lines, parseInt(this.newLineName), res); res['del'] = 0; res['id'] = 0; this.complex.lines[idLine].corpuses.push(res); this.inputClose(idLine); $('.ui-tooltip').remove(); }) .catch(function(error) { console.log(error); }); } }, //Редактировать корпус editCorpusSave(idLine, idCorpus) { var deadline = this.complex.lines[idLine].corpuses[idCorpus].date; var corpus = this.complex.lines[idLine].corpuses[idCorpus].corpus; var corpus_id = this.complex.lines[idLine].corpuses[idCorpus].corpus_id; var corpus_floors = this.complex.lines[idLine].corpuses[idCorpus].corpus_floors; var corpus_floors_ready = this.complex.lines[idLine].corpuses[idCorpus].corpus_floors_ready; var corpus_fz_214 = this.complex.lines[idLine].corpuses[idCorpus].corpus_fz_214; var corpus_status = this.complex.lines[idLine].corpuses[idCorpus].corpus_status; axios.post('/ajax/vue_ajax/complex_axios.php', { request: 'convert_corpus', deadline: deadline, corpus: corpus, corpus_id: corpus_id, corpus_floors: corpus_floors, corpus_floors_ready: corpus_floors_ready, corpus_fz_214: corpus_fz_214, corpus_status: corpus_status }, ) .then((response) => { var res = response.data; //this.complex.lines[idLine].corpuses[idCorpus].id = res.id; this.complex.lines[idLine].corpuses[idCorpus].date = ''; this.complex.lines[idLine].corpuses[idCorpus].corpus = res.corpus; this.complex.lines[idLine].corpuses[idCorpus].period = res.period; this.complex.lines[idLine].corpuses[idCorpus].deadline = res.deadline; this.complex.lines[idLine].corpuses[idCorpus].corpus_id = res.corpus_id; this.complex.lines[idLine].corpuses[idCorpus].corpus_floors = res.corpus_floors; this.complex.lines[idLine].corpuses[idCorpus].corpus_floors_ready = res.corpus_floors_ready; this.complex.lines[idLine].corpuses[idCorpus].corpus_fz_214 = res.corpus_fz_214; this.complex.lines[idLine].corpuses[idCorpus].corpus_status = res.corpus_status; this.complex.lines[idLine].corpuses[idCorpus].del = 0; this.corpusClose(idLine, idCorpus); }) .catch(function(error) { console.log(error); }); }, //Удалить корпус deleteCorpus(idLine, idCorpus) { $('.ui-tooltip').remove(); this.complex.lines[idLine].corpuses[idCorpus].del = 1; }, //Удалить очередь deleteLine(idLine) { $('.ui-tooltip').remove(); console.log(this.complex.lines[idLine].corpuses); for (let i in this.complex.lines[idLine].corpuses) { this.complex.lines[idLine].corpuses[i].del = 1; } this.complex.lines[idLine].del = 1; console.log(this.complex.lines); //this.complex.lines.splice(idLine, 1); }, //УТП openUTP() { this.isInputUTP = true; $('#complex_form .small-photo .photoUTP').html(''); setTimeout(function() { fileUploaderSettingsComplex('UTP'); }, 200); //photoUTP }, openUTP2() { this.isInputUTP2 = true; $('#complex_form .small-photo .photoUTP2').html(''); setTimeout(function() { fileUploaderSettingsComplex('UTP2'); }, 200); //photoUTP*/ }, inputUTPClose() { $('.ui-tooltip').remove(); this.isInputUTP = false; this.titleUTP = ''; this.descUTP = ''; this.imagesUTP = []; }, inputUTPClose2() { $('.ui-tooltip').remove(); this.isInputUTP2 = false; this.titleUTP2 = ''; this.descUTP2 = ''; this.imagesUTP2 = []; }, addUTP() { if (!this.isEmpty(this.titleUTP)) { $('.ui-tooltip').remove(); var res = { title: this.titleUTP, desc: this.descUTP, isDiv: true, isEdit: false, images: [], imagesUTP: [], isInput: false } if (this.isEmpty(this.complex.dop.UTP)) { this.complex.dop.UTP = []; } var photos = $("[name=fileuploader-list-photoComplexUTP]").val(); if (!this.isEmpty(photos)) { res.images = JSON.parse(photos); } if (!this.isEmpty(this.imagesUTP)) { res.imagesUTP = this.imagesUTP; } let index = this.complex.dop.UTP.length; this.$set(this.complex.dop.UTP, index, res); //complexform.complex.dop.UTP.push(res); } this.inputUTPClose(); }, addUTP2() { if (!this.isEmpty(this.titleUTP2)) { $('.ui-tooltip').remove(); var res = { title: this.titleUTP2, desc: this.descUTP2, isDiv: true, isEdit: false, images: [], imagesUTP: [], isInput: false } if (this.isEmpty(this.complex.dop.UTP2)) { this.complex.dop.UTP2 = []; } var photos = $("[name=fileuploader-list-photoComplexUTP2]").val(); if (!this.isEmpty(photos)) { res.images = JSON.parse(photos); } if (!this.isEmpty(this.imagesUTP2)) { res.imagesUTP = this.imagesUTP2; } let index = this.complex.dop.UTP2.length; this.$set(this.complex.dop.UTP2, index, res); //complexform.complex.dop.UTP.push(res); } this.inputUTPClose2(); }, deleteUTP(idUtp) { $('.ui-tooltip').remove(); this.complex.dop.UTP.splice(idUtp, 1); }, deleteUTP2(idUtp) { $('.ui-tooltip').remove(); this.complex.dop.UTP2.splice(idUtp, 1); }, editUTP(idUtp) { $('.ui-tooltip').remove(); this.complex.dop.UTP[idUtp].isEdit = true; this.complex.dop.UTP[idUtp].isDiv = false; }, editUTP(idUtp) { $('.ui-tooltip').remove(); this.complex.dop.UTP2[idUtp].isEdit = true; this.complex.dop.UTP2[idUtp].isDiv = false; }, //Акции add_action() { $('.ui-tooltip').remove(); let index = this.complex.actions.length let res = { name: '', desc: '', link: '', images: [] }; this.complex.actions.push(res); // $('#photoAction' + index).html(''); setTimeout(function() { $('#photoAction' + index).html(''); fileUploaderSettingsComplex('Action'); }, 200); }, del_action(actionId) { $('.ui-tooltip').remove(); this.complex.actions.splice(actionId, 1); }, get_photos_actions() { //setTimeout(function() { console.log(complexform.complex.actions); }, 2000); //console.log(this.complex); if (!this.isEmpty(this.complex.actions)) { //console.log(i); for (let i = 0; i < this.complex.actions.length; i++) { setTimeout(function() { //console.log(complexform.complex.actions[i].images); $('#photoAction' + i).html(''); if (!this.isEmpty(complexform.complex.actions[i].images)) { $('#photoAction' + i + ' input[name="photoComplexAction"]').attr("data-fileuploader-files", JSON.stringify(complexform.complex.actions[i].images)); } fileUploaderSettingsComplex('Action'); }, 500); } } }, //Установка даты get_date(date) { var arrDate = date.split('.'); var year = parseInt(arrDate[2]); var mes = parseInt(arrDate[1]) - 1; var day = parseInt(arrDate[0]); return new Date(year, mes, day); }, //Список застройщиков get_builders() { if (this.isEmpty(this.builder_list)) { axios.post('/ajax/vue_ajax/complex_axios.php', { request: 'get_builders', }, ) .then((response) => { var res = response.data; this.builders = res.list; this.builder_list = res.options; }) .catch(function(error) { console.log(error); }); } }, //Доп инфа для застройщика getInfoBuilder() { this.newBuilderPhone = ''; this.newBuilderLink = ''; if (this.complex.builder_id > 0) { if (this.builders[this.complex.builder_id]) { this.newBuilderPhone = this.builders[this.complex.builder_id].phone; this.newBuilderLink = this.builders[this.complex.builder_id].link; } } }, inputBuilderClose() { this.isInputBuilder = false; this.newBuilderName = ''; $('.ui-tooltip').remove(); }, addBuilder() { if (this.isEmpty(this.newBuilderName)) { this.mes_error_builder = true; } else { axios.post('/ajax/vue_ajax/complex_axios.php', { request: 'add_builder', name: this.newBuilderName, phone: this.newBuilderPhone, link: this.newBuilderLink, }, ) .then((response) => { var res = response.data; //console.log(res); if (res.result == 'old') { this.complex.builder_id = res.builder_id; } else if (res.result == 'new') { this.builders = []; this.builder_list = []; this.get_builders(); this.complex.builder_id = res.builder_id; } this.inputBuilderClose(); }) .catch(function(error) { console.log(error); }); } }, //Закрытие closes() { this.is_show = false; this.clear(); $("body").removeClass("lock"); $('.jw__add-popup').removeClass('is__show'); }, closes_foto() { this.is_show_foto = false; setTimeout(function() { $("body").addClass("lock"); }, 300); $('.jw__add-popup').removeClass('is__show'); }, clearFiles() { this.selectedFiles = []; this.progressUoload = []; this.isSelect = 0; }, onFileSelected(event) { //console.log(event); var files = Array.from(event.target.files); var j = complexform.selectedFiles.length; this.isSelect = event.target.files.length; for (var i = 0; i < files.length; i++) { files[i].typeFile = complexform.typeFile(files[i].name); files[i].classFile = complexform.classTypesFile.undefined; files[i].guid = ''; if (complexform.classTypesFile[files[i].typeFile]) { files[i].classFile = complexform.classTypesFile[files[i].typeFile]; } var proc = { 'progress': 0, 'isUpload': false, 'uploads': false, 'isEdit': false, 'edit_name': '', 'real_name': files[i].name } complexform.$set(complexform.progressUoload, j, proc); complexform.$set(complexform.selectedFiles, j, files[i]); complexform.onUpload(j, files[i]); j++; } }, onUpload: function(index, file) { complexform.$set(complexform.progressUoload[index], 'uploads', true); let fd = new FormData(); fd.append('type_file', file.typeFile); fd.append('upload_complex', 1); fd.append('file', complexform.selectedFiles[index]); axios.post('/ajax/vue_ajax/complex_upload_axios.php', fd, { onUploadProgress: progressEvent => { var pr = Math.ceil(progressEvent.loaded / progressEvent.total * 100); complexform.$set(complexform.progressUoload[index], 'progress', pr); } }) .then((response) => { var res = response.data; if (res.filed) { } else { complexform.$set(complexform.selectedFiles[index], 'guid', res.guid); complexform.$set(complexform.progressUoload[index], 'isUpload', true); complexform.$set(complexform.progressUoload[index], 'uploads', false); this.complex.images.push(res.guid); if (this.swiper != null) { this.swiper.destroy(); this.swiper2.destroy(); } setTimeout(function() { complexform.init_swiper(true); complexform.onDeleteFile(index); }, 500) } }) .catch(function(error) { console.log(error); }); }, onDeleteFile: function(index) { complexform.selectedFiles.splice(index, 1); $('.ui-tooltip').remove(); complexform.progressUoload.splice(index, 1); /*if (file.guid != '') { axios.post('/ajax/vue_ajax/complex_axios.php', { request: 'deleteFile', funnelId: complexform.funnelId, guid: file.guid, type_file: file.typeFile }) }*/ }, typeFile: function(nameFile) { var tchk = nameFile.lastIndexOf("."); if (tchk != -1) { return nameFile.slice(tchk + 1); } return 'undefined'; }, clear() { this.errorMes = false; this.errorText = ''; this.errors = []; this.type_complex = 'complex'; this.errorMes = false; this.errorText = ''; this.errors = { 'name': false, 'addres': false }; this.block_id = 0; this.check_blocks = false; this.complex = { id: 0, name: '', address_line: '', address: [], rf_region_id: '', country_id: 171, rf_region_rayon: '', rayon_id: '', city: '', street: '', korpus: '', dom: '', litera: '', kladr_id: '', region_kladr_id: '', latitude: '', longitude: '', deadline: [], builder_id: null, images: [], payment_types: [], contract_type: '', housing_class_id: null, first_floor: '', last_floor: '', number_apartments: '', ceiling_height: '', decoration_id: null, house_type: null, house_material: null, parking: 0, closed_area: 0, protected_area: 0, concierge: 0, infrastructure: { 'school': 0, 'kindergarten': 0, 'playgrounds': 0, 'sportsgrounds': 0, 'cafes': 0, 'shops': 0, 'beautysalons': 0, 'fitnessclub': 0, 'park': 0, 'trc': 0, 'commercialobjects': 0, }, metros: [{ 'id': null, 'subway_time': '', 'subway_type': null, 'metro_id' : '' }], dop: { domclick_id: null, title_desc: '', text_desc: '', title_desc_dop: '', text_desc_dop: '', url_video: '', type_video: null, UTP: [], UTP2: [], phone_op: '', phone_mobil_op: '', address_op: '', latitude_op: '', longitude_op: '', timezone_op: '', workdays_op: null, opentime_op: '', closetime_op: '' }, actions: [], }; }, save() { this.errorMes = false; this.errorText = ''; if (this.isEmpty(this.complex.name)) { this.errorMes = true; this.errorText += '

Введите название ЖК

'; this.errors.name = true; } if (this.isEmpty(this.complex.address_line)) { this.errorMes = true; this.errorText += '

Введите адрес

'; this.errors.addres = true; } var photo = $("[name=fileuploader-list-photoComplex]").val(); //console.log(photo); //console.log(this.complex); if (!this.isEmpty(this.complex.actions)) { //Sthis.errorMes = true; for (let i = 0; i < this.complex.actions.length; i++) { //console.log($('#photoAction' + i + ' [name=fileuploader-list-photoComplexAction]').val()) if (!this.isEmpty($('#photoAction' + i + ' [name=fileuploader-list-photoComplexAction]').val())) { this.complex.actions[i].images = JSON.parse($('#photoAction' + i + ' [name=fileuploader-list-photoComplexAction]').val()); } } } console.log(this.complex); if (!this.errorMes) { this.complex.address.address = this.complex.address_line; axios.post('/ajax/vue_ajax/complex_axios.php', { request: 'save_complex', complex: this.complex, photo: photo, newBuilderPhone: this.newBuilderPhone, newBuilderLink: this.newBuilderLink, }, ) .then((response) => { console.log(response.data); var res = response.data; this.closes(); this.is_show_result = true; if (document.location.pathname == '/complex_list.php') { complexsearchform.search_global(); } }) .catch(function(error) { console.log(error); }); } else { $('.full_modal-bg').stop().animate({ scrollTop: 0 }, '500'); } }, openComplexList() { if (document.location.pathname == '/complex_list.php') { //complexsearchform.search_global(); } else { window.location = '/complex_list.php'; } this.is_show_result = false; }, //Проверка на пустоту isEmpty(data) { if (typeof(data) === 'object') { if (JSON.stringify(data) === '{}' || JSON.stringify(data) === '[]') { return true; } else if (!data) { return true; } return false; } else if (typeof(data) === 'string') { if (!data.trim()) { return true; } return false; } else if (typeof(data) === 'undefined') { return true; } else { return false; } }, }, mounted() { }, created: function() { $("#complex_form").removeClass("hidden"); this.getTypesComplex(); this.getPaymentTypes(); this.getHousingClass(); this.getDecorations(); } })