431 lines
14 KiB
JavaScript
431 lines
14 KiB
JavaScript
var req_info = new Vue({
|
||
el: '#req_info',
|
||
components: {
|
||
vuejsDatepicker: window.vuejsDatepicker
|
||
},
|
||
data() {
|
||
|
||
return {
|
||
agency_id: $('#session_agency_id').val(),
|
||
ru: vdp_translation_ru.js,
|
||
is_show: false,
|
||
is_show_result: false,
|
||
errorMes: false,
|
||
errorText: '',
|
||
id: 0,
|
||
errors: { 'name': false, 'addres': false },
|
||
OpenIndicator: {
|
||
render: createElement => createElement('span', { class: { 'vueToggleSpan': true } }),
|
||
},
|
||
req: [],
|
||
type_req: null,
|
||
types_req: [],
|
||
reqFields: [],
|
||
fieldModels: [],
|
||
}
|
||
},
|
||
methods: {
|
||
|
||
openFromOtherPage(id) {
|
||
this.type_req = null;
|
||
this.client = [];
|
||
this.reqFields = [];
|
||
this.fieldModels = [];
|
||
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_req_id',
|
||
req_id: id
|
||
}, )
|
||
.then((response) => {
|
||
//console.log(response.data);
|
||
this.req = response.data['req' + id];
|
||
|
||
if (this.types_req.find((el, idx) => el.code == this.req.type_id)) {
|
||
this.type_req = this.types_req.find((el, idx) => el.code == this.req.type_id).name;
|
||
}
|
||
if (this.isEmpty(this.req.client)) {
|
||
this.getClient(this.req.client_id, this.req.id);
|
||
}
|
||
if (this.req.object_id > 0 && this.isEmpty(this.req.object)) {
|
||
this.getObject(this.req.object_id);
|
||
}
|
||
|
||
this.getReqFields();
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
|
||
this.getReqFields();
|
||
|
||
this.is_show = true;
|
||
$("body").addClass("lock");
|
||
$('.jw__add-popup').removeClass('is__show');
|
||
},
|
||
|
||
//Открытие
|
||
open(id) {
|
||
this.type_req = null;
|
||
this.client = [];
|
||
this.reqFields = [];
|
||
this.fieldModels = [];
|
||
if (requisitions.req[id]) {
|
||
console.log(requisitions.req[id]);
|
||
|
||
this.req = requisitions.req[id];
|
||
if (this.types_req.find((el, idx) => el.code == this.req.type_id)) {
|
||
this.type_req = this.types_req.find((el, idx) => el.code == this.req.type_id).name;
|
||
}
|
||
if (this.isEmpty(this.req.client)) {
|
||
this.getClient(this.req.client_id, this.req.id);
|
||
}
|
||
if (this.req.object_id > 0 && this.isEmpty(this.req.object)) {
|
||
this.getObject(this.req.object_id);
|
||
}
|
||
|
||
this.getReqFields();
|
||
|
||
} else {
|
||
this.errorMes = true;
|
||
this.errorMes = "Ой, что-то не так. Не могу открыть заявку. Пожалуйста, сообщите в тех поддержку.";
|
||
}
|
||
|
||
|
||
this.is_show = true;
|
||
$("body").addClass("lock");
|
||
$('.jw__add-popup').removeClass('is__show');
|
||
},
|
||
|
||
closes() {
|
||
this.is_show = false;
|
||
$("body").removeClass("lock");
|
||
$('.jw__add-popup').removeClass('is__show');
|
||
},
|
||
|
||
//Получение типов заявок
|
||
getTypes() {
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_type',
|
||
agency_id: this.agency_id,
|
||
active: 1,
|
||
},
|
||
|
||
)
|
||
.then((response) => {
|
||
// console.log(response.data);
|
||
this.types_req = response.data.type;
|
||
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
},
|
||
|
||
//Получение клиента
|
||
getClient(client_id, reqId) {
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_client',
|
||
client_id: client_id
|
||
}, )
|
||
.then((response) => {
|
||
//console.log(response.data);
|
||
this.req.client = response.data;
|
||
|
||
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
},
|
||
|
||
//Получение объекта
|
||
getObject(object_id) {
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_object',
|
||
object_id: object_id
|
||
}, )
|
||
.then((response) => {
|
||
//console.log(response.data);
|
||
this.req.object = response.data;
|
||
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
},
|
||
|
||
//Получение дополнительных полей
|
||
getReqFields() {
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_req_fields',
|
||
agency_id: this.agency_id,
|
||
req_id: this.req.id,
|
||
}).then((response) => {
|
||
//console.log(response.data);
|
||
this.reqFields = response.data.fields;
|
||
var values = response.data.values;
|
||
for (var i = 0; i < this.reqFields.length; i++) {
|
||
|
||
this.$set(this.fieldModels, 'model_' + this.reqFields[i].id, null);
|
||
if (this.reqFields[i].is_podgroup > 0) {
|
||
for (var j = 0; j < this.reqFields[i].podgroups.length; j++) {
|
||
this.$set(this.fieldModels, 'modelp_' + this.reqFields[i].podgroups[j].id, null);
|
||
}
|
||
}
|
||
}
|
||
for (var index in this.fieldModels) {
|
||
if (index.indexOf('model') != -1) {
|
||
|
||
if (!this.isEmpty(values[index])) {
|
||
|
||
this.fieldModels[index] = JSON.parse(values[index]);
|
||
}
|
||
}
|
||
}
|
||
console.log(this.fieldModels);
|
||
|
||
}).catch(function(error) {
|
||
console.log(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;
|
||
}
|
||
},
|
||
|
||
openObjectReqInfo(object_id) {
|
||
object_card.open(object_id);
|
||
this.closes();
|
||
},
|
||
|
||
},
|
||
mounted() {
|
||
|
||
},
|
||
created: function() {
|
||
|
||
$("#req_info").removeClass("hidden");
|
||
this.getTypes();
|
||
|
||
}
|
||
})
|
||
|
||
|
||
var client__info = new Vue({
|
||
el: '#client_info',
|
||
components: {
|
||
vuejsDatepicker: window.vuejsDatepicker
|
||
},
|
||
data() {
|
||
|
||
return {
|
||
agency_id: $('#session_agency_id').val(),
|
||
ru: vdp_translation_ru.js,
|
||
is_show: false,
|
||
is_show_result: false,
|
||
errorMes: false,
|
||
errorText: '',
|
||
id: 0,
|
||
errors: { 'name': false, 'addres': false },
|
||
OpenIndicator: {
|
||
render: createElement => createElement('span', { class: { 'vueToggleSpan': true } }),
|
||
},
|
||
client: [],
|
||
type_req: null,
|
||
types_req: [],
|
||
clientFields: [],
|
||
fieldModels: [],
|
||
objects: [],
|
||
}
|
||
},
|
||
methods: {
|
||
|
||
//Открытие
|
||
open(id) {
|
||
this.clientFields = [];
|
||
this.fieldModels = [];
|
||
this.getClient(id);
|
||
/* this.type_req = null;
|
||
this.client = [];
|
||
this.reqFields = [];
|
||
this.fieldModels = [];
|
||
if (requisitions.req[id]) {
|
||
console.log(requisitions.req[id]);
|
||
|
||
this.req = requisitions.req[id];
|
||
if (this.types_req.find((el, idx) => el.code == this.req.type_id)) {
|
||
this.type_req = this.types_req.find((el, idx) => el.code == this.req.type_id).name;
|
||
}
|
||
if (this.isEmpty(this.req.client)) {
|
||
this.getClient(this.req.client_id, this.req.id);
|
||
}
|
||
if (this.req.object_id > 0 && this.isEmpty(this.req.object)) {
|
||
this.getObject(this.req.object_id);
|
||
}
|
||
|
||
this.getReqFields();
|
||
|
||
} else {
|
||
this.errorMes = true;
|
||
this.errorMes = "Ой, что-то не так. Не могу открыть заявку. Пожалуйста, сообщите в тех поддержку.";
|
||
}*/
|
||
|
||
|
||
this.is_show = true;
|
||
$("body").addClass("lock");
|
||
$('.jw__add-popup').removeClass('is__show');
|
||
},
|
||
|
||
closes() {
|
||
this.is_show = false;
|
||
this.client = [];
|
||
$("body").removeClass("lock");
|
||
$('.jw__add-popup').removeClass('is__show');
|
||
},
|
||
|
||
saveChatId(chatType, channelId, integrationId, userId, chatId, telephone) {
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'save_chat_id',
|
||
chatType: chatType,
|
||
channelId: channelId,
|
||
integrationId: integrationId,
|
||
userId: userId,
|
||
chatId: chatId,
|
||
telephone: telephone,
|
||
}, )
|
||
.then((response) => {
|
||
console.log(response);
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
},
|
||
|
||
//Получение клиента
|
||
getClient(client_id) {
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_client_id',
|
||
id: client_id,
|
||
agency_id: this.agency_id,
|
||
}, )
|
||
.then((response) => {
|
||
//console.log(response.data);
|
||
this.client = response.data;
|
||
if (!this.isEmpty(this.client.objects)) {
|
||
this.getObject(this.client.objects);
|
||
|
||
}
|
||
this.getClientFields(client_id);
|
||
console.log(this.client);
|
||
|
||
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
},
|
||
|
||
//Получение объекта
|
||
getObject(objects_id) {
|
||
console.log(objects_id)
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_objects_ids',
|
||
objects_id: objects_id
|
||
}, )
|
||
.then((response) => {
|
||
console.log(response.data);
|
||
this.objects = response.data;
|
||
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
},
|
||
|
||
//Получение дополнительных полей
|
||
getClientFields(client_id) {
|
||
axios.post('/ajax/ajax_vue_fields.php', {
|
||
request: 'get_client_fields',
|
||
agency_id: this.agency_id,
|
||
client_id: client_id,
|
||
}).then((response) => {
|
||
//console.log(response.data);
|
||
this.clientFields = response.data.fields;
|
||
var values = response.data.values;
|
||
for (var i = 0; i < this.clientFields.length; i++) {
|
||
|
||
this.$set(this.fieldModels, 'model_' + this.clientFields[i].id, null);
|
||
if (this.clientFields[i].is_podgroup > 0) {
|
||
for (var j = 0; j < this.clientFields[i].podgroups.length; j++) {
|
||
this.$set(this.fieldModels, 'modelp_' + this.clientFields[i].podgroups[j].id, null);
|
||
}
|
||
}
|
||
}
|
||
for (var index in this.fieldModels) {
|
||
if (index.indexOf('model') != -1) {
|
||
|
||
if (!this.isEmpty(values[index])) {
|
||
|
||
this.fieldModels[index] = JSON.parse(values[index]);
|
||
}
|
||
}
|
||
}
|
||
//console.log(this.fieldModels);
|
||
|
||
}).catch(function(error) {
|
||
console.log(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() {
|
||
|
||
},
|
||
created: function() {
|
||
|
||
$("#client_info").removeClass("hidden");
|
||
//this.getTypes();
|
||
|
||
}
|
||
}) |