247 lines
8.1 KiB
JavaScript
247 lines
8.1 KiB
JavaScript
|
|
var client_req_bind = new Vue({
|
||
|
|
el: '#client_req_bind',
|
||
|
|
|
||
|
|
data() {
|
||
|
|
|
||
|
|
return {
|
||
|
|
user_id: $('#session_user_id').val(),
|
||
|
|
agency_id: $('#session_agency_id').val(),
|
||
|
|
ru: vdp_translation_ru.js,
|
||
|
|
is_show: false,
|
||
|
|
OpenIndicator: {
|
||
|
|
render: createElement => createElement('span', { class: { 'vueToggleSpan': true } }),
|
||
|
|
},
|
||
|
|
clients: [],
|
||
|
|
client_id: 0,
|
||
|
|
spinner: true,
|
||
|
|
clientSelect: [],
|
||
|
|
debounceTimer: null,
|
||
|
|
objectId: 0,
|
||
|
|
is_req: false,
|
||
|
|
text_req: '',
|
||
|
|
req_id: null,
|
||
|
|
show_block_req: true
|
||
|
|
}
|
||
|
|
},
|
||
|
|
methods: {
|
||
|
|
|
||
|
|
//Открытие
|
||
|
|
open() {
|
||
|
|
this.is_show = true;
|
||
|
|
$("body").addClass("lock");
|
||
|
|
$('.jw__add-popup').removeClass('is__show');
|
||
|
|
setSelectsFastselect('client_req_bind_funnel', null, 'select_form_funnel.php', 'Воронка', 'req');
|
||
|
|
},
|
||
|
|
|
||
|
|
|
||
|
|
//Закрытие
|
||
|
|
closes() {
|
||
|
|
this.is_show = false;
|
||
|
|
//this.updateCanOpen();
|
||
|
|
$("body").removeClass("lock");
|
||
|
|
$('.jw__add-popup').removeClass('is__show');
|
||
|
|
this.objectId = 0;
|
||
|
|
this.client_id = 0;
|
||
|
|
this.clientSelect = [];
|
||
|
|
this.debounceTimer = null;
|
||
|
|
this.is_req = false;
|
||
|
|
this.text_req = 0;
|
||
|
|
this.req_id = null;
|
||
|
|
this.show_block_req = true;
|
||
|
|
$('#client_req_bind_funnel-input').html('<img src="../images/rocket-spinner.svg" width="45px">');
|
||
|
|
},
|
||
|
|
|
||
|
|
//Новая заявка
|
||
|
|
create_new_req(){
|
||
|
|
this.req_id = 'new';
|
||
|
|
this.is_req = true;
|
||
|
|
this.text_req = 'Будет создана новая заявка';
|
||
|
|
this.show_block_req = false;
|
||
|
|
},
|
||
|
|
|
||
|
|
//список старых заявок
|
||
|
|
open_old_req(){
|
||
|
|
setTimeout(function(){
|
||
|
|
$('#liReq').click();
|
||
|
|
}, 500);
|
||
|
|
},
|
||
|
|
|
||
|
|
//Выбор заявки из списка
|
||
|
|
change_req(req){
|
||
|
|
this.req_id = req.id;
|
||
|
|
this.is_req = true;
|
||
|
|
this.text_req = "Объект будет прикреплен к заявке " + req.name;
|
||
|
|
this.show_block_req = false;
|
||
|
|
},
|
||
|
|
|
||
|
|
save() {
|
||
|
|
|
||
|
|
let funnelId = $('#client_req_bind_funnel').val();
|
||
|
|
|
||
|
|
axios.post('/ajax/ajax_vue_clients.php', {
|
||
|
|
request: 'save_client_req_bind',
|
||
|
|
client_id: this.client_id,
|
||
|
|
object_id: this.objectId,
|
||
|
|
user_id: this.user_id,
|
||
|
|
funnel_id: funnelId,
|
||
|
|
req_id: this.req_id,
|
||
|
|
agency_id: this.agency_id
|
||
|
|
|
||
|
|
}, )
|
||
|
|
.then((response) => {
|
||
|
|
var res = response.data;
|
||
|
|
// console.log(response.data);
|
||
|
|
let object_id = this.objectId;
|
||
|
|
|
||
|
|
/// console.log( $('#object_req_stagebar'+object_id+' .crm__small-stagebar').length);
|
||
|
|
if(res.html){
|
||
|
|
//console.log($('#object_req_stagebar'+object_id));
|
||
|
|
$('#object_req_stagebar'+object_id).html(res.html);
|
||
|
|
get_bar_obj();
|
||
|
|
}
|
||
|
|
this.closes();
|
||
|
|
getClientsForObjects();
|
||
|
|
|
||
|
|
})
|
||
|
|
.catch(function(error) {
|
||
|
|
console.log(error);
|
||
|
|
});
|
||
|
|
},
|
||
|
|
|
||
|
|
//Переход на видосы
|
||
|
|
openHelp() {
|
||
|
|
this.updateCanOpen();
|
||
|
|
window.location.href = "/help.php";
|
||
|
|
},
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
selectClientList() {
|
||
|
|
//console.log(selectedOption);
|
||
|
|
this.client_id = 0;
|
||
|
|
//console.log(this.clientSelect);
|
||
|
|
//bindObjReq();
|
||
|
|
if (!isEmpty(this.clientSelect)) {
|
||
|
|
this.client_id = this.clientSelect.id;
|
||
|
|
//bindObjReq(this.client_id);
|
||
|
|
//this.setValueInput();
|
||
|
|
|
||
|
|
} else {
|
||
|
|
this.client_id = 0;
|
||
|
|
//this.setValueInput();
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
/*setValueInput() {
|
||
|
|
var values = [];
|
||
|
|
if(!this.isEmpty(this.clientSelect)){
|
||
|
|
for (var i = 0; i < this.clientSelect.length; i++) {
|
||
|
|
values.push(this.clientSelect.id);
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
},*/
|
||
|
|
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.error(error);
|
||
|
|
});
|
||
|
|
},
|
||
|
|
getClientsListNew(search, loading) {
|
||
|
|
|
||
|
|
clearTimeout(this.debounceTimer);
|
||
|
|
this.debounceTimer = setTimeout(() => this.getClientsList(search, loading), 500);
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
search_client(client_id) {
|
||
|
|
//console.log(client_id);
|
||
|
|
this.client_id = 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.error(error);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
checkClient() {
|
||
|
|
|
||
|
|
var clientsId = JSON.parse($("#object-new-client-vue").val());
|
||
|
|
// console.log(clientsId.length);
|
||
|
|
if (clientsId.length > 0) {
|
||
|
|
for (var i = 0; i < clientsId.length; i++) {
|
||
|
|
this.clientId = clientsId[i];
|
||
|
|
this.search_client(clientsId[i]);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
//Проверка на пустоту
|
||
|
|
isEmpty(data) {
|
||
|
|
if (typeof(data) === 'object') {
|
||
|
|
if (JSON.stringify(data) === '{}' || JSON.stringify(data) === '[]') {
|
||
|
|
return true;
|
||
|
|
} else if (!data) {
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
return false;
|
||
|
|
} else if (typeof(data) === 'string') {
|
||
|
|
if (!data.trim()) {
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
return false;
|
||
|
|
} else if (typeof(data) === 'undefined') {
|
||
|
|
return true;
|
||
|
|
} else {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
},
|
||
|
|
mounted() {
|
||
|
|
//this.canOpen();
|
||
|
|
},
|
||
|
|
created: function() {
|
||
|
|
this.getClientsList();
|
||
|
|
|
||
|
|
$("#client_req_bind").removeClass("hidden");
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
})
|