Joywork/js/vue_scripts/filelist_vue.js

150 lines
4.0 KiB
JavaScript
Raw Normal View History

2026-05-22 20:21:54 +02:00
var fileslist = new Vue({
el: '#files_list',
components: {
vuejsDatepicker: window.vuejsDatepicker
},
data(){
return {
ru: vdp_translation_ru.js,
isShow: false,
errorText: '',
errorMes: false,
isPreloader: 1,
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'},
id: 0,
type: '',
list:[],
names: [],
}
},
methods:{
//Открытие
open(id, type){
this.isShow = true;
this.isPreloader = 1;
this.id = id;
this.type = type;
this.getFiles();
/* this.steps = [];
this.client_id = 0;
this.req_id = 0;
this.funnelId = funnel_id;
if(type == 'req'){
this.req_id = id;
}
if(type == 'client'){
this.client_id = id
}
axios.post('/ajax/ajax_vue_funnel.php',{
request: 'get_steps_order',
funnel_id: funnel_id,
},
)
.then((response)=> {
// console.log(response.data);
this.isPreloader = 0;
this.steps = this.getSteps(response.data);
$("body").addClass("lock");
$('.jw__add-popup').removeClass('is__show');
})
.catch(function (error) {
console.log(error);
});*/
},
getFiles(){
if(this.id > 0 && !this.isEmpty(this.type)){
axios.post('/ajax/ajax_vue_files.php',{
request: 'get_files',
id: this.id,
type: this.type,
},
)
.then((response)=> {
console.log(response.data);
var res = response.data;
this.list = res.list;
this.names = res.names;
this.isPreloader = 0;
})
.catch(function (error) {
console.log(error);
});
}
},
typeFile: function(nameFile){
var tchk = nameFile.lastIndexOf(".");
if(tchk != -1){
return nameFile.slice(tchk+1);
}
return 'undefined';
},
//Закрытие
closes(){
this.isShow = false;
this.list = [];
this.type = '';
this.id = 0;
this.names = [];
$("body").removeClass("lock");
$('.jw__add-popup').removeClass('is__show');
},
//Проверка на пустоту
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() {
$("#files_list").removeClass("hidden");
}
})