1637 lines
76 KiB
JavaScript
1637 lines
76 KiB
JavaScript
Vue.config.devtools = true;
|
||
Vue.component('v-select', VueSelect.VueSelect)
|
||
|
||
var ac = new Vue({
|
||
el: '#app_step',
|
||
name: 'app_step',
|
||
components: {
|
||
Multiselect: window.VueMultiselect.default,
|
||
vuejsDatepicker: window.vuejsDatepicker
|
||
},
|
||
data: {
|
||
stepVal: 0,
|
||
nowUserId: 0,
|
||
prevStage: 'В работе',
|
||
stepId: 0,
|
||
closesStep: false,
|
||
errorMes: false,
|
||
kanban: false,
|
||
kanbanReq: false,
|
||
step: [],
|
||
clientId: 0,
|
||
reqId: 0,
|
||
adjacentId: 0,
|
||
notSelectedFileMessage: "",
|
||
typePole: { "Строка": "input",
|
||
"Текст": "textarea",
|
||
"Ветвление этапов": "select",
|
||
"Выпадающий список":"select",
|
||
"Дата": "date",
|
||
"Файл": "file",
|
||
"Задача на выбор": "checkbox",
|
||
"Поле с галочкой": "checkbox",
|
||
"Задаток": "deposit",
|
||
"Ожидаемая комиссия":"commission",
|
||
"Расходы":"expenses",
|
||
},
|
||
nextStepSelect: '',
|
||
options: [],
|
||
errorText: '',
|
||
ru: vdp_translation_ru.js,
|
||
format: "dd.MM.yyyy",
|
||
mondayfirst: true,
|
||
classTypesFile: {
|
||
'xls': 'far fa-file-excel',
|
||
'xlsx': 'far fa-file-excel',
|
||
'doc': 'far fa-file-word',
|
||
'docx': 'far fa-file-word',
|
||
'img': 'far fa-file-image',
|
||
'png': 'far fa-file-image',
|
||
'pdf': 'far fa-file-pdf',
|
||
'txt': 'far fa-file-alt',
|
||
'xml': 'far fa-file-alt',
|
||
'html': 'far fa-file-code',
|
||
'rar': 'far fa-file-archive',
|
||
'zip': 'far fa-file-archive',
|
||
'7z': 'far fa-file-archive',
|
||
'undefined': 'far fa-file'
|
||
},
|
||
selectFile: { 'file': {}, 'typeFile': '', 'classFile': '', 'guid': '', 'progress': 0, 'isUpload': false, 'uploads': false, 'is': false },
|
||
selectFiles: [],
|
||
updateWhoWork: false,
|
||
doers: [],
|
||
listDoers: [],
|
||
stepDoers: [],
|
||
tasks: [],
|
||
objects: [],
|
||
isOpenPrevStep: false,
|
||
stepPrev: [],
|
||
errorTextPrevStep: '',
|
||
OpenIndicator: {
|
||
render: createElement => createElement('span', { class: { 'vueToggleSpan': true } }),
|
||
},
|
||
errorMesPrevStep: false,
|
||
is_Other_prev_step: 0,
|
||
is_looad: false,
|
||
is_load_open: false,
|
||
list_open_step: [],
|
||
load_open_step: false,
|
||
step_id_open: null,
|
||
step_name_open: '',
|
||
pole_dop_close_step: [],
|
||
user_id: $('#session_user_id').val(),
|
||
activites_close_step_val: null,
|
||
fields: [],
|
||
fieldModels: [],
|
||
forms: [],
|
||
OpenIndicator: {
|
||
render: createElement => createElement('span', { class: { 'vueToggleSpan': true } }),
|
||
},
|
||
formsFilled: { 'specifications_object': 0, 'contract_form': 0 },
|
||
no_close_step: false,
|
||
adjacent_funnels: [],
|
||
open_step_load: false,
|
||
step_complex_status_id: null,
|
||
complexBus: undefined,
|
||
isRoomForm: false,
|
||
selectedRoom: {
|
||
id: null,
|
||
name: null,
|
||
plan_url: null,
|
||
complex_id: null,
|
||
house_id: null,
|
||
complex_entrance_id: null,
|
||
floor_id: null,
|
||
transaction_amount: null,
|
||
status_type: null
|
||
},
|
||
room_types: {
|
||
apartment: 'Квартира',
|
||
apartments: 'Апартаменты',
|
||
parking_space: 'Машиноместо',
|
||
office: 'Офис',
|
||
storage_room: 'Кладовка',
|
||
warehouse: 'Склад',
|
||
retail_space: 'Торговое Помещение',
|
||
commercial_space: 'Помещение свободного назначения',
|
||
townhouse: 'Таунхаус',
|
||
villa: 'Вилла',
|
||
penthouse: 'Пентхаус',
|
||
duplex: 'Дуплекс',
|
||
cottage: 'Коттедж',
|
||
},
|
||
dealCloseData: null,
|
||
dealCloseReqs: [],
|
||
dealCloseObjects: [],
|
||
dealCloseAgentCommission: 0,
|
||
dealCloseSumma: 0,
|
||
},
|
||
methods: {
|
||
closedStep: function(id, clientId) {
|
||
ac.errorText = '';
|
||
ac.errorMes = false;
|
||
if(ac.no_close_step){
|
||
ac.closesStep = false;
|
||
ac.is_looad = false;
|
||
} else {
|
||
if (ac.step.pole_end_list.length > 0) {
|
||
for (var i in ac.step.pole_end_list) {
|
||
//console.log(ac.step.values[i].value);
|
||
if (ac.step.pole_end_list[i].binding && ac.step.values[i].value === '') {
|
||
if (ac.step.pole_end_list[i].dopSettings.select) {
|
||
if (ac.nextStepSelect == null || ac.nextStepSelect == '' || ac.nextStepSelect == undefined) {
|
||
ac.errorText += "<p>Заполните поле «" + ac.step.pole_end_list[i].name + "»</p>";
|
||
} else {
|
||
ac.step.values[i].value = ac.nextStepSelect;
|
||
}
|
||
} else {
|
||
if(!ac.isEmpty(ac.nextStepSelect) && !this.isEmpty(ac.step.pole_end_list[i].view_next)){
|
||
if(ac.step.pole_end_list[i].view_next.indexOf(ac.nextStepSelect.code) == -1){
|
||
/*** */
|
||
} else {
|
||
ac.errorText += "<p>Заполните поле «" + ac.step.pole_end_list[i].name + "»</p>";
|
||
}
|
||
} else
|
||
ac.errorText += "<p>Заполните поле «" + ac.step.pole_end_list[i].name + "»</p>";
|
||
}
|
||
} else if (ac.step.pole_end_list[i].binding && (ac.step.values[i].type == "deposit" || ac.step.values[i].type == "commission" || ac.step.values[i].type == "expenses")) {
|
||
|
||
if ((ac.step.values[i].type == "deposit" || ac.step.values[i].type == "commission") && parseInt(ac.step.values[i].value) == 0)
|
||
ac.errorText += "<p>Заполните поле «" + ac.step.pole_end_list[i].name + "»</p>";
|
||
if(ac.step.values[i].type == "expenses" && (parseInt(ac.step.values[i].value.summa) == 0 || this.isEmpty(ac.step.values[i].value.summa)))
|
||
ac.errorText += "<p>Заполните поле «" + ac.step.pole_end_list[i].name + "»</p>";
|
||
}
|
||
}
|
||
}
|
||
|
||
if (ac.step.is_select_room == 1) {
|
||
if (!ac.selectedRoom || !ac.selectedRoom.id) {
|
||
ac.errorText += "<p>Выберите комплекс</p>";
|
||
}
|
||
}
|
||
|
||
var poles = {};
|
||
// console.log(this.fields);
|
||
if (!this.isEmpty(this.fields)) {
|
||
for (var i = 0; i < this.fields.length; i++) {
|
||
if (!this.isEmpty(this.fieldModels['model_' + this.fields[i].id]) && this.fieldModels['model_' + this.fields[i].id]) {
|
||
|
||
if (this.fields[i].type == 4) {
|
||
poles['model_' + this.fields[i].id] = 1;
|
||
} else {
|
||
poles['model_' + this.fields[i].id] = this.fieldModels['model_' + this.fields[i].id];
|
||
}
|
||
}
|
||
if (this.fields[i].is_podgroup > 0) {
|
||
for (var j = 0; j < this.fields[i].podgroups.length; j++) {
|
||
//console.log(this.fieldModels['modelp_11']);
|
||
if (!this.isEmpty(this.fieldModels['modelp_' + this.fields[i].podgroups[j].id]) && this.fieldModels['modelp_' + this.fields[i].podgroups[j].id]) {
|
||
$('#linking_step_p' + this.fields[i].podgroups[j].id).removeClass('invalid');
|
||
if (this.fields[i].podgroups[j].type == 4) {
|
||
poles['modelp_' + this.fields[i].podgroups[j].id] = 1;
|
||
} else {
|
||
|
||
poles['modelp_' + this.fields[i].podgroups[j].id] = this.fieldModels['modelp_' + this.fields[i].podgroups[j].id];
|
||
}
|
||
} else {
|
||
if (this.fields[i].podgroups[j].is_required > 0 && this.fields[i].podgroups[j].id == this.fieldModels['model_' + this.fields[i].id]) {
|
||
if(!ac.isEmpty(ac.nextStepSelect) && !this.isEmpty(this.fields[i].view_next)){
|
||
if(this.fields[i].view_next.indexOf(ac.nextStepSelect.code) == -1){
|
||
/*** */
|
||
} else {
|
||
this.isError = true;
|
||
this.errorText += "<p>Не заполнено поле: " + this.fields[i].podgroups[j].title + "</p>";
|
||
$('#linking_step_p' + this.fields[i].podgroups[j].id).addClass('invalid');
|
||
}
|
||
} else {
|
||
this.isError = true;
|
||
this.errorText += "<p>Не заполнено поле: " + this.fields[i].podgroups[j].title + "</p>";
|
||
$('#linking_step_p' + this.fields[i].podgroups[j].id).addClass('invalid');
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if (this.fields[i].is_required > 0) {
|
||
//console.log(JSON.parse(this.fields[i].req_type));
|
||
// (JSON.parse(this.fields[i].req_type).indexOf(this.selectedType) != -1) {
|
||
if (this.isEmpty(this.fieldModels['model_' + this.fields[i].id])) {
|
||
|
||
if(!ac.isEmpty(ac.nextStepSelect) && !this.isEmpty(this.fields[i].view_next)){
|
||
if(this.fields[i].view_next.indexOf(ac.nextStepSelect.code) == -1){
|
||
/*** */
|
||
} else {
|
||
this.isError = true;
|
||
this.errorText += "<p>Не заполнено поле: " + this.fields[i].title + "</p>";
|
||
$('#linking_step_' + this.fields[i].id).addClass('invalid');
|
||
}
|
||
|
||
} else {
|
||
this.isError = true;
|
||
this.errorText += "<p>Не заполнено поле: " + this.fields[i].title + "</p>";
|
||
$('#linking_step_' + this.fields[i].id).addClass('invalid');
|
||
}
|
||
} else {
|
||
$('#linking_step_' + this.fields[i].id).removeClass('invalid');
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
if (ac.errorText != '') {
|
||
ac.errorMes = true;
|
||
$('.full_modal-bg').stop().animate({ scrollTop: 0 }, '500');
|
||
} else {
|
||
this.is_looad = true;
|
||
axios.post('/ajax/ajax_vue_clients.php', {
|
||
request: 'save_steps_client',
|
||
user_id: ac.nowUserId,
|
||
agency_id: $('#session_agency_id').val(),
|
||
client_id: ac.clientId,
|
||
req_id: ac.reqId,
|
||
adjacent_id: ac.adjacentId,
|
||
step_id: ac.stepId,
|
||
step_name: ac.step.name,
|
||
funnel_id: ac.step.funnel_id,
|
||
next_step_select: ac.nextStepSelect,
|
||
values: JSON.stringify(ac.step.values),
|
||
is_closet: ac.step.stage,
|
||
next_step: JSON.parse(ac.step.next_step),
|
||
activites_close_step_val: this.activites_close_step_val,
|
||
field_models: poles,
|
||
complex_room_id: ac.selectedRoom.id,
|
||
complex_status_id: ac.step_complex_status_id,
|
||
transaction_amount: ac.selectedRoom.transaction_amount,
|
||
selected_room_name: ac.selectedRoom.name
|
||
})
|
||
.then(function(response) {
|
||
|
||
if(response.data.adjacent_id > 0){
|
||
var req_id = response.data.req_id;
|
||
var client_id = response.data.client_id;
|
||
if(req_id > 0){
|
||
if (typeof requisitions !== 'undefined') {
|
||
requisitions.getBarFunnel(req_id, response.data.adjacent_id);
|
||
if (ac.kanbanReq) {
|
||
requisitions.getList();
|
||
ac.kanbanReq = false;
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
if (ac.clientId > 0) {
|
||
|
||
if(ac.kanban == 1 && document.location.pathname == '/clients.php'){
|
||
get_count_clients();
|
||
}
|
||
$.post('/ajax/getStageBar.php', { client_id: ac.clientId, funnel_id: ac.step.funnel_id }, function(result) {
|
||
$('#editClientStagebar').html(result);
|
||
ac.closesStep = false;
|
||
ac.is_looad = false;
|
||
});
|
||
if (!ac.isEmpty(ac.activites_close_step_val)) {
|
||
let id = ac.clientId;
|
||
let instance = "clients";
|
||
let tagsView = $('.jw__object.item#item' + id + ' .tags');
|
||
if (instance == "clients")
|
||
tagsView = $('.client#client__' + id + ' .tags');
|
||
$.post('/ajax/addActivities.php', {
|
||
id: id,
|
||
activities: ac.activites_close_step_val,
|
||
instance: instance
|
||
}, function(data) {
|
||
console.log(data);
|
||
let result = JSON.parse(data);
|
||
if (result.length > 0) {
|
||
tagsView.empty();
|
||
tagsView.append('<i class="ti-tag"></i> ');
|
||
for (let i = 0; i < result.length; i++) {
|
||
if (result[i]['id'] && result[i]['name']) {
|
||
if (i != result.length - 1)
|
||
tagsView.append('<span data-id="' + result[i]['id'] + '">' + result[i]['name'] + '</span>, ');
|
||
else
|
||
tagsView.append('<span data-id="' + result[i]['id'] + '">' + result[i]['name'] + '</span>');
|
||
}
|
||
}
|
||
tagsView.show();
|
||
} else {
|
||
tagsView.hide();
|
||
}
|
||
// popup.removeClass('show');
|
||
ac.activites_close_step_val = null;
|
||
});
|
||
}
|
||
} else {
|
||
ac.closesStep = false;
|
||
ac.is_looad = false;
|
||
}
|
||
|
||
var steps = response.data;
|
||
|
||
if ($('#client-history__bg').css('display') == 'block') {
|
||
$('#client-history__bg').css('zIndex', '99998');
|
||
}
|
||
|
||
if (ac.reqId > 0) {
|
||
var page = window.location.pathname;
|
||
|
||
if (typeof requisitions !== 'undefined') {
|
||
requisitions.getBarFunnel(ac.reqId);
|
||
room_requisitions.getBarFunnel(ac.reqId);
|
||
console.log(requisitions.page);
|
||
if(requisitions.view == 'kanban'){
|
||
//requisitions.page = requisitions.page+1;
|
||
requisitions.get_req_id(ac.reqId, 1);
|
||
} else if(requisitions.view == 'list'){
|
||
requisitions.get_req_id(ac.reqId);
|
||
}
|
||
/* if (ac.kanbanReq) {
|
||
requisitions.getList();
|
||
ac.kanbanReq = false;
|
||
}*/
|
||
//console.log(ac.activites_close_step_val);
|
||
if (!ac.isEmpty(ac.activites_close_step_val)) {
|
||
var name_tag = '';
|
||
console.log(requisitions.req['req' + ac.reqId]);
|
||
requisitions.req['req' + ac.reqId].activities = ac.activites_close_step_val;
|
||
for (var i = 0; i < requisitions.req['req' + ac.reqId].activities.length; i++) {
|
||
if (name_tag != '') name_tag += ', ';
|
||
name_tag += requisitions.activities_name['act' + requisitions.req['req' + ac.reqId].activities[i]];
|
||
}
|
||
requisitions.req['req' + ac.reqId].activities_name = name_tag;
|
||
requisitions.req['req' + ac.reqId].add_tag = false;
|
||
ac.activites_close_step_val = null;
|
||
}
|
||
} else {
|
||
//if(page == '/charts.php'){
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_bar_funnel',
|
||
funnel_id: ac.step.funnel_id,
|
||
req_id: ac.reqId,
|
||
adjacent_id: 0,
|
||
}, )
|
||
.then((response) => {
|
||
ac.closesStep = false;
|
||
ac.is_looad = false;
|
||
ac.is_load_open = false;
|
||
ac.isOpenPrevStep = false;
|
||
//console.log(response.data);
|
||
var bar = response.data;
|
||
|
||
//console.log($('#client-history__bg').css('display'));
|
||
if ($('#client-history__bg').css('display') != 'none') {
|
||
$('#client-history__bg .crm__small-stagebar .stage').removeClass('nextStep');
|
||
$('#client-history__bg .crm__small-stagebar .stage').removeClass('active');
|
||
for (var i in bar.bar) {
|
||
$('#client-history__bg .crm__small-stagebar .stageFunnel__' + bar.bar[i].id).addClass(bar.bar[i].classF);
|
||
}
|
||
$('#client-history__bg .stagebar-title').text(bar.stage);
|
||
}
|
||
})
|
||
.catch(function(error) {
|
||
console.error(error);
|
||
});
|
||
// }
|
||
}
|
||
|
||
if (typeof requisitions_client !== 'undefined') {
|
||
requisitions_client.getBarFunnel(ac.reqId);
|
||
}
|
||
|
||
if (typeof requisitions_object !== 'undefined') {
|
||
requisitions_object.getBarFunnel(ac.reqId);
|
||
}
|
||
|
||
if (typeof reqobj !== 'undefined') {
|
||
reqobj[ac.reqId].getBarFunnel(ac.reqId);
|
||
}
|
||
}
|
||
|
||
$('#client__' + ac.clientId + ' .stage').removeClass('nextStep');
|
||
$('#client__' + ac.clientId + ' .stage').removeClass('active');
|
||
for (var i in steps) {
|
||
$('#client__' + ac.clientId + ' .stageFunnel__' + i).addClass(steps[i]);
|
||
}
|
||
$('#client__' + ac.clientId + ' .stagebar-title').text(steps.stage);
|
||
var isHidden = 0;
|
||
if ($('#client__' + ac.clientId + ' .main-info.hidden').length > 0) {
|
||
isHidden = 1;
|
||
}
|
||
if (ac.step.stage == 'Закрыт') {
|
||
$("#del_client_bg").fadeIn(500);
|
||
|
||
$("#del_client").toggle(10);
|
||
|
||
$("#del_client").find('input[name="id_funnel_client"]').val(ac.step.funnel_id);
|
||
$("#del_client").find('input[name="id_del_client"]').val(ac.clientId);
|
||
$("#del_client #id_del_req").val(ac.reqId);
|
||
|
||
$("#del_client #temp_id").val(steps.tempid);
|
||
set_select_denial_work(ac.reqId);
|
||
$("body").addClass("lock");
|
||
}
|
||
if (ac.prevStage == ac.step.stage && !ac.kanban) {
|
||
|
||
if(ac.clientId > 0){
|
||
axios.post('/ajax/get_step_details.php', {
|
||
client_id: ac.clientId,
|
||
funnel_id: ac.step.funnel_id,
|
||
is_hidden: isHidden
|
||
})
|
||
.then(function(response) {
|
||
//console.log(response.data);
|
||
//get_count_clients();
|
||
$('#step_details_' + ac.clientId).html(response.data);
|
||
})
|
||
.catch(function(error) {
|
||
ac.errorText = error;
|
||
ac.errorMes = true;
|
||
});
|
||
}
|
||
} else {
|
||
if (ac.kanban) {
|
||
if(ac.clientId > 0){
|
||
get_count_clients();
|
||
}
|
||
} else {
|
||
if(ac.clientId !== undefined)
|
||
get_list();
|
||
}
|
||
}
|
||
if ($('#client-history__bg').css('display') != 'none') {
|
||
if (ac.clientId === undefined) ac.clientId = 0;
|
||
var url = '/ajax/getClientLogForEventsNew.php?id=' + ac.clientId;
|
||
if (ac.reqId > 0) {
|
||
url += "&req_id=" + ac.reqId;
|
||
}
|
||
|
||
$.ajax({
|
||
url: url,
|
||
success: function(data) {
|
||
$('#client-info-block').html(data);
|
||
$('#client_history .history__chat-n').animate({
|
||
scrollTop: $('#client-info-block').prop("scrollHeight")
|
||
}, 500, function() {
|
||
$('#client_history .history__chat-n').slimScroll({ scrollTo: $('#client-info-block').prop("scrollHeight") + 'px' });
|
||
});
|
||
if ($('#calendar').length) {
|
||
$('#calendar').fullCalendar('refetchEvents');
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
})
|
||
.catch(function(error) {
|
||
ac.errorText = error;
|
||
ac.errorMes = true;
|
||
});
|
||
}
|
||
}
|
||
},
|
||
openStep: function(id, clientId) {
|
||
this.open_step_load = true;
|
||
ac.pole_dop_close_step = [];
|
||
this.is_looad = false;
|
||
this.dealCloseData = null;
|
||
this.dealCloseReqs = [];
|
||
this.dealCloseObjects = [];
|
||
this.dealCloseAgentCommission = 0;
|
||
this.dealCloseSumma = 0;
|
||
if ($('#client-history__bg').css('display') == 'block') {
|
||
$('#client-history__bg').css('zIndex', '99988');
|
||
}
|
||
ac.fieldModels = [];
|
||
ac.fields = [];
|
||
ac.forms = [];
|
||
ac.options = [];
|
||
ac.nextStepSelect = '';
|
||
ac.selectFiles = [];
|
||
ac.step.pole_end_list = JSON.parse(ac.step.pole_end_list);
|
||
console.log(ac.step.pole_end_list);
|
||
for (var i in ac.step.pole_end_list) {
|
||
|
||
ac.selectFiles.push({ 'file': {}, 'typeFile': '', 'classFile': '', 'guid': '', 'progress': 0, 'name': '', 'isUpload': false, 'uploads': false, 'is': false });
|
||
}
|
||
|
||
|
||
|
||
ac.$set(ac.step, 'vidPole', []);
|
||
ac.$set(ac.step, 'values', []);
|
||
ac.errorText = '';
|
||
ac.errorMes = false;
|
||
// console.log(ac.step.doers);
|
||
ac.stepDoers = JSON.parse(ac.step.doers.replace(/""/g, "\""));
|
||
ac.$set(ac.step, 'tasks', []);
|
||
ac.tasks = [];
|
||
ac.no_close_step = false;
|
||
ac.adjacent_funnels = [];
|
||
axios.post('/ajax/ajax_vue_clients.php', {
|
||
request: 'openDetailsStep',
|
||
client_id: ac.clientId,
|
||
req_id: ac.reqId,
|
||
adjacent_id: ac.adjacentId,
|
||
step_id: ac.step.id,
|
||
}, )
|
||
.then(function(response) {
|
||
ac.open_step_load = false;
|
||
var res = response.data;
|
||
if(res.no_close_step){
|
||
ac.no_close_step = res.no_close_step;
|
||
ac.adjacent_funnels = res.adjacent_funnels;
|
||
|
||
} else {
|
||
if (res != 0) {
|
||
ac.selectedRoom = {
|
||
id: res.room_id,
|
||
name: `${res.complex_name}/${res.house_name}<br/> ${ac.room_types[res.room_type]} № ${res.room_number} ID ${res.room_id}`,
|
||
plan_url: res.plan_url,
|
||
complex_id: res.complex_id,
|
||
house_id: res.house_id,
|
||
complex_entrance_id: res.room_complex_entrance_id,
|
||
floor_id: res.room_floor_id,
|
||
transaction_amount: res.room_total_amount
|
||
}
|
||
|
||
ac.step_complex_status_id = ac.step.complex_status_id > 0 ? ac.step.complex_status_id : res.complex_status_id
|
||
|
||
for (var i in res) {
|
||
if (i == 'next_step_select') {
|
||
ac.nextStepSelect = res.next_step_select;
|
||
if (ac.nextStepSelect && ac.nextStepSelect.id && ac.nextStepSelect.id.id) {
|
||
//if (ac.nextStepSelect.name === undefined) {
|
||
let temp_next = ac.step.arr_next_steps.find((el, idx) => el.id && ac.nextStepSelect && ac.nextStepSelect.id && el.id.id == ac.nextStepSelect.id.id);
|
||
//console.log(temp_next);
|
||
if (temp_next === undefined) {
|
||
ac.nextStepSelect = '';
|
||
} else {
|
||
if (temp_next.name) {
|
||
if (ac.nextStepSelect.name === undefined) {
|
||
ac.nextStepSelect.name = temp_next.name;
|
||
}
|
||
} else {
|
||
ac.nextStepSelect.name = '';
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if (res[i]) {
|
||
if (res[i].type == 'checkbox') {
|
||
if (res[i].value != '') {
|
||
ac.tasks = res[i].value;
|
||
}
|
||
|
||
ac.$set(ac.step.values[i], 'value', res[i].value);
|
||
} else
|
||
if (res[i].type == 'file') {
|
||
ac.$set(ac.step.values[i], 'value', res[i].value);
|
||
if (res[i].value.file) {
|
||
for (var f in res[i].value) {
|
||
ac.$set(ac.selectFiles[i], f, res[i].value[f]);
|
||
}
|
||
|
||
}
|
||
} else if (res[i].type == 'textarea' || res[i].type == 'input' || res[i].type == 'date' || res[i].type == 'deposit' || res[i].type == 'commission' || res[i].type == 'expenses') {
|
||
if(res[i].value.file) res[i].value = '';
|
||
ac.$set(ac.step.values[i], 'value', res[i].value);
|
||
//ac.step.values[] = res;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
ac.activites_close_step_val = null;
|
||
if (!this.isEmpty(ac.step.pole_dop)) {
|
||
//console.log(JSON.parse(ac.step.pole_dop));
|
||
axios.post('/ajax/ajax_vue_clients.php', {
|
||
request: 'get_pole_dop_details',
|
||
client_id: ac.clientId,
|
||
req_id: ac.reqId,
|
||
step_id: ac.step.id,
|
||
pole_dop: JSON.parse(ac.step.pole_dop),
|
||
user_id: this.user_id,
|
||
}, )
|
||
.then((response) => {
|
||
// console.log(response.data);
|
||
ac.pole_dop_close_step = response.data;
|
||
if (ac.pole_dop_close_step.add_activity_close_step && !this.isEmpty(ac.pole_dop_close_step.add_activity_close_step)) {
|
||
console.log(ac.pole_dop_close_step.add_activity_close_step.activities_val);
|
||
ac.activites_close_step_val = ac.pole_dop_close_step.add_activity_close_step.activities_val;
|
||
}
|
||
// console.log(ac.pole_dop_close_step);
|
||
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
|
||
}
|
||
|
||
var vala = [];
|
||
if (ac.step.pole_end_list.length > 0) {
|
||
for (var i = 0; i < ac.step.pole_end_list.length; i++) {
|
||
ac.step.vidPole.push(ac.typePole[ac.step.pole_end_list[i].type]);
|
||
var val = { 'name': ac.step.pole_end_list[i].name, 'type': ac.step.vidPole[i], 'value': '' };
|
||
|
||
ac.$set(ac.step.values, i, {});
|
||
ac.$set(ac.step.values[i], 'name', ac.step.pole_end_list[i].name);
|
||
ac.$set(ac.step.values[i], 'type', ac.step.vidPole[i]);
|
||
console.log(ac.step.vidPole[i]);
|
||
if(ac.step.vidPole[i] == 'expenses'){
|
||
ac.$set(ac.step.values[i], 'value', {'summa':'', 'comment':''});
|
||
} else
|
||
ac.$set(ac.step.values[i], 'value', '');
|
||
/* if(ac.step.vidPole[i] == 'checkbox'){
|
||
val = {'name': ac.step.pole_end_list[i].name,'type':ac.step.vidPole[i], 'value': false};
|
||
}*/
|
||
// vala.push(val);
|
||
if (ac.step.pole_end_list[i].dopSettings.select && !this.isEmpty(ac.step.arr_next_steps)) {
|
||
|
||
ac.step.arr_next_steps = JSON.parse(ac.step.arr_next_steps);
|
||
ac.options = ac.step.arr_next_steps;
|
||
}
|
||
if (ac.step.vidPole[i] == 'date') {
|
||
$('#datepickerApp').datepicker({
|
||
autoClose: 'true'
|
||
});
|
||
}
|
||
}
|
||
}
|
||
//ac.step.values = vala
|
||
//console.log(ac.step.values);
|
||
for (var i in ac.step.files) {
|
||
ac.step.files[i].typeFile = ac.typeFile(ac.step.files[i].name);
|
||
ac.step.files[i].classFile = ac.classTypesFile[ac.step.files[i].typeFile];
|
||
}
|
||
|
||
//Сопряженные поля с клиентом/заявкой
|
||
axios.post('/ajax/ajax_vue_clients.php', {
|
||
request: 'openLinkingStep',
|
||
client_id: ac.clientId,
|
||
req_id: ac.reqId,
|
||
step_id: ac.step.id,
|
||
agency_id: $('#session_agency_id').val(),
|
||
}, )
|
||
.then((response) => {
|
||
// console.log(response.data);
|
||
ac.fields = response.data.fields;
|
||
|
||
|
||
var values = response.data.values;
|
||
if (!this.isEmpty(ac.fields)) {
|
||
for (var i = 0; i < ac.fields.length; i++) {
|
||
|
||
this.$set(ac.fieldModels, 'model_' + ac.fields[i].id, null);
|
||
if (ac.fields[i].is_podgroup > 0) {
|
||
for (var j = 0; j < ac.fields[i].podgroups.length; j++) {
|
||
this.$set(this.fieldModels, 'modelp_' + ac.fields[i].podgroups[j].id, null);
|
||
}
|
||
}
|
||
}
|
||
for (var index in this.fieldModels) {
|
||
if (index.indexOf('model') != -1) {
|
||
|
||
if (!this.isEmpty(values[index])) {
|
||
if (this.IsJsonString(values[index])) {
|
||
this.fieldModels[index] = JSON.parse(values[index]);
|
||
} else {
|
||
this.fieldModels[index] = values[index];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
// console.log(this.forms);
|
||
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
|
||
// Загрузка данных сделки для блока закрытия
|
||
if (ac.step.is_deal === 1) {
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_deal_by_req',
|
||
req_id: ac.reqId,
|
||
})
|
||
.then(function(response) {
|
||
var res = typeof response.data === 'string' ? JSON.parse(response.data) : response.data;
|
||
if (res.deal_id) {
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_deal_data',
|
||
deal_id: res.deal_id,
|
||
})
|
||
.then(function(dealRes) {
|
||
var dealData = dealRes.data.deal;
|
||
if (dealData) {
|
||
ac.dealCloseData = dealData;
|
||
ac.dealCloseAgentCommission = dealData.agent_commission || 0;
|
||
ac.dealCloseSumma = dealData.contract_price || 0;
|
||
|
||
// Загрузка связанных заявок
|
||
var reqIds = [];
|
||
if (dealData.side_one_requisition_id) reqIds.push(dealData.side_one_requisition_id);
|
||
if (dealData.side_two_requisition_id) reqIds.push(dealData.side_two_requisition_id);
|
||
if (reqIds.length > 0) {
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_deals_linked_reqs',
|
||
req_ids: reqIds,
|
||
})
|
||
.then(function(reqRes) {
|
||
ac.dealCloseReqs = reqRes.data.reqs || [];
|
||
});
|
||
}
|
||
|
||
// Загрузка связанных объектов
|
||
var objIds = [];
|
||
if (dealData.side_one_object_id) objIds.push(dealData.side_one_object_id);
|
||
if (dealData.side_two_object_id) objIds.push(dealData.side_two_object_id);
|
||
if (objIds.length > 0) {
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_deals_linked_objects',
|
||
object_ids: objIds,
|
||
})
|
||
.then(function(objRes) {
|
||
ac.dealCloseObjects = objRes.data.objects || [];
|
||
});
|
||
}
|
||
}
|
||
});
|
||
}
|
||
});
|
||
}
|
||
},
|
||
|
||
IsJsonString(str) {
|
||
try {
|
||
JSON.parse(str);
|
||
} catch (e) {
|
||
return false;
|
||
}
|
||
return true;
|
||
},
|
||
|
||
set_autosearch() {
|
||
console.log(ac.pole_dop_close_step);
|
||
let asfilter_id = ac.pole_dop_close_step.req.autosearch_id;
|
||
let autoSearchEnabled = ac.pole_dop_close_step.req.autoSearchEnabled;
|
||
let req_id = ac.pole_dop_close_step.req.id;
|
||
|
||
|
||
|
||
axios.post('/ajax/ajax_vue_clients.php', {
|
||
request: 'set_autosearch_pole_dop',
|
||
req_id: req_id,
|
||
autosearch_enabled: autoSearchEnabled,
|
||
asfilter_id: asfilter_id,
|
||
user_id: this.user_id,
|
||
}, )
|
||
.then((response) => {
|
||
// console.log(response.data);
|
||
// ac.pole_dop_close_step = response.data;
|
||
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
},
|
||
open_form_contract(parent_id, type) {
|
||
if (type == 'req') {
|
||
parent_id = 'req' + parent_id;
|
||
}
|
||
open_form_contract(parent_id, 0, type);
|
||
|
||
},
|
||
onFileSelected(event) {
|
||
|
||
var id = $(event.target).data("id");
|
||
ac.$set(ac.selectFiles[id], 'uploads', false);
|
||
ac.$set(ac.selectFiles[id], 'isUpload', false);
|
||
ac.$set(ac.selectFiles[id], 'progress', 0);
|
||
var file = event.target.files[0];
|
||
console.log(id);
|
||
const MAX_FILE_SIZE = 16 * 1024 * 1024;
|
||
if(file.size < MAX_FILE_SIZE){
|
||
console.log(ac);
|
||
|
||
if (file.name) {
|
||
ac.selectFiles[id].file = file;
|
||
ac.selectFiles[id].typeFile = ac.typeFile(file.name).toLowerCase();
|
||
|
||
if (ac.selectFiles[id].typeFile !== 'doc' && ac.selectFiles[id].typeFile !== 'docx' && ac.selectFiles[id].typeFile !== 'xls'
|
||
&& ac.selectFiles[id].typeFile !== 'xlsx' && ac.selectFiles[id].typeFile !== 'pdf' && ac.selectFiles[id].typeFile !== 'jpeg' && ac.selectFiles[id].typeFile !== 'jpg'
|
||
&& ac.selectFiles[id].typeFile !== 'gif' && ac.selectFiles[id].typeFile !== 'png' && ac.selectFiles[id].typeFile !== 'mp3'
|
||
&& ac.selectFiles[id].typeFile !== 'zip' && ac.selectFiles[id].typeFile !== 'rar') {
|
||
alert("Неверный тип файла");
|
||
return;
|
||
}
|
||
|
||
ac.selectFiles[id].classFile = ac.classTypesFile[ac.selectFiles[id].typeFile];
|
||
ac.selectFiles[id].guid = '';
|
||
ac.selectFiles[id].is = true;
|
||
ac.selectFiles[id].name = file.name;
|
||
}
|
||
// console.log(ac.selectFiles);
|
||
ac.onUpload(id, file);
|
||
}
|
||
else {
|
||
const sizeMB = (file.size / 1024 / 1024).toFixed(1);
|
||
ac.notSelectedFileMessage = `${file.name} ${sizeMB} MБ`;
|
||
console.log(ac.notSelectedFileMessage);
|
||
|
||
}
|
||
},
|
||
onUpload: function(index, file) {
|
||
ac.$set(ac.selectFiles[index], 'uploads', true);
|
||
ac.$set(ac.selectFiles[index], 'isUpload', false);
|
||
ac.$set(ac.selectFiles[index], 'progress', 0);
|
||
let fd = new FormData();
|
||
fd.append('client_id', ac.clientId);
|
||
fd.append('req_id', ac.reqId);
|
||
fd.append('type_file', ac.selectFiles[index].typeFile);
|
||
fd.append('etap_id', ac.stepId);
|
||
fd.append('file', file);
|
||
|
||
axios.post('/ajax/vue_upload.php', fd, {
|
||
onUploadProgress: progressEvent => {
|
||
var pr = Math.ceil(progressEvent.loaded / progressEvent.total * 100);
|
||
ac.$set(ac.selectFiles[index], 'progress', pr);
|
||
}
|
||
})
|
||
.then(function(response) {
|
||
if (response.data.res === 'done') {
|
||
// console.log(response.data);
|
||
ac.$set(ac.selectFiles[index], 'guid', response.data.guid);
|
||
ac.$set(ac.selectFiles[index], 'isUpload', true);
|
||
|
||
ac.step.values[index].value = ac.selectFiles[index];
|
||
ac.$set(ac.selectFiles[index], 'uploads', false);
|
||
} else {
|
||
// alert(response.data.res);
|
||
}
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
|
||
},
|
||
onDeleteFile: function(index, guid) {
|
||
$('.ui-tooltip').remove();
|
||
ac.$set(ac.selectFiles, index, { 'file': {}, 'typeFile': '', 'classFile': '', 'guid': '', 'progress': 0, 'name': '', 'isUpload': false, 'uploads': false, 'is': false });
|
||
ac.step.values[index].value = '';
|
||
|
||
},
|
||
openUpdate: function() {
|
||
ac.listDoers = [];
|
||
ac.objects = [];
|
||
ac.updateWhoWork = true;
|
||
console.log(ac.clientId);
|
||
|
||
axios.post('/ajax/ajax_vue_clients.php', {
|
||
request: 'get_objects',
|
||
client_id: ac.clientId
|
||
})
|
||
.then(function(res) {
|
||
if (res != 0) {
|
||
ac.objects = res.data;
|
||
}
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
|
||
$.post("/ajax/get_who_work.php", {
|
||
funnel_id: ac.step.funnel_id,
|
||
step_id: ac.stepId,
|
||
upStep: 1
|
||
}, function(res) {
|
||
|
||
var html = '<select name="who_work" id="update-client-work">' + res + '</select>';
|
||
|
||
$(".inputs.updateSelect").html(html);
|
||
$('#update-client-work [value=0]').remove();
|
||
$("#update-client-work").fastselect({
|
||
placeholder: 'Ответственный'
|
||
});
|
||
ac.updateWhoWork = true;
|
||
});
|
||
ac.getDoer();
|
||
|
||
},
|
||
|
||
getDoer: function() {
|
||
axios.post('/ajax/ajax_vue_funnel.php', {
|
||
request: 'get_doers',
|
||
agency_id: $('#session_agency_id').val()
|
||
})
|
||
.then(function(response) {
|
||
// console.log(response.data);
|
||
var tempDoers = response.data;
|
||
// console.log(ac.step.doers);
|
||
var doersUsers = JSON.parse(ac.step.doers);
|
||
//console.log(doersUsers);
|
||
|
||
var doersId = [];
|
||
if (doersUsers.length > 0) {
|
||
for (var i = 0; i < doersUsers.length; i++) {
|
||
doersId.push(doersUsers[i].id);
|
||
}
|
||
}
|
||
//console.log(doersId);
|
||
if (doersId.length > 0) {
|
||
for (var i in tempDoers) {
|
||
// console.log(tempDoers[i].manager.id+'-'+doersId.indexOf(tempDoers[i].manager.id));
|
||
if (doersId.indexOf(tempDoers[i].manager.id) == -1) {
|
||
tempDoers[i].isManager = false;
|
||
} else {
|
||
tempDoers[i].isManager = true;
|
||
}
|
||
if (tempDoers[i].agents !== undefined) {
|
||
var tempArrAgents = [];
|
||
// console.log(tempDoers[i].agents);
|
||
for (var a in tempDoers[i].agents) {
|
||
// console.log(tempDoers[i].agents[a].id+'-'+doersId.indexOf(tempDoers[i].agents[a].id));
|
||
if (doersId.indexOf(tempDoers[i].agents[a].id) != -1) {
|
||
tempArrAgents.push(tempDoers[i].agents[a]);
|
||
// tempArrAgents.splice(a, 1);
|
||
}
|
||
}
|
||
|
||
if (tempArrAgents.length == 0) {
|
||
tempDoers[i].isAgents = false;
|
||
} else {
|
||
tempDoers[i].isAgents = true;
|
||
tempDoers[i].agents = tempArrAgents;
|
||
}
|
||
} else {
|
||
tempDoers[i].isAgents = false;
|
||
}
|
||
}
|
||
|
||
} else {
|
||
for (var i in tempDoers) {
|
||
tempDoers[i].isManager = true;
|
||
// console.log(tempDoers[i].agents);
|
||
if (tempDoers[i].agents !== undefined && tempDoers[i].agents.length > 0) {
|
||
tempDoers[i].isAgents = true;
|
||
} else {
|
||
tempDoers[i].isAgents = false;
|
||
}
|
||
}
|
||
}
|
||
//console.log(tempDoers);
|
||
ac.doers = tempDoers;
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
},
|
||
selectDoer: function(doerId, userId, otdel) {
|
||
if (otdel == 'all') {
|
||
// for(var id in ac.doers[doerId].manager){
|
||
if (ac.doers[doerId].isManager) {
|
||
var fio = ac.doers[doerId].manager.fio;
|
||
var id = ac.doers[doerId].manager.id;
|
||
var isDoer = false;
|
||
if (ac.listDoers.find(x => x.id === id) === undefined) {
|
||
var newDoer = { 'fio': fio, 'id': id };
|
||
ac.listDoers.push(newDoer);
|
||
}
|
||
}
|
||
for (var i in ac.doers[doerId].agents) {
|
||
var fio = ac.doers[doerId].agents[i].fio;
|
||
var id = ac.doers[doerId].agents[i].id;
|
||
var isDoer = false;
|
||
if (ac.listDoers.find(x => x.id === id) === undefined) {
|
||
var newDoer = { 'fio': fio, 'id': id };
|
||
ac.listDoers.push(newDoer);
|
||
}
|
||
}
|
||
}
|
||
if (otdel == 'manager') {
|
||
var fio = ac.doers[doerId].manager.fio;
|
||
var id = ac.doers[doerId].manager.id;
|
||
var isDoer = false;
|
||
if (ac.listDoers.find(x => x.id === id) === undefined) {
|
||
var newDoer = { 'fio': fio, 'id': id };
|
||
ac.listDoers.push(newDoer);
|
||
}
|
||
}
|
||
if (otdel == 'agent') {
|
||
var fio = ac.doers[doerId].agents[userId].fio;
|
||
var id = ac.doers[doerId].agents[userId].id;
|
||
var isDoer = false;
|
||
if (ac.listDoers.find(x => x.id === id) === undefined) {
|
||
var newDoer = { 'fio': fio, 'id': id };
|
||
ac.listDoers.push(newDoer);
|
||
}
|
||
}
|
||
// }
|
||
// console.log(ac.listDoers);
|
||
},
|
||
seeDoer: function(id) {
|
||
if (ac.doers[id].isSee) {
|
||
ac.doers[id].isSee = false;
|
||
} else {
|
||
ac.doers[id].isSee = true;
|
||
}
|
||
},
|
||
deleteDoer: function(doerId) {
|
||
ac.listDoers.splice(doerId, 1);
|
||
$('.ui-tooltip').remove();
|
||
},
|
||
saveUpdateUser: function() {
|
||
//console.log(ac.listDoers);
|
||
var user_obj = $('#update-client-work').val();
|
||
// console.log(user_obj+ ' ' + ac.objects[0].id);
|
||
|
||
axios.post('/ajax/ajax_vue_clients.php', {
|
||
request: 'saveUpdateUser',
|
||
client_id: ac.clientId,
|
||
req_id: ac.reqId,
|
||
doers: ac.listDoers,
|
||
user_id: ac.nowUserId,
|
||
user_obj: user_obj,
|
||
objects: ac.objects
|
||
}, )
|
||
.then(function(response) {
|
||
// console.log(response.data);
|
||
ac.updateWhoWork = false;
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
},
|
||
typeFile: function(nameFile) {
|
||
var tchk = nameFile.lastIndexOf(".");
|
||
|
||
if (tchk != -1) {
|
||
return nameFile.slice(tchk + 1);
|
||
}
|
||
return 'undefined';
|
||
},
|
||
|
||
onloadForm: function() {
|
||
$('#app_step').removeClass('hidden');
|
||
this.nowUserId = $('#nowUserId').val();
|
||
},
|
||
|
||
//Закрытие окна "открыть этап"
|
||
formClosePrevStep: function() {
|
||
if (ac.kanbanReq) {
|
||
if (typeof requisitions !== 'undefined') {
|
||
requisitions.getBarFunnel(ac.reqId);
|
||
if (ac.kanbanReq) {
|
||
requisitions.getList();
|
||
ac.kanbanReq = false;
|
||
}
|
||
}
|
||
ac.kanbanReq = false;
|
||
}
|
||
console.log(ac.kanban);
|
||
if (ac.kanban) {
|
||
$('.kanban__items-lists .kanban__items-list .kanban__sortable .kanban__item').remove();
|
||
page_kanban = 1;
|
||
get_list();
|
||
}
|
||
this.isOpenPrevStep = false;
|
||
},
|
||
//Закрытие окна "открыть этап"
|
||
formCloseStep: function() {
|
||
if ($('#client-history__bg').css('display') == 'block') {
|
||
$('#client-history__bg').css('zIndex', '99998');
|
||
}
|
||
|
||
if (ac.kanbanReq) {
|
||
if (typeof requisitions !== 'undefined') {
|
||
let html_li = '<li id="kanban_item_li_' + ac.reqId + '" class="kanban__item p0">' + $("#kanban_item_li_" + ac.reqId).html() + '</li>';
|
||
$("#kanban_item_li_" + ac.reqId).remove();
|
||
if (!this.isEmpty(requisitions.prev_selectors.li)) {
|
||
$('#' + requisitions.prev_selectors.ul + ' ' + '#' + requisitions.prev_selectors.li).after(html_li);
|
||
} else {
|
||
$('#' + requisitions.prev_selectors.ul).prepend(html_li);
|
||
}
|
||
//req50882
|
||
$("#kanban_item_li_" + ac.reqId + " .get_req_index").off('click');
|
||
$("#kanban_item_li_" + ac.reqId + " .get_req_index").click(function(){
|
||
requisitions.getReq('req'+ac.reqId);
|
||
});
|
||
|
||
requisitions.prev_selectors = { 'li': null, 'ul': null };
|
||
requisitions.getBarFunnel(ac.reqId);
|
||
|
||
}
|
||
ac.kanbanReq = false;
|
||
}
|
||
//console.log(ac.kanban);
|
||
if (ac.kanban) {
|
||
$('.kanban__items-lists .kanban__items-list .kanban__sortable .kanban__item').remove();
|
||
page_kanban = 1;
|
||
get_list();
|
||
}
|
||
ac.closesStep = false;
|
||
ac.notSelectedFileMessage = "";
|
||
|
||
},
|
||
selectOpenStep() {
|
||
//console.log(this.step_id_open);
|
||
this.errorMesPrevStep = false;
|
||
this.errorTextPrevStep = "";
|
||
if (!this.isEmpty(this.step_id_open)) {
|
||
this.step_name_open = this.list_open_step.find((el, idx) => el.id == this.step_id_open).name;
|
||
} else {
|
||
this.errorMesPrevStep = true;
|
||
this.errorTextPrevStep = "Не выбран этап для открытия";
|
||
this.step_name_open = '';
|
||
}
|
||
},
|
||
//Открытие предыдущего этапа
|
||
openPrevStep: function() {
|
||
this.errorMesPrevStep = false;
|
||
this.errorTextPrevStep = "";
|
||
this.load_open_step = true;
|
||
this.step_id_open = null;
|
||
this.list_open_step = [];
|
||
this.stepPrev = [];
|
||
this.step_name_open = '';
|
||
this.is_Other_prev_step = 0;
|
||
if ($('#client-history__bg').css('display') == 'block') {
|
||
$('#client-history__bg').css('zIndex', '99988');
|
||
}
|
||
ac.errorTextPrevStep = '';
|
||
ac.errorMesPrevStep = false;
|
||
this.isOpenPrevStep = true;
|
||
axios.post('/ajax/ajax_vue_clients.php', {
|
||
request: 'openPrevStep',
|
||
client_id: ac.clientId,
|
||
req_id: ac.reqId,
|
||
adjacent_id: ac.adjacentId,
|
||
}, )
|
||
.then((response) => {
|
||
this.load_open_step = false;
|
||
this.list_open_step = response.data.steps;
|
||
if (!this.isEmpty(response.data.res.step_id) && response.data.res.step_id > 0) {
|
||
// this.step_id_open = response.data.res.step_id;
|
||
this.step_name_open = response.data.res.name;
|
||
} else {
|
||
this.errorMesPrevStep = true;
|
||
this.errorTextPrevStep = "Не выбран этап для открытия";
|
||
}
|
||
// ac.stepPrev = response.data;
|
||
|
||
//ac.updateWhoWork=false;
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
},
|
||
saveOpenPrevStep: function() {
|
||
// console.log(ac.adjacentId);
|
||
ac.errorTextPrevStep = '';
|
||
ac.errorMesPrevStep = false;
|
||
var now_step_id = $('#client__' + ac.clientId + ' .nextStep .crm__small-step').data("stage");
|
||
if ($('#req__' + ac.reqId + ' .nextStep .crm__small-step').length > 0) {
|
||
now_step_id = $('#req__' + ac.reqId + ' .nextStep .crm__small-step').data("stage");
|
||
}
|
||
if (this.is_Other_prev_step == 1 && this.isEmpty(this.step_id_open)) {
|
||
ac.errorTextPrevStep = 'Не выбран этап для открытия';
|
||
ac.errorMesPrevStep = true;
|
||
} else {
|
||
let stepInfo = [];
|
||
if (this.is_Other_prev_step == 1) {
|
||
stepInfo = this.list_open_step.find((el, idx) => el.id == this.step_id_open);
|
||
}
|
||
this.is_load_open = true;
|
||
|
||
axios.post('/ajax/ajax_vue_clients.php', {
|
||
request: 'saveOpenPrevStep',
|
||
user_id: ac.nowUserId,
|
||
step_id: ac.step_id_open,
|
||
client_id: ac.clientId,
|
||
req_id: ac.reqId,
|
||
adjacent_id: ac.adjacentId,
|
||
now_step_id: now_step_id,
|
||
is_Other_prev_step: this.is_Other_prev_step,
|
||
stepInfo: stepInfo,
|
||
}, )
|
||
.then((response) => {
|
||
console.log(response.data);
|
||
if(ac.adjacentId > 0){
|
||
if(ac.reqId > 0){
|
||
if (typeof requisitions !== 'undefined') {
|
||
requisitions.getBarFunnel(ac.reqId, ac.adjacentId);
|
||
if (ac.kanbanReq) {
|
||
requisitions.getList();
|
||
ac.kanbanReq = false;
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
$.post('/ajax/getStageBar.php', { client_id: ac.clientId, funnel_id: ac.step.funnel_id }, function(result) {
|
||
$('#editClientStagebar').html(result);
|
||
ac.is_load_open = false;
|
||
ac.isOpenPrevStep = false;
|
||
});
|
||
var steps = response.data;
|
||
if (steps == 0) {
|
||
ac.errorTextPrevStep = 'Произошла ошибка при открытии этапа';
|
||
ac.errorMesPrevStep = true;
|
||
} else {
|
||
if (ac.reqId > 0) {
|
||
|
||
if (typeof requisitions !== 'undefined') {
|
||
requisitions.getBarFunnel(ac.reqId);
|
||
if (ac.kanbanReq) {
|
||
requisitions.getList();
|
||
ac.kanbanReq = false;
|
||
}
|
||
} else {
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_bar_funnel',
|
||
funnel_id: ac.step.funnel_id,
|
||
req_id: ac.reqId,
|
||
adjacent_id: 0,
|
||
}, )
|
||
.then((response) => {
|
||
ac.closesStep = false;
|
||
ac.is_looad = false;
|
||
ac.is_load_open = false;
|
||
ac.isOpenPrevStep = false;
|
||
//console.log(response.data);
|
||
var bar = response.data;
|
||
|
||
//console.log($('#client-history__bg').css('display'));
|
||
if ($('#client-history__bg').css('display') != 'none') {
|
||
$('#client-history__bg .crm__small-stagebar .stage').removeClass('nextStep');
|
||
$('#client-history__bg .crm__small-stagebar .stage').removeClass('active');
|
||
for (var i in bar.bar) {
|
||
$('#client-history__bg .crm__small-stagebar .stageFunnel__' + bar.bar[i].id).addClass(bar.bar[i].classF);
|
||
}
|
||
$('#client-history__bg .stagebar-title').text(bar.stage);
|
||
}
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
}
|
||
if (typeof requisitions_client !== 'undefined') {
|
||
requisitions_client.getBarFunnel(ac.reqId);
|
||
}
|
||
|
||
if (typeof requisitions_object !== 'undefined') {
|
||
requisitions_object.getBarFunnel(ac.reqId);
|
||
}
|
||
|
||
|
||
if (typeof reqobj !== 'undefined') {
|
||
reqobj[ac.reqId].getBarFunnel(ac.reqId);
|
||
}
|
||
} else {
|
||
console.log(2112121212);
|
||
|
||
// ac.isOpenPrevStep = false;
|
||
if ($('#client-history__bg').css('display') == 'block') {
|
||
$('#client-history__bg').css('zIndex', '99998');
|
||
}
|
||
|
||
$('#client__' + ac.clientId + ' .stage').removeClass('nextStep');
|
||
$('#client__' + ac.clientId + ' .stage').removeClass('active');
|
||
for (var i in steps) {
|
||
$('#client__' + ac.clientId + ' .stageFunnel__' + i).addClass(steps[i]);
|
||
}
|
||
$('#client__' + ac.clientId + ' .stagebar-title').text(steps.stage);
|
||
var isHidden = 0;
|
||
if ($('#client__' + ac.clientId + ' .main-info.hidden').length > 0) {
|
||
isHidden = 1;
|
||
}
|
||
|
||
if (ac.prevStage == ac.step.stage && !ac.kanban) {
|
||
axios.post('/ajax/get_step_details.php', {
|
||
client_id: ac.clientId,
|
||
funnel_id: ac.step.funnel_id,
|
||
is_hidden: isHidden
|
||
})
|
||
.then(function(response) {
|
||
//console.log(response.data);
|
||
$('#step_details_' + ac.clientId).html(response.data);
|
||
})
|
||
.catch(function(error) {
|
||
ac.errorText = error;
|
||
ac.errorMes = true;
|
||
});
|
||
} else {
|
||
if (ac.kanban) {
|
||
console.log(ac.kanban);
|
||
get_count_clients();
|
||
} else {
|
||
get_list();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
}
|
||
|
||
},
|
||
isEmpty: function(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;
|
||
}
|
||
},
|
||
//Поиск и сравнение
|
||
isFindValue(val1, val2){
|
||
let res = false;
|
||
|
||
if(!this.isEmpty(val2)){
|
||
if(Array.isArray(val2)){
|
||
for(let i=0; i<val2.length; i++){
|
||
if(val2[i] == val1){
|
||
res = true;
|
||
break;
|
||
}
|
||
}
|
||
} else {
|
||
if(val1 == val2){
|
||
res = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
return res;
|
||
},
|
||
validateEmail: function(email) {
|
||
var result = true;
|
||
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
|
||
|
||
if (reg.test(email) == false) {
|
||
|
||
result = false;
|
||
}
|
||
return result;
|
||
},
|
||
//Сохранение ответственного по смежной воронке
|
||
save_whowork_adjacent(index){
|
||
/* console.log(index);
|
||
console.log(this.adjacent_funnels[index]);*/
|
||
// this.adjacent_funnels[index].save_whowork_adjacent = true;
|
||
axios.post('/ajax/vue_ajax/funnel_axios_vue.php', {
|
||
request: 'save_who_work',
|
||
id: this.adjacent_funnels[index].id,
|
||
who_work: this.adjacent_funnels[index].who_work,
|
||
})
|
||
.then((response) => {
|
||
console.log(response.data);
|
||
this.adjacent_funnels[index].save_whowork_adjacent = true;
|
||
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
|
||
},
|
||
openRoomForm() {
|
||
this.isRoomForm = true;
|
||
},
|
||
closeRoomForm() {
|
||
this.isRoomForm = false;
|
||
this.$refs.complexForFunnel.src = '/complexForFunnel/index.php/#/view';
|
||
|
||
},
|
||
observeRefs() {
|
||
setInterval(() => {
|
||
if (this.$refs.complexForFunnel?.contentWindow?.complexBus)
|
||
{
|
||
this.complexBus = this.$refs.complexForFunnel?.contentWindow?.complexBus
|
||
}
|
||
}, 200)
|
||
},
|
||
initCreateDeal(reqId) {
|
||
if (window.createDeal) {
|
||
window.createDeal(reqId);
|
||
ac.closesStep = false;
|
||
} else {
|
||
console.error('createDeal function not found');
|
||
}
|
||
},
|
||
initEditDeal(reqId) {
|
||
$.ajax({
|
||
url: '/ajax/ajax_vue_requisitions.php',
|
||
type: 'POST',
|
||
contentType: 'application/json',
|
||
data: JSON.stringify({ request: 'get_deal_by_req', req_id: reqId }),
|
||
success: function(response) {
|
||
var res = typeof response === 'string' ? JSON.parse(response) : response;
|
||
if (res.deal_id) {
|
||
window.editDeal(reqId, res.deal_id);
|
||
}
|
||
}
|
||
});
|
||
},
|
||
},
|
||
mounted() {
|
||
this.$nextTick(() => {
|
||
this.observeRefs();
|
||
});
|
||
},
|
||
watch: {
|
||
complexBus(complexBus) {
|
||
if (complexBus) {
|
||
complexBus.$on('selcet-room', (room) => {
|
||
this.selectedRoom = room;
|
||
this.closeRoomForm();
|
||
});
|
||
complexBus.$on('apartament-is-open', (isOpen) => {
|
||
const elements = document.getElementById('complexes_for_funnel_close_icon');
|
||
|
||
if (isOpen)
|
||
{
|
||
elements.style.display = 'none'
|
||
}
|
||
else
|
||
{
|
||
setTimeout(() => elements.style.display = 'block', 350)
|
||
}
|
||
})
|
||
}
|
||
}
|
||
},
|
||
created: function() {
|
||
this.onloadForm();
|
||
}
|
||
});
|
||
|
||
//Для клиентов в задачах для документов
|
||
if ($('#docs-new-client-input-vue').length > 0) {
|
||
var docs_new_client_input_vue = new Vue({
|
||
el: '#docs-new-client-input-vue',
|
||
components: {
|
||
// Multiselect: window.VueMultiselect.default,
|
||
//vuejsDatepicker: window.vuejsDatepicker
|
||
},
|
||
data() {
|
||
return {
|
||
OpenIndicator: {
|
||
render: createElement => createElement('span', { class: { 'vueToggleSpan': true } }),
|
||
},
|
||
clients: [],
|
||
client_id: 0,
|
||
spinner: true,
|
||
clientSelect: [],
|
||
debounceTimer: null,
|
||
values: [],
|
||
}
|
||
},
|
||
methods: {
|
||
clear(){
|
||
|
||
this.clientId = 0;
|
||
this.clientSelect = [];
|
||
},
|
||
selectClientList() {
|
||
//console.log(selectedOption);
|
||
this.client_id = 0;
|
||
//console.log(this.clientSelect);
|
||
//bindObjReq();
|
||
if (!isEmpty(this.clientSelect)) {
|
||
this.client_id = this.clientSelect[this.clientSelect.length - 1].id;
|
||
|
||
this.setValueInput();
|
||
|
||
} else {
|
||
this.client_id = 0;
|
||
this.setValueInput();
|
||
}
|
||
},
|
||
|
||
setValueInput() {
|
||
var values = [];
|
||
for (var i = 0; i < this.clientSelect.length; i++) {
|
||
values.push(this.clientSelect[i].id);
|
||
|
||
}
|
||
this.values = values;
|
||
//$("#docs-new-client-vue").val(JSON.stringify(values));
|
||
},
|
||
get_clientid_req(req_id){
|
||
// console.log(req_id);
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_clientid_req',
|
||
req_id: req_id,
|
||
})
|
||
.then((response) => {
|
||
//console.log(response.data);
|
||
if(!isEmpty(response.data.client_id)){
|
||
this.search_client(response.data.client_id);
|
||
}
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
|
||
},
|
||
getClientsList(search, loading) {
|
||
// console.log(typeof loading);
|
||
if (typeof loading == 'function') {
|
||
loading(true);
|
||
}
|
||
var search_val = '';
|
||
if (!isEmpty(search)) {
|
||
search_val = search;
|
||
}
|
||
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_clients_list',
|
||
search: search_val,
|
||
})
|
||
.then((response) => {
|
||
// console.log(response.data);
|
||
this.clients = response.data;
|
||
if (typeof loading == 'function') {
|
||
loading(false);
|
||
}
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
},
|
||
getClientsListNew(search, loading) {
|
||
|
||
clearTimeout(this.debounceTimer);
|
||
this.debounceTimer = setTimeout(() => this.getClientsList(search, loading), 500);
|
||
|
||
},
|
||
|
||
search_client(client_id) {
|
||
// console.log(client_id);
|
||
if (parseInt(client_id) > 0) {
|
||
// $("#object-new-client-vue").val(client_id);
|
||
axios.post('/ajax/ajax_vue_requisitions.php', {
|
||
request: 'get_client',
|
||
client_id: client_id
|
||
}, )
|
||
.then((response) => {
|
||
//console.log(response.data);
|
||
var this_client = response.data;
|
||
var index = this.clientSelect.length;
|
||
this.$set(this.clientSelect, index, { id: client_id, color: '#000', name: this_client.text, fio: this_client.fio });
|
||
this.setValueInput();
|
||
|
||
})
|
||
.catch(function(error) {
|
||
console.log(error);
|
||
});
|
||
}
|
||
},
|
||
|
||
checkClient(client_id) {
|
||
|
||
//var clientsId = JSON.parse($("#docs-new-client-vue").val());
|
||
// console.log(clientsId.length);
|
||
if (client_id > 0) {
|
||
// for (var i = 0; i < clientsId.length; i++) {
|
||
this.clientId = client_id;
|
||
this.search_client(client_id);
|
||
// }
|
||
}
|
||
|
||
}
|
||
},
|
||
|
||
mounted() {
|
||
|
||
},
|
||
created: function() {
|
||
|
||
this.getClientsList();
|
||
//this.checkClient();
|
||
$("#docs-new-client-input-vue").closest('.inputs').removeClass("hidden");
|
||
}
|
||
})
|
||
} |