Joywork/js/autosearch_vue.js

4190 lines
196 KiB
JavaScript
Raw Normal View History

2026-05-22 20:21:54 +02:00
Vue.config.devtools = true;
//Параметры автопоиска
if ($('#modalAutoSearchFiltr').length > 0) {
var autosearch_filtr = new Vue({
name: 'AutoSearchFilter',
el: '#modalAutoSearchFiltr',
components: {
},
data() {
return {
id: null, // ИД фильтра
req_id: null, // ИД заявки
req_type: 1, // тип заявки
deal_type: 2, // тип сделки/операции
object_type: 0, // тип объекта
object_source: 0, // источник добавления объекта
category_type: 0, // тип категории
stoim_ot: null, // цена, от
stoim_do: null, // цена, до
komn_ot: null, // комнат, от
komn_do: null, // комнат, до
sq_all_ot: null, // общая площадь, от
sq_all_do: null, // общая площадь, до
ploshad_k_ot: null, // площадь кухни, от
ploshad_k_do: null, // площадь кухни, до
rent_srok: 0, // срок аренды объекта
rooms: [], // кол-во комнат
regions: [], // регион объекта
rayons: [], // район(ы) объекта
metro_stations: [], // ближ. станции метро
do_metro: 0, // время до метро
do_metro_type: null, // до метро пешком/на траспорте
etazhnost_ot: null, // этажность дома квартиры, от
etazhnost_do: null, // этажность дома квартиры, до
etazhnost: 0, // Не первый и не последний этаж
//order_type: 0, // тип оформления сделки
newbilding_date: null, // срок сдачи
ipoteka: 0, // ипотека
use_area_price: 0,
voen_ipoteka: 0, // воен. ипотека
subsidya: 0, // субсидия
mather_kapital: 0, // материнский капитал
house_type: 0, // тип дома
house_material: 0, // материал дома (тип стен)
build_year: null, // год постройки
tax_number: null, //
legal_address: 0, //
etazh_ot: null, //
etazh_do: null, //
is_occupied: 0, //
layout_id: 0, //
wet_spots: 0, //
el_power_ot: null, //
el_power_do: null, //
commer_condition: 0, //
is_furniture: 0, //
commer_access: 0, //
parking_types: [], //
parking_id: [], //
parking_price: null, //
parking_price_free: 0, //
ceiling_height_ot: null, //
ceiling_height_do: null, //
column_grid: null, //
vat_type_id: 0, //
commerc_site: null, //
commerc_owned1: 0, //
commerc_owned2: 0, //
floor_material_id: 0, //
commerc_portal_id: 0, //
commerc_purpose: [], //
commerc_land_category_id: [], //
commerc_permitted_use_id: [], //
commerc_electricity_id: 0, //
can_electricity: 0, //
commerc_gas_id: 0, //
can_gas: 0, //
commerc_water_id: 0, //
can_water: 0, //
commerc_sewage_id: 0, //
can_sewage: 0, //
commerc_driveways: 0, //
commerc_year_ot: null, //
commerc_year_do: null, //
commerc_building_type_id: [], //
commerc_building_class_id: [], //
building_area_ot: null, //
building_area_do: null, //
commerc_houseline_type_id: [], //
commerc_building_category_id: 0, //
commerc_opened_id: [], //
commerc_building_ventilation: 0, //
commerc_building_conditioning: 0, //
commerc_building_heating: 0, //
commerc_building_fire: 0, //
garage_type_id: 0, //
garage_vid_id: 0, //
boks_vid_id: 0, //
commerc_status_id: 0, //
commerc_specifications: [], //
commerc_infrastructure: [], //
commerc_infrastructure1: [], //
commerc_infrastructure2: [], //
commerc_lift1: null, //
lift1_carrying: null, //
commerc_lift2: null, //
lift2_carrying: null, //
commerc_lift3: null, //
lift3_carrying: null, //
commerc_crane1: null, //
crane1_carrying: null, //
commerc_crane2: null, //
crane2_carrying: null, //
commerc_crane3: null, //
crane3_carrying: null, //
commerc_crane4: null, //
crane4_carrying: null, //
geo: null, // гео-области поиска
opis: '', // описание
comment: '', // комментарий
is_active: 0, // флаг активности фильтра
telegram_notify: 0, // флаг уведомления в Телеграм
// ...
isError: false, // флаг об ошибке
errorText: '', // текст ошибки(ок)
// ...
objectTypes: [], // коллекция типов объектов
roomsCounts: [], // коллекция кол-ва комнат
objectSources: [], // коллекция источнико объектов
categoryTypes: {}, // коллекция типов помещений (коммерция)
objectRentSrok: [], // коллекция типов объектов
objectRegions: [], // коллекция регионов РФ
objectRayons: [], // коллекция районов РФ
objectCityRayons: [], // коллекция районов РФ
metroStations: [], // коллекция станций метро
houseTypes: [], // коллекция типов домов
houseMaterials: [], // коллекция материалов домов
buildYears: [], // коллекция годов постройки
legalAddress: [], // коллекция
isCccupied: [], // коллекция
layoutIds: [], // коллекция
wetSpots: [], // коллекция
commerCondition: [], // коллекция
isFurniture: [], // коллекция
commerAccess: [], // коллекция
parkingTypes: [], // коллекция
parkingIds: [], // коллекция
vatTypeIds: [], // коллекция
floorMaterials: [], // коллекция
commercPortalIds: [], // коллекция
commercPurpose: [], // коллекция
commercLandCategoryIds: [], // коллекция
commercPrmittedUseIds: [], // коллекция
commercElectricityId: [], // коллекция
commercGasIds: [], // коллекция
commercWaterIds: [], // коллекция
commercSewageIds: [], // коллекция
commercDriveways: [], // коллекция
commercBuildingTypeIds: [], //
commercBuildingClassIds: [], //
commercHouselineTypeIds: [], //
commercBuildingCategoryIds: [], //
commercOpenedIds: [], //
commercBuildingVentilation: [], //
commercBuildingConditioning: [], //
commercBuildingHeating: [], //
commercBuildingFire: [], //
garageTypeIds: [], //
garageVidIds: [], //
boksVidIds: [], //
commercStatusIds: [], //
commercSpecifications: [], //
commercInfrastructure: [], //
commercInfrastructure1: [], //
commercInfrastructure2: [], //
is_search: 1, //
is_reverse: 1, //
myMap: null,
objectManager: null,
mapGroup: null,
accessScroll: true,
styles: [],
polygons: [],
buttonClearMode: null,
buttonEditMode: null,
currentIndex: 0,
paintProcess: null,
mouseIsDraw: false,
isOpenFromReq: false,
}
},
methods: {
//
setData(filter_id, req_id, user_id) {
if (!this.isEmpty(user_id))
this.user_id = user_id;
else
this.user_id = $('#modalAutoSearchFiltr [name="user_id"]').val();
if (!this.isEmpty(req_id))
this.req_id = req_id;
else
this.req_id = $('#modalAutoSearchFiltr [name="req_id"]').val();
if (!this.isEmpty(filter_id))
this.id = filter_id;
else
this.id = $('#modalAutoSearchFiltr [name="filter_id"]').val();
console.info({filter_id: this.id, req_id: this.req_id, user_id: this.user_id});
if (
typeof this.user_id !== "undefined" &&
typeof this.req_id !== "undefined" &&
typeof this.id !== "undefined"
) {
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_filter',
user_id: this.user_id,
req_id: this.req_id,
filter_id: this.id
}).then((response) => {
if (!this.isEmpty(response.data.id)) {
let res = response.data;
console.info(res);
this.id = res.id;
if (this.isEmpty(res.req_type_id))
this.req_type = res.req_type_id;
this.deal_type = res.deal_type;
this.object_type = res.object_type;
this.object_source = res.object_source;
this.category_type = JSON.parse(res.category_type);
this.getCategoryTypes(this.category_type);
this.stoim_ot = res.stoim_ot;
this.stoim_do = res.stoim_do;
this.komn_ot = res.komn_ot;
this.komn_do = res.komn_do;
this.rooms = JSON.parse(res.rooms);
this.sq_all_ot = res.sq_all_ot;
this.sq_all_do = res.sq_all_do;
this.ploshad_k_ot = res.ploshad_k_ot;
this.ploshad_k_do = res.ploshad_k_do;
this.rent_srok = res.rent_srok;
this.getObjectRentSrok(this.rent_srok);
this.regions = res.regions;
this.getObjectRegions(this.regions);
this.rayons = res.rayons;
this.getObjectRayons(this.regions, this.rayons);
this.metro_stations = res.metro_stations;
this.getMetroStations(this.regions, this.metro_stations);
this.do_metro = res.do_metro;
this.do_metro_type = res.do_metro_type;
this.etazhnost_ot = res.etazhnost_ot;
this.etazhnost_do = res.etazhnost_do;
this.etazhnost = (res.etazhnost == 1) ? true : false;
//this.order_type = res.order_type;
//this.getOrderTypes(this.order_type);
this.newbilding_date = this.formatDate(res.newbilding_date);
this.ipoteka = (res.ipoteka == 1) ? true : false;
this.use_area_price = (res.use_area_price == 1) ? true : false;
this.voen_ipoteka = (res.voen_ipoteka == 1) ? true : false;
this.subsidya = (res.subsidya == 1) ? true : false;
this.mather_kapital = (res.mather_kapital == 1) ? true : false;
this.house_type = res.house_type;
this.getHouseTypes(this.house_type);
this.house_material = res.house_material;
this.getHouseMaterials(this.house_material);
this.build_year = res.build_year;
this.getBuildYears(this.build_year);
this.opis = res.opis;
this.comment = res.comment;
this.is_active = (res.is_active == 1) ? true : false;
this.telegram_notify = (res.telegram_notify == 1) ? true : false;
this.tax_number = res.tax_number;
this.legal_address = res.legal_address;
this.etazh_ot = res.etazh_ot;
this.etazh_do = res.etazh_do;
this.is_occupied = res.is_occupied;
this.layout_id = res.layout_id;
this.wet_spots = res.wet_spots;
this.el_power_ot = res.el_power_ot;
this.el_power_do = res.el_power_do;
this.commer_condition = res.commer_condition;
this.is_furniture = res.is_furniture;
this.commer_access = res.commer_access;
this.parking_types = res.parking_types;
this.parking_id = res.parking_id;
this.parking_price = res.parking_price;
this.parking_price_free = res.parking_price_free;
this.ceiling_height_ot = res.ceiling_height_ot;
this.ceiling_height_do = res.ceiling_height_do;
this.column_grid = res.column_grid;
this.vat_type_id = res.vat_type_id;
this.commerc_site = res.commerc_site;
this.commerc_owned1 = res.commerc_owned1;
this.commerc_owned2 = res.commerc_owned2;
this.floor_material_id = res.floor_material_id;
this.commerc_portal_id = res.commerc_portal_id;
this.commerc_purpose = res.commerc_purpose;
this.commerc_land_category_id = res.commerc_land_category_id;
this.commerc_permitted_use_id = res.commerc_permitted_use_id;
this.commerc_electricity_id = res.commerc_electricity_id;
this.can_electricity = (res.can_electricity == 1) ? true : false;
this.commerc_gas_id = res.commerc_gas_id;
this.can_gas = (res.can_gas == 1) ? true : false;
this.commerc_water_id = res.commerc_water_id;
this.can_water = (res.can_water == 1) ? true : false;
this.commerc_sewage_id = res.commerc_sewage_id;
this.can_sewage = (res.can_sewage == 1) ? true : false;
this.commerc_driveways = res.commerc_driveways;
this.commerc_year_ot = res.commerc_year_ot;
this.commerc_year_do = res.commerc_year_do;
this.commerc_building_type_id = res.commerc_building_type_id;
this.getCommercBuildingTypeId(this.commerc_building_type_id);
this.commerc_building_class_id = res.commerc_building_class_id;
this.getCommercBuildingClassId(this.commerc_building_class_id);
this.building_area_ot = res.building_area_ot;
this.building_area_do = res.building_area_do;
this.commerc_houseline_type_id = res.commerc_houseline_type_id;
this.getCommercHouselineTypeId(this.commerc_houseline_type_id);
this.commerc_building_category_id = res.commerc_building_category_id;
this.getCommercBuildingCategoryId(this.commerc_building_category_id);
this.commerc_opened_id = res.commerc_opened_id;
this.getCommercOpenedId(this.commerc_opened_id);
this.commerc_building_ventilation = res.commerc_building_ventilation;
this.getCommercBuildingVentilation(this.commerc_building_ventilation);
this.commerc_building_conditioning = res.commerc_building_conditioning;
this.getCommercBuildingConditioning(this.commerc_building_conditioning);
this.commerc_building_heating = res.commerc_building_heating;
this.getCommercBuildingHeating(this.commerc_building_heating);
this.commerc_building_fire = res.commerc_building_fire;
this.getCommercBuildingFire(this.commerc_building_fire);
this.garage_type_id = res.garage_type_id;
this.getGarageTypeId(this.garage_type_id);
this.garage_vid_id = res.garage_vid_id;
this.getGarageVidId(this.garage_vid_id);
this.boks_vid_id = res.boks_vid_id;
this.getBoksVidId(this.boks_vid_id);
this.commerc_status_id = res.commerc_status_id;
this.getCommercStatusId(this.commerc_status_id);
this.commerc_specifications = res.commerc_specifications;
this.getCommercSpecifications(this.commerc_specifications);
this.commerc_infrastructure = res.commerc_infrastructure;
this.getCommercSpecifications(this.commerc_infrastructure);
this.commerc_infrastructure1 = res.commerc_infrastructure1;
this.getCommercInfrastructure1(this.commerc_infrastructure1);
this.commerc_infrastructure2 = res.commerc_infrastructure2;
this.getCommercInfrastructure2(this.commerc_infrastructure2);
this.commerc_lift1 = res.commerc_lift1;
this.lift1_carrying = res.lift1_carrying;
this.commerc_lift2 = res.commerc_lift2;
this.lift2_carrying = res.lift2_carrying;
this.commerc_lift3 = res.commerc_lift3;
this.lift3_carrying = res.lift3_carrying;
this.commerc_crane1 = res.commerc_crane1;
this.crane1_carrying = res.crane1_carrying;
this.commerc_crane2 = res.commerc_crane2;
this.crane2_carrying = res.crane2_carrying;
this.commerc_crane3 = res.commerc_crane3;
this.crane3_carrying = res.crane3_carrying;
this.commerc_crane4 = res.commerc_crane4;
this.crane4_carrying = res.crane4_carrying;
this.commerceCategoryInit(this.object_type);
this.is_search = res.is_search;
this.is_reverse = res.is_reverse;
this.geo = null;
if (!this.isEmpty(res.geo)) {
let entries = Object.entries(JSON.parse(res.geo));
if (!this.isEmpty(entries)) {
this.geo = [];
entries.filter((poly) => {
return !this.isEmpty(poly[1])
}).forEach((poly) => {
//let index = poly[0];
this.geo.push(poly[1])
});
}
}
if (!this.isEmpty(this.geo)) {
$('#asfiltr-object-rayons').prop('disabled', true);
$('#asfiltr-metro-stations').prop('disabled', true);
$('#asfiltr-metro-minut').prop('disabled', true);
$('#asfiltr-metro-minut').closest('.inputs-group').find('select').prop('disabled', true);
} else {
$('#asfiltr-object-rayons').removeAttr('disabled');
$('#asfiltr-metro-stations').removeAttr('disabled');
$('#asfiltr-metro-minut').removeAttr('disabled');
$('#asfiltr-metro-minut').closest('.inputs-group').find('select').removeAttr('disabled');
}
} else {
this.clearFiltr();
this.rent_srok = null;
this.getObjectRentSrok(this.rent_srok);
this.regions = null;
this.getObjectRegions(this.regions);
this.rayons = null;
this.getObjectRayons(this.regions, this.rayons);
this.metro_stations = null;
this.getMetroStations(this.regions, this.metro_stations);
this.do_metro = null;
this.do_metro_type = 0;
this.geo = null;
}
console.info(this.req_type);
if (this.isEmpty(response.data.id)) {
if (!this.isEmpty(this.req_type)) {
if (this.req_type == 1) {
this.is_search = 1;
this.is_reverse = 1;
} else if (this.req_type == 4) {
this.is_search = 0;
this.is_reverse = 1;
}
}
}
}).catch(function(error) {
if (error)
console.debug(error);
});
}
},
// Переключение типа сделки
changeDealType(num) {
this.deal_type = num;
},
// Переключение типа объекта
changeObjectType(num, event) {
this.object_type = num;
// this.category_type = 0;
// $('#modalAutoSearchFiltr .form .button-row .selector-button.object_type').removeClass('selected');
// $(event.target).closest('.selector-button').addClass('selected');
this.commerceCategoryInit(this.object_type);
},
// Переключение источника добавления объекта
changeObjectSource(num, event) {
this.object_source = num;
$('#modalAutoSearchFiltr .form .button-row .selector-button.object_source').removeClass('selected');
$(event.target).closest('.selector-button').addClass('selected');
},
// Переключение типа объекта
changeCategoryType(item, event) {
// this.category_type = item.value;
item.selected = !item.selected
// $('#modalAutoSearchFiltr .form .button-row .selector-button.category_type').removeClass('selected');
// $(event.target).closest('.selector-button').addClass('selected');
},
// Переключение срока аренды
changeObjectRentSrok(num, event) {
this.rent_srok = num;
$('#modalAutoSearchFiltr .form .button-row .selector-button.rent_srok').removeClass('selected');
$(event.target).closest('.selector-button').addClass('selected');
},
// Переключение кол-ва комнат
changeRoomsCount(value, event) {
if (value) {
if (this.rooms.indexOf(value.toString()) != -1) {
this.rooms.splice(this.rooms.indexOf(value.toString()), 1)
$(event.target).closest('.selector-button').removeClass('selected');
} else {
this.rooms.push(value.toString());
$(event.target).closest('.selector-button').addClass('selected');
}
}
},
checkRoomSelected(item) {
return item.selected || (item.value && this.rooms.indexOf(item.value.toString()) != -1)
},
// Типы объектов
getObjectTypes(object_type) {
if (typeof object_type !== "undefined")
this.object_type = object_type;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_object_types',
object_type_id: this.object_type,
}).then((response) => {
this.objectTypes = response.data;
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getRoomsCounts() {
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_rooms_counts'
}).then((response) => {
this.roomsCounts = response.data;
}).catch(function(error) {
if (error)
console.debug(error);
});
},
// Источники добавления объектов
getObjectSources(object_source) {
if (typeof object_source !== "undefined")
this.object_source = object_source;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_object_sources',
object_source_id: this.object_source,
}).then((response) => {
this.objectSources = response.data;
}).catch(function(error) {
if (error)
console.debug(error);
});
},
// Типы категории помещений
getCategoryTypes(category_type) {
if (typeof category_type !== "undefined")
this.category_type = category_type;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_category_types',
category_type_ids: Array.isArray(this.category_type) && this.category_type.length ? this.category_type : this.selectedCategoryTypes,
}).then((response) => {
//this.categoryTypes = this.arrayChunk(response.data, 5);
this.categoryTypes = response.data;
}).catch(function(error) {
if (error)
console.debug(error);
});
},
// Срок аренды
getObjectRentSrok(srok) {
if (typeof srok !== "undefined")
this.srok = srok;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_rent_srok',
rent_srok_id: this.srok,
}).then((response) => {
this.objectRentSrok = response.data;
}).catch(function(error) {
if (error)
console.debug(error);
});
},
// Регионы РФ/субъекты
getObjectRegions(region) {
var ref = this;
if (typeof region !== "undefined")
this.regions = region;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_regions',
user_id: $("#session_user_id").val(),
regions: this.regions
}).then((response) => {
this.objectRegions = response.data.list;
$("#asfiltr-object-regions-input").html(response.data.html);
$("#asfiltr-object-regions").fastselect({
placeholder: 'Выберите субъект/регион',
onItemSelect: function(item, val) {
ref.regions = JSON.stringify($("#asfiltr-object-regions").val());
ref.getObjectRayons(ref.regions);
ref.getMetroStations(ref.regions);
console.log(ref.regions);
},
onItemDelete: function() {
ref.regions = JSON.stringify($("#asfiltr-object-regions").val());
ref.getObjectRayons(ref.regions);
ref.getMetroStations(ref.regions);
}
});
ref.regions = JSON.stringify($("#asfiltr-object-regions").val());
ref.getObjectRayons(ref.regions);
}).catch(function(error) {
if (error)
console.debug(error);
});
},
// Раоны субъекта
getObjectRayons(region, rayons) {
var ref = this;
if (typeof rayons !== "undefined")
this.rayons = rayons;
if (region == null)
return;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_rayons',
user_id: $("#session_user_id").val(),
regions: ((typeof region != "undefined") ? region : this.regions),
rayons: this.rayons
}).then((response) => {
this.objectRayons = response.data.list;
if (this.isEmpty(this.geo)) {
$("#asfiltr-object-rayons-input").html(response.data.html);
//$("#asfiltr-object-rayons-input").attr('data-initial-value', this.rayons);
$("#asfiltr-object-rayons-input .fstElement").removeClass('disabled');
$("#asfiltr-object-rayons").fastselect({
placeholder: 'Выберите район(ы)',
onItemSelect: function(item, val) {
ref.rayons = JSON.stringify($("#asfiltr-object-rayons").val());
ref.getMetroStations(ref.regions);
console.log(ref.rayons);
},
onItemDelete: function(item, val) {
ref.rayons = JSON.stringify($("#asfiltr-object-rayons").val());
ref.getMetroStations(ref.regions);
console.log(ref.rayons);
},
});
} else {
$("#asfiltr-object-rayons-input").html('<select id="asfiltr-object-rayons" multiple></select>');
$("#asfiltr-object-rayons").fastselect();
$("#asfiltr-object-rayons-input .fstElement").addClass('disabled');
}
}).catch(function(error) {
if (error)
console.debug(error);
});
},
// Список станций метро
getMetroStations(region, metro_stations) {
let ref = this;
if (typeof metro_stations !== "undefined")
this.metro_stations = metro_stations;
if (region == null)
return;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_metro',
user_id: $("#session_user_id").val(),
regions: ((typeof region != "undefined") ? region : this.regions),
metro_stations: this.metro_stations
}).then((response) => {
this.metroStations = response.data.list;
if (this.isEmpty(this.geo)) {
//console.debug(this.metroStations);
$("#asfiltr-metro-stations-input").html(response.data.html);
//$("#asfiltr-metro-stations-input").attr('data-initial-value', JSON.stringify(this.metro_stations));
$("#asfiltr-metro-stations-input .fstElement").removeClass('disabled');
$("#asfiltr-metro-stations").fastselect({
placeholder: 'Выберите станцию(и)',
onItemSelect: function(item, val) {
ref.metro_stations = JSON.stringify($("#asfiltr-metro-stations").val());
console.log(ref.metro_stations);
},
onItemDelete: function() {
ref.metro_stations = JSON.stringify($("#asfiltr-metro-stations").val());
console.log(ref.metro_stations);
},
});
} else {
$("#asfiltr-metro-stations-input").html('<select id="asfiltr-metro-stations" multiple></select>');
$("#asfiltr-metro-stations").fastselect();
$("#asfiltr-metro-stations-input .fstElement").addClass('disabled');
}
}).catch(function(error) {
if (error)
console.debug(error);
});
},
// Список типов оформлений сделок
/*getOrderTypes(order_type) {
let ref = this;
if (typeof order_type !== "undefined")
this.order_type = order_type;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_deal_type',
user_id: $("#session_user_id").val(),
order_type: this.order_type
}).then((response) => {
this.orderTypes = response.data.list;
$("#asfiltr-order-types-input").html(response.data.html);
$("#asfiltr-order-types").fastselect({
placeholder: 'Выберите тип',
onItemSelect: function(item, val) {
ref.order_type = val.value;
console.log(ref.order_type);
},
onItemDelete: function(item, val) {
ref.order_type = val.value;
console.log(ref.order_type);
},
});
}).catch(function (error) {
if (error)
console.debug(error);
});
},
*/
// Список типов домов
getHouseTypes(house_type) {
let ref = this;
if (typeof house_type !== "undefined")
this.house_type = house_type;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_house_type',
user_id: $("#session_user_id").val(),
house_type: this.house_type
}).then((response) => {
this.houseTypes = response.data.list;
$("#asfiltr-house-types-input").html(response.data.html);
$("#asfiltr-house-types").fastselect({
placeholder: 'Выберите тип',
onItemSelect: function(item, val) {
ref.house_type = val.value;
console.log(ref.house_type);
},
onItemDelete: function(item, val) {
ref.house_type = val.value;
console.log(ref.house_type);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
// Список типов стен
getHouseMaterials(house_material) {
let ref = this;
if (typeof house_material !== "undefined")
this.house_material = house_material;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_house_material',
user_id: $("#session_user_id").val(),
house_material: this.house_material
}).then((response) => {
this.houseMaterials = response.data.list;
$("#asfiltr-house-materials-input").html(response.data.html);
$("#asfiltr-house-materials").fastselect({
placeholder: 'Выберите тип',
onItemSelect: function(item, val) {
ref.house_material = val.value;
console.log(ref.house_material);
},
onItemDelete: function(item, val) {
ref.house_material = val.value;
console.log(ref.house_material);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
// Список годов постройки
getBuildYears(build_year) {
let ref = this;
if (typeof build_year !== "undefined")
this.build_year = build_year;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_build_year',
user_id: $("#session_user_id").val(),
build_year: this.build_year
}).then((response) => {
this.buildYears = response.data.list;
$("#asfiltr-build-year-input").html(response.data.html);
$("#asfiltr-build-year").fastselect({
placeholder: 'Выберите год',
onItemSelect: function(item, val) {
ref.build_year = val.value;
console.log(ref.build_year);
},
onItemDelete: function(item, val) {
ref.build_year = val.value;
console.log(ref.build_year);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getLegalAddress(legal_address) {
let ref = this;
if (typeof legal_address !== "undefined")
this.legal_address = legal_address;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_legal_address',
user_id: $("#session_user_id").val(),
legal_address: this.legal_address
}).then((response) => {
this.legalAddress = response.data.list;
$("#asfiltr-legal-address-input").html(response.data.html);
$("#asfiltr-legal-address").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.legal_address = val.value;
console.log(ref.legal_address);
},
onItemDelete: function(item, val) {
ref.legal_address = val.value;
console.log(ref.legal_address);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getIsOccupied(is_occupied) {
let ref = this;
if (typeof is_occupied !== "undefined")
this.is_occupied = is_occupied;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_is_occupied',
user_id: $("#session_user_id").val(),
is_occupied: this.is_occupied
}).then((response) => {
this.isOccupied = response.data.list;
$("#asfiltr-is-occupied-input").html(response.data.html);
$("#asfiltr-is-occupied").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
objectTypeItem.is_occupied = val.value;
console.log(ref.is_occupied);
},
onItemDelete: function(item, val) {
objectTypeItem.is_occupied = val.value;
console.log(ref.is_occupied);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getLayoutId(layout_id) {
let ref = this;
if (typeof layout_id !== "undefined")
this.layout_id = layout_id;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_layout_id',
user_id: $("#session_user_id").val(),
layout_id: this.layout_id
}).then((response) => {
this.layoutIds = response.data.list;
$("#asfiltr-layout-id-input").html(response.data.html);
$("#asfiltr-layout-id").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.layout_id = val.value;
console.log(ref.layout_id);
},
onItemDelete: function(item, val) {
ref.layout_id = val.value;
console.log(ref.layout_id);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getWetSpots(wet_spots) {
let ref = this;
if (typeof wet_spots !== "undefined")
this.wet_spots = wet_spots;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_wet_spots',
user_id: $("#session_user_id").val(),
wet_spots: this.wet_spots
}).then((response) => {
this.wetSpots = response.data.list;
$("#asfiltr-wet-spots-input").html(response.data.html);
$("#asfiltr-wet-spots").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.wet_spots = val.value;
console.log(ref.wet_spots);
},
onItemDelete: function(item, val) {
ref.wet_spots = val.value;
console.log(ref.wet_spots);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommerCondition(commer_condition) {
let ref = this;
if (typeof commer_condition !== "undefined")
this.commer_condition = commer_condition;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commer_condition',
user_id: $("#session_user_id").val(),
commer_condition: this.commer_condition
}).then((response) => {
this.commerCondition = response.data.list;
console.log(response.data.list);
$("#asfiltr-commer-condition-input").html(response.data.html);
$("#asfiltr-commer-condition").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commer_condition = val.value;
console.log(ref.commer_condition);
},
onItemDelete: function(item, val) {
ref.commer_condition = val.value;
console.log(ref.commer_condition);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getIsFurniture(is_furniture) {
let ref = this;
if (typeof is_furniture !== "undefined")
this.is_furniture = is_furniture;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_is_furniture',
user_id: $("#session_user_id").val(),
is_furniture: this.is_furniture
}).then((response) => {
this.isFurniture = response.data.list;
$("#asfiltr-is-furniture-input").html(response.data.html);
$("#asfiltr-is-furniture").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.is_furniture = val.value;
console.log(ref.is_furniture);
},
onItemDelete: function(item, val) {
ref.is_furniture = val.value;
console.log(ref.is_furniture);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommerAccess(commer_access) {
let ref = this;
if (typeof commer_access !== "undefined")
this.commer_access = commer_access;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commer_access',
user_id: $("#session_user_id").val(),
commer_access: this.commer_access
}).then((response) => {
this.commerAccess = response.data.list;
$("#asfiltr-commer-access-input").html(response.data.html);
$("#asfiltr-commer-access").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commer_access = val.value;
console.log(ref.commer_access);
},
onItemDelete: function(item, val) {
ref.commer_access = val.value;
console.log(ref.commer_access);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getParkingTypes(parking_types) {
let ref = this;
if (typeof parking_types !== "undefined")
this.parking_types = parking_types;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_parking_types',
user_id: $("#session_user_id").val(),
parking_types: this.parking_types
}).then((response) => {
this.parkingTypes = response.data.list;
$("#asfiltr-parking-types-input").html(response.data.html);
$("#asfiltr-parking-types").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.parking_types = val.value;
console.log(ref.parking_types);
},
onItemDelete: function(item, val) {
ref.parking_types = val.value;
console.log(ref.parking_types);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getParkingId(parking_id) {
let ref = this;
if (typeof parking_id !== "undefined")
this.parking_id = parking_id;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_parking_id',
user_id: $("#session_user_id").val(),
parking_id: this.parking_id
}).then((response) => {
this.parkingIds = response.data.list;
$("#asfiltr-parking-id-input").html(response.data.html);
$("#asfiltr-parking-id").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.parking_id = val.value;
console.log(ref.parking_id);
},
onItemDelete: function(item, val) {
ref.parking_id = val.value;
console.log(ref.parking_id);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getVatTypeId(vat_type_id) {
let ref = this;
if (typeof vat_type_id !== "undefined")
this.vat_type_id = vat_type_id;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_vat_type_id',
user_id: $("#session_user_id").val(),
vat_type_id: this.vat_type_id
}).then((response) => {
this.vatTypeIds = response.data.list;
$("#asfiltr-vat-type-id-input").html(response.data.html);
$("#asfiltr-vat-type-id").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.vat_type_id = val.value;
console.log(ref.vat_type_id);
},
onItemDelete: function(item, val) {
ref.vat_type_id = val.value;
console.log(ref.vat_type_id);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getFloorMaterials(floor_material_id) {
let ref = this;
if (typeof floor_material_id !== "undefined")
this.floor_material_id = floor_material_id;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_floor_material_id',
user_id: $("#session_user_id").val(),
floor_material_id: this.floor_material_id
}).then((response) => {
this.floorMaterials = response.data.list;
$("#asfiltr-floor-material-input").html(response.data.html);
$("#asfiltr-floor-material").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.floor_material_id = JSON.stringify($("#asfiltr-floor-material").val());
console.log(ref.floor_material_id);
},
onItemDelete: function(item, val) {
ref.floor_material_id = JSON.stringify($("#asfiltr-floor-material").val());
console.log(ref.floor_material_id);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommercPortalId(commerc_portal_id) {
let ref = this;
if (typeof commerc_portal_id !== "undefined")
this.commerc_portal_id = commerc_portal_id;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commerc_portal_id',
user_id: $("#session_user_id").val(),
commerc_portal_id: this.commerc_portal_id
}).then((response) => {
this.commercPortalIds = response.data.list;
$("#asfiltr-commerc-portal-input").html(response.data.html);
$("#asfiltr-commerc-portal").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commerc_portal_id = JSON.stringify($("#asfiltr-commerc-portal").val());
console.log(ref.commerc_portal_id);
},
onItemDelete: function(item, val) {
ref.commerc_portal_id = JSON.stringify($("#asfiltr-commerc-portal").val());
console.log(ref.commerc_portal_id);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommercPurpose(commerc_purpose) {
let ref = this;
if (typeof commerc_purpose !== "undefined")
this.commerc_purpose = commerc_purpose;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commerc_purpose',
user_id: $("#session_user_id").val(),
commerc_purpose: this.commerc_purpose
}).then((response) => {
this.commercPurpose = response.data.list;
$("#asfiltr-commerc-purpose-input").html(response.data.html);
$("#asfiltr-commerc-purpose").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commerc_purpose = JSON.stringify($("#asfiltr-commerc-purpose").val());
console.log(ref.commerc_purpose);
},
onItemDelete: function(item, val) {
ref.commerc_purpose = JSON.stringify($("#asfiltr-commerc-purpose").val());
console.log(ref.commerc_purpose);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommercLandCategoryId(commerc_land_category_id) {
let ref = this;
if (typeof commerc_land_category_id !== "undefined")
this.commerc_land_category_id = commerc_land_category_id;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commerc_land_category_id',
user_id: $("#session_user_id").val(),
commerc_land_category_id: this.commerc_land_category_id
}).then((response) => {
this.commercLandCategoryIds = response.data.list;
$("#asfiltr-commerc-land-category-input").html(response.data.html);
$("#asfiltr-commerc-land-category").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commerc_land_category_id = JSON.stringify($("#asfiltr-commerc-land-category").val());
console.log(ref.commerc_land_category_id);
},
onItemDelete: function(item, val) {
ref.commerc_land_category_id = JSON.stringify($("#asfiltr-commerc-land-category").val());
console.log(ref.commerc_land_category_id);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommercPrmittedUseId(commerc_permitted_use_id) {
let ref = this;
if (typeof commerc_permitted_use_id !== "undefined")
this.commerc_permitted_use_id = commerc_permitted_use_id;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commerc_permitted_use_id',
user_id: $("#session_user_id").val(),
commerc_permitted_use_id: this.commerc_permitted_use_id
}).then((response) => {
this.commercPrmittedUseIds = response.data.list;
$("#asfiltr-commerc-permitted-use-input").html(response.data.html);
$("#asfiltr-commerc-permitted-use").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commerc_permitted_use_id = JSON.stringify($("#asfiltr-commerc-permitted-use").val());
console.log(ref.commerc_permitted_use_id);
},
onItemDelete: function(item, val) {
ref.commerc_permitted_use_id = JSON.stringify($("#asfiltr-commerc-permitted-use").val());
console.log(ref.commerc_permitted_use_id);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommercElectricityId(commerc_electricity_id) {
let ref = this;
if (typeof commerc_electricity_id !== "undefined")
this.commerc_electricity_id = commerc_electricity_id;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commerc_electricity_id',
user_id: $("#session_user_id").val(),
commerc_electricity_id: this.commerc_electricity_id
}).then((response) => {
this.commercElectricityIds = response.data.list;
$("#asfiltr-commerc-electricity-input").html(response.data.html);
$("#asfiltr-commerc-electricity").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commerc_electricity_id = val.value;
console.log(ref.commerc_electricity_id);
},
onItemDelete: function(item, val) {
ref.commerc_electricity_id = val.value;
console.log(ref.commerc_electricity_id);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommercGasId(commerc_gas_id) {
let ref = this;
if (typeof commerc_gas_id !== "undefined")
this.commerc_gas_id = commerc_gas_id;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commerc_gas_id',
user_id: $("#session_user_id").val(),
commerc_gas_id: this.commerc_gas_id
}).then((response) => {
this.commercGasIdss = response.data.list;
$("#asfiltr-commerc-gas-input").html(response.data.html);
$("#asfiltr-commerc-gas").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commerc_gas_id = val.value;
console.log(ref.commerc_gas_id);
},
onItemDelete: function(item, val) {
ref.commerc_gas_id = val.value;
console.log(ref.commerc_gas_id);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommercWaterId(commerc_water_id) {
let ref = this;
if (typeof commerc_water_id !== "undefined")
this.commerc_water_id = commerc_water_id;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commerc_water_id',
user_id: $("#session_user_id").val(),
commerc_water_id: this.commerc_water_id
}).then((response) => {
this.commercWaterIdss = response.data.list;
$("#asfiltr-commerc-water-input").html(response.data.html);
$("#asfiltr-commerc-water").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commerc_water_id = val.value;
console.log(ref.commerc_water_id);
},
onItemDelete: function(item, val) {
ref.commerc_water_id = val.value;
console.log(ref.commerc_water_id);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommercSewageId(commerc_sewage_id) {
let ref = this;
if (typeof commerc_sewage_id !== "undefined")
this.commerc_sewage_id = commerc_sewage_id;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commerc_sewage_id',
user_id: $("#session_user_id").val(),
commerc_sewage_id: this.commerc_sewage_id
}).then((response) => {
this.commercSewageIdss = response.data.list;
$("#asfiltr-commerc-sewage-input").html(response.data.html);
$("#asfiltr-commerc-sewage").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commerc_sewage_id = val.value;
console.log(ref.commerc_sewage_id);
},
onItemDelete: function(item, val) {
ref.commerc_sewage_id = val.value;
console.log(ref.commerc_sewage_id);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommercDriveways(commerc_driveways) {
let ref = this;
if (typeof commerc_driveways !== "undefined")
this.commerc_driveways = commerc_driveways;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commerc_driveways',
user_id: $("#session_user_id").val(),
commerc_driveways: this.commerc_driveways
}).then((response) => {
this.commercDriveways = response.data.list;
$("#asfiltr-commerc-driveways-input").html(response.data.html);
$("#asfiltr-commerc-driveways").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commerc_driveways = val.value;
console.log(ref.commerc_driveways);
},
onItemDelete: function(item, val) {
ref.commerc_driveways = val.value;
console.log(ref.commerc_driveways);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommercBuildingTypeId(commerc_building_type_id) {
let ref = this;
if (typeof commerc_building_type_id !== "undefined")
this.commerc_building_type_id = commerc_building_type_id;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commerc_building_type_id',
user_id: $("#session_user_id").val(),
commerc_building_type_id: this.commerc_building_type_id
}).then((response) => {
this.commercBuildingTypeIds = response.data.list;
$("#asfiltr-commerc-building-type-input").html(response.data.html);
$("#asfiltr-commerc-building-type").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commerc_building_type_id = JSON.stringify($("#asfiltr-commerc-building-type").val());
console.log(ref.commerc_building_type_id);
},
onItemDelete: function(item, val) {
ref.commerc_building_type_id = JSON.stringify($("#asfiltr-commerc-building-type").val());
console.log(ref.commerc_building_type_id);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommercBuildingClassId(commerc_building_class_id) {
let ref = this;
if (typeof commerc_building_class_id !== "undefined")
this.commerc_building_class_id = commerc_building_class_id;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commerc_building_class_id',
user_id: $("#session_user_id").val(),
commerc_building_class_id: this.commerc_building_class_id
}).then((response) => {
this.commercBuildingClassIds = response.data.list;
$("#asfiltr-commerc-building-class-input").html(response.data.html);
$("#asfiltr-commerc-building-class").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commerc_building_class_id = JSON.stringify($("#asfiltr-commerc-building-class").val());
console.log(ref.commerc_building_class_id);
},
onItemDelete: function(item, val) {
ref.commerc_building_class_id = JSON.stringify($("#asfiltr-commerc-building-class").val());
console.log(ref.commerc_building_class_id);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommercHouselineTypeId(commerc_houseline_type_id) {
let ref = this;
if (typeof commerc_houseline_type_id !== "undefined")
this.commerc_houseline_type_id = commerc_houseline_type_id;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commerc_houseline_type_id',
user_id: $("#session_user_id").val(),
commerc_houseline_type_id: this.commerc_houseline_type_id
}).then((response) => {
this.commercHouselineTypeIds = response.data.list;
$("#asfiltr-commerc-houseline-type-id-input").html(response.data.html);
$("#asfiltr-commerc-houseline-type-id").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commerc_houseline_type_id = val.value;
console.log(ref.commerc_houseline_type_id);
},
onItemDelete: function(item, val) {
ref.commerc_houseline_type_id = val.value;
console.log(ref.commerc_houseline_type_id);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommercBuildingCategoryId(commerc_building_category_id) {
let ref = this;
if (typeof commerc_building_category_id !== "undefined")
this.commerc_building_category_id = commerc_building_category_id;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commerc_building_category_id',
user_id: $("#session_user_id").val(),
commerc_building_category_id: this.commerc_building_category_id
}).then((response) => {
this.commercBuildingCategoryIds = response.data.list;
$("#asfiltr-commerc-building-category-input").html(response.data.html);
$("#asfiltr-commerc-building-category").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commerc_building_category_id = val.value;
console.log(ref.commerc_building_category_id);
},
onItemDelete: function(item, val) {
ref.commerc_building_category_id = val.value;
console.log(ref.commerc_building_category_id);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommercOpenedId(commerc_opened_id) {
let ref = this;
if (typeof commerc_opened_id !== "undefined")
this.commerc_opened_id = commerc_opened_id;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commerc_opened_id',
user_id: $("#session_user_id").val(),
commerc_opened_id: this.commerc_opened_id
}).then((response) => {
this.commercOpenedIds = response.data.list;
$("#asfiltr-commerc-opened-input").html(response.data.html);
$("#asfiltr-commerc-opened").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commerc_opened_id = JSON.stringify($("#asfiltr-commerc-opened").val());
console.log(ref.commerc_opened_id);
},
onItemDelete: function(item, val) {
ref.commerc_opened_id = JSON.stringify($("#asfiltr-commerc-opened").val());
console.log(ref.commerc_opened_id);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommercBuildingVentilation(commerc_building_ventilation) {
let ref = this;
if (typeof commerc_building_ventilation !== "undefined")
this.commerc_building_ventilation = commerc_building_ventilation;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commerc_building_ventilation',
user_id: $("#session_user_id").val(),
commerc_building_ventilation: this.commerc_building_ventilation
}).then((response) => {
this.commercBuildingVentilation = response.data.list;
$("#asfiltr-commerc-building-ventilation-input").html(response.data.html);
$("#asfiltr-commerc-building-ventilation").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commerc_building_ventilation = val.value;
console.log(ref.commerc_building_ventilation);
},
onItemDelete: function(item, val) {
ref.commerc_building_ventilation = val.value;
console.log(ref.commerc_building_ventilation);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommercBuildingConditioning(commerc_building_conditioning) {
let ref = this;
if (typeof commerc_building_conditioning !== "undefined")
this.commerc_building_conditioning = commerc_building_conditioning;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commerc_building_conditioning',
user_id: $("#session_user_id").val(),
commerc_building_conditioning: this.commerc_building_conditioning
}).then((response) => {
this.commercBuildingConditioning = response.data.list;
$("#asfiltr-commerc-building-conditioning-input").html(response.data.html);
$("#asfiltr-commerc-building-conditioning").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commerc_building_conditioning = val.value;
console.log(ref.commerc_building_conditioning);
},
onItemDelete: function(item, val) {
ref.commerc_building_conditioning = val.value;
console.log(ref.commerc_building_conditioning);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommercBuildingHeating(commerc_building_heating) {
let ref = this;
if (typeof commerc_building_heating !== "undefined")
this.commerc_building_heating = commerc_building_heating;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commerc_building_heating',
user_id: $("#session_user_id").val(),
commerc_building_heating: this.commerc_building_heating
}).then((response) => {
this.commercBuildingHeating = response.data.list;
$("#asfiltr-commerc-building-heating-input").html(response.data.html);
$("#asfiltr-commerc-building-heating").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commerc_building_heating = val.value;
console.log(ref.commerc_building_heating);
},
onItemDelete: function(item, val) {
ref.commerc_building_heating = val.value;
console.log(ref.commerc_building_heating);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommercBuildingFire(commerc_building_fire) {
let ref = this;
if (typeof commerc_building_fire !== "undefined")
this.commerc_building_fire = commerc_building_fire;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commerc_building_fire',
user_id: $("#session_user_id").val(),
commerc_building_fire: this.commerc_building_fire
}).then((response) => {
this.commercBuildingFire = response.data.list;
$("#asfiltr-commerc-building-fire-input").html(response.data.html);
$("#asfiltr-commerc-building-fire").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commerc_building_fire = val.value;
console.log(ref.commerc_building_fire);
},
onItemDelete: function(item, val) {
ref.commerc_building_fire = val.value;
console.log(ref.commerc_building_fire);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getGarageTypeId(garage_type_id) {
let ref = this;
if (typeof garage_type_id !== "undefined")
this.garage_type_id = garage_type_id;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_garage_type_id',
user_id: $("#session_user_id").val(),
garage_type_id: this.garage_type_id
}).then((response) => {
this.garageTypeIds = response.data.list;
$("#asfiltr-garage-type-id-input").html(response.data.html);
$("#asfiltr-garage-type-id").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.garage_type_id = val.value;
console.log(ref.garage_type_id);
},
onItemDelete: function(item, val) {
ref.garage_type_id = val.value;
console.log(ref.garage_type_id);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getGarageVidId(garage_vid_id) {
let ref = this;
if (typeof garage_vid_id !== "undefined")
this.garage_vid_id = garage_vid_id;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_garage_vid_id',
user_id: $("#session_user_id").val(),
garage_vid_id: this.garage_vid_id
}).then((response) => {
this.garageVidIds = response.data.list;
$("#asfiltr-garage-vid-id-input").html(response.data.html);
$("#asfiltr-garage-vid-id").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.garage_vid_id = val.value;
console.log(ref.garage_vid_id);
},
onItemDelete: function(item, val) {
ref.garage_vid_id = val.value;
console.log(ref.garage_vid_id);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getBoksVidId(boks_vid_id) {
let ref = this;
if (typeof boks_vid_id !== "undefined")
this.boks_vid_id = boks_vid_id;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_boks_vid_id',
user_id: $("#session_user_id").val(),
boks_vid_id: this.boks_vid_id
}).then((response) => {
this.boksVidIds = response.data.list;
$("#asfiltr-boks-vid-id-input").html(response.data.html);
$("#asfiltr-boks-vid-id").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.boks_vid_id = val.value;
console.log(ref.boks_vid_id);
},
onItemDelete: function(item, val) {
ref.boks_vid_id = val.value;
console.log(ref.boks_vid_id);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommercStatusId(commerc_status_id) {
let ref = this;
if (typeof commerc_status_id !== "undefined")
this.commerc_status_id = commerc_status_id;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commerc_status_id',
user_id: $("#session_user_id").val(),
commerc_status_id: this.commerc_status_id
}).then((response) => {
this.commercStatusIds = response.data.list;
$("#asfiltr-commerc-status-id-input").html(response.data.html);
$("#asfiltr-commerc-status-id").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commerc_status_id = val.value;
console.log(ref.commerc_status_id);
},
onItemDelete: function(item, val) {
ref.commerc_status_id = val.value;
console.log(ref.commerc_status_id);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommercSpecifications(commerc_specifications) {
let ref = this;
if (typeof commerc_specifications !== "undefined")
this.commerc_specifications = commerc_specifications;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commerc_specifications',
user_id: $("#session_user_id").val(),
commerc_specifications: this.commerc_specifications
}).then((response) => {
this.commercSpecifications = response.data.list;
$("#asfiltr-commerc-specifications-input").html(response.data.html);
$("#asfiltr-commerc-specifications").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commerc_specifications = JSON.stringify($("#asfiltr-commerc-specifications").val());
console.log(ref.commerc_specifications);
},
onItemDelete: function(item, val) {
ref.commerc_specifications = JSON.stringify($("#asfiltr-commerc-specifications").val());
console.log(ref.commerc_specifications);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommercInfrastructure(commerc_infrastructure) {
let ref = this;
if (typeof commerc_infrastructure !== "undefined")
this.commerc_infrastructure = commerc_infrastructure;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commerc_infrastructure',
user_id: $("#session_user_id").val(),
commerc_infrastructure: this.commerc_infrastructure
}).then((response) => {
this.commercInfrastructure = response.data.list;
$("#asfiltr-commerc-infrastructure-input").html(response.data.html);
$("#asfiltr-commerc-infrastructure").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commerc_infrastructure = JSON.stringify($("#asfiltr-commerc-infrastructure").val());
console.log(ref.commerc_infrastructure);
},
onItemDelete: function(item, val) {
ref.commerc_infrastructure = JSON.stringify($("#asfiltr-commerc-infrastructure").val());
console.log(ref.commerc_infrastructure);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommercInfrastructure1(commerc_infrastructure1) {
let ref = this;
if (typeof commerc_infrastructure1 !== "undefined")
this.commerc_infrastructure1 = commerc_infrastructure1;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commerc_infrastructure1',
user_id: $("#session_user_id").val(),
commerc_infrastructure1: this.commerc_infrastructure1
}).then((response) => {
this.commercInfrastructure1 = response.data.list;
$("#asfiltr-commerc-infrastructure1-input").html(response.data.html);
$("#asfiltr-commerc-infrastructure1").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commerc_infrastructure1 = JSON.stringify($("#asfiltr-commerc-infrastructure1").val());
console.log(ref.commerc_infrastructure1);
},
onItemDelete: function(item, val) {
ref.commerc_infrastructure1 = JSON.stringify($("#asfiltr-commerc-infrastructure1").val());
console.log(ref.commerc_infrastructure1);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
getCommercInfrastructure2(commerc_infrastructure2) {
let ref = this;
if (typeof commerc_infrastructure2 !== "undefined")
this.commerc_infrastructure2 = commerc_infrastructure2;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_commerc_infrastructure2',
user_id: $("#session_user_id").val(),
commerc_infrastructure2: this.commerc_infrastructure2
}).then((response) => {
this.commercInfrastructure2 = response.data.list;
$("#asfiltr-commerc-infrastructure2-input").html(response.data.html);
$("#asfiltr-commerc-infrastructure2").fastselect({
placeholder: 'Выберите вариант(ы)',
onItemSelect: function(item, val) {
ref.commerc_infrastructure2 = JSON.stringify($("#asfiltr-commerc-infrastructure2").val());
console.log(ref.commerc_infrastructure2);
},
onItemDelete: function(item, val) {
ref.commerc_infrastructure2 = JSON.stringify($("#asfiltr-commerc-infrastructure2").val());
console.log(ref.commerc_infrastructure2);
},
});
}).catch(function(error) {
if (error)
console.debug(error);
});
},
// Сохранение/редактирование параметров автопоиска
addEditFiltr() {
this.errorText = '';
this.isError = false;
this.req_id = $('#modalAutoSearchFiltr [name="req_id"]').val();
// Валидация параметров автопоиска
/*if (this.isEmpty(this.req_id)) {
this.isError = true;
this.errorText += "<p>Не указан ИД заявки</p>";
}*/
if (this.isEmpty(this.deal_type) || this.deal_type == 0) {
this.isError = true;
this.errorText += "<p>Не указан тип сделки.</p>";
}
if (this.isEmpty(this.object_type) || this.object_type == 0) {
this.isError = true;
this.errorText += "<p>Не указан тип объекта.</p>";
}
if (this.isEmpty(this.stoim_ot) && this.isEmpty(this.stoim_do)) {
this.isError = true;
this.errorText += "<p>Не указана цена объекта.</p>";
}
if (this.isEmpty(this.regions)) {
this.isError = true;
this.errorText += "<p>Не указан субъект/регион объекта.</p>";
}
if (this.isError) {
let modal = document.getElementById("modalAutoSearchFiltr");
modal.scrollIntoView({
behavior: "smooth",
block: "start"
});
}
if (!this.isError) {
let ref = this;
let data = {
id: this.id, // ИД фильтра
req_id: this.req_id, // ИД заявки
deal_type: this.deal_type, // тип сделки
object_type: this.object_type, // тип объекта
object_source: this.object_source, // источник добавления объекта
category_type: this.selectedCategoryTypes, // категория объекта
stoim_ot: this.stoim_ot, // цена; от
stoim_do: this.stoim_do, // цена; до
komn_ot: this.komn_ot, // комнат; от
komn_do: this.komn_do, // комнат; до
rooms: this.rooms, // комнат
sq_all_ot: this.sq_all_ot, // общая площадь; от
sq_all_do: this.sq_all_do, // общая площадь; до
ploshad_k_ot: this.ploshad_k_ot, // площадь кухни; от
ploshad_k_do: this.ploshad_k_do, // площадь кухни; до
rent_srok: this.rent_srok, // срок аренды объекта
regions: this.regions, // регион(ы) объекта
rayons: this.rayons, // район(ы) объекта
metro_stations: this.metro_stations, // ближ. станции метро
do_metro: this.do_metro, // время до метро
do_metro_type: this.do_metro_type, // до метро пешком/на траспорте
etazhnost_ot: this.etazhnost_ot, // этажность дома квартиры, от
etazhnost_do: this.etazhnost_do, // этажность дома квартиры, до
etazhnost: this.etazhnost, // не первый и не последний этаж
//order_type: this.order_type, // тип оформления сделки
newbilding_date: this.newbilding_date, // срок сдачи
ipoteka: this.ipoteka, // ипотека
use_area_price: this.use_area_price,
voen_ipoteka: this.voen_ipoteka, // воен. ипотека
subsidya: this.subsidya, // субсидия
mather_kapital: this.mather_kapital, // материнский капитал
house_type: this.house_type, // тип дома
house_material: this.house_material, // материал дома (тип стен)
build_year: this.build_year, // год постройки
opis: this.opis, // описание
comment: this.comment, // комментарий
is_active: this.is_active, // флаг активности фильтра
telegram_notify: this.telegram_notify, // флаг уведомления в Телеграм
tax_number: this.tax_number, // Номер налоговой
legal_address: this.legal_address, //
etazh_ot: this.etazh_ot, //
etazh_do: this.etazh_do, //
is_occupied: this.is_occupied, //
layout_id: this.layout_id, //
wet_spots: this.wet_spots, //
el_power_ot: this.el_power_ot, //
el_power_do: this.el_power_do, //
commer_condition: this.commer_condition, //
is_furniture: this.is_furniture, //
commer_access: this.commer_access, //
parking_types: this.parking_types, //
parking_id: this.parking_id, //
parking_price: this.parking_price, //
parking_price_free: this.parking_price_free, //
ceiling_height_ot: this.ceiling_height_ot, //
ceiling_height_do: this.ceiling_height_do, //
column_grid: this.column_grid, //
vat_type_id: this.vat_type_id, //
commerc_site: this.commerc_site, //
commerc_owned1: this.commerc_owned1, //
commerc_owned2: this.commerc_owned2, //
floor_material_id: this.floor_material_id, //
commerc_portal_id: this.commerc_portal_id, //
commerc_purpose: this.commerc_purpose, //
commerc_land_category_id: this.commerc_land_category_id, //
commerc_permitted_use_id: this.commerc_permitted_use_id, //
commerc_electricity_id: this.commerc_electricity_id, //
can_electricity: this.can_electricity, //
commerc_gas_id: this.commerc_gas_id, //
can_gas: this.can_gas, //
commerc_water_id: this.commerc_water_id, //
can_water: this.can_water, //
commerc_sewage_id: this.commerc_sewage_id, //
can_sewage: this.can_sewage, //
commerc_driveways: this.commerc_driveways, //
commerc_year_ot: this.commerc_year_ot, //
commerc_year_do: this.commerc_year_do, //
commerc_building_type_id: this.commerc_building_type_id, //
commerc_building_class_id: this.commerc_building_class_id, //
building_area_ot: this.building_area_ot, //
building_area_do: this.building_area_do, //
commerc_houseline_type_id: this.commerc_houseline_type_id, //
commerc_building_category_id: this.commerc_building_category_id, //
commerc_opened_id: this.commerc_opened_id, //
commerc_building_ventilation: this.commerc_building_ventilation, //
commerc_building_conditioning: this.commerc_building_conditioning, //
commerc_building_heating: this.commerc_building_heating, //
commerc_building_fire: this.commerc_building_fire, //
garage_type_id: this.garage_type_id, //
garage_vid_id: this.garage_vid_id, //
boks_vid_id: this.boks_vid_id, //
commerc_status_id: this.commerc_status_id, //
commerc_specifications: this.commerc_specifications, //
commerc_infrastructure: this.commerc_infrastructure, //
commerc_infrastructure1: this.commerc_infrastructure1, //
commerc_infrastructure2: this.commerc_infrastructure2, //
commerc_lift1: this.commerc_lift1, //
lift1_carrying: this.lift1_carrying, //
commerc_lift2: this.commerc_lift2, //
lift2_carrying: this.lift2_carrying, //
commerc_lift3: this.commerc_lift3, //
lift3_carrying: this.lift3_carrying, //
commerc_crane1: this.commerc_crane1, //
crane1_carrying: this.crane1_carrying, //
commerc_crane2: this.commerc_crane2, //
crane2_carrying: this.crane2_carrying, //
commerc_crane3: this.commerc_crane3, //
crane3_carrying: this.crane3_carrying, //
commerc_crane4: this.commerc_crane4, //
crane4_carrying: this.crane4_carrying, //
geo: this.geo, //
};
Object.keys(data).map(function(field, index) {
let value = data[field];
let form_field = '#asfiltr-' + field.replace('_', '-');
if ($(form_field).closest('.control-group').length) {
if ($(form_field).closest('.control-group').is(":hidden")) {
data[field] = null;
console.log('Param ' + field + ' set to NULL because is hidden form field.');
}
}
});
console.debug(data);
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'add_edit',
user_id: this.user_id,
is_new_req: ((this.req_id == null || this.req_id == 0) ? true : false),
params: data
}).then((response) => {
//console.log(response.data);
let res = response.data;
if (res.success && response.data.id) {
this.id = response.data.id;
req_form.autosearch_filter_id = this.id;
req_form.autosearch_filter = response.data.filter;
this.$emit('add_edit_autosearch_filter', this.id, response.data.filter);
this.closeAutoSearchFiltr();
this.clearFiltr();
} else if (res.error) {
this.isError = true;
this.errorText += res.error;
}
}).catch(function(error) {
if (error)
console.debug(error);
});
if (document.location.pathname == '/requisitions.php') {
setTimeout(function() {
requisitions.getList();
}, 2000)
}
}
},
showSaveAutosearchFieldsWindow() {
$.ajax({
url: '/ajax/modals/saveAutosearchWinContent.php',
success: function(data) {
$("#save_autosearch_fields_bg").html(data).fadeIn(500);
$("#save_autosearch_fields").toggle(10);
$("body").addClass("lock");
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
console.log("eRROR: " + errorThrown + "; status:" + textStatus);
}
});
},
confirmSaveAutosearch() {
$("#save_autosearch_fields_bg").hide(10);
$("#save_autosearch_fields").hide(10);
this.addEditFiltr();
},
changeStoim(field_id) {
if (field_id == 'stoim_ot') {
this.stoim_ot = $('#asfiltr-stoim [id="stoim_ot"]').val();
}
if (field_id == 'stoim_do') {
this.stoim_do = $('#asfiltr-stoim [id="stoim_do"]').val();
}
},
editShortField(filter_id, field_id) {
console.log({ filter_id, field_id });
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_field_input',
user_id: $("#session_user_id").val(),
filter_id: filter_id,
field_id: field_id
}).then((response) => {
let html = response.data.html;
this.$emit('edit_short_field_input', html);
}).catch(function(error) {
if (error)
console.debug(error);
});
},
saveShortField(filter_id, param_id, fields) {
console.log({ filter_id, param_id });
console.log(fields);
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'save_field_input',
user_id: $("#session_user_id").val(),
filter_id: filter_id,
param_id: param_id,
fields: fields
}).then((response) => {
console.log(response.data);
if (response.data.result) {
let value = response.data.value;
this.$emit('edit_short_field_value', value);
} else {
let error = response.data.error;
this.$emit('edit_short_field_error', error);
}
}).catch(function(error) {
if (error)
console.debug(error);
});
},
deleteShortField(filter_id, param_id, fields) {
console.log({ filter_id, param_id });
console.log(fields);
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'delete_field_input',
user_id: $("#session_user_id").val(),
filter_id: filter_id,
field_id: param_id
}).then((response) => {
console.log(response.data);
if (response.data.result && response.data.field_id)
this.$emit('removed_short_field_value', response.data.field_id);
}).catch(function(error) {
if (error)
console.debug(error);
});
},
setReqToFilter(req_id, filter_id) {
console.log({ req_id, filter_id });
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'set_req_filter',
user_id: $("#session_user_id").val(),
req_id: req_id,
filter_id: filter_id
}).then((response) => {
console.log(response.data);
}).catch(function(error) {
if (error)
console.debug(error);
});
},
// Очистка формы
clearFiltr() {
this.isError = false;
this.errorText = '';
this.id = null; // ИД фильтра
this.req_id = null; // ИД заявки
this.deal_type = 2; // тип сделки
this.object_type = 0; // тип объекта
this.object_source = 0; // источник добавления объекта
this.category_type = 0; // тип категории
this.categoryTypes = {}; // типы категории
this.stoim_ot = null; // цена; от
this.stoim_do = null; // цена; до
this.komn_ot = null; // комнат; от
this.komn_do = null; // комнат; до
this.rooms = []; // комнаты
this.sq_all_ot = null; // общая площадь; от
this.sq_all_do = null; // общая площадь; до
this.ploshad_k_ot = null; // площадь кухни; от
this.ploshad_k_do = null; // площадь кухни; до
this.rent_srok = 0; // срок аренды объекта
this.regions = []; // регион объекта
this.rayons = []; // район(ы) объекта
this.metro_stations = []; // ближ. станции метро
this.do_metro = 0; // время до метро
this.do_metro_type = null; // до метро пешком/на траспорте
this.etazhnost_ot = null; // этажность дома квартиры, от
this.etazhnost_do = null; // этажность дома квартиры, до
this.etazhnost = 0; // не первый и не последний этаж
//this.order_type = 0; // тип оформления сделки
this.newbilding_date = null; // срок сдачи
this.ipoteka = 0; // ипотека
this.use_area_price = 0;
this.voen_ipoteka = 0; // воен. ипотека
this.subsidya = 0; // субсидия
this.mather_kapital = 0; // материнский капитал
this.house_type = 0; // тип дома
this.house_material = 0; // материал дома (тип стен)
this.build_year = null; // год постройки
this.opis = ''; // описание
this.comment = ''; // комментарий
this.is_active = 0; // флаг активности фильтра
this.telegram_notify = 0; // флаг уведомления в Телеграм
this.tax_number = null; //
this.legal_address = 0; //
this.etazh_ot = null; //
this.etazh_do = null; //
this.is_occupied = 0; //
this.layout_id = 0; //
this.wet_spots = 0; //
this.el_power_ot = null; //
this.el_power_do = null; //
this.commer_condition = 0; //
this.is_furniture = 0; //
this.commer_access = 0; //
this.parking_types = []; //
this.parking_id = []; //
this.parking_price = null; //
this.parking_price_free = 0; //
this.ceiling_height_ot = null; //
this.ceiling_height_do = null; //
this.column_grid = null; //
this.vat_type_id = 0; //
this.commerc_site = null; //
this.commerc_owned1 = 0; //
this.commerc_owned2 = 0; //
this.floor_material_id = 0; //
this.commerc_portal_id = 0; //
this.commerc_purpose = []; //
this.commerc_land_category_id = []; //
this.commerc_permitted_use_id = []; //
this.commerc_electricity_id = 0; //
this.can_electricity = 0; //
this.commerc_gas_id = 0; //
this.can_gas = 0; //
this.commerc_water_id = 0; //
this.can_water = 0; //
this.commerc_sewage_id = 0; //
this.can_sewage = 0; //
this.commerc_driveways = 0; //
this.commerc_year_ot = null; //
this.commerc_year_do = null; //
this.commerc_building_type_id = []; //
this.commerc_building_class_id = []; //
this.building_area_ot = null; //
this.building_area_do = null; //
this.commerc_houseline_type_id = []; //
this.commerc_building_category_id = 0; //
this.commerc_opened_id = []; //
this.commerc_building_ventilation = 0; //
this.commerc_building_conditioning = 0; //
this.commerc_building_heating = 0; //
this.commerc_building_fire = 0; //
this.garage_type_id = 0; //
this.garage_vid_id = 0; //
this.boks_vid_id = 0; //
this.commerc_status_id = 0; //
this.commerc_specifications = []; //
this.commerc_infrastructure = []; //
this.commerc_infrastructure1 = []; //
this.commerc_infrastructure2 = []; //
this.commerc_lift1 = null; //
this.lift1_carrying = null; //
this.commerc_lift2 = null; //
this.lift2_carrying = null; //
this.commerc_lift3 = null; //
this.lift3_carrying = null; //
this.commerc_crane1 = null; //
this.crane1_carrying = null; //
this.commerc_crane2 = null; //
this.crane2_carrying = null; //
this.commerc_crane3 = null; //
this.crane3_carrying = null; //
this.commerc_crane4 = null; //
this.crane4_carrying = null; //
this.geo = null; //
},
formatDate(input, short_year) {
if (typeof(input) === 'string') {
let datePart = input.match(/\d+/g),
year = (short_year == true) ? datePart[0].substring(2) : datePart[0],
month = datePart[1],
day = datePart[2];
return day + '.' + month + '.' + year;
}
return input;
},
// Проверка на пустоту
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;
}
},
openAutoSearchFiltr(reqId, filterId) {
this.baseSelectInit();
console.info({ reqId, filterId });
let userId = $('#session_user_id').val();
if (typeof filterId != "undefined" && typeof reqId != "undefined") {
$('#modalAutoSearchFiltr [name="user_id"]').val(userId);
$('#modalAutoSearchFiltr [name="req_id"]').val(reqId);
$('#modalAutoSearchFiltr [name="filter_id"]').val(filterId);
this.setData();
}
$('#modalAutoSearchFiltr_bg').fadeIn(500);
$('#modalAutoSearchFiltr').toggle(10);
$("body").addClass("lock");
},
// Закрытие модала параметров автопоиска
closeAutoSearchFiltr() {
this.clearFiltr();
$("#modalAutoSearchFiltr_bg").fadeOut(300);
$("#modalAutoSearchFiltr").toggle(100);
$("body").removeClass("lock");
},
resetAutoSearchMap() {
this.myMap = null;
this.objectManager = null;
this.mapGroup = null;
this.accessScroll = true;
this.styles = [];
this.polygons = [];
this.buttonClearMode = null;
this.buttonEditMode = null;
this.currentIndex = 0;
this.paintProcess = null;
},
clearPolygons() {
if (this.myMap && this.myMap.geoObjects) {
for (var i = 0; i <= this.polygons.length; i++) {
if (this.polygons[i]) {
this.myMap.geoObjects.remove(this.polygons[i]);
}
}
this.polygons = [];
if (this.objectManager) {
this.objectManager.removeAll();
}
}
},
addMapButtons() {
let _this = this;
// Создадим кнопку для очистки.
_this.buttonClearMode = new ymaps.control.Button({data: {content: 'Очистить'}, options: {maxWidth: 100, selectOnClick: false}});
_this.buttonClearMode.events.add('click', function () {
_this.clearPolygons();
});
_this.myMap.controls.add(_this.buttonClearMode);
// Создадим кнопку для выбора режима рисования
_this.buttonEditMode = new ymaps.control.Button({
data: {content: 'Выделение области'},
options: {maxWidth: 150}
});
_this.buttonEditMode.events.add('click', function (e) {
// Проверяем, находится ли кнопка в состоянии "Подтвердить"
if (_this.buttonEditMode.isSelected()) {
_this.buttonEditMode.data.set('content', 'Выделение области');
if (_this.paintProcess) {
_this.cleanupAfterDrawing();
}
} else {
_this.buttonEditMode.data.set('content', 'Подтвердить');
if (_this.polygons && _this.polygons.length < 4) {
if (_this.currentIndex == _this.styles.length - 1) {
_this.currentIndex = 0;
} else {
_this.currentIndex += 1;
}
if (!_this.paintProcess) {
_this.paintProcess = ymaps.ext.paintOnMap(_this.myMap, e, {style: _this.styles[_this.currentIndex]});
}
} else {
alert("Максимальное количество областей = 4");
}
}
});
_this.myMap.controls.add(_this.buttonEditMode);
},
addNewPolygon(coordinates) {
let _this = this;
var polygon = new ymaps.Polygon([coordinates], {}, _this.styles[_this.currentIndex]);
//polygon.description = '<button>Удалить</button>';
_this.polygons[_this.polygons.length] = polygon;
_this.myMap.geoObjects.add(polygon);
},
defineDrawOnMap() {
let _this = this;
ymaps.modules.define('ext.paintOnMap', ['meta', 'util.extend', 'pane.EventsPane', 'Event'], function (provide, meta, extend, EventsPane, Event) {
'use strict';
var EVENTS_PANE_ZINDEX = 500;
var DEFAULT_UNWANTED_BEHAVIORS = ['drag', 'scrollZoom'];
var DEFAULT_STYLE = {strokeColor: '#0000ff', strokeWidth: 1, strokeOpacity: 1};
var DEFAULT_TOLERANCE = 16;
var badFinishPaintingCall = function () {
throw new Error('(ymaps.ext.paintOnMap) некорректный вызов PaintingProcess#finishPaintingAt. Рисование уже завершено.');
};
function paintOnMap(map, positionOrEvent, config) {
config = config || {};
var style = extend(DEFAULT_STYLE, config.style || {});
var unwantedBehaviors = config.unwantedBehaviors === undefined ?
DEFAULT_UNWANTED_BEHAVIORS : config.unwantedBehaviors;
var pane = new EventsPane(map, {
css: {position: 'absolute', width: '100%', height: '100%'},
zIndex: EVENTS_PANE_ZINDEX + 50,
transparent: true
});
map.panes.append('ext-paint-on-map', pane);
if (unwantedBehaviors) {
map.behaviors.disable(unwantedBehaviors);
}
// Создаём canvas-элемент.
var canvas = document.createElement('canvas');
var ctx2d = canvas.getContext('2d');
var rect = map.container.getParentElement().getBoundingClientRect();
canvas.width = rect.width;
canvas.height = rect.height;
ctx2d.globalAlpha = style.strokeOpacity;
ctx2d.strokeStyle = style.strokeColor;
ctx2d.lineWidth = style.strokeWidth;
canvas.style.width = '100%';
canvas.style.height = '100%';
pane.getElement().appendChild(canvas);
var firstPosition = positionOrEvent ? toPosition(positionOrEvent) : null;
var coordinates = firstPosition ? [firstPosition] : [];
var bounds = map.getBounds();
var latDiff = bounds[1][0] - bounds[0][0];
var lonDiff = bounds[1][1] - bounds[0][1];
canvas.onmousedown = function (e) {
_this.mouseIsDraw = true;
}
canvas.onmouseup = function (e) {
_this.mouseIsDraw = false;
}
canvas.onmousemove = function (e) {
if (!_this.mouseIsDraw || !_this.buttonEditMode.isSelected()) {
return;
}
coordinates.push([e.offsetX, e.offsetY]);
ctx2d.clearRect(0, 0, canvas.width, canvas.height);
ctx2d.beginPath();
ctx2d.moveTo(coordinates[0][0], coordinates[0][1]);
for (var i = 1; i < coordinates.length; i++) {
ctx2d.lineTo(coordinates[i][0], coordinates[i][1]);
}
ctx2d.stroke();
}.bind(this);
// Создаём косвенное обращение, чтобы не сдерживать сборщик мусора.
var paintingProcess = {
finishPaintingAt: function (positionOrEvent) {
paintingProcess.finishPaintingAt = badFinishPaintingCall;
// Получаем координаты, прежде чем удалить пейн.
if (positionOrEvent) {
coordinates.push(toPosition(positionOrEvent));
}
map.panes.remove(pane);
if (unwantedBehaviors) {
map.behaviors.enable(unwantedBehaviors);
}
var tolerance = config.tolerance === undefined ? DEFAULT_TOLERANCE : Number(config.tolerance);
if (tolerance) {
coordinates = simplify(coordinates, tolerance);
}
// Преобразовываем координаты canvas-элемента в геодезические координаты.
return coordinates.map(function (x) {
var lon = bounds[0][1] + (x[0] / canvas.width) * lonDiff;
var lat = bounds[0][0] + (1 - x[1] / canvas.height) * latDiff;
return meta.coordinatesOrder === 'latlong' ? [lat, lon] : [lon, lat];
});
}
};
return paintingProcess;
}
function toPosition(positionOrEvent) {
return positionOrEvent instanceof Event ?
[positionOrEvent.get('offsetX'), positionOrEvent.get('offsetY')] :
positionOrEvent;
}
function simplify(coordinates, tolerance) {
var toleranceSquared = tolerance * tolerance;
var simplified = [coordinates[0]];
var prev = coordinates[0];
for (var i = 1; i < coordinates.length; i++) {
var curr = coordinates[i];
if (Math.pow(prev[0] - curr[0], 2) + Math.pow(prev[1] - curr[1], 2) > toleranceSquared) {
simplified.push(curr);
prev = curr;
}
}
return simplified;
}
provide(paintOnMap);
});
ymaps.ready(['ext.paintOnMap']).then(function () {
// Опции многоугольника или линии.
_this.styles = [
{
strokeColor: '#ff0000',
strokeOpacity: 0.6,
strokeWidth: 2,
fillColor: '#ff0000',
fillOpacity: 0.3
}
];
_this.currentIndex = 0;
if (_this.mapGroup == null)
_this.mapGroup = _this.myMap.events.group();
_this.mapGroup.removeAll();
// Подпишемся на событие нажатия кнопки мыши.
_this.mapGroup.add('mousedown', function (e) {
console.info(e);
// _this.paintProcess = null;
if (_this.buttonEditMode.isSelected()) {
if(_this.polygons && _this.polygons.length < 4) {
if (_this.currentIndex == _this.styles.length - 1) {
_this.currentIndex = 0;
} else {
_this.currentIndex += 1;
}
_this.paintProcess = ymaps.ext.paintOnMap(_this.myMap, e, {style: _this.styles[_this.currentIndex]});
} else {
_this.mouseIsDraw = false;
alert("Максимальное количество областей не более 4-х.");
}
}
});
// Подпишемся на событие отпускания кнопки мыши.
_this.mapGroup.add('mouseup', function (e) {
console.info(e);
if (_this.paintProcess && _this.buttonEditMode.isSelected()) {
// Получаем координаты отрисованного контура.
var coordinates = _this.paintProcess.finishPaintingAt(e);
_this.paintProcess = null;
if (coordinates && coordinates.length > 2) {
// В зависимости от состояния кнопки добавляем на карту многоугольник или линию с полученными координатами.
_this.addNewPolygon(coordinates);
} else {
alert("Количество вершин для области меньше 3-х, пожалуйста перерисуйте многоугольник более точнее.");
}
}
});
// Добавляем на карту уже ранее сохраненные гео-области
if (!this.isEmpty(_this.geo)) {
let max_lat = 0;
let max_lng = 0;
_this.geo.forEach((poly) => {
var i = 0
let coordinates = [];
if (poly) {
let points = poly.split(',');
while (i < points.length) {
if (!_this.isEmpty(points[i])) {
let lat = points[i];
if (!_this.isEmpty(points[i+1])) {
let lng = points[i + 1];
coordinates.push([Number(lat), Number(lng)]);
if (Number(lat) > max_lat)
max_lat = Number(lat);
if (Number(lng) > max_lng)
max_lng = Number(lng);
}
i++;
}
i++;
}
if (!_this.isEmpty(coordinates)) {
_this.addNewPolygon(coordinates);
}
}
});
if (max_lat != 0 && max_lng != 0) {
_this.myMap.setCenter([max_lat, max_lng]);
}
}
}).catch(console.error);
},
initAutoSearchMap() {
var center_cords = [59.929100, 30.311602];
if (this.myMap) {
if (this.myMap && this.objectManager) {
if (this.polygons) {
for (var i = 0; i <= this.polygons.length; i++) {
if (this.polygons[i]) {
this.myMap.geoObjects.remove(this.polygons[i]);
}
}
}
this.polygons = [];
if (this.objectManager) {
this.objectManager.removeAll();
}
}
}
this.objectManager = new ymaps.ObjectManager({
clusterize: false,
clusterDisableClickZoom: true,
clusterOpenBalloonOnClick: false,
geoObjectOpenBalloonOnClick: false,
clusterIconColor: "#43a047",
iconColor: "#43a047"
});
this.myMap = new ymaps.Map('autoSearchMap', {
center: center_cords,
zoom: 12,
controls: ['zoomControl']
}, {
fullscreenZIndex : 999999999
});
this.objectManager.objects.options.set('iconColor', '#43a047');
this.myMap.geoObjects.add(this.objectManager);
this.myMap.events.add('boundschange', function (e) {
this.accessScroll = true;
});
this.objectManager.removeAll();
let _this = this;
if (_this.isEmpty(_this.geo) && $('#asfiltr-object-regions').val()) {
let region_id = $('#asfiltr-object-regions').val();
if (Array.isArray(region_id) && region_id.length > 1) {
region_id.splice(1);
}
let region = $('#asfiltr-object-regions [value="'+region_id+'"]').text();
console.info(region);
ymaps.geocode(region, {
results: 1
}).then(function (res) {
center_cords = res.geoObjects.get(0).geometry.getCoordinates();
_this.myMap.setCenter(center_cords, 12);
});
}
this.defineDrawOnMap();
ymaps.ready(['ext.paintOnMap']).then(function () {
_this.addMapButtons();
}).catch(console.error);
this.clearPolygons();
$('#modalAutoSearchMap .modal__body').addClass('is-active');
$('#autoSearchMap > ymaps:not(:last-child)').remove();
$('#modalAutoSearchMap_bg').fadeIn(500);
$('#modalAutoSearchMap').toggle(10);
$("body").addClass("lock");
},
asyncSetData(filter_id, req_id, user_id) {
return new Promise((resolve, reject) => {
this.setData(filter_id, req_id, user_id);
setTimeout(() => {
resolve(true);
}, 500);
})
},
openAutoSearchMap(filter_id, req_id, user_id) {
if (typeof ymaps == 'undefined') {
var elem = document.createElement('script');
elem.type = 'text/javascript';
elem.src = 'https://api-maps.yandex.ru/2.1/?apikey=692f0a05-cb88-4158-88b9-06bc0dc93004&lang=ru_RU&onload=getYaMap';
document.body.appendChild(elem);
}
if (!this.isEmpty(filter_id) && !this.isEmpty(req_id) && !this.isEmpty(user_id)) {
this.user_id = user_id;
this.req_id = req_id;
this.id = filter_id;
this.isOpenFromReq = true;
this.asyncSetData(filter_id, req_id, user_id).then(() => {
setTimeout(() => this.initAutoSearchMap(), 500);
});
} else {
setTimeout(() => this.initAutoSearchMap(), 500);
}
},
closeAutoSearchMap() {
this.resetAutoSearchMap();
this.getObjectRayons(this.region, this.rayons);
this.getMetroStations(this.region, this.metro_stations);
$("#modalAutoSearchMap_bg").fadeOut(300);
$("#modalAutoSearchMap").toggle(100);
$("body").removeClass("lock");
},
saveAutoSearchMap() {
this.geo = [];
if (this.polygons && this.polygons.length) {
let {geoArr1, geoArr2, geoArr3, geoArr4} = [];
if (this.polygons[0])
geoArr1 = this.polygons[0].geometry.getCoordinates();
if (this.polygons[1])
geoArr2 = this.polygons[1].geometry.getCoordinates();
if (this.polygons[2])
geoArr3 = this.polygons[2].geometry.getCoordinates();
if (this.polygons[3])
geoArr4 = this.polygons[3].geometry.getCoordinates();
let coordsToScript1 = "";
let coordsToScript2 = "";
let coordsToScript3 = "";
let coordsToScript4 = "";
if (geoArr1 && geoArr1.length) {
if (geoArr1[0] && geoArr1[0].length) {
for (var j = 0; j <= geoArr1[0].length; j++) {
if (geoArr1[0][j] && geoArr1[0][j].length) {
if (coordsToScript1) {
coordsToScript1 += ","
}
coordsToScript1 += geoArr1[0][j][0] + "," + geoArr1[0][j][1];
}
}
}
}
if (geoArr2 && geoArr2.length) {
if (geoArr2[0] && geoArr2[0].length) {
for (var j = 0; j <= geoArr2[0].length; j++) {
if (geoArr2[0][j] && geoArr2[0][j].length) {
if (coordsToScript2) {
coordsToScript2 += ","
}
coordsToScript2 += geoArr2[0][j][0] + "," + geoArr2[0][j][1];
}
}
}
}
if (geoArr3 && geoArr3.length) {
if (geoArr3[0] && geoArr3[0].length) {
for (var j = 0; j <= geoArr3[0].length; j++) {
if (geoArr3[0][j] && geoArr3[0][j].length) {
if (coordsToScript3) {
coordsToScript3 += ","
}
coordsToScript3 += geoArr3[0][j][0] + "," + geoArr3[0][j][1];
}
}
}
}
if (geoArr4 && geoArr4.length) {
if (geoArr4[0] && geoArr4[0].length) {
for (var j = 0; j <= geoArr4[0].length; j++) {
if (geoArr4[0][j] && geoArr4[0][j].length) {
if (coordsToScript4) {
coordsToScript4 += ","
}
coordsToScript4 += geoArr4[0][j][0] + "," + geoArr4[0][j][1];
}
}
}
}
if (!this.isEmpty(coordsToScript1))
this.geo.push(coordsToScript1);
if (!this.isEmpty(coordsToScript2))
this.geo.push(coordsToScript2);
if (!this.isEmpty(coordsToScript3))
this.geo.push(coordsToScript3);
if (!this.isEmpty(coordsToScript4))
this.geo.push(coordsToScript4);
let geo_data = {
"poly1": (!this.isEmpty(this.geo[0])) ? this.geo[0] : null,
"poly2": (!this.isEmpty(this.geo[1])) ? this.geo[1] : null,
"poly3": (!this.isEmpty(this.geo[2])) ? this.geo[2] : null,
"poly4": (!this.isEmpty(this.geo[3])) ? this.geo[3] : null
};
if (this.isOpenFromReq) {
this.saveShortField(this.id, 'geo', {
geo: geo_data
});
this.$once('edit_short_field_value', function(value) {
let row = $('#req_form .params-list tr[data-key="' + 'geo' + '"]');
if (row && value !== null) {
row.find('td[data-key="value"]').data('origin', value);
row.find('td[data-key="value"]').html(value);
}
});
}
}
this.isOpenFromReq = false;
this.closeAutoSearchMap();
},
arrayChunk(array, length) {
let chunked = [],
i = 0,
n = array.length;
while (i < n) {
chunked.push(array.slice(i, i += length));
}
return chunked
},
baseSelectInit() {
this.getObjectTypes();
this.getRoomsCounts();
this.getObjectSources();
this.getCategoryTypes();
this.getObjectRentSrok();
this.getObjectRegions();
this.getObjectRayons(this.regions);
//this.getOrderTypes();
this.getHouseTypes();
this.getHouseMaterials();
this.getBuildYears();
},
commerceCategoryInit(object_type) {
if (typeof object_type == "undefined")
object_type = this.object_type;
if (object_type == 4 || object_type == '4') {
this.getLegalAddress();
this.getIsOccupied();
this.getLayoutId();
this.getWetSpots();
this.getCommerCondition();
this.getIsFurniture();
this.getCommerAccess();
this.getParkingTypes();
this.getParkingId();
this.getVatTypeId();
this.getFloorMaterials();
this.getCommercPortalId();
this.getCommercPurpose();
this.getCommercLandCategoryId();
this.getCommercPrmittedUseId();
this.getCommercElectricityId();
this.getCommercGasId();
this.getCommercWaterId();
this.getCommercSewageId();
this.getCommercDriveways();
this.getCommercBuildingTypeId();
this.getCommercBuildingClassId();
this.getCommercHouselineTypeId();
this.getCommercBuildingCategoryId();
this.getCommercOpenedId();
this.getCommercBuildingVentilation();
this.getCommercBuildingConditioning();
this.getCommercBuildingHeating();
this.getCommercBuildingFire();
this.getGarageTypeId();
this.getGarageVidId();
this.getBoksVidId();
this.getCommercStatusId();
this.getCommercSpecifications();
this.getCommercInfrastructure();
this.getCommercInfrastructure1();
this.getCommercInfrastructure2();
}
}
},
mounted() {
this.commerceCategoryInit(this.object_type);
},
computed: {
selectedCategoryTypes() {
return Object.values(this.categoryTypes).filter(category => category.selected).map(category => parseInt(category.value))
},
getRegionsCount() {
return this.objectRegions && Object.keys(this.objectRegions).length;
},
getRayonsCount() {
return this.objectRayons && Object.keys(this.objectRayons).length;
},
getMetroCount() {
return this.metroStations && Object.keys(this.metroStations).length;
},
},
created: function() {
}
});
}
//Параметры автопоиска
if ($('#modalAutoSearchResults').length > 0) {
var autosearch_objs = new Vue({
el: '#modalAutoSearchResults',
components: {},
data() {
return {
req_id: 0,
filter_id: 0,
filter_info: '',
objectsMatchList: [],
objectsMatchCount: 0,
objectsMatchTotal: 0,
// objectsSimilarList: [],
objectsSimilarCount: 0,
objectsSimilarTotal: 0,
objectsFavouredList: [],
objectsFavouredCount: 0,
errors: '',
objectsViewedIds: [],
//objectsIgnoredIds: [],
objectsFavouredIds: [],
objectsSendedIds: [],
axios_processed: false,
search_processed: false,
isPreloader: 1,
order: {
company: 0,
price: 0,
not_viewed: 0,
not_sended: 0,
with_commission: 0,
with_photo: 0,
},
pagination: {
match: {
pages: 0,
offset: 0,
current: 1
},
similar: {
pages: 0,
offset: 0,
current: 1
},
favoured: {
pages: 0,
offset: 0,
current: 1
},
}
}
},
methods: {
addItemToViewed(filter_id, object_id) {
if (typeof filter_id !== "undefined")
this.filter_id = parseInt(filter_id);
if (typeof object_id !== "undefined") {
object_id = parseInt(object_id);
let ref = this;
let timeoutID = null;
setTimeout(function() {
if (!ref.axios_processed && (ref.objectsViewedIds.indexOf(object_id) == -1)) {
ref.axios_processed = true;
console.log({ filter_id, object_id });
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'set_object_viewed',
user_id: $("#session_user_id").val(),
filter_id: ref.filter_id,
object_id: object_id,
}).then((response) => {
ref.axios_processed = false;
clearTimeout(timeoutID);
if (response.data.success) {
ref.objectsViewedIds.push(object_id);
if (object_id in ref.objectsMatchList && ref.objectsMatchCount >= 1)
ref.objectsMatchCount--;
// if (object_id in ref.objectsSimilarList && ref.objectsSimilarCount >= 1)
// ref.objectsSimilarCount--;
if (object_id in ref.objectsFavouredList && ref.objectsFavouredCount >= 1)
ref.objectsFavouredCount--;
ref.$emit('change_autosearch_counters', ref.filter_id, {
match: ref.objectsMatchCount,
similar: ref.objectsSimilarCount,
favoured: ref.objectsFavouredCount,
total: (ref.objectsMatchCount)
});
let viewed_label = $('<span class="viewed_label">Просмотрено</span>');
$('#modalAutoSearchResults #item' + object_id + ' .actions-menu__icons').prepend(viewed_label);
viewed_label.addClass('show');
}
}).catch(function(error) {
ref.axios_processed = false;
clearTimeout(timeoutID);
if (error)
console.debug(error);
});
}
}, 1200);
}
},
bindViewedEvents(listElement, filter_id) {
let ref = this;
$(listElement).on('click, focus, blur, mousemove', '.jw__object.item', function() {
let object_id = $(this).attr('id').replace('item', '');
ref.addItemToViewed(filter_id, object_id);
});
$(listElement).scroll(function() {
$(this).find('.jw__object.item').each(function() {
let targetPosition = {
top: window.pageYOffset + this.getBoundingClientRect().top,
left: window.pageXOffset + this.getBoundingClientRect().left,
right: window.pageXOffset + this.getBoundingClientRect().right,
bottom: window.pageYOffset + this.getBoundingClientRect().bottom
},
windowPosition = {
top: window.pageYOffset,
left: window.pageXOffset,
right: window.pageXOffset + document.documentElement.clientWidth,
bottom: window.pageYOffset + document.documentElement.clientHeight
};
if (targetPosition.bottom > windowPosition.top && // Если позиция нижней части элемента больше позиции верхней чайти окна, то элемент виден сверху
targetPosition.top < windowPosition.bottom && // Если позиция верхней части элемента меньше позиции нижней чайти окна, то элемент виден снизу
targetPosition.right > windowPosition.left && // Если позиция правой стороны элемента больше позиции левой части окна, то элемент виден слева
targetPosition.left < windowPosition.right) { // Если позиция левой стороны элемента меньше позиции правой чайти окна, то элемент виден справа
let object_id = $(this).attr('id').replace('item', '');
ref.addItemToViewed(filter_id, object_id);
}
});
});
},
addItemToFavour(filter_id, object_id) {
let ref = this;
if (typeof filter_id !== "undefined")
ref.filter_id = parseInt(filter_id);
if (typeof object_id !== "undefined") {
ref.isPreloader = 1;
object_id = parseInt(object_id);
console.debug({ filter_id, object_id });
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'add_object_to_favour',
user_id: $("#session_user_id").val(),
filter_id: ref.filter_id,
object_id: object_id
}).then((response) => {
ref.isPreloader = 0;
if (response.data.success) {
console.debug($('#modalAutoSearchResults #item' + object_id + ' .object-content__name .ti-heart').attr('class'));
let heart = $('#modalAutoSearchResults #item' + object_id + ' .object-content__name .ti-heart');
if (heart.hasClass('active'))
heart.removeClass('active');
else
heart.addClass('active');
ref.error = response.data.error;
ref.objectsFavouredList = response.data.favoured || [];
ref.objectsFavouredCount = parseInt(response.data.total) || 0;
/***/
let page = parseInt($('#objectsFavour .pagination').data('current')) || 1;
let offset = (page * parseInt(response.data.perpage));
ref.pagination.favoured.pages = Math.ceil(ref.objectsFavouredCount / parseInt(response.data.perpage));
ref.pagination.favoured.offset = offset;
ref.pagination.favoured.current = Math.round(offset / parseInt(response.data.perpage));
/***/
if (object_id in ref.objectsFavouredIds) {
ref.objectsFavouredIds.remove(object_id);
} else {
ref.objectsFavouredIds.push(object_id);
}
setTimeout(function() {
$(ref.$refs.favouredObjectsList).find('.fotorama').fotorama();
}, 1000);
}
}).catch(function(error) {
ref.isPreloader = 0;
if (error)
console.debug(error);
});
}
},
addItemToExclude(filter_id, object_id) {
if (typeof filter_id !== "undefined")
this.filter_id = parseInt(filter_id);
if (typeof object_id !== "undefined") {
object_id = parseInt(object_id);
console.log({ filter_id, object_id });
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'add_object_to_ignored',
user_id: $("#session_user_id").val(),
filter_id: filter_id,
object_id: object_id
}).then((response) => {
if (response.data.success) {
if (object_id in this.objectsMatchList) {
if (this.objectsMatchCount >= 1)
this.objectsMatchCount--;
$(this.$refs.matchObjectsList).find('#item' + object_id).remove();
delete this.objectsMatchList[object_id];
}
// if (object_id in this.objectsSimilarList) {
// if (this.objectsSimilarCount >= 1)
// this.objectsSimilarCount--;
// $(this.$refs.similarObjectsList).find('#item' + object_id).remove();
// delete this.objectsSimilarList[object_id];
// }
if (object_id in this.objectsFavouredList) {
if (this.objectsFavouredCount >= 1)
this.objectsFavouredCount--;
$(this.$refs.favouredObjectsList).find('#item' + object_id).remove();
delete this.objectsFavouredList[object_id];
}
this.$emit('change_autosearch_counters', this.filter_id, {
match: this.objectsMatchCount,
similar: this.objectsSimilarCount,
favoured: this.objectsFavouredCount,
total: (this.objectsMatchCount + this.objectsSimilarCount)
});
}
}).catch(function(error) {
if (error)
console.debug(error);
});
}
},
getResults(filter_id, section, offset) {
this.isPreloader = 1;
if (typeof filter_id !== "undefined")
this.filter_id = filter_id;
if (typeof offset == "undefined")
offset = 0;
this.axios_processed = true;
return axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_results',
user_id: $("#session_user_id").val(),
filter_id: this.filter_id,
order: this.order,
section: section,
offset: offset
}).then((response) => {
console.debug(response.data);
getClientsForObjects();
if (response.data.success) {
let total = parseInt(response.data.total) || 0;
let count = parseInt(response.data.count) || 0;
/*if (total > 0)
this.isPreloader = 0;*/
this.axios_processed = false;
return {
req_id: response.data.req_id || 0,
filter_id: response.data.filter_id || 0,
objects: response.data.objects || [],
count: count,
total: total,
perpage: parseInt(response.data.perpage) || 10,
error: response.data.error,
meta: {
viewed_id: response.data.viewed_id || [],
//ignored_id: response.data.ignored_id || [],
favoured_id: response.data.favoured_id || []
}
};
}
}).catch(function(error) {
if (error)
console.debug(error);
this.isPreloader = 0;
this.axios_processed = false;
return {
objects: [],
count: 0,
total: 0,
error: error
};
});
},
setData(filter_id) {
this.isPreloader = 1;
if (typeof filter_id !== "undefined")
this.filter_id = filter_id;
let ref = this;
let match = this.getResults(filter_id, 'match');
match.then(function(result) {
console.debug(result);
if (typeof result != "undefined") {
ref.req_id = result.req_id;
ref.filter_id = result.filter_id;
ref.objectsMatchList = result.objects;
ref.objectsMatchCount = parseInt(result.count);
ref.objectsMatchTotal = parseInt(result.total);
//ref.errors.push(result.error);
ref.objectsViewedIds = result.meta.viewed_id;
ref.pagination.match.pages = Math.round(ref.objectsMatchTotal / parseInt(result.perpage));
ref.pagination.match.offset = 0;
ref.pagination.match.current = 1;
if (ref.objectsMatchTotal > 0) {
let tabs = $('#modalAutoSearchResults .jw-tabs');
tabs.find('li').removeClass('active');
tabs.find('#objectsMatchTab').addClass('active');
tabs.find('.tabs__content').hide();
tabs.find('#objectsMatch').show();
}
setTimeout(function() {
if (!ref.search_processed && parseInt(result.total) == 0 && ref.objectsSimilarTotal == 0) {
ref.search_processed = true;
ref.restartSearch(filter_id, 'match');
} else {
if (ref.objectsMatchTotal > 0)
ref.isPreloader = 0;
$(ref.$refs.matchObjectsList).find('.fotorama').fotorama();
}
}, 1000);
}
});
let similar = this.getResults(filter_id, 'similar');
similar.then(function(result) {
console.debug(result);
if (typeof result != "undefined") {
ref.objectsSimilarList = result.objects;
ref.objectsSimilarCount = parseInt(result.count);
ref.objectsSimilarTotal = parseInt(result.total);
//ref.errors.push(result.error);
ref.pagination.similar.pages = Math.round(ref.objectsSimilarTotal / parseInt(result.perpage));
ref.pagination.similar.offset = 0;
ref.pagination.similar.current = 1;
if (ref.objectsMatchTotal == 0 && ref.objectsSimilarTotal > 0) {
let tabs = $('#modalAutoSearchResults .jw-tabs');
tabs.find('li').removeClass('active');
tabs.find('#objectsSimilarTab').addClass('active');
tabs.find('.tabs__content').hide();
tabs.find('#objectsSimilar').show();
}
setTimeout(function() {
/*if (!ref.search_processed && ref.objectsSimilarCount == 0 && parseInt(result.total) == 0) {
ref.search_processed = true;
ref.restartSearch(filter_id, 'similar');
} else {*/
if (ref.objectsSimilarTotal > 0)
ref.isPreloader = 0;
$(ref.$refs.similarObjectsList).find('.fotorama').fotorama();
//}
}, 1000);
}
});
let favoured = this.getResults(filter_id, 'favoured');
favoured.then(function(result) {
console.debug(result);
if (typeof result != "undefined") {
ref.objectsFavouredList = result.objects;
ref.objectsFavouredCount = parseInt(result.total);
//ref.errors.push(result.error);
ref.objectsFavouredIds = result.meta.favoured_id;
ref.objectsSendedIds = result.meta.sended_id;
ref.pagination.favoured.pages = Math.ceil(ref.objectsFavouredCount / parseInt(result.perpage));
ref.pagination.favoured.offset = 0;
ref.pagination.favoured.current = 1;
console.debug(ref);
if (ref.objectsMatchTotal != 0 || parseInt(result.total) != 0) {
setTimeout(function() {
if (ref.objectsFavouredCount > 0)
ref.isPreloader = 0;
$(ref.$refs.favouredObjectsList).find('.fotorama').fotorama();
}, 1000);
}
}
});
setTimeout(function() {
this.isPreloader = 0;
}, 2000);
return true;
},
openAutoSearchResults(filter_id, req_id) {
if (typeof filter_id !== "undefined")
this.filter_id = filter_id;
if (typeof req_id !== "undefined")
this.req_id = req_id;
if (this.filter_id) {
this.clearData();
$(this.$refs.objectsMatchContent).empty();
$(this.$refs.objectsSimilarContent).empty();
$(this.$refs.objectsFavouredContent).empty();
console.debug(this.filter_id, this.req_id);
if (this.setData(this.filter_id)) {
this.getFilterInfo(this.filter_id);
$('#modalAutoSearchResults_bg').fadeIn(500);
$('#modalAutoSearchResults').toggle(300);
$("body").addClass("lock");
let tabs = $('#modalAutoSearchResults .jw-tabs');
tabs.find('li').removeClass('active');
tabs.find('#objectsMatchTab').addClass('active');
tabs.find('.tabs__content').hide();
tabs.find('#objectsMatch').show();
let ref = this;
autosearch_filtr.$once('add_edit_autosearch_filter', function(filter_id) {
ref.getFilterInfo(filter_id);
});
$(this.$refs.clearResultsBtn).unbind('click');
this.bindViewedEvents(this.$refs.matchObjectsList, filter_id);
this.bindViewedEvents(this.$refs.similarObjectsList, filter_id);
}
}
},
closeAutoSearchResults() {
$('#modalAutoSearchResults_bg').fadeOut(300);
$('#modalAutoSearchResults').toggle(100);
$("body").removeClass("lock");
},
goToPage(section, page) {
this.isPreloader = 1;
let ref = this;
let offset = (page * 10);
let results = this.getResults(ref.filter_id, section, (offset - 10));
results.then(function(result) {
console.debug(result);
if (typeof result != "undefined") {
if (section == 'match') {
ref.objectsMatchList = result.objects;
ref.objectsMatchCount = parseInt(result.count);
ref.objectsMatchTotal = parseInt(result.total);
ref.pagination.match.pages = Math.ceil(ref.objectsMatchTotal / parseInt(result.perpage));
ref.pagination.match.offset = offset;
ref.pagination.match.current = Math.round(offset / parseInt(result.perpage));
console.debug(ref.pagination.match);
$(ref.$refs.matchObjectsList).animate({
scrollTop: 0
}, 300);
setTimeout(function() {
ref.isPreloader = 0;
$(ref.$refs.matchObjectsList).find('.fotorama').fotorama();
}, 1000);
} else if (section == 'similar') {
// ref.objectsSimilarList = result.objects;
ref.objectsSimilarCount = parseInt(result.count);
ref.objectsSimilarTotal = parseInt(result.total);
ref.pagination.similar.pages = Math.ceil(ref.objectsSimilarTotal / parseInt(result.perpage));
ref.pagination.similar.offset = offset;
ref.pagination.similar.current = Math.round(offset / parseInt(result.perpage));
console.debug(ref.pagination.similar);
$(ref.$refs.similarObjectsList).animate({
scrollTop: 0
}, 300);
setTimeout(function() {
ref.isPreloader = 0;
$(ref.$refs.similarObjectsList).find('.fotorama').fotorama();
}, 1000);
} else if (section == 'favoured') {
ref.objectsFavouredList = result.objects;
ref.objectsFavouredCount = parseInt(result.total);
ref.pagination.favoured.pages = Math.ceil(ref.objectsFavouredCount / parseInt(result.perpage));
ref.pagination.favoured.offset = offset;
ref.pagination.favoured.current = Math.round(offset / parseInt(result.perpage));
console.debug(ref.pagination.favoured);
$(ref.$refs.favouredObjectsList).animate({
scrollTop: 0
}, 300);
setTimeout(function() {
ref.isPreloader = 0;
$(ref.$refs.favouredObjectsList).find('.fotorama').fotorama();
}, 1000);
}
}
});
},
getPagination(section, page, all_pages) {
console.debug({ section, page, all_pages });
let pagination = '';
let prev, next, page_from, page_to = 0;
if (page == 1) {
pagination += '<li class="active"><a href="javascript:{};" onclick="goToPageResults(\'' + section + '\', 1)">1</a></li>';
} else {
prev = page - 1;
pagination += '<li><a href="javascript:{};" onclick="goToPageResults(\'' + section + '\', ' + prev + ')">&laquo;</a></li>';
pagination += '<li><a href="javascript:{};" onclick="goToPageResults(\'' + section + '\', 1)">1</a></li>';
}
if (all_pages > 8) {
if (page > 4) {
page_from = page - 3;
pagination += '<li><span>...</span></li>';
} else {
page_from = 2;
}
if (page < all_pages - 4) {
page_to = page + 3;
} else {
page_to = all_pages;
}
} else {
page_from = 2;
page_to = all_pages;
}
for (let i = page_from; i < page_to; i++) {
let class_name = '';
if (i == page)
class_name = "active";
pagination += '<li class="' + class_name + '"><a href="javascript:{};" onclick="goToPageResults(\'' + section + '\', ' + i + ')">' + i + '</a></li>';
}
if (all_pages > 5 && page < all_pages - 4) {
pagination += '<li><span>...</span></li>';
}
if (page == all_pages) {
pagination += '<li class="active" ><a href="javascript:{};" onclick="goToPageResults(\'' + section + '\', ' + all_pages + ')">' + all_pages + '</a></li>';
} else {
pagination += '<li><a href="javascript:{};" onclick="goToPageResults(\'' + section + '\', ' + all_pages + ')">' + all_pages + '</a></li>';
next = page + 1;
pagination += '<li><a href="javascript:{};" onclick="goToPageResults(\'' + section + '\', ' + next + ')">&raquo;</a></li>';
}
return '<ul class="pagination" style="display: inline-block;">' + pagination + '</ul><div class="clear"></div>';
},
updateResults() {
this.isPreloader = 1;
let section = 'match';
if ($('#modalAutoSearchResults #objectsMatch').is(':visible'))
section = 'match';
else if ($('#modalAutoSearchResults #objectsSimilar').is(':visible'))
section = 'similar';
else if ($('#modalAutoSearchResults #objectsFavour').is(':visible'))
section = 'favoured';
this.goToPage(section, 1);
},
clearData() {
this.isPreloader = 1;
this.objectsMatchList = [];
this.objectsMatchCount = 0;
this.objectsMatchTotal = 0;
// this.objectsSimilarList = [];
this.objectsSimilarCount = 0;
this.objectsSimilarTotal = 0;
this.objectsFavouredList = [];
this.objectsFavouredCount = 0;
this.errors = '';
this.objectsFavouredIds = [];
this.objectsSendedIds = [];
this.axios_processed = false;
this.order = {
company: 0,
price: 0,
not_viewed: 0,
not_sended: 0,
with_commission: 0,
with_photo: 0,
},
this.pagination = {
match: {
pages: 0,
offset: 0,
current: 1
},
similar: {
pages: 0,
offset: 0,
current: 1
},
favoured: {
pages: 0,
offset: 0,
current: 1
},
};
},
clearAllResults(filter_id, event) {
if (confirm('Вы действительно хотите удалить все результаты поиска? \r\nЭто также приведёт к очистке списка избранных объектов.')) {
if (typeof filter_id !== "undefined") {
this.filter_id = parseInt(filter_id);
filter_id = parseInt(filter_id);
console.log({ filter_id });
this.isPreloader = 1;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'clear_results',
user_id: $("#session_user_id").val(),
filter_id: filter_id
}).then((response) => {
if (response.data.success) {
this.clearData();
$(this.$refs.matchObjectsList).find('.item').remove();
$(this.$refs.similarObjectsList).find('.item').remove();
$(this.$refs.favouredObjectsList).find('.item').remove();
this.$emit('change_autosearch_counters', this.filter_id, {
match: this.objectsMatchCount,
similar: this.objectsSimilarCount,
favoured: this.objectsFavouredCount,
total: (this.objectsMatchCount + this.objectsSimilarCount)
});
this.isPreloader = 0;
//this.closeAutoSearchResults();
}
}).catch(function(error) {
this.isPreloader = 0;
if (error)
console.debug(error);
});
}
}
},
restartSearch(filter_id, section, event) {
let ref = this;
if (typeof filter_id !== "undefined") {
this.filter_id = parseInt(filter_id);
console.log({ filter_id, section });
this.isPreloader = 1;
this.search_processed = true;
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'restart_search',
user_id: $("#session_user_id").val(),
filter_id: ref.filter_id
}).then((response) => {
ref.search_processed = false;
ref.clearData();
ref.setData();
setTimeout(function() {
ref.isPreloader = 0;
console.log(ref.objectsMatchList);
console.log(ref.objectsMatchCount);
}, 2000);
}).catch(function(error) {
ref.isPreloader = 0;
ref.search_processed = false;
if (error)
console.debug(error);
});
}
},
//Открыть редактирование параметров автопоиска
openAutoSearchFiltr(req_id, filter_id) {
if (typeof req_id == "undefined")
req_id = this.req_id;
if (typeof filter_id == "undefined")
filter_id = this.filter_id;
autosearch_filtr.openAutoSearchFiltr(req_id, filter_id);
},
getFilterInfo() {
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_filter_info',
user_id: $("#session_user_id").val(),
filter_id: this.filter_id
}).then((response) => {
this.filter_info = response.data.html;
}).catch(function(error) {
if (error)
console.debug(error);
});
},
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() {},
computed: {},
created: function() {}
});
}
//Заявки по автопоиску
if ($('#modalAutoSearchObjectReq').length > 0) {
var autosearch_req = new Vue({
el: '#modalAutoSearchObjectReq',
components: {},
data() {
return {
req: [],
axios_processed: false,
isPreloader: 0,
user_id: $("#session_user_id").val(),
count: 0,
pagination: {
requisitions: {
pages: 1,
offset: 0,
current: 1
},
}
}
},
methods: {
getData(object_id, offset) {
if (typeof object_id !== "undefined")
this.object_id = object_id;
if (typeof offset == "undefined")
offset = 0;
this.isPreloader = 1;
return axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_requisitions',
user_id: $("#session_user_id").val(),
object_id: this.object_id,
offset: offset
}).then((response) => {
this.isPreloader = 0;
return {
req: response.data.requisitions || [],
count: parseInt(response.data.count) || 0,
offset: parseInt(response.data.offset) || 0,
perpage: parseInt(response.data.perpage) || 10,
error: response.data.error
};
}).catch(function(error) {
this.isPreloader = 0;
if (error)
console.debug(error);
return false;
});
},
// Проверяем просмотрены ли заявки конкретного объекта
isChecked(object_id, user_id, req_id) {
const item = this.req['req' + req_id];
if (!item || !item.watched_data) {
return false;
}
const watchedData = item.watched_data;
if (
watchedData &&
watchedData.user_id == user_id &&
watchedData.req_id == req_id &&
watchedData.object_id == object_id
) {
return watchedData.watched == '1';
} else {
return false;
}
},
openAutoSearchObjectReq(object_id) {
let ref = this;
ref.req = [];
$('#modalAutoSearchObjectReq_bg').fadeIn(500);
$('#modalAutoSearchObjectReq').toggle(300);
$("body").addClass("lock");
let requisitions = this.getData(object_id);
console.info(requisitions);
requisitions.then(function(result) {
console.debug(result);
if (typeof result != "undefined") {
ref.req = result.req;
ref.count = result.count;
//ref.pagination.requisitions.pages = Math.ceil((result.count - parseInt(result.perpage)) / parseInt(result.perpage));
ref.pagination.requisitions.pages = Math.ceil((result.count / parseInt(result.perpage)));
ref.pagination.requisitions.offset = result.offset;
ref.pagination.requisitions.perpage = result.perpage;
ref.pagination.requisitions.current = 1;
ref.error = result.error;
console.info(ref.req);
console.info(ref.pagination.requisitions);
$(ref.$refs.requisitionsList).animate({
scrollTop: 0
}, 300);
}
});
},
closeAutoSearchObjectReq() {
$('#modalAutoSearchObjectReq_bg').fadeOut(300);
$('#modalAutoSearchObjectReq').toggle(100);
$("body").removeClass("lock");
},
goToPage(page) {
let ref = this;
let offset = (page * 10);
let requisitions = this.getData(ref.object_id, (offset - 10));
requisitions.then(function(results) {
console.debug(results);
if (typeof results != "undefined") {
ref.req = results.req;
ref.count = results.count;
ref.pagination.requisitions.offset = offset;
ref.pagination.requisitions.perpage = results.perpage;
ref.pagination.requisitions.current = Math.ceil(offset / parseInt(results.perpage));
ref.error = results.error;
console.debug(ref.pagination.requisitions);
$(ref.$refs.requisitionsList).animate({
scrollTop: 0
}, 300);
}
});
},
getPagination(page, all_pages) {
let pagination = '';
let prev, next, page_from, page_to = 0;
if (page == 1) {
pagination += '<li class="active"><a href="javascript:{};" onclick="goToPageReq(1)">1</a></li>';
} else {
prev = page - 1;
pagination += '<li><a href="javascript:{};" onclick="goToPageReq(' + prev + ')">&laquo;</a></li>';
pagination += '<li><a href="javascript:{};" onclick="goToPageReq(1)">1</a></li>';
}
if (all_pages > 8) {
if (page > 4) {
page_from = page - 3;
pagination += '<li><span>...</span></li>';
} else {
page_from = 2;
}
if (page < all_pages - 4) {
page_to = page + 3;
} else {
page_to = all_pages;
}
} else {
page_from = 2;
page_to = all_pages;
}
for (let i = page_from; i < page_to; i++) {
let class_name = '';
if (i == page)
class_name = "active";
pagination += '<li class="' + class_name + '"><a href="javascript:{};" onclick="goToPageReq(' + i + ')">' + i + '</a></li>';
}
if (all_pages > 5 && page < all_pages - 4) {
pagination += '<li><span>...</span></li>';
}
if (page == all_pages) {
pagination += '<li class="active" ><a href="javascript:{};" onclick="goToPageReq(' + all_pages + ')">' + all_pages + '</a></li>';
} else {
pagination += '<li><a href="javascript:{};" onclick="goToPageReq(' + all_pages + ')">' + all_pages + '</a></li>';
next = page + 1;
pagination += '<li><a href="javascript:{};" onclick="goToPageReq(' + next + ')">&raquo;</a></li>';
}
return '<ul class="pagination" style="display: inline-block;">' + pagination + '</ul><div class="clear"></div>';
},
clearData() {
this.req = [];
this.axios_processed = false;
this.isPreloader = 0;
this.count = 0;
this.pagination = {
requisitions: {
pages: 1,
offset: 0,
current: 1
}
};
},
//Для редактирования
getReq(id) {
$('#send_bg_new .closer').click();
req_form.openReqForm();
if (this.req[id] === undefined) {
console.log(this.req[id]);
axios.post('/ajax/ajax_vue_requisitions.php', {
request: 'get_req_id',
req_id: id
}, ).then((response) => {
console.log(response.data);
requisitions_client.$set(requisitions_client, 'req', response.data);
console.log(requisitions_client.req[id].object_id);
if (requisitions_client.req[id].object_id > 0 && requisitions_client.isEmpty(requisitions_client.req[id].object)) {
requisitions_client.getObject(requisitions_client.req[id].object_id, id, 1);
} else {
req_form.setReq(requisitions_client.req[id]);
}
if (this.req[id].client_id > 0 && this.isEmpty(this.req[id].client)) {
this.getClient(this.req[id].client_id, id, 1);
} else {
req_form.setReq(requisitions_client.req[id]);
}
}).catch(function(error) {
console.debug(error);
});
} else {
if (this.req[id].object_id > 0 && this.isEmpty(this.req[id].object)) {
this.getObject(this.req[id].object_id, id, 1);
} else {
req_form.setReq(requisitions_client.req[id]);
}
if (this.req[id].client_id > 0 && this.isEmpty(this.req[id].client)) {
this.getClient(this.req[id].client_id, id, 1);
} else {
req_form.setReq(requisitions_client.req[id]);
}
}
},
//Получение объекта
getObject(object_id, reqId, forma) {
axios.post('/ajax/ajax_vue_requisitions.php', {
request: 'get_object',
object_id: object_id
}, ).then((response) => {
console.log(response.data);
this.req[reqId].object = response.data;
if (forma) {
req_form.setReq(requisitions_client.req[reqId]);
}
}).catch(function(error) {
console.debug(error);
});
},
//Получение клиента
getClient(client_id, reqId, forma) {
axios.post('/ajax/ajax_vue_requisitions.php', {
request: 'get_client',
client_id: client_id
}, ).then((response) => {
console.log(response.data);
this.req[reqId].client = response.data;
if (forma) {
req_form.setReq(requisitions_client.req[reqId]);
}
}).catch(function(error) {
console.debug(error);
});
},
toggleWatched(index, reqId, objId, isWatched) {
const userId = this.user_id;
$.post('/ajax/addEditClient.php',
{
is_watched: isWatched ? 1 : 0, // Преобразуем true/false в 1/0
watched_req_id: reqId,
watched_obj_id: objId,
watched_user_id: userId
},
(data) => {
console.log('Ответ сервера:', data);
if (data.status === 'success') {
this.$set(this.req, index, { ...this.req[index], is_watched: isWatched ? 1 : 0 });
} else {
console.error('Ошибка:', data.message);
}
},
'json'
);
},
//открыть/закрыть подробности
toggleClient(id) {
if (this.req[id].isMainInfo) {
this.req[id].isMainInfo = false;
} else {
if (this.req[id].object_id > 0 && this.isEmpty(this.req[id].object)) {
this.getObject(this.req[id].object_id, id);
}
if (this.req[id].client_id > 0 && this.isEmpty(this.req[id].client)) {
this.getClient(this.req[id].client_id, id);
}
this.req[id].isMainInfo = true;
}
},
//показать объект
showObject(id) {
$('#liObject').click();
},
//показать клиента
showClient() {
$('#liGlobal').click();
},
//Проверка на пустоту
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() {},
computed: {},
created: function() {}
});
}
function openAutoSearchFiltr(req_id, filter_id) {
autosearch_filtr.openAutoSearchFiltr(req_id, filter_id);
}
function closeAutoSearchFiltr() {
autosearch_filtr.closeAutoSearchFiltr();
}
function closeAutoSearchMap() {
autosearch_filtr.closeAutoSearchMap();
}
function openAutoSearchResults(filter_id, req_id) {
autosearch_objs.openAutoSearchResults(filter_id, req_id);
}
function closeAutoSearchResults() {
autosearch_objs.closeAutoSearchResults();
}
function goToPageResults(section, page) {
autosearch_objs.goToPage(section, page);
}
function openAutoSearchObjectReq(object_id) {
autosearch_req.openAutoSearchObjectReq(object_id);
}
function closeAutoSearchObjectReq() {
autosearch_req.closeAutoSearchObjectReq();
}
function goToPageReq(page) {
autosearch_req.goToPage(page);
}
function getReSearchObjectsCounts() {
if ($('.jw__objects .jw__object.item .fltr-req-list').length > 0) {
$('.jw__objects .jw__object.item .fltr-req-list').each(function(index) {
let object_id = $(this).data("id");
if (typeof object_id !== "undefined") {
axios.post('/ajax/ajax_vue_autosearch.php', {
request: 'get_reverse_counter',
object_id: object_id
}).then((response) => {
let time = response.data.time;
let total = response.data.total;
let has_items = response.data.has_items;
if (time && total) {
$(this).attr("data-time", time);
$(this).attr("data-total", total);
$(this).append('<span class="counter">' + total + '</span>');
} else if (has_items === true) {
$(this).append('<span class="counter">' + 0 + '</span>');
}
}).catch(function(error) {
console.log(error);
});
}
});
}
}
function confirmSaveAutosearch() {
$("#save_autosearch_fields_bg").hide(10);
$("#save_autosearch_fields").hide(10);
autosearch_filtr.addEditFiltr();
}
function saveAutoSearchMap() {
autosearch_filtr.saveAutoSearchMap();
}