1122 lines
37 KiB
JavaScript
1122 lines
37 KiB
JavaScript
Vue.config.devtools = true;
|
||
|
||
Vue.component('v-select', VueSelect.VueSelect);
|
||
|
||
var requisitions_client = new Vue({
|
||
el: '#requisitions_list_client',
|
||
name: 'requisitions_list_client',
|
||
components: {
|
||
Multiselect: window.VueMultiselect.default,
|
||
vuejsDatepicker: window.vuejsDatepicker
|
||
},
|
||
data() {
|
||
|
||
return {
|
||
req: [],
|
||
isAddObj: 0,
|
||
isPreloader: 0,
|
||
user_id: $("#sid").attr("data-id"),
|
||
funnel_id: $('#funnelIdClients').val(),
|
||
clientId: 0,
|
||
isReqClient: 0,
|
||
}
|
||
},
|
||
methods: {
|
||
//Список
|
||
getList() {
|
||
if (this.clientId > 0) {
|
||
this.req = [];
|
||
this.isAddObj = 0;
|
||
$('#addReqClientFormList').attr("data-client", this.clientId);
|
||
this.isReqClient = 0;
|
||
if (document.location.pathname == '/add-object.php' || document.location.pathname == '/my-objects.php' || document.location.pathname == '/agency-objects.php') {
|
||
this.isAddObj = 1;
|
||
}
|
||
//requisitions_client.isPreloader=true;
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_all',
|
||
client_id: this.clientId,
|
||
funnel_id: this.funnel_id,
|
||
//user_id: this.user_id,
|
||
}, )
|
||
.then((response) => {
|
||
this.req = response.data.req;
|
||
//requisitions_client.isPreloader=false;
|
||
if (!requisitions_client.isEmpty(requisitions_client.req)) {
|
||
this.isReqClient = 1;
|
||
//$("#requisitions_list_client .clients").show();
|
||
} else {
|
||
this.isReqClient = 2;
|
||
}
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
}
|
||
},
|
||
|
||
//Получение бара воронки
|
||
getBarFunnel(reqId) {
|
||
if (this.req['req' + reqId]) {
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_bar_funnel',
|
||
funnel_id: this.req['req' + reqId].funnel_id,
|
||
req_id: reqId
|
||
}, )
|
||
.then((response) => {
|
||
this.req['req' + reqId].steps = response.data;
|
||
requisitions_client.isPreloader = 0;
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
}
|
||
},
|
||
|
||
|
||
//Для редактирования
|
||
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.log(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.log(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.log(error);
|
||
});
|
||
},
|
||
|
||
//открыть/закрыть подробности
|
||
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();
|
||
},
|
||
|
||
openCardClient(client_id, ignoreFunnelsUpdate = false) {
|
||
openClientEventsWindowNew(client_id, $('#session_to_send').val(), 0, undefined, undefined, ignoreFunnelsUpdate);
|
||
},
|
||
|
||
//Проверка на пустоту
|
||
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(req_id, filter_id) {
|
||
autosearch_filtr.openAutoSearchFiltr(req_id, filter_id);
|
||
},
|
||
|
||
//Открыть список объектов автопоиска
|
||
showAutoSearchObjects(filter_id, event) {
|
||
let req_id = $(event.target).data('id');
|
||
$('#send_bg_new').fadeOut(300);
|
||
$('#send_new').toggle(100);
|
||
$("body").removeClass("lock");
|
||
|
||
autosearch_objs.openAutoSearchResults(filter_id, req_id);
|
||
},
|
||
},
|
||
mounted() {
|
||
//this.getList();
|
||
},
|
||
created: function() {
|
||
|
||
$(".clients").removeClass("hidden");
|
||
|
||
}
|
||
})
|
||
|
||
var requisitions_object = new Vue({
|
||
el: '#requisitions_list_object',
|
||
components: {
|
||
Multiselect: window.VueMultiselect.default,
|
||
vuejsDatepicker: window.vuejsDatepicker
|
||
},
|
||
data() {
|
||
|
||
return {
|
||
req: [],
|
||
//isPreloader: true,
|
||
agency_id: $('#session_agency_id').val(),
|
||
user_id: $("#sid").attr("data-id"),
|
||
//funnel_id: $('#funnelIdClients').val(),
|
||
objectId: 0,
|
||
isReqClient: 0,
|
||
isShow: false,
|
||
page: 1,
|
||
all_pages: 1,
|
||
prevPage: 0,
|
||
ot: 0,
|
||
do: 0,
|
||
pagePagin: [],
|
||
}
|
||
},
|
||
methods: {
|
||
//Список
|
||
getList() {
|
||
this.req = [];
|
||
requisitions_object.isReqClient = 0;
|
||
this.pagePagin = [];
|
||
this.ot = 0;
|
||
this.do = 0;
|
||
|
||
var requestData = {
|
||
request: 'get_all',
|
||
object_id: this.objectId,
|
||
page: this.page,
|
||
per_page: 5,
|
||
};
|
||
|
||
if (this.periodStart && this.periodEnd) {
|
||
requestData.filtr = {
|
||
period: 'period',
|
||
onDate: this.periodStart,
|
||
offDate: this.periodEnd
|
||
};
|
||
}
|
||
|
||
//console.log(this.objectId);
|
||
//requisitions_client.isPreloader=true;
|
||
axios.post('/ajax/ajax_vue_requisitions.php', requestData)
|
||
.then((response) => {
|
||
// console.log(response.data);
|
||
this.req = response.data.req;
|
||
//requisitions_client.isPreloader=false;
|
||
if (!requisitions_object.isEmpty(requisitions_object.req)) {
|
||
requisitions_object.isReqClient = 1;
|
||
this.all_pages = parseInt(response.data.allPages);
|
||
if (this.all_pages > 1) {
|
||
if (this.page > 1)
|
||
this.prevPage = this.page - 1;
|
||
}
|
||
if (this.all_pages > 8) {
|
||
if (this.page > 4) {
|
||
this.ot = this.page - 3;
|
||
} else {
|
||
this.ot = 2;
|
||
}
|
||
|
||
if (this.page < this.all_pages - 4) {
|
||
this.do = this.page + 3;
|
||
} else {
|
||
this.do = this.all_pages;
|
||
}
|
||
} else {
|
||
this.ot = 2;
|
||
this.do = this.all_pages;
|
||
}
|
||
for (var i = this.ot; i < this.do; i++) {
|
||
this.pagePagin.push(i);
|
||
}
|
||
//$("#requisitions_list_client .clients").show();
|
||
} else {
|
||
requisitions_object.isReqClient = 2;
|
||
}
|
||
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
|
||
},
|
||
|
||
//Пагинация
|
||
pagin(page) {
|
||
this.page = page;
|
||
this.getList();
|
||
},
|
||
|
||
//Пагинация
|
||
goToRequisitionsPage(event) {
|
||
if (event.keyCode === 13) {
|
||
var pageNum = $('#requisitionClientPageNumberInputForManualGoToPage').val();
|
||
|
||
if (pageNum) {
|
||
this.page = Number.parseInt(pageNum);
|
||
this.getList();
|
||
$('#requisitionClientPageNumberInputForManualGoToPage').val('');
|
||
}
|
||
}
|
||
},
|
||
|
||
//Получение бара воронки
|
||
getBarFunnel(reqId) {
|
||
if (this.req['req' + reqId]) {
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_bar_funnel',
|
||
funnel_id: this.req['req' + reqId].funnel_id,
|
||
req_id: reqId
|
||
}, )
|
||
.then((response) => {
|
||
this.req['req' + reqId].steps = response.data;
|
||
requisitions_client.isPreloader = 0;
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
}
|
||
},
|
||
|
||
|
||
//Для редактирования
|
||
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_object.$set(requisitions_object, 'req', response.data);
|
||
|
||
//console.log(requisitions_client.req[id].object_id);
|
||
if (requisitions_object.req[id].object_id > 0 && requisitions_object.isEmpty(requisitions_object.req[id].object)) {
|
||
|
||
requisitions_object.getObject(requisitions_object.req[id].object_id, id, 1);
|
||
} else {
|
||
req_form.setReq(requisitions_object.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_object.req[id]);
|
||
}
|
||
})
|
||
.catch(function(error) {
|
||
console.log(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_object.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_object.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_object.req[reqId]);
|
||
}
|
||
|
||
})
|
||
.catch(function(error) {
|
||
console.log(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_object.req[reqId]);
|
||
}
|
||
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
},
|
||
|
||
//открыть/закрыть подробности
|
||
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();
|
||
},
|
||
|
||
//Открыть форму
|
||
openForm(objectId, periodStart, periodEnd) {
|
||
console.log('openForm', objectId, periodStart, periodEnd);
|
||
this.page = 1;
|
||
this.isShow = true;
|
||
this.objectId = objectId;
|
||
this.periodStart = periodStart;
|
||
this.periodEnd = periodEnd;
|
||
this.getList();
|
||
$("body").addClass("lock");
|
||
},
|
||
|
||
//закрыть форму
|
||
closeForm() {
|
||
this.isShow = false;
|
||
$("body").removeClass("lock");
|
||
},
|
||
|
||
openCardClient(client_id, ignoreFunnelsUpdate = false) {
|
||
openClientEventsWindowNew(client_id, $('#session_to_send').val(), 0, undefined, undefined, ignoreFunnelsUpdate);
|
||
},
|
||
|
||
//Проверка на пустоту
|
||
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() {
|
||
//this.getList();
|
||
},
|
||
created: function() {
|
||
|
||
$("#requisitions_list_object").removeClass("hidden");
|
||
|
||
}
|
||
})
|
||
|
||
|
||
var room_requisitions = new Vue({
|
||
name: 'room_requisitions',
|
||
el: '#room_requisitions',
|
||
components:
|
||
{
|
||
Multiselect: window.VueMultiselect.default,
|
||
vuejsDatepicker: window.vuejsDatepicker
|
||
},
|
||
data()
|
||
{
|
||
return {
|
||
requisitions: [],
|
||
agency_id: $('#session_agency_id').val(),
|
||
user_id: $("#sid").attr("data-id"),
|
||
complexRoomId: 0,
|
||
apartmentTitle: null,
|
||
inProgress: false,
|
||
isShow: false,
|
||
page: 1,
|
||
all_pages: 1,
|
||
prevPage: 0,
|
||
ot: 0,
|
||
do: 0,
|
||
pagePagin: [],
|
||
complexBus: null
|
||
}
|
||
},
|
||
methods:
|
||
{
|
||
//Список
|
||
getList()
|
||
{
|
||
this.requisitions = [];
|
||
this.inProgress = true;
|
||
this.pagePagin = [];
|
||
this.ot = 0;
|
||
this.do = 0;
|
||
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_all',
|
||
complex_room_id: this.complexRoomId,
|
||
page: this.page,
|
||
per_page: 5,
|
||
})
|
||
.then((response) => {
|
||
this.requisitions = response.data.req;
|
||
|
||
if (!this.isEmpty(this.requisitions)) {
|
||
this.all_pages = parseInt(response.data.allPages);
|
||
if (this.all_pages > 1) {
|
||
if (this.page > 1)
|
||
this.prevPage = this.page - 1;
|
||
}
|
||
if (this.all_pages > 8) {
|
||
if (this.page > 4) {
|
||
this.ot = this.page - 3;
|
||
} else {
|
||
this.ot = 2;
|
||
}
|
||
|
||
if (this.page < this.all_pages - 4) {
|
||
this.do = this.page + 3;
|
||
} else {
|
||
this.do = this.all_pages;
|
||
}
|
||
} else {
|
||
this.ot = 2;
|
||
this.do = this.all_pages;
|
||
}
|
||
for (var i = this.ot; i < this.do; i++) {
|
||
this.pagePagin.push(i);
|
||
}
|
||
//$("#requisitions_list_client .clients").show();
|
||
}
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
})
|
||
.finally(() => this.inProgress = false);
|
||
|
||
},
|
||
|
||
//Пагинация
|
||
pagin(page)
|
||
{
|
||
this.page = page;
|
||
this.getList();
|
||
},
|
||
|
||
//Пагинация
|
||
goToRequisitionsPage(event)
|
||
{
|
||
if (event.keyCode === 13) {
|
||
var pageNum = $('#requisitionClientPageNumberInputForManualGoToPage').val();
|
||
|
||
if (pageNum) {
|
||
this.page = Number.parseInt(pageNum);
|
||
this.getList();
|
||
$('#requisitionClientPageNumberInputForManualGoToPage').val('');
|
||
}
|
||
}
|
||
},
|
||
|
||
//Получение бара воронки
|
||
getBarFunnel(reqId)
|
||
{
|
||
if (this.requisitions['req' + reqId]) {
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_bar_funnel',
|
||
funnel_id: this.requisitions['req' + reqId].funnel_id,
|
||
req_id: reqId
|
||
}, )
|
||
.then((response) => {
|
||
this.requisitions['req' + reqId].steps = response.data;
|
||
requisitions_client.isPreloader = 0;
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
}
|
||
},
|
||
|
||
|
||
//Для редактирования
|
||
getReq(id)
|
||
{
|
||
$('#send_bg_new .closer').click();
|
||
req_form.openReqForm();
|
||
|
||
if (this.requisitions[id] === undefined) {
|
||
//console.log(this.req[id]);
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_req_id',
|
||
req_id: id
|
||
}, )
|
||
.then((response) => {
|
||
this.$set(this, 'requisitions', response.data);
|
||
|
||
if (this.requisitions[id].complex_room_id > 0 && this.isEmpty(this.requisitions[id].object)) {
|
||
|
||
this.getRoom(this.requisitions[id].complex_room_id, id, 1);
|
||
} else {
|
||
req_form.setReq(this.requisitions[id]);
|
||
}
|
||
|
||
if (this.requisitions[id].client_id > 0 && this.isEmpty(this.requisitions[id].client)) {
|
||
this.getClient(this.requisitions[id].client_id, id, 1);
|
||
} else {
|
||
req_form.setReq(this.requisitions[id]);
|
||
}
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
} else {
|
||
|
||
if (this.requisitions[id].complex_room_id > 0 && this.isEmpty(this.requisitions[id].object)) {
|
||
this.getRoom(this.requisitions[id].complex_room_id, id, 1);
|
||
} else {
|
||
req_form.setReq(this.requisitions[id]);
|
||
}
|
||
|
||
if (this.requisitions[id].client_id > 0 && this.isEmpty(this.requisitions[id].client)) {
|
||
this.getClient(this.requisitions[id].client_id, id, 1);
|
||
} else {
|
||
req_form.setReq(this.requisitions[id]);
|
||
}
|
||
}
|
||
|
||
},
|
||
|
||
//Получение объекта
|
||
getRoom(complex_room_id, reqId, forma)
|
||
{
|
||
axios.post('/ajax/vue_ajax/complex_axios.php', {
|
||
request: 'get_room_requisitions',
|
||
complex_room_id
|
||
}, )
|
||
.then((response) => {
|
||
this.requisitions[reqId].object = response.data;
|
||
if (forma) {
|
||
req_form.setReq(this.requisitions[reqId]);
|
||
}
|
||
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
},
|
||
|
||
//Получение клиента
|
||
getClient(client_id, reqId, forma)
|
||
{
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_client',
|
||
client_id: client_id
|
||
}, )
|
||
.then((response) => {
|
||
this.requisitions[reqId].client = response.data;
|
||
if (forma) {
|
||
req_form.setReq(this.requisitions[reqId]);
|
||
}
|
||
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
},
|
||
|
||
//открыть/закрыть подробности
|
||
toggleClient(id)
|
||
{
|
||
|
||
if (this.requisitions[id].isMainInfo) {
|
||
this.requisitions[id].isMainInfo = false;
|
||
} else {
|
||
|
||
if (this.requisitions[id].complex_room_id > 0 && this.isEmpty(this.requisitions[id].object)) {
|
||
this.getRoom(this.requisitions[id].complex_room_id, id);
|
||
}
|
||
|
||
if (this.requisitions[id].client_id > 0 && this.isEmpty(this.requisitions[id].client)) {
|
||
this.getClient(this.requisitions[id].client_id, id);
|
||
}
|
||
this.requisitions[id].isMainInfo = true;
|
||
}
|
||
},
|
||
|
||
//показать объект
|
||
showObject()
|
||
{
|
||
$('#liObject').click();
|
||
},
|
||
|
||
//показать клиента
|
||
showClient()
|
||
{
|
||
$('#liGlobal').click();
|
||
},
|
||
|
||
//Открыть форму
|
||
openForm(complexRoomId)
|
||
{
|
||
this.page = 1;
|
||
this.isShow = true;
|
||
this.complexRoomId = complexRoomId;
|
||
this.getList();
|
||
$("body").addClass("lock");
|
||
},
|
||
|
||
//закрыть форму
|
||
closeForm()
|
||
{
|
||
this.isShow = false;
|
||
$("body").removeClass("lock");
|
||
},
|
||
|
||
openCardClient(client_id, ignoreFunnelsUpdate = false) {
|
||
openClientEventsWindowNew(client_id, $('#session_to_send').val(), 0, undefined, undefined, ignoreFunnelsUpdate);
|
||
},
|
||
|
||
//Проверка на пустоту
|
||
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;
|
||
}
|
||
},
|
||
|
||
observeRefs()
|
||
{
|
||
setInterval(() => {
|
||
if (window.complexBus) {
|
||
this.complexBus = window.complexBus
|
||
}
|
||
}, 200)
|
||
}
|
||
},
|
||
mounted()
|
||
{
|
||
this.$nextTick(() => {
|
||
this.observeRefs();
|
||
});
|
||
},
|
||
watch:
|
||
{
|
||
complexBus(complexBus)
|
||
{
|
||
if (complexBus) {
|
||
complexBus.$on('apartment-open-requisitions', (apartment) => {
|
||
if (apartment)
|
||
{
|
||
this.complexRoomId = apartment.id
|
||
this.apartmentTitle = apartment.title
|
||
this.getList();
|
||
this.isShow = true;
|
||
}
|
||
});
|
||
}
|
||
}
|
||
},
|
||
created: function()
|
||
{
|
||
$("#room_requisitions").removeClass("hidden");
|
||
}
|
||
})
|
||
|
||
|
||
var room_reservation = new Vue({
|
||
name: 'room_reservation',
|
||
el: '#room_reservation',
|
||
components:
|
||
{
|
||
Multiselect: window.VueMultiselect.default,
|
||
vuejsDatepicker: window.vuejsDatepicker
|
||
},
|
||
data()
|
||
{
|
||
return {
|
||
reservation: [],
|
||
agency_id: $('#session_agency_id').val(),
|
||
user_id: $("#sid").attr("data-id"),
|
||
reservationId: 0,
|
||
apartmentTitle: null,
|
||
inProgress: false,
|
||
isShow: false,
|
||
complexBus: null
|
||
}
|
||
},
|
||
methods:
|
||
{
|
||
getReservation()
|
||
{
|
||
this.reservation = [];
|
||
this.inProgress = true;
|
||
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_req_id',
|
||
req_id: this.reservationId
|
||
})
|
||
.then((response) => {
|
||
this.reservation = response.data[`req${this.reservationId}`];
|
||
})
|
||
.catch(function(error) {
|
||
console.error(error);
|
||
})
|
||
.finally(() => this.inProgress = false);
|
||
},
|
||
|
||
//Получение бара воронки
|
||
getBarFunnel(reqId)
|
||
{
|
||
if (this.reservationId == reqId) {
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_bar_funnel',
|
||
funnel_id: this.reservation.funnel_id,
|
||
req_id: reqId
|
||
}, )
|
||
.then((response) => {
|
||
this.reservation.steps = response.data;
|
||
requisitions_client.isPreloader = 0;
|
||
})
|
||
.catch(function(error) {
|
||
console.error(error);
|
||
});
|
||
}
|
||
},
|
||
|
||
|
||
//Для редактирования
|
||
getReq(id)
|
||
{
|
||
$('#send_bg_new .closer').click();
|
||
req_form.openReqForm();
|
||
|
||
if (this.reservationId === undefined) {
|
||
//console.log(this.req[id]);
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_req_id',
|
||
req_id: id
|
||
}, )
|
||
.then((response) => {
|
||
this.$set(this, 'reservation', response.data);
|
||
|
||
if (this.reservation.complex_room_id > 0 && this.isEmpty(this.reservation.object)) {
|
||
|
||
this.getRoom(this.reservation.complex_room_id, id, 1);
|
||
} else {
|
||
req_form.setReq(this.reservation);
|
||
}
|
||
|
||
if (this.reservation.client_id > 0 && this.isEmpty(this.reservation.client)) {
|
||
this.getClient(this.reservation.client_id, id, 1);
|
||
} else {
|
||
req_form.setReq(this.reservation);
|
||
}
|
||
})
|
||
.catch(function(error) {
|
||
console.error(error);
|
||
});
|
||
} else {
|
||
|
||
if (this.reservation.complex_room_id > 0 && this.isEmpty(this.reservation.object)) {
|
||
this.getRoom(this.reservation.complex_room_id, id, 1);
|
||
} else {
|
||
req_form.setReq(this.reservation);
|
||
}
|
||
|
||
if (this.reservation.client_id > 0 && this.isEmpty(this.reservation.client)) {
|
||
this.getClient(this.reservation.client_id, id, 1);
|
||
} else {
|
||
req_form.setReq(this.reservation);
|
||
}
|
||
}
|
||
|
||
},
|
||
|
||
//Получение объекта
|
||
getRoom(complex_room_id, reqId, forma)
|
||
{
|
||
axios.post('/ajax/vue_ajax/complex_axios.php', {
|
||
request: 'get_room_requisitions',
|
||
complex_room_id
|
||
})
|
||
.then((response) => {
|
||
this.reservation.object = response.data;
|
||
if (forma) {
|
||
req_form.setReq(this.reservation);
|
||
}
|
||
|
||
})
|
||
.catch(function(error) {
|
||
console.error(error);
|
||
});
|
||
},
|
||
|
||
//Получение клиента
|
||
getClient(client_id, reqId, forma)
|
||
{
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_client',
|
||
client_id: client_id
|
||
}, )
|
||
.then((response) => {
|
||
this.reservation.client = response.data;
|
||
if (forma) {
|
||
req_form.setReq(this.reservation);
|
||
}
|
||
})
|
||
.catch(function(error) {
|
||
console.error(error);
|
||
});
|
||
},
|
||
|
||
//открыть/закрыть подробности
|
||
toggleClient(id)
|
||
{
|
||
|
||
if (this.reservation.isMainInfo) {
|
||
this.reservation.isMainInfo = false;
|
||
} else {
|
||
|
||
if (this.reservation.complex_room_id > 0 && this.isEmpty(this.reservation.object)) {
|
||
this.getRoom(this.reservation.complex_room_id, id);
|
||
}
|
||
|
||
if (this.reservation.client_id > 0 && this.isEmpty(this.reservation.client)) {
|
||
this.getClient(this.reservation.client_id, id);
|
||
}
|
||
this.reservation.isMainInfo = true;
|
||
}
|
||
},
|
||
|
||
//показать объект
|
||
showObject()
|
||
{
|
||
$('#liObject').click();
|
||
},
|
||
|
||
//показать клиента
|
||
showClient()
|
||
{
|
||
$('#liGlobal').click();
|
||
},
|
||
|
||
//Открыть форму
|
||
openForm(reservationId)
|
||
{
|
||
this.page = 1;
|
||
this.isShow = true;
|
||
this.reservationId = reservationId;
|
||
this.getList();
|
||
$("body").addClass("lock");
|
||
},
|
||
|
||
//закрыть форму
|
||
closeForm()
|
||
{
|
||
this.isShow = false;
|
||
$("body").removeClass("lock");
|
||
},
|
||
|
||
openCardClient(client_id, ignoreFunnelsUpdate = false) {
|
||
openClientEventsWindowNew(client_id, $('#session_to_send').val(), 0, undefined, undefined, ignoreFunnelsUpdate);
|
||
},
|
||
|
||
//Проверка на пустоту
|
||
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;
|
||
}
|
||
},
|
||
|
||
observeRefs()
|
||
{
|
||
setInterval(() => {
|
||
if (window.complexBus) {
|
||
this.complexBus = window.complexBus
|
||
}
|
||
}, 200)
|
||
}
|
||
},
|
||
mounted()
|
||
{
|
||
this.$nextTick(() => {
|
||
this.observeRefs();
|
||
});
|
||
},
|
||
watch:
|
||
{
|
||
complexBus(complexBus)
|
||
{
|
||
if (complexBus) {
|
||
complexBus.$on('apartment-open-reservation', (reservation) => {
|
||
if (reservation)
|
||
{
|
||
openClientEventsWindowNew(0, $('#session_to_send').val(), 0, reservation.id);
|
||
// this.reservationId = reservation.id
|
||
// this.apartmentTitle = reservation.apartment_title
|
||
// this.getReservation();
|
||
// this.isShow = true;
|
||
}
|
||
});
|
||
}
|
||
}
|
||
},
|
||
created: function()
|
||
{
|
||
$("#room_reservation").removeClass("hidden");
|
||
}
|
||
}) |