Joywork/js/funnel_vue.js
2026-06-10 13:09:29 +03:00

1736 lines
70 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Vue.config.devtools = true;
var app = new Vue({
name: 'tuning_funnel',
el: '#app',
components: {
Multiselect: window.VueMultiselect.default
},
data: {
funnels: [],
id_block: 0,
templateFunnels: [],
changeTemplateFunnels:[],
user_id: this.session_user_id,
agency_id: this.agency_id,
userId: $('#session_user_id').val(),
agencyId: $('#session_agency_id').val(),
name: '',
mes_error: false,
mes_error_update: false,
is_client: 1,
is_req: 1,
is_no_see: 0,
users_see: [{ 'code': '0', 'name': '', 'type':'agent' }],
selected_users_see_no: null,
addFunelmodal: false,
addFunelmodalTemplate: false,
funnelTemplateLoad: true,
isDisabled: true,
updateFunnelmodal: false,
updateStepFunnel: false,
transmitFunnelmodal: false,
mes_error_step: false,
errorTransmite: false,
mesErrorTransmite: '',
error_close: 0,
ctype: [],
clientstypes: [],
role: [],
options_role: [],
errorUpdate: "",
nameUpdate: "",
ctype_update: [],
role_update: [],
funnelId: 0,
stepId: -1,
name_step: "",
order_number: "",
order_number_funnnel: 0,
color_step: "",
days_step: 0,
is_move_end_srok: 0,
tasks_move: { 'is_move': 0, 'is_task': 0 },
start_parallel: 0,
stage: 'В работе',
stages: ['В работе', 'Закрыт'],
selectedFiles: [],
progressUoload: [],
selectedFilesPrev: [],
progressUoloadPrev: [],
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'
},
doers: [],
listDoers: [],
poleType: ['Строка', 'Текст', 'Дата', 'Файл', 'Ветвление этапов', 'Задача на выбор', 'Задаток'],
poleEndlist: [],
tasks: ['Позвонить', 'Встретиться в офисе', 'Встретиться на объекте', 'Текстовая заметка'],
tasksList: [],
name_step_task: '',
docs_step_task: '',
next_step: ['Всегда один'],
nextStep: [],
steps: [],
listSteps: [],
arrNextSteps: [],
nextStepChange: '',
svgPath: [],
isInput: false,
pole_select_value: '',
polesOptionsSetting: [],
onePole: true,
mainSteps: [],
poleListIndex: 0,
errorPole: false,
updateClientStep: false,
clientsSteps: '',
clientsStepsId: 0,
mesUpdateClientStep: false,
textError: '',
mainStep: 0,
OpenIndicator: {
render: createElement => createElement('span', { class: { 'vueToggleSpan': true } }),
},
funnel_transmite: [{ 'id': -1, 'name': '' }],
type_trasmite: '',
funnelTrasmiteId: -1,
process_trasmited: false,
is_show_funnels: 1,
is_stage: 1,
typeTrasmite: '',
delFunnel: 0,
is_mes: false,
users_mes: [],
list_users: [],
adjacent_funnels: [],
list_users_select: [0],
list_users_prev_pole: [],
tab_close: true,
tab_prev_close: false,
tab_dop_close: false,
type_task: null,
types_task: [{ 'code': 'call', 'name': 'Звонок' },
{ 'code': 'meet', 'name': 'Встреча' },
{ 'code': 'deal', 'name': 'Сделка' },
{ 'code': 'show', 'name': 'Показ' },
{ 'code': 'even', 'name': 'Мероприятие' },
],
time_task: [
{ 'code': '+5 minutes', 'name': '5 мин' },
{ 'code': '+30 minutes', 'name': '30 мин' },
{ 'code': '+1 hours', 'name': '1 час' },
{ 'code': '+2 hours', 'name': '2 часа' },
{ 'code': '+3 hours', 'name': '3 часа' },
{ 'code': '+1 days', 'name': 'Завтра' },
{ 'code': '+3 days', 'name': '3 дня' },
{ 'code': '+7 days', 'name': '7 дней' },
{ 'code': '+14 days', 'name': '14 дней' },
{ 'code': '+30 days', 'name': '30 дней' },
{ 'code': '+90 days', 'name': '90 дней' },
{ 'code': '+6 month', 'name': '6 месяцев' },
{ 'code': '+1 year', 'name': '1 год' }
],
pole_prev: {
'tasks': [],
'tasks_all': [],
'comment': '',
'is_new_who_work': 0,
'new_who_work': null,
'is_new_file_attach': 0,
'is_new_doers': 0,
'adjacent_funnels' : null,
'is_adjacent_funnels': 0,
'steps_close_main_funnel': [],
'new_doers': null,
'files_attach': [],
'is_mes': 0,
'list_users_select': [],
'new_who_work_object': 0,
},
pole_dop: {
'advert_close': 0,
'avtopoisk_close': 0,
'add_contract_close_ste': 0,
'add_activity_close_step': 0,
},
adjacent_funnels_steps: [],
steps_close_main_funnel: {},
is_select_room: false,
is_changing_status: false,
complex_status_id: null,
complex_status_type: null,
list_next_poles: [],
view_next: null
},
methods: {
onFileSelected(event) {
var files = Array.from(event.target.files);
var j = app.selectedFiles.length;
$error = "";
for (var i = 0; i < files.length; i++) {
files[i].typeFile = app.typeFile(files[i].name).toLowerCase();
if (files[i].typeFile !== 'doc' && files[i].typeFile !== 'docx' && files[i].typeFile !== 'xls'
&& files[i].typeFile !== 'xlsx' && files[i].typeFile !== 'pdf' && files[i].typeFile !== 'jpeg' && files[i].typeFile !== 'jpg'
&& files[i].typeFile !== 'gif' && files[i].typeFile !== 'png' && files[i].typeFile !== 'mp3' && files[i].typeFile !== 'zip' && files[i].typeFile !== 'rar') {
$error = "Неверный тип файла";
continue;
}
files[i].classFile = app.classTypesFile.undefined;
files[i].guid = '';
if (app.classTypesFile[files[i].typeFile]) {
files[i].classFile = app.classTypesFile[files[i].typeFile];
}
var proc = { 'progress': 0, 'isUpload': false, 'uploads': false }
app.$set(app.progressUoload, j, proc);
app.$set(app.selectedFiles, j, files[i]);
app.onUpload(j, files[i]);
j++;
}
if ($error) {
alert($error);
}
},
onUpload: function(index, file) {
app.$set(app.progressUoload[index], 'uploads', true);
let fd = new FormData();
fd.append('funnel_id', app.funnelId);
fd.append('type_file', file.typeFile);
fd.append('file', app.selectedFiles[index]);
axios.post('/ajax/vue_upload.php', fd, {
onUploadProgress: progressEvent => {
var pr = Math.ceil(progressEvent.loaded / progressEvent.total * 100);
app.$set(app.progressUoload[index], 'progress', pr);
}
})
.then(function(response) {
if (response.data.res === 'done') {
app.$set(app.selectedFiles[index], 'guid', response.data.guid);
app.$set(app.progressUoload[index], 'isUpload', true);
app.$set(app.progressUoload[index], 'uploads', false);
} else {
alert(response.data.res);
}
})
.catch(function(error) {
console.error(error);
});
},
onDeleteFile: function(index, file) {
app.selectedFiles.splice(index, 1);
$('.ui-tooltip').remove();
app.progressUoload.splice(index, 1);
if (file.guid != '') {
axios.post('/ajax/ajax_vue_funnel.php', {
request: 'deleteFile',
funnelId: app.funnelId,
guid: file.guid,
type_file: file.typeFile
})
}
},
openAddFunnel: function() {
app.addFunelmodal = true;
app.ctype = [];
app.role = [];
app.name = "";
app.poleEndlist = [];
this.id_block = 0;
},
openFunelmodalTemplate: function(){
this.changeTemplateFunnels = [];
this.isDisabled = true;
this.addFunelmodalTemplate = true;
app.ctype = [];
app.role = [];
app.name = "";
app.poleEndlist = [];
this.funnelTemplateLoad = true;
axios.post('/ajax/ajax_vue_funnel.php', {
request: 'get_template_funnels',
agency_id: this.agencyId
})
.then((response) => {
console.log(response.data);
this.funnelTemplateLoad = false;
this.templateFunnels = response.data;
})
.catch(function(error) {
console.error(error);
});
},
changeFunnel(){
this.changeTemplateFunnels = [];
this.isDisabled = true;
for(var i = 0; i < this.templateFunnels.length; i++){
if(this.templateFunnels[i].is_change > 0){
this.changeTemplateFunnels.push(this.templateFunnels[i].id);
}
}
if(!this.isEmpty(this.changeTemplateFunnels)){
this.isDisabled = false;
}
},
allFunnels: function() {
axios.post('/ajax/ajax_vue_funnel.php', {
request: 'get_all_funnel',
agency_id: this.agency_id.value
})
.then((response) => {
app.funnels = response.data;
app.getSvg();
if(this.id_block > 0){
var id = "#idFunnelBlock"+this.id_block;
setTimeout(function(){
if($(id).offset()){
$('html, body').animate({
scrollTop: $(id).offset().top // класс объекта к которому приезжаем
}, 500);
}
}, 1000);
}
})
.catch(function(error) {
console.error(error);
});
},
get_user_see(){
axios.post('/ajax/ajax_vue_funnel.php', {
request: 'get_users_see',
agency_id: this.agencyId,
user_id: this.userId,
})
.then((response) => {
this.users_see = response.data;
})
.catch(function(error) {
console.error(error);
});
},
getLine(id1, id2, main) {
// var arrowRight = document.querySelector("#arrowRight");
var drawConnector = function() {
var divA = $("#step" + id1);
var divB = $("#step" + id2);
var divMain = divA.closest(".client-inner");
// var arrowLeft = $("#arrowLeft");
var posnALeft = {
x: divA.offset().left - divMain.offset().left + divA.width() / 2,
y: divA.offset().top - divMain.offset().top + divA.height() + 2
};
var posnBLeft = {
x: divB.offset().left - divMain.offset().left + divB.width() / 2,
y: divB.offset().top - divMain.offset().top - 3
};
var posnBRight = {
x: divB.offset().left,
y: divB.offset().top
};
var dStrLeft =
"M" +
(posnALeft.x) + "," + (posnALeft.y) + " " +
"C" +
(posnALeft.x - 0) + "," + (posnALeft.y) + " " +
(posnBLeft.x - 0) + "," + (posnBLeft.y) + " " +
(posnBLeft.x) + "," + (posnBLeft.y);
$("#arrow_" + main + '_' + id1 + '_' + id2).attr("d", dStrLeft);
};
setTimeout(drawConnector, 250);
},
getLineLeft(id1, id2, main, branch) {
// var arrowRight = document.querySelector("#arrowRight");
var drawConnector = function() {
var divA = $("#step" + id1);
var divB = $("#step" + id2);
var divMain = divA.closest(".client-inner");
var posnALeft = {
x: divA.offset().left - divMain.offset().left + divA.width() + 2,
y: divA.offset().top - divMain.offset().top + divA.height() / 2
};
var posnBLeft = {
x: divB.offset().left - divMain.offset().left + divB.width() + 2,
y: divB.offset().top - divMain.offset().top + divB.height() / 2 - 3
};
var dStrLeft =
"M" +
(posnALeft.x) + "," + (posnALeft.y) + " " +
"C" +
(posnALeft.x + branch * 20) + "," + (posnALeft.y) + " " +
(posnBLeft.x + branch * 20) + "," + (posnBLeft.y) + " " +
(posnBLeft.x + 3) + "," + (posnBLeft.y);
$("#arrowLeft_" + main + '_' + id1 + '_' + id2).attr("d", dStrLeft);
};
setTimeout(drawConnector, 250);
},
getLineLine(id1, id2, main) {
var drawConnector = function() {
var divA = $("#step" + id1);
var divB = $("#step" + id2);
var divMain = divA.closest(".client-inner");
var leftA = divA.offset().left;
var leftB = divB.offset().left;
if (leftA > leftB) {
var posnALeft = {
x: divA.offset().left - divMain.offset().left,
y: divA.offset().top - divMain.offset().top + divA.height() / 2
};
var posnBLeft = {
x: divB.offset().left - divMain.offset().left + divB.width() + 6,
y: divB.offset().top - divMain.offset().top + divB.height() / 2
};
}
if (leftA < leftB) {
var posnALeft = {
x: divA.offset().left - divMain.offset().left + divA.width() + 2,
y: divA.offset().top - divMain.offset().top + divA.height() / 2
};
var posnBLeft = {
x: divB.offset().left - divMain.offset().left - 4,
y: divB.offset().top - divMain.offset().top + divB.height() / 2
};
}
var dStrLeft =
"M" +
(posnALeft.x) + "," + (posnALeft.y) + " " +
"C" +
(posnALeft.x) + "," + (posnALeft.y) + " " +
(posnBLeft.x) + "," + (posnBLeft.y) + " " +
(posnBLeft.x) + "," + (posnBLeft.y);
$("#arrowLine_" + main + '_' + id1 + '_' + id2).attr("d", dStrLeft);
};
setTimeout(drawConnector, 250);
},
getSvg: function() {
for (var funnelId in app.funnels) {
var id_funnel = app.funnels[funnelId].id;
app.svgPath[id_funnel] = [];
for (var stepId in app.funnels[funnelId].steps) {
var step = app.funnels[funnelId].steps[stepId];
if (!app.isEmpty(step.next_step)) {
var stepsNexts = JSON.parse(step.next_step);
for (var stId in stepsNexts) {
var next_step = stepsNexts[stId];
var stepNext = app.funnels[funnelId].steps[next_step];
if (stepNext !== undefined) {
if ((stepNext.branch - step.branch) > 0) {
var path = { 'id': 'arrow_' + id_funnel + '_' + stepId + '_' + next_step };
app.svgPath[id_funnel].push(path);
app.getLine(stepId, next_step, id_funnel);
}
if ((stepNext.branch - step.branch) < 0) {
var path = { 'id': 'arrowLeft_' + id_funnel + '_' + stepId + '_' + next_step };
app.svgPath[id_funnel].push(path);
app.getLineLeft(stepId, next_step, id_funnel, (stepNext.branch - step.branch) * -1);
}
if ((stepNext.branch - step.branch) == 0) {
var path = { 'id': 'arrowLine_' + id_funnel + '_' + stepId + '_' + next_step };
app.svgPath[id_funnel].push(path);
app.getLineLine(stepId, next_step, id_funnel);
}
}
}
}
}
}
},
getSelect: function() {
axios.post('/ajax/ajax_vue_funnel.php', {
request: 'get_type'
})
.then(function(response) {
app.clientstypes = response.data;
})
.catch(function(error) {
console.error(error);
});
axios.post('/ajax/ajax_vue_funnel.php', {
request: 'get_role'
})
.then(function(response) {
app.options_role = response.data;
})
.catch(function(error) {
console.error(error);
});
},
set_mes_error: function(text) {
app.mes_error = true;
app.error = text;
},
addFunnel: function() {
this.id_block = 0;
if (this.name == "") {
this.set_mes_error('Не введено наименование воронки');
} else {
axios.post('/ajax/ajax_vue_funnel.php', {
request: 'addFunnel',
name: this.name,
client_type: JSON.stringify(this.ctype),
role: JSON.stringify(this.role),
user_id: app.user_id.value,
agency_id: app.agency_id.value,
is_req: app.is_req,
is_client: app.is_client,
is_no_see: app.is_no_see,
users_no_see: this.selected_users_see_no,
order_number: app.order_number_funnel,
})
.then(function(response) {
if (response.data.error) {
app.set_mes_error(response.data.error);
} else {
app.addFunelmodal = false;
app.allFunnels();
}
})
.catch(function(error) {
app.set_mes_error(error);
});
}
},
addFunnelTemplate: function(){
axios.post('/ajax/ajax_vue_funnel.php', {
request: 'set_template_funnels',
agency_id: this.agencyId,
user_id: this.userId,
funnels: this.changeTemplateFunnels,
})
.then((response) => {
this.id_block = response.data;
this.changeTemplateFunnels = [];
this.isDisabled = true;
this.addFunelmodalTemplate = false;
this.funnelTemplateLoad = true;
this.allFunnels();
})
.catch(function(error) {
console.error(error);
});
},
updateFunnel: function(index, id) {
var name = this.funnels[index].name;
if (id > 0) {
var role = JSON.parse(this.funnels[index].role);
var client_type = JSON.parse(this.funnels[index].client_type);
app.is_stage = 1;
app.is_show_funnels = 1;
} else {
app.is_stage = this.funnels[index].is_stage;
app.is_show_funnels = this.funnels[index].is_show_funnels;
}
app.mes_error_update = false;
app.updateFunnelmodal = true;
app.funnelId = id;
app.name_update = name;
app.nameUpdate = name;
app.role_update = role;
app.ctype_update = client_type;
app.is_req = this.funnels[index].is_req;
app.is_client = this.funnels[index].is_client;
app.order_number_funnel = this.funnels[index].order_number;
app.selected_users_see_no = null;
app.is_no_see = this.funnels[index].is_no_see;
if(!this.isEmpty(this.funnels[index].users_no_see)){
var tempUS = JSON.parse(this.funnels[index].users_no_see);
var tempUS2 = [];
if(!this.isEmpty(tempUS)){
for(var i in tempUS){
if(!this.isEmpty(tempUS[i]) && tempUS[i] != 'null'){
tempUS2.push(tempUS[i]);
}
}
}
app.selected_users_see_no = tempUS2;
}
},
updateRowFunnel: function() {
this.id_block = 0;
this.mes_error_update = false;
app.type_trasmite = '';
app.typeTrasmite = '';
this.error_close = 0;
axios.post('/ajax/ajax_vue_funnel.php', {
request: 'updateFunnel',
name: this.name_update,
role: JSON.stringify(this.role_update),
client_type: JSON.stringify(this.ctype_update),
is_req: this.is_req,
is_client: this.is_client,
id: app.funnelId,
agency_id: app.agency_id.value,
is_stage: app.is_stage,
is_show_funnels: app.is_show_funnels,
order_number: app.order_number_funnel,
users_no_see: this.selected_users_see_no,
is_no_see: this.is_no_see,
})
.then((response) => {
console.log(response.data);
if (response.data.result == 'error') {
app.mes_error_update = true;
app.errorUpdate = response.data.mes;
if (response.data.error_close > 0) {
this.error_close = response.data.error_close;
app.open_transmit_funnel(response.data.type_error);
}
}
if (!app.mes_error_update) {
app.updateFunnelmodal = false;
app.allFunnels();
}
})
.catch(function(error) {
console.error(error);
});
},
open_transmit_funnel(type) {
this.funnelTrasmiteId = -1;
this.errorTransmite = false;
this.mesErrorTransmite = '';
app.type_trasmite = '';
if (type == 'client') {
app.typeTrasmite = type;
app.type_trasmite = "клиентов (" + this.error_close + " шт.)";
this.getTrasmitFunnels('client');
} else
if (type == 'req') {
app.typeTrasmite = type;
if (app.type_trasmite != '') app.type_trasmite += " и ";
app.type_trasmite += "заявки (" + this.error_close + " шт.)";
this.getTrasmitFunnels('req');
}
app.transmitFunnelmodal = true;
},
getTrasmitFunnels(type) {
app.typeTrasmite = type;
var tempFunnels = [];
tempFunnels.push({ 'id': -1, 'name': '' });
for (var i = 0; i < this.funnels.length; i++) {
if (this.funnels[i].id != this.funnelId) {
if (type == 'client' && this.funnels[i].is_client == 1) {
tempFunnels.push(this.funnels[i]);
} else if (type == 'req' && this.funnels[i].is_req == 1) {
tempFunnels.push(this.funnels[i]);
}
}
}
this.funnel_transmite = tempFunnels;
},
transmite() {
this.errorTransmite = false;
this.mesErrorTransmite = '';
if (this.funnelTrasmiteId == -1) {
this.errorTransmite = true;
this.mesErrorTransmite = "Не выбрана воронка!";
}
if (!this.errorTransmite) {
var funnel_old_name = "Обычные";
if (this.funnelId > 0) {
funnel_old_name = this.funnels.find((el, idx) => el.id == this.funnelId).name;
}
this.process_trasmited = true;
axios.post('/ajax/ajax_vue_funnel.php', {
request: 'transmite_funnel',
type: app.typeTrasmite,
funnel_old: this.funnelId,
funnel_old_name: funnel_old_name,
funnel_new: this.funnelTrasmiteId,
})
.then((response) => {
this.mes_error_update = false;
this.process_trasmited = false;
this.transmitFunnelmodal = false;
if (this.delFunnel == 1) {
this.ajax_delete_funnel();
this.delFunnel = 0;
}
})
.catch(function(error) {
console.error(error);
});
}
},
deleteFunnel: function(index, id) {
app.mes_error_update = false;
app.errorUpdate = '';
if (confirm('Вы точно хотите безвозвратно удалить эту воронку?')) {
this.funnelId = id;
this.ajax_delete_funnel();
}
},
ajax_delete_funnel() {
this.id_block = 0;
axios.post('/ajax/ajax_vue_funnel.php', {
request: 'delete_funnel',
id: this.funnelId,
})
.then((response) => {
var res = response.data;
if (res.result == 'error') {
if (response.data.error_close > 0) {
this.delFunnel = 1;
this.error_close = response.data.error_close;
app.open_transmit_funnel(response.data.type_error);
}
} else if (res.result == 'done') {
app.allFunnels();
}
})
.catch(function(error) {
console.error(error);
});
},
onUpdateStepFunnel: function(index, id, funnelId) {
app.getDoer();
app.getStatuses();
app.poleEndlist = [];
app.name_step = '';
app.order_number = '';
app.mainStep = 0;
app.color_step = '';
app.days_step = 0;
app.is_move_end_srok = 0;
app.tasks_move = { 'is_move': 0, 'is_task': 0 };
app.start_parallel = 0;
app.stage = 'В работе';
app.listDoers = [];
app.tasksList = [];
app.name_step_task = '';
app.docs_step_task = '';
app.stepId = index;
app.steps = [];
app.nextStep = '';
app.listSteps = [];
app.next_step = ['Всегда один'];
app.nextStepChange = '';
app.polesOptionsSetting = [];
app.poleListIndex = 0;
app.tab_close = true;
app.tab_prev_close = false;
app.tab_dop_close = false;
app.adjacent_funnels = [];
app.pole_prev = {
'tasks': [],
'tasks_all': [],
'comment': '',
'is_new_who_work': 0,
'new_who_work': null,
'is_new_file_attach': 0,
'is_new_doers': 0,
'is_adjacent_funnels': 0,
'adjacent_funnels' : null,
'steps_close_main_funnel' : [],
'new_doers': null,
'files_attach': [],
'is_mes': 0,
'list_users_select': [],
'new_who_work_object': 0,
'is_select_room': false,
'is_changing_status': false
};
app.list_next_poles = [];
app.view_next = null;
for (var sid in app.funnels[id].steps) {
if (sid != index) {
var tempStep = { 'id': sid, 'name': app.funnels[id].steps[sid].name }
app.steps.push(tempStep);
}
}
app.arrNextSteps = [];
app.onePole = true;
app.selectedFiles = [];
app.progressUoload = [];
app.selectedFilesPrev = [];
app.progressUoloadPrev = [];
app.is_mes = false;
app.is_select_room = false;
app.is_changing_status = false;
app.complex_status_id = null;
app.complex_status_type = null;
app.users_mes = [];
app.list_users_select = [0];
app.pole_dop = {
'advert_close': 0,
'avtopoisk_close': 0,
'add_contract_close_ste': 0,
'add_activity_close_step': 0,
}
app.adjacent_funnels_steps = [];
app.create_deal = false;
if (index > -1) {
var upstep = app.funnels[id].steps[index];
app.name_step = upstep.name;
app.order_number = upstep.order_number;
app.mainStep = upstep.main;
if (app.mainStep == 1) {
app.order_number = 1;
}
app.color_step = upstep.color_step;
app.days_step = upstep.days_step;
app.is_move_end_srok = upstep.is_move_end_srok;
app.is_select_room = !!Number(upstep.is_select_room);
app.is_changing_status = !!Number(upstep.complex_status_id);
app.complex_status_id = Number(upstep.complex_status_id);
app.complex_status_type = upstep.complex_status_type;
app.getStatuses(upstep.complex_status_id);
if (!this.isEmpty(upstep.tasks_move)) {
app.tasks_move = upstep.tasks_move;
}
app.start_parallel = upstep.start_parallel;
app.stage = upstep.stage;
// app.poleListIndex = upstep.pole_list_index;
if (app.stage == '') app.stage = 'В работе';
app.listDoers = JSON.parse(upstep.doers.replace(/""/g, "\""));
if (!this.isEmpty(upstep.pole_prev)) {
console.log(upstep.pole_prev);
app.pole_prev = JSON.parse(upstep.pole_prev);
if(!this.isEmpty(app.pole_prev.tasks)){
for(let index in app.pole_prev.tasks){
if(app.pole_prev.tasks[index].comment && !this.isEmpty(app.pole_prev.tasks[index].comment)){
app.pole_prev.tasks[index].comment = this.decodeHTMLEntities(app.pole_prev.tasks[index].comment);
}
}
}
if(!this.isEmpty(app.pole_prev.tasks_all)){
for(let index in app.pole_prev.tasks_all){
if(app.pole_prev.tasks_all[index].comment && !this.isEmpty(app.pole_prev.tasks_all[index].comment)){
app.pole_prev.tasks_all[index].comment = this.decodeHTMLEntities(app.pole_prev.tasks_all[index].comment);
}
}
}
//} else {
// app.pole_prev = JSON.parse(upstep.pole_prev.replace(/\n/g,"&&n&&"));
// }
app.pole_prev.comment = app.pole_prev.comment.replace(/&&n&&/g,"\n");
}
if (!this.isEmpty(upstep.pole_dop)) {
app.pole_dop = JSON.parse(upstep.pole_dop);
}
app.poleEndlist = JSON.parse(upstep.pole_end_list.replace(/\\/g, "/"));
if(app.funnels[id].is_req == 1){
app.poleType = ['Строка', 'Текст', 'Дата', 'Файл', 'Ветвление этапов', 'Задача на выбор', 'Задаток', 'Ожидаемая комиссия', 'Расходы'];
} else {
app.poleType = ['Строка', 'Текст', 'Дата', 'Файл', 'Ветвление этапов', 'Задача на выбор', 'Задаток'];
}
if (app.poleEndlist.length > 0) {
console.log(app.poleEndlist);
for (var i in app.poleEndlist) {
if (app.poleEndlist[i].type == 'Ветвление этапов' || app.poleEndlist[i].type == 'Выпадающий список') {
app.next_step.push('Зависит от поля ' + app.poleEndlist[i].name);
app.poleListIndex = parseInt(i);
}
}
for (var id in app.poleEndlist[app.poleListIndex].dopSettings.select.options) {
app.polesOptionsSetting.push({ 'isDiv': true, 'isEdit': false });
}
}
app.tasksList = JSON.parse(upstep.tasks_list);
app.name_step_task = upstep.name_step_task;
app.docs_step_task = upstep.docs_step_task;
app.nextStepChange = upstep.next_step_change;
app.listSteps = app.steps;
if (app.nextStepChange == 'Всегда один') {
// app.listSteps = app.steps;
if (upstep.next_step.indexOf("[") != -1) {
app.nextStep = app.listSteps.find(x => x.id === JSON.parse(upstep.next_step)[0]);
}
app.onePole = true;
} else {
if (app.nextStepChange.indexOf("Зависит") != -1) {
app.onePole = false;
var arr = JSON.parse(upstep.next_step);
console.log(app.poleEndlist)
for (var idx in arr) {
if (app.poleEndlist[app.poleListIndex]) {
app.arrNextSteps.push({'code': arr[idx], 'label': app.poleEndlist[app.poleListIndex].dopSettings.select.options[idx], 'name': app.poleEndlist[app.poleListIndex].dopSettings.select.options[idx], 'id': app.listSteps.find(x => x.id === arr[idx]) })
}
if(typeof app.poleEndlist[app.poleListIndex].view_next == 'undefined')
app.poleEndlist[app.poleListIndex].view_next = null;
app.list_next_poles.push({'code': arr[idx], 'name': app.poleEndlist[app.poleListIndex].dopSettings.select.options[idx]})
}
}
}
for (var i in upstep.files) {
var files = {};
files.name = upstep.files[i].name;
files.typeFile = app.typeFile(upstep.files[i].name);
files.classFile = app.classTypesFile[files.typeFile];
files.guid = upstep.files[i].guid;
var proc = { 'progress': 0, 'isUpload': upstep.files[i].isUpload, 'uploads': false }
app.$set(app.progressUoload, i, proc);
app.$set(app.selectedFiles, i, files);
}
for (var i in upstep.prev_files) {
var files = {};
files.name = upstep.prev_files[i].name;
files.typeFile = app.typeFile(upstep.prev_files[i].name);
files.classFile = app.classTypesFile[files.typeFile];
files.guid = upstep.prev_files[i].guid;
var proc = { 'progress': 0, 'isUpload': upstep.prev_files[i].isUpload, 'uploads': false }
app.$set(app.progressUoloadPrev, i, proc);
app.$set(app.selectedFilesPrev, i, files);
}
if (upstep.is_mes > 0) {
app.is_mes = true;
if (!app.isEmpty(upstep.users_mes)) {
app.list_users_select = upstep.users_mes;
}
}
if (upstep.create_deal > 0) {
app.create_deal = true;
}
}
app.updateStepFunnel = true;
app.funnelId = funnelId;
this.get_adjacent_funnels();
},
resetNextStep: function() {
app.nextStepChange = 'Всегда один';
app.nextStep = '';
app.listSteps = app.steps;
app.arrNextSteps = [];
app.onePole = true;
},
typeFile: function(nameFile) {
var tchk = nameFile.lastIndexOf(".");
if (tchk != -1) {
return nameFile.slice(tchk + 1);
}
return 'undefined';
},
getDoer: function() {
axios.post('/ajax/ajax_vue_funnel.php', {
request: 'get_doers',
agency_id: this.agency_id.value
})
.then(function(response) {
app.doers = response.data;
})
.catch(function(error) {
consle.error(error);
});
},
getUsers() {
axios.post('/ajax/ajax_vue_funnel.php', {
request: 'get_users',
agency_id: this.agency_id.value
})
.then((response) => {
app.list_users = response.data.emp;
for (var i = 0; i < app.list_users.length; i++) {
if (app.list_users[i].code != 0 && app.list_users[i].code != 'manager')
this.list_users_prev_pole.push(app.list_users[i]);
}
})
.catch(function(error) {
console.error(error);
});
},
get_adjacent_funnels(){
this.adjacent_funnels_steps = [];
axios.post('/ajax/vue_ajax/funnel_axios_vue.php', {
request: 'get_adjacent_funnels',
agency_id: this.agencyId,
funnel_id: this.funnelId,
})
.then((response) => {
if(response.data.error){
console.error(response.data.error);
} else {
if(response.data.funnels){
this.adjacent_funnels = response.data.funnels;
}
if(response.data.steps){
this.adjacent_funnels_steps = response.data.steps;
for(var i = 0; i < this.pole_prev.steps_close_main_funnel.length; i++ ){
this.$set(this.adjacent_funnels_steps[this.pole_prev.steps_close_main_funnel[i].funnel], 'value', this.pole_prev.steps_close_main_funnel[i].step);
}
}
}
})
.catch(function(error) {
console.error(error);
});
},
selectMes() {
if (!this.is_mas) {
this.list_users_select = [0];
}
},
selectDoer: function(doerId, userId, otdel) {
if (otdel == 'all') {
// for(var id in app.doers[doerId].manager){
var fio = app.doers[doerId].manager.fio;
var id = app.doers[doerId].manager.id;
var isDoer = false;
if (app.listDoers.find(x => x.id === id) === undefined) {
var newDoer = { 'fio': fio, 'id': id };
app.listDoers.push(newDoer);
}
// }
for (var i in app.doers[doerId].agents) {
var fio = app.doers[doerId].agents[i].fio;
var id = app.doers[doerId].agents[i].id;
var isDoer = false;
if (app.listDoers.find(x => x.id === id) === undefined) {
var newDoer = { 'fio': fio, 'id': id };
app.listDoers.push(newDoer);
}
}
}
if (otdel == 'manager') {
var fio = app.doers[doerId].manager.fio;
var id = app.doers[doerId].manager.id;
var isDoer = false;
if (app.listDoers.find(x => x.id === id) === undefined) {
var newDoer = { 'fio': fio, 'id': id };
app.listDoers.push(newDoer);
}
}
if (otdel == 'agent') {
var fio = app.doers[doerId].agents[userId].fio;
var id = app.doers[doerId].agents[userId].id;
var isDoer = false;
if (app.listDoers.find(x => x.id === id) === undefined) {
var newDoer = { 'fio': fio, 'id': id };
app.listDoers.push(newDoer);
}
}
},
seeDoer: function(id) {
if (app.doers[id].isSee) {
app.doers[id].isSee = false;
} else {
app.doers[id].isSee = true;
}
},
deleteDoer: function(doerId) {
app.listDoers.splice(doerId, 1);
$('.ui-tooltip').remove();
},
addPole: function() {
var newPole = { 'name': '', 'type': '', 'binding': false, 'dopSettings': { 'select': false, 'radio': false } };
app.poleEndlist.push(newPole);
},
setOption: function(index) {
var val = this.pole_select_value;
if (!app.isEmpty(val)) {
var options = app.poleEndlist[index].dopSettings.select.options;
app.poleEndlist[index].dopSettings.select.options.push(val);
app.isInput = false;
this.pole_select_value = '';
app.polesOptionsSetting.push({ 'isDiv': true, 'isEdit': false })
$('.ui-tooltip').remove();
app.getArrNextStep(index);
}
},
nextOptionUpdate(){
var index = 0;
for(var poleInd in app.poleEndlist){
console.log(app.poleEndlist[poleInd]);
if(typeof app.poleEndlist[poleInd].dopSettings.select == 'object')
index = poleInd;
}
//app.getArrNextStep(index);
},
getArrNextStep: function(index) {
if (app.nextStepChange.indexOf("Зависит") != -1) {
var tempArr = [];
if (app.arrNextSteps.length != 0) {
tempArr = app.arrNextSteps;
}
app.arrNextSteps = [];
for (var opt in app.poleEndlist[index].dopSettings.select.options) {
//console.log(app.poleEndlist[index].dopSettings.select.options[opt]);
var idn = '';
if (tempArr[opt]) {
idn = tempArr[opt].id;
//console.log(idn);
}
app.arrNextSteps.push({'code':idn.id, 'name': app.poleEndlist[index].dopSettings.select.options[opt], 'id': idn });
}
}
},
editOption: function(id) {
app.polesOptionsSetting[id].isDiv = false;
app.polesOptionsSetting[id].isEdit = true;
$('.ui-tooltip').remove();
},
saveEditOption: function(index, id) {
var val = $('#pole_select_value_' + id).val();
if (!app.isEmpty(val)) {
app.poleEndlist[index].dopSettings.select.options[id] = val;
app.polesOptionsSetting[id].isDiv = true;
app.polesOptionsSetting[id].isEdit = false;
$('.ui-tooltip').remove();
app.getArrNextStep(index);
}
},
deleteOption: function(index, id) {
app.poleEndlist[index].dopSettings.select.options.splice(id, 1);
app.polesOptionsSetting.splice(id, 1);
app.arrNextSteps.splice(id, 1);
$('.ui-tooltip').remove();
},
onlyOneList: function(index) {
var res = true;
for (var i in app.poleEndlist) {
if ((app.poleEndlist[i].type == "Ветвление этапов" || app.poleEndlist[i].type == "Выпадающий список") && i != index) {
var res = false;
}
}
return res;
},
chengePoleSelect: function(actionName, index) {
switch (actionName) {
case 'Ветвление этапов':
{
if (app.onlyOneList(index)) {
app.arrNextSteps = [];
app.poleEndlist[index].dopSettings = { 'select': false, 'radio': false };
app.poleEndlist[index].dopSettings.select = { 'options': [] };
app.polesOptionsSetting = [];
app.next_step = ['Всегда один'];
app.next_step.push('Зависит от поля ' + app.poleEndlist[index].name);
app.poleListIndex = index;
} else {
alert("Нельзя создать более одного поля со списком!!!");
app.poleEndlist.splice(index, 1);
}
break;
}
case 'Выпадающий список':
{
if (app.onlyOneList(index)) {
app.arrNextSteps = [];
app.poleEndlist[index].dopSettings = { 'select': false, 'radio': false };
app.poleEndlist[index].dopSettings.select = { 'options': [] };
app.polesOptionsSetting = [];
app.next_step = ['Всегда один'];
app.next_step.push('Зависит от поля ' + app.poleEndlist[index].name);
app.poleListIndex = index;
} else {
alert("Нельзя создать более одного поля со списком!!!");
app.poleEndlist.splice(index, 1);
}
break;
}
case 'Переключатель':
{
if (app.poleEndlist[index].dopSettings.select) {
app.nextStepChange = '';
app.nextStep = '';
app.arrNextSteps = [];
}
app.poleEndlist[index].dopSettings = { 'select': false, 'radio': false };
app.poleEndlist[index].dopSettings.radio = { 'pole1': '', 'pole2': '' }
app.next_step = ['Всегда один'];
break;
}
default:
if (app.poleEndlist[index].dopSettings.select) {
app.nextStepChange = '';
app.nextStep = '';
app.arrNextSteps = [];
}
app.poleEndlist[index].dopSettings = { 'select': false, 'radio': false };
app.next_step = ['Всегда один'];
break;
}
},
deletePole: function(index) {
app.poleEndlist.splice(index, 1);
$('.ui-tooltip').remove();
for (var i in app.poleEndlist) {
if (app.poleEndlist[i].type == "Ветвление этапов" || app.poleEndlist[i].type == "Выпадающий список") {
app.poleListIndex = i;
break;
}
}
},
addTask: function() {
var newTask = { 'name': '', 'type': '' };
app.tasksList.push(newTask);
},
deleteTask: function(index) {
app.tasksList.splice(index, 1);
$('.ui-tooltip').remove();
},
removeNextStep: function(removedOption) {
console.log(removedOption);
},
changeNextStep: function(actionName) {
if (actionName == 'Всегда один') {
app.listSteps = app.steps;
app.arrNextSteps = [];
app.onePole = true;
} else {
if (actionName.indexOf("Зависит") != -1) {
var poleListIndex = 0;
for (var i in app.poleEndlist) {
if (app.poleEndlist[i].type == "Ветвление этапов" || app.poleEndlist[i].type == "Выпадающий список") {
poleListIndex = i;
break;
}
}
app.onePole = false;
app.arrNextSteps = [];
app.poleListIndex = poleListIndex;
for (var opt in app.poleEndlist[poleListIndex].dopSettings.select.options) {
app.arrNextSteps.push({ 'name': app.poleEndlist[poleListIndex].dopSettings.select.options[opt], 'id': '' });
}
} else {
app.onePole = true;
app.listSteps = [];
app.arrNextSteps = [];
}
}
},
getSteps: function(funnelId) {
axios.post('/ajax/ajax_vue_funnel.php', {
request: 'get_steps',
funnel_id: funnelId
})
.then(function(response) {
//app.doers = response.data;
})
.catch(function(error) {
consle.error(error);
});
},
selet_task_task() {
if (this.tasks_move.is_task > 0) {
this.tasks_move.is_move = 1
}
},
selet_task_move() {
if (this.tasks_move.is_move == 0) {
this.tasks_move.is_task = 0
}
},
change_adjacent_funnels() {
setTimeout(function(){
if(app.pole_prev.is_adjacent_funnels == 0){
app.pole_prev.adjacent_funnels = null;
}
},
100);
},
escapeHtml(str) {
const map = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#039;',
};
return str.replace(/[&<>"']/g, function(m) { return map[m]; });
},
decodeHTMLEntities (str) {
return str.replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&quot;/g, '"').replace(/&#039;/g, "'").replace(/<br>/g, "\n");
},
saveStep: function() {
this.id_block = 0;
app.errorPole = false;
app.textError = '';
var nextStepId = [];
var arr_next_steps = '';
if (this.nextStepChange == 'Всегда один') {
if (typeof this.nextStep == 'object' && this.nextStep !== undefined && this.nextStep !== null) nextStepId.push(this.nextStep.id);
} else {
if (this.nextStepChange.indexOf("Зависит") != -1) {
for (var id in app.arrNextSteps) {
if (!app.isEmpty(app.arrNextSteps[id].id))
nextStepId.push(app.arrNextSteps[id].id.id);
}
arr_next_steps = JSON.stringify(app.arrNextSteps);
}
}
// проверка на пустой тип поля.
for (var i in this.poleEndlist) {
if (app.isEmpty(this.poleEndlist[i].name) || app.isEmpty(this.poleEndlist[i].type)) {
app.errorPole = true;
app.textError = "Не заполнены Название или Тип одного или нескольких полей для заполнения при завершении этапа";
$(".full_modal-bg").stop().animate({ scrollTop: 0 }, 500);
}
if ((this.poleEndlist[i].type == "Ветвление этапов" || this.poleEndlist[i].type == "Выпадающий список") && !this.poleEndlist[i].binding) {
app.errorPole = true;
app.textError = "Поле &laquo;Ветвление этапов&raquo; должно быть обязательным";
$(".full_modal-bg").stop().animate({ scrollTop: 0 }, 500);
}
if (!isEmpty(this.poleEndlist[i].name)) {
this.poleEndlist[i].name = this.poleEndlist[i].name.replace(/'/g, "").replace(/"/g, "").replace(/\\/g, "/");
}
}
if (app.is_mes) {
if (this.isEmpty(app.list_users_select)) {
app.errorPole = true;
app.textError = "Не выбраны получатели уведомлений";
$(".full_modal-bg").stop().animate({ scrollTop: 0 }, 500);
}
}
if (!this.isEmpty(this.pole_prev.files_attach)) {
for (let index = 0; index < this.pole_prev.files_attach.length; index++) {
if (this.pole_prev.files_attach[index].id) {
this.pole_prev.files_attach[index].comment = this.pole_prev.files_attach[index].comment.replace(/'/g, "").replace(/"/g, "").replace(/\\/g, "/");
this.pole_prev.files_attach[index].name = this.pole_prev.files_attach[index].name.replace(/'/g, "").replace(/"/g, "").replace(/\\/g, "/");
} else {
app.pole_prev.files_attach.splice(index, 1);
}
}
}
if(!this.isEmpty(this.pole_prev.comment)){
this.pole_prev.comment = this.pole_prev.comment.replace(/'/g, "").replace(/"/g, "").replace(/\n/g, " ").replace(/\\/g, "/");
}
app.pole_prev.steps_close_main_funnel = [];
for(var i in this.adjacent_funnels_steps){
if(this.adjacent_funnels_steps[i].value > 0){
app.pole_prev.steps_close_main_funnel.push({'funnel':i, 'step': this.adjacent_funnels_steps[i].value});
}
}
if (!app.errorPole) {
var reques = {
request: 'save_step',
step_id: app.stepId,
funnel_id: app.funnelId,
name_step: this.name_step,
order_number: this.order_number,
color_step: this.color_step,
days_step: this.days_step,
is_move_end_srok: this.is_move_end_srok,
tasks_move: this.tasks_move,
stage: this.stage,
files: this.selectedFiles,
start_parallel: this.start_parallel,
doers: JSON.stringify(this.listDoers),
poleEndlist: JSON.stringify(this.poleEndlist),
tasksList: JSON.stringify(this.tasksList),
name_step_task: this.name_step_task,
docs_step_task: this.docs_step_task,
nextStepChange: this.nextStepChange,
nextStep: JSON.stringify(nextStepId),
is_mes: this.is_mes,
users_mes: app.list_users_select,
pole_prev: JSON.stringify(this.pole_prev),
pole_dop: JSON.stringify(this.pole_dop),
is_select_room: this.is_select_room,
complex_status_id: $("#ms-req-status").val(),
create_deal: this.create_deal,
}
if (arr_next_steps != '') {
reques.arr_next_steps = arr_next_steps;
}
axios.post('/ajax/ajax_vue_funnel.php', reques)
.then(function(response) {
//console.log(response.data);
app.updateStepFunnel = false;
// app.funnels[app.funnelId].steps = app.getSteps(app.funnelId);
app.allFunnels();
//app.doers = response.data;
})
.catch(function(error) {
app.updateStepFunnel = false;
console.error(error);
});
}
},
deleteStep: function(id) {
app.clientsStepsId = 0;
app.clientsSteps = '';
this.id_block = 0;
if (confirm('Вы точно хотите безвозвратно удалить этот этап?')) {
axios.post('/ajax/ajax_vue_funnel.php', {
request: 'delete_step',
step_id: id
})
.then(function(response) {
var res = response.data;
if (res.result == 'isClients') {
app.updateClientStep = true;
app.clientsSteps = 'Клиентов в работе на этом этапе: ' + res.mes;
app.clientsStepsId = id;
} else if (res.result == 'done') {
app.mesUpdateClientStep = true;
app.allFunnels();
}
//app.allFunnels();
//app.doers = response.data;
})
.catch(function(error) {
console.error(error);
});
}
$('.ui-tooltip').remove();
},
updateStepClients: function() {
this.id_block = 0;
axios.post('/ajax/ajax_vue_funnel.php', {
request: 'update_clients_step',
step_id: app.clientsStepsId,
user_id: app.user_id.value
})
.then(function(response) {
app.updateClientStep = false;
app.mesUpdateClientStep = true;
app.allFunnels();
})
.catch(function(error) {
console.error(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;
}
},
changeFirstStep: function(actionName) {
this.id_block =0;
axios.post('/ajax/ajax_vue_funnel.php', {
request: 'save_first_step',
step_id: actionName.id
}).then(function(response) {
app.allFunnels();
//app.doers = response.data;
})
.catch(function(error) {
console.error(error);
});
},
validPole: function(val, id) {
$('#pole_select_value_' + id).val(val.replace(/'/g, "").replace(/"/g, ""));
},
open_tab(tab) {
if (tab == 'tab_close') {
this.tab_close = true;
this.tab_dop_close = false;
this.tab_prev_close = false;
}
if (tab == 'tab_prev_close') {
this.tab_close = false;
this.tab_dop_close = false;
this.tab_prev_close = true;
}
if (tab == 'tab_dop_close') {
this.tab_close = false;
this.tab_prev_close = false;
this.tab_dop_close = true;
}
},
add_pole_prev(selector = '') {
var newPole = { 'name': '', 'type': '', comment: '', time: '' };
if (selector == 'all') {
this.pole_prev.tasks_all.push(newPole);
} else {
this.pole_prev.tasks.push(newPole);
}
},
del_pole_prev(index, selector = '') {
if (selector == 'all') {
this.pole_prev.tasks_all.splice(index, 1);
$('.ui-tooltip').remove();
} else {
this.pole_prev.tasks.splice(index, 1);
$('.ui-tooltip').remove();
}
},
check_prev_is_mes() {
if (this.pole_prev.is_mes) {
if (this.pole_prev.is_mes == 0) {
this.pole_prev.list_users_select = []
}
}
},
onFileSelectedPrev(event) {
var files = Array.from(event.target.files);
var j = app.selectedFilesPrev.length;
$error = "";
for (var i = 0; i < files.length; i++) {
files[i].typeFile = app.typeFile(files[i].name).toLowerCase();
if (files[i].typeFile !== 'doc' && files[i].typeFile !== 'docx' && files[i].typeFile !== 'xls'
&& files[i].typeFile !== 'xlsx' && files[i].typeFile !== 'pdf' && files[i].typeFile !== 'jpeg' && files[i].typeFile !== 'jpg'
&& files[i].typeFile !== 'gif' && files[i].typeFile !== 'png' && files[i].typeFile !== 'mp3' && files[i].typeFile !== 'zip' && files[i].typeFile !== 'rar') {
$error = "Неверный тип файла";
continue;
}
files[i].classFile = app.classTypesFile.undefined;
files[i].guid = '';
if (app.classTypesFile[files[i].typeFile]) {
files[i].classFile = app.classTypesFile[files[i].typeFile];
}
var proc = { 'progress': 0, 'isUpload': false, 'uploads': false }
app.$set(app.progressUoloadPrev, j, proc);
app.$set(app.selectedFilesPrev, j, files[i]);
var temp_file = { 'id': null, 'name': '', 'comment': '' };
app.$set(app.pole_prev.files_attach, j, temp_file);
app.onUploadPrev(j, files[i]);
j++;
}
if ($error) {
alert($error);
}
},
onUploadPrev: function(index, file) {
app.$set(app.progressUoloadPrev[index], 'uploads', true);
let fd = new FormData();
fd.append('funnel_id_prev', app.funnelId);
fd.append('type_file', file.typeFile);
fd.append('file', app.selectedFilesPrev[index]);
axios.post('/ajax/vue_upload.php', fd, {
onUploadProgress: progressEvent => {
var pr = Math.ceil(progressEvent.loaded / progressEvent.total * 100);
app.$set(app.progressUoloadPrev[index], 'progress', pr);
}
})
.then((response) => {
if (response.data.res === 'done') {
app.$set(app.selectedFilesPrev[index], 'guid', response.data.guid);
app.$set(app.progressUoloadPrev[index], 'isUpload', true);
app.$set(app.progressUoloadPrev[index], 'uploads', false);
app.$set(app.pole_prev.files_attach[index], 'id', response.data.id);
} else {
alert(response.data.res);
}
})
.catch(function(error) {
console.error(error);
});
},
onDeleteFilePrev: function(index, file) {
app.selectedFilesPrev.splice(index, 1);
$('.ui-tooltip').remove();
app.progressUoloadPrev.splice(index, 1);
app.pole_prev.files_attach.splice(index, 1);
if (file.guid != '') {
axios.post('/ajax/ajax_vue_funnel.php', {
request: 'deleteFilePrev',
funnelId: app.funnelId,
guid: file.guid,
type_file: file.typeFile
})
.then((response) => {
console.log(app.pole_prev);
})
}
},
getStatuses(selectedStatus) {
// if ($('#status').length) {
if ($('#ms-req-status').length < 1) {
axios.post('/ajax/select_form_status.php')
.then(response => {
$('#ms-req-status-input').html(response.data);
$("#ms-req-status").val(selectedStatus);
$('#ms-req-status').fastselect({
placeholder: 'Выберите статус',
onItemCreate: function() { $(this).find('.fstQueryInput').hide() },
});
})
} else {
$('#ms-req-status').fastselect().data('fastselect').destroy();
$("#ms-req-status").val(selectedStatus);
$('#ms-req-status').fastselect({
placeholder: 'Выберите статус',
onItemCreate: function() { $(this).find('.fstQueryInput').hide() },
});
}
// }
},
},
watch: {
"is_changing_status": function() {
if (!this.is_changing_status)
{
this.complex_status_id = null;
$("#ms-req-status").val(null);
}
else
{
this.is_select_room = this.is_changing_status
}
},
"is_select_room": function() {
if (!this.is_select_room)
{
this.is_changing_status = this.is_select_room
}
}
},
created: function() {
$('#app').removeClass('hidden');
this.allFunnels();
this.getSelect();
this.getUsers();
this.get_user_see();
}
});