temporary fix

This commit is contained in:
mac 2026-06-21 13:32:45 +03:00
parent 4eae476d2f
commit 0054d5c328
2 changed files with 566 additions and 499 deletions

View File

@ -72,6 +72,8 @@ var ac = new Vue({
}, },
errorMesPrevStep: false, errorMesPrevStep: false,
is_Other_prev_step: 0, is_Other_prev_step: 0,
isRequisitionHasDeal: false,
is_cancel_deal: 1,
is_looad: false, is_looad: false,
is_load_open: false, is_load_open: false,
list_open_step: [], list_open_step: [],
@ -94,6 +96,7 @@ var ac = new Vue({
step_complex_status_id: null, step_complex_status_id: null,
complexBus: undefined, complexBus: undefined,
isRoomForm: false, isRoomForm: false,
currentPage: window.location.pathname,
selectedRoom: { selectedRoom: {
id: null, id: null,
name: null, name: null,
@ -270,6 +273,8 @@ var ac = new Vue({
}) })
.then(function(response) { .then(function(response) {
console.log(response.data);
if(response.data.adjacent_id > 0){ if(response.data.adjacent_id > 0){
var req_id = response.data.req_id; var req_id = response.data.req_id;
var client_id = response.data.client_id; var client_id = response.data.client_id;
@ -289,6 +294,7 @@ var ac = new Vue({
get_count_clients(); get_count_clients();
} }
$.post('/ajax/getStageBar.php', { client_id: ac.clientId, funnel_id: ac.step.funnel_id }, function(result) { $.post('/ajax/getStageBar.php', { client_id: ac.clientId, funnel_id: ac.step.funnel_id }, function(result) {
$('#editClientStagebar').html(result); $('#editClientStagebar').html(result);
ac.closesStep = false; ac.closesStep = false;
ac.is_looad = false; ac.is_looad = false;
@ -422,17 +428,82 @@ var ac = new Vue({
isHidden = 1; isHidden = 1;
} }
if (ac.step.stage == 'Закрыт') { 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() { callback(); });
};
loadDealData(function() {
$("#del_client_bg").fadeIn(500); $("#del_client_bg").fadeIn(500);
$("#del_client").toggle(10); $("#del_client").toggle(10);
$("#del_client").find('input[name="id_funnel_client"]').val(ac.step.funnel_id); $("#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").find('input[name="id_del_client"]').val(ac.clientId);
$("#del_client #id_del_req").val(ac.reqId); $("#del_client #id_del_req").val(ac.reqId);
$("#del_client #temp_id").val(steps.tempid); $("#del_client #temp_id").val(steps.tempid);
set_select_denial_work(ac.reqId); set_select_denial_work(ac.reqId);
$("body").addClass("lock"); $("body").addClass("lock");
});
} }
if (ac.prevStage == ac.step.stage && !ac.kanban) { if (ac.prevStage == ac.step.stage && !ac.kanban) {
@ -564,7 +635,7 @@ var ac = new Vue({
ac.nextStepSelect = res.next_step_select; ac.nextStepSelect = res.next_step_select;
if (ac.nextStepSelect && ac.nextStepSelect.id && ac.nextStepSelect.id.id) { if (ac.nextStepSelect && ac.nextStepSelect.id && ac.nextStepSelect.id.id) {
//if (ac.nextStepSelect.name === undefined) { //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); //console.log(temp_next);
if (temp_next === undefined) { if (temp_next === undefined) {
ac.nextStepSelect = ''; ac.nextStepSelect = '';
@ -716,59 +787,6 @@ var ac = new Vue({
.catch(function(error) { .catch(function(error) {
console.log(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) { IsJsonString(str) {
@ -1164,6 +1182,7 @@ var ac = new Vue({
this.stepPrev = []; this.stepPrev = [];
this.step_name_open = ''; this.step_name_open = '';
this.is_Other_prev_step = 0; this.is_Other_prev_step = 0;
this.isRequisitionHasDeal = false;
if ($('#client-history__bg').css('display') == 'block') { if ($('#client-history__bg').css('display') == 'block') {
$('#client-history__bg').css('zIndex', '99988'); $('#client-history__bg').css('zIndex', '99988');
} }
@ -1186,6 +1205,13 @@ var ac = new Vue({
this.errorMesPrevStep = true; this.errorMesPrevStep = true;
this.errorTextPrevStep = "Не выбран этап для открытия"; this.errorTextPrevStep = "Не выбран этап для открытия";
} }
if (response.data.res && typeof response.data.res.has_deal !== 'undefined') {
this.isRequisitionHasDeal = response.data.res.has_deal === true;
} else {
this.isRequisitionHasDeal = false;
}
// ac.stepPrev = response.data; // ac.stepPrev = response.data;
//ac.updateWhoWork=false; //ac.updateWhoWork=false;
@ -1222,6 +1248,7 @@ var ac = new Vue({
now_step_id: now_step_id, now_step_id: now_step_id,
is_Other_prev_step: this.is_Other_prev_step, is_Other_prev_step: this.is_Other_prev_step,
stepInfo: stepInfo, stepInfo: stepInfo,
is_cancel_deal: this.isRequisitionHasDeal ? this.is_cancel_deal : 0
}, ) }, )
.then((response) => { .then((response) => {
console.log(response.data); console.log(response.data);
@ -1433,6 +1460,8 @@ var ac = new Vue({
}, 200) }, 200)
}, },
initCreateDeal(reqId) { initCreateDeal(reqId) {
console.log('reqId', reqId);
console.log('window', window);
if (window.createDeal) { if (window.createDeal) {
window.createDeal(reqId); window.createDeal(reqId);
ac.closesStep = false; ac.closesStep = false;
@ -1450,6 +1479,7 @@ var ac = new Vue({
var res = typeof response === 'string' ? JSON.parse(response) : response; var res = typeof response === 'string' ? JSON.parse(response) : response;
if (res.deal_id) { if (res.deal_id) {
window.editDeal(reqId, res.deal_id); window.editDeal(reqId, res.deal_id);
ac.closesStep = false;
} }
} }
}); });
@ -1459,6 +1489,7 @@ var ac = new Vue({
this.$nextTick(() => { this.$nextTick(() => {
this.observeRefs(); this.observeRefs();
}); });
window.step = this.step;
}, },
watch: { watch: {
complexBus(complexBus) { complexBus(complexBus) {

View File

@ -4163,6 +4163,91 @@ $user_id = $_SESSION['id'];
<div class="clear"></div> <div class="clear"></div>
</div> </div>
</div> </div>
<!-- Блок информации о сделке (показывается когда "По клиенту прошла сделка" включена) -->
<?php if (in_array((int)$_SESSION['id'], $allowed_users_deal)) { ?>
<div id="deal_close_block" style="display: none; margin: 15px 0; padding: 15px; border: 1px solid #e0e0e0; border-radius: 5px;">
<div style="font-weight: 600; margin-bottom: 10px; width: 100%;">Информация о сделке</div>
<div id="deal_close_content">
<div style="color: #999;">Загрузка данных сделки...</div>
</div>
</div>
<script>
$(document).ready(function() {
$('#luck').on('change', function() {
if ($(this).is(':checked') && window.dealCloseData) {
renderDealCloseContent();
$('#deal_close_block').show();
} else {
$('#deal_close_block').hide();
}
});
});
function renderDealCloseContent() {
var d = window.dealCloseData;
if (!d) return;
var html = '';
if (d.title) html += '<div style="margin-bottom: 8px;"><span style="font-weight: 500;">Название:</span> ' + d.title + '</div>';
if (d.contract_price) html += '<div style="margin-bottom: 8px;"><span style="font-weight: 500;">Сумма в договоре:</span> ' + Number(d.contract_price).toLocaleString('ru-RU') + ' руб.</div>';
if (d.agent_commission) html += '<div style="margin-bottom: 8px;"><span style="font-weight: 500;">Комиссия агента:</span> ' + Number(d.agent_commission).toLocaleString('ru-RU') + ' руб.</div>';
var reqIds = [];
if (d.side_one_requisition_id) reqIds.push(d.side_one_requisition_id);
if (d.side_two_requisition_id) reqIds.push(d.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) {
var reqs = reqRes.reqs || [];
if (reqs.length > 0) {
html += '<div style="margin-top: 10px;"><b>Связанные заявки:</b></div>';
reqs.forEach(function(req) {
html += '<div style="padding: 3px 0;">' + req.name;
html += req.deleted == 1 ? ' <span style="color: #43A047;">✓ закрыта</span>' : ' <span style="color: #f57c00;">открыта</span>';
html += '</div>';
});
}
var objIds = [];
if (d.side_one_object_id) objIds.push(d.side_one_object_id);
if (d.side_two_object_id) objIds.push(d.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) {
var objs = objRes.objects || [];
if (objs.length > 0) {
html += '<div style="margin-top: 10px;"><b>Связанные объекты:</b></div>';
objs.forEach(function(obj) {
html += '<div style="padding: 3px 0;">' + obj.nazv + ' <span style="color: #999;">' + obj.adres + '</span></div>';
});
}
html += '<div style="margin-top: 12px; padding-top: 10px; border-top: 1px solid #e0e0e0;"><b>Фактические данные</b></div>';
html += '<div><span style="color: #666;">Комиссия агента:</span> ' + (d.agent_commission || 0) + ' руб. | <span style="color: #666;">Сумма сделки:</span> ' + (d.contract_price || 0) + ' руб.</div>';
$('#deal_close_content').html(html);
}
});
} else {
html += '<div style="margin-top: 12px; padding-top: 10px; border-top: 1px solid #e0e0e0;"><b>Фактические данные</b></div>';
html += '<div><span style="color: #666;">Комиссия агента:</span> ' + (d.agent_commission || 0) + ' руб. | <span style="color: #666;">Сумма сделки:</span> ' + (d.contract_price || 0) + ' руб.</div>';
$('#deal_close_content').html(html);
}
}
});
} else {
html += '<div style="margin-top: 12px; padding-top: 10px; border-top: 1px solid #e0e0e0;"><b>Фактические данные</b></div>';
html += '<div><span style="color: #666;">Комиссия агента:</span> ' + (d.agent_commission || 0) + ' руб. | <span style="color: #666;">Сумма сделки:</span> ' + (d.contract_price || 0) + ' руб.</div>';
$('#deal_close_content').html(html);
}
}
</script>
<?php } ?>
<script src=""></script> <script src=""></script>
<div class="modal-submit"> <div class="modal-submit">
<input type="hidden" name="id_funnel_client" value="0"> <input type="hidden" name="id_funnel_client" value="0">
@ -5400,55 +5485,6 @@ $user_id = $_SESSION['id'];
</div> </div>
<?php } ?> <?php } ?>
<!-- Блок информации о сделке при закрытии этапа -->
<?php if (in_array((int)$_SESSION['id'], $allowed_users_deal)) { ?>
<div v-if="step.is_deal === 1 && currentPage.includes('/requisitions.php')" class="form-block" style="border: 1px solid #e0e0e0; border-radius: 5px; padding: 15px; margin-top: 10px;">
<div class="label" style="font-weight: 600; margin-bottom: 10px; width: 100%;">Информация о сделке</div>
<div v-if="dealCloseData">
<div v-if="dealCloseData.title" style="margin-bottom: 8px;">
<span style="font-weight: 500;">Название:</span> {{ dealCloseData.title }}
</div>
<!-- Связанные заявки -->
<div v-if="dealCloseReqs.length > 0" style="margin-top: 10px;">
<span style="font-weight: 500;">Связанные заявки:</span>
<div v-for="req in dealCloseReqs" style="padding: 5px 0; border-bottom: 1px solid #f0f0f0;">
<span style="color: #666;">{{ req.name }}</span>
<span v-if="req.deleted == 1" style="color: #43A047; margin-left: 5px;"> закрыта</span>
<span v-else style="color: #f57c00; margin-left: 5px;">открыта</span>
</div>
</div>
<!-- Связанные объекты -->
<div v-if="dealCloseObjects.length > 0" style="margin-top: 10px;">
<span style="font-weight: 500;">Связанные объекты:</span>
<div v-for="obj in dealCloseObjects" style="padding: 5px 0; border-bottom: 1px solid #f0f0f0;">
<span style="color: #666;">{{ obj.nazv }}</span>
<span style="color: #999; margin-left: 5px;">{{ obj.adres }}</span>
</div>
</div>
<!-- Фактические данные -->
<div style="margin-top: 12px; padding-top: 10px; border-top: 1px solid #e0e0e0;">
<div class="label" style="font-weight: 500; margin-bottom: 8px; width: 100%;">Фактические данные</div>
<div class="form-block">
<div style="width: 100%;" class="label">Комиссия агента (руб.)</div>
<div class="inputs">
<input v-model="dealCloseAgentCommission" type="number" class="text" style="width: 200px;" placeholder="0">
</div>
</div>
<div class="form-block">
<div style="width: 100%;" class="label">Сумма сделки (руб.)</div>
<div class="inputs">
<input v-model="dealCloseSumma" type="number" class="text" style="width: 200px;" placeholder="0">
</div>
</div>
</div>
</div>
<div v-else style="color: #999;">Загрузка данных сделки...</div>
</div>
<?php } ?>
</div> </div>
</div> </div>
</div> </div>