diff --git a/js/crm_vue.js b/js/crm_vue.js index 6c21cb1..23ebe5d 100644 --- a/js/crm_vue.js +++ b/js/crm_vue.js @@ -22,18 +22,18 @@ var ac = new Vue({ reqId: 0, adjacentId: 0, notSelectedFileMessage: "", - typePole: { "Строка": "input", - "Текст": "textarea", - "Ветвление этапов": "select", - "Выпадающий список":"select", - "Дата": "date", - "Файл": "file", - "Задача на выбор": "checkbox", - "Поле с галочкой": "checkbox", - "Задаток": "deposit", + typePole: { "Строка": "input", + "Текст": "textarea", + "Ветвление этапов": "select", + "Выпадающий список":"select", + "Дата": "date", + "Файл": "file", + "Задача на выбор": "checkbox", + "Поле с галочкой": "checkbox", + "Задаток": "deposit", "Ожидаемая комиссия":"commission", "Расходы":"expenses", - }, + }, nextStepSelect: '', options: [], errorText: '', @@ -72,6 +72,8 @@ var ac = new Vue({ }, errorMesPrevStep: false, is_Other_prev_step: 0, + isRequisitionHasDeal: false, + is_cancel_deal: 1, is_looad: false, is_load_open: false, list_open_step: [], @@ -94,6 +96,7 @@ var ac = new Vue({ step_complex_status_id: null, complexBus: undefined, isRoomForm: false, + currentPage: window.location.pathname, selectedRoom: { id: null, name: null, @@ -155,12 +158,12 @@ var ac = new Vue({ ac.errorText += "
Заполните поле «" + ac.step.pole_end_list[i].name + "»
"; } } 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 += "Заполните поле «" + ac.step.pole_end_list[i].name + "»
"; - if(ac.step.values[i].type == "expenses" && (parseInt(ac.step.values[i].value.summa) == 0 || this.isEmpty(ac.step.values[i].value.summa))) + + if ((ac.step.values[i].type == "deposit" || ac.step.values[i].type == "commission") && parseInt(ac.step.values[i].value) == 0) ac.errorText += "Заполните поле «" + ac.step.pole_end_list[i].name + "»
"; - } + 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 += "Заполните поле «" + ac.step.pole_end_list[i].name + "»
"; + } } } @@ -217,12 +220,12 @@ var ac = new Vue({ //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.isError = true; this.errorText += "Не заполнено поле: " + this.fields[i].title + "
"; $('#linking_step_' + this.fields[i].id).addClass('invalid'); } @@ -235,7 +238,7 @@ var ac = new Vue({ } else { $('#linking_step_' + this.fields[i].id).removeClass('invalid'); } - + } } @@ -248,28 +251,30 @@ var ac = new Vue({ } 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 - }) + 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) { + console.log(response.data); + if(response.data.adjacent_id > 0){ var req_id = response.data.req_id; var client_id = response.data.client_id; @@ -279,212 +284,278 @@ var ac = new Vue({ 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(' '); - for (let i = 0; i < result.length; i++) { - if (result[i]['id'] && result[i]['name']) { - if (i != result.length - 1) - tagsView.append('' + result[i]['name'] + ', '); - else - tagsView.append('' + result[i]['name'] + ''); - } - } - tagsView.show(); - } else { - tagsView.hide(); - } - // popup.removeClass('show'); - ac.activites_close_step_val = null; + 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; }); - } - } 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; + 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(' '); + for (let i = 0; i < result.length; i++) { + if (result[i]['id'] && result[i]['name']) { + if (i != result.length - 1) + tagsView.append('' + result[i]['name'] + ', '); + else + tagsView.append('' + result[i]['name'] + ''); + } + } + tagsView.show(); + } else { + tagsView.hide(); + } + // popup.removeClass('show'); + ac.activites_close_step_val = null; + }); } } else { - //if(page == '/charts.php'){ + 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); + .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); } - $('#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 == 'Закрыт') { + ac.dealCloseData = null; + ac.dealCloseReqs = []; + ac.dealCloseObjects = []; + ac.dealCloseAgentCommission = 0; + ac.dealCloseSumma = 0; + + // Сначала загружаем данные сделки, потом открываем модал + var loadDealData = function(callback) { + 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; + window.dealCloseData = dealData; + + 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) { + $.ajax({ + url: '/ajax/ajax_vue_requisitions.php', + type: 'POST', + contentType: 'application/json', + data: JSON.stringify({ request: 'get_deals_linked_reqs', req_ids: reqIds }), + success: function(reqRes) { + ac.dealCloseReqs = reqRes.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) { + $.ajax({ + url: '/ajax/ajax_vue_requisitions.php', + type: 'POST', + contentType: 'application/json', + data: JSON.stringify({ request: 'get_deals_linked_objects', object_ids: objIds }), + success: function(objRes) { + ac.dealCloseObjects = objRes.objects || []; + } + }); + } + } + callback(); + }); + } else { + callback(); } }) - .catch(function(error) { - console.error(error); - }); - // } - } + .catch(function() { callback(); }); + }; - 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); - } + loadDealData(function() { + $("#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) { - $('#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', { + 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; - }); + .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'); + 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; @@ -531,19 +602,19 @@ var ac = new Vue({ 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, - }, ) + 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 = { @@ -564,7 +635,7 @@ var ac = new Vue({ 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); + let temp_next = ac.step.arr_next_steps.find((el, idx) => el.id.id == ac.nextStepSelect.id.id); //console.log(temp_next); if (temp_next === undefined) { ac.nextStepSelect = ''; @@ -600,7 +671,7 @@ var ac = new Vue({ if(res[i].value.file) res[i].value = ''; ac.$set(ac.step.values[i], 'value', res[i].value); //ac.step.values[] = res; - } + } } } } @@ -613,13 +684,13 @@ var ac = new Vue({ 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, - }, ) + 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; @@ -655,7 +726,7 @@ var ac = new Vue({ }*/ // 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; } @@ -681,94 +752,41 @@ var ac = new Vue({ step_id: ac.step.id, agency_id: $('#session_agency_id').val(), }, ) - .then((response) => { - // console.log(response.data); - ac.fields = response.data.fields; - + .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); + 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) { + 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]; + 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); + // 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 || []; - }); - } - } - }); - } + .catch(function(error) { + console.log(error); }); - } }, IsJsonString(str) { @@ -789,12 +807,12 @@ var ac = new Vue({ 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, - }, ) + 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; @@ -822,12 +840,12 @@ var ac = new Vue({ 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' + 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') { @@ -847,7 +865,7 @@ var ac = new Vue({ const sizeMB = (file.size / 1024 / 1024).toFixed(1); ac.notSelectedFileMessage = `${file.name} ${sizeMB} MБ`; console.log(ac.notSelectedFileMessage); - + } }, onUpload: function(index, file) { @@ -862,11 +880,11 @@ var ac = new Vue({ 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); - } - }) + 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); @@ -897,9 +915,9 @@ var ac = new Vue({ console.log(ac.clientId); axios.post('/ajax/ajax_vue_clients.php', { - request: 'get_objects', - client_id: ac.clientId - }) + request: 'get_objects', + client_id: ac.clientId + }) .then(function(res) { if (res != 0) { ac.objects = res.data; @@ -930,9 +948,9 @@ var ac = new Vue({ getDoer: function() { axios.post('/ajax/ajax_vue_funnel.php', { - request: 'get_doers', - agency_id: $('#session_agency_id').val() - }) + request: 'get_doers', + agency_id: $('#session_agency_id').val() + }) .then(function(response) { // console.log(response.data); var tempDoers = response.data; @@ -1055,14 +1073,14 @@ var ac = new Vue({ // 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 - }, ) + 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; @@ -1110,7 +1128,7 @@ var ac = new Vue({ if ($('#client-history__bg').css('display') == 'block') { $('#client-history__bg').css('zIndex', '99998'); } - + if (ac.kanbanReq) { if (typeof requisitions !== 'undefined') { let html_li = '