Joywork/js/requisitions_obj_vue.js

151 lines
5.4 KiB
JavaScript
Raw Permalink Normal View History

2026-05-22 20:21:54 +02:00
Vue.config.devtools = true;
Vue.component('v-select', VueSelect.VueSelect);
var reqobj = {};
/*var getinterval = setInterval(function(){
//console.log($('.additional-info .stagebar').length);
if($('.additional-info .stagebar').length > 0){
get_bar_obj();
getReSearchObjectsCounts();
clearInterval(getinterval);
}
}, 500);*/
//Получение бара
function get_bar_obj(){
$('.stagebar').each(function(index){
if($(this).data("req")){
var req_id = $(this).data("req");
var funnel_id = $(this).data("funnel");
var stage = $(this).data("stage");
reqobj[req_id] = new Vue({
el: '#stagebar__'+req_id,
components: {
Multiselect: window.VueMultiselect.default,
vuejsDatepicker: window.vuejsDatepicker
},
data(){
return {
agency_id: $('#session_agency_id').val(),
user_id: $('#session_user_id').val(),
steps:[],
reqId: req_id,
funnelId: funnel_id,
stage: stage,
bars: 1,
funnels: [],
selectFunnel: funnel_id,
OpenIndicator: {
render: createElement => createElement('span', { class: { 'vueToggleSpan': true } }),
},
is_edit_funnel: false
}
},
methods:{
//Получение бара воронки
getBarFunnel(reqId) {
axios.post('/ajax/ajax_vue_requisitions.php',{
request: 'get_bar_funnel',
funnel_id: this.funnelId,
req_id: reqId,
stage: stage,
agency_id: this.agency_id
},
)
.then((response)=> {
this.steps = response.data;
this.bars = this.steps.bar.length;
this.funnels = response.data.funnels;
})
.catch(function (error) {
console.log(error);
});
},
closeEdit(){
this.is_edit_funnel = false;
this.selectFunnel = this.funnelId;
},
saveFunnel(){
if(!this.isEmpty(this.selectFunnel)){
axios.post('/ajax/ajax_vue_requisitions.php',{
request: 'funnel_change',
new_funnel_id: this.selectFunnel,
old_funnel_id: this.funnelId,
req_id: this.reqId,
agency_id: this.agency_id,
user_id: this.user_id
},
)
.then((response)=> {
//console.log(response.data);
this.funnelId = this.selectFunnel;
this.getBarFunnel(this.reqId);
this.closeEdit();
})
.catch(function (error) {
console.log(error);
});
}
},
//Проверка на пустоту
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() {
},
created: function() {
$('.editFunnelObject').removeClass('hidden');
this.getBarFunnel(this.reqId);
$("#stagebar__"+this.reqId).show();
}
})
}
});
}