819527061@qq.com
2025-01-08 1618162f712fc414702bce924ff367397ff8ec1d
src/assets/js/ByUtils.js
@@ -111,8 +111,17 @@
                    vm.$router.push({'path': '/login'});
                    vm.$alert('会话结束,请重新登录', {'title': '提示', 'type': 'warning', 'center': true, 'showClose': false});
                }else{
                    vm.$alert('操作失败:' + data.message, {'title': '提示', 'type': 'warning', 'center': true, 'showClose': false});
                }
                    let a = '';
                    if(response.data){
                        if(response.data.msg){
                            a=response.data.msg
                        }else {
                            a='服务器故障'
                        }
                    }else {
                        a="数据错误"
                    }
                    vm.$alert(a , {'title': '提示', 'type': 'warning', 'center': true, 'showClose': false});                }
            }
        }).catch((e) => {
            vm.$loading().close();
@@ -265,14 +274,27 @@
        }).then((response) => {
            //vm.$loading().close();
            let data = response.data;
            if (data && data.code==0) {
            console.log(response)
        if (data && data.code==0) {
                callBackFunction(data);
            } else {
            } else if(data.code==1) {
            callBackFunction(data);
        }else {
                if(data.message=='-9999'){
                    vm.$router.push({'path': '/login'});
                    vm.$alert('会话结束,请重新登录', {'title': '提示', 'type': 'warning', 'center': true, 'showClose': false});
                }else{
                    vm.$alert('操作失败:' + data.message, {'title': '提示', 'type': 'warning', 'center': true, 'showClose': false});
                    let a = '';
                    if(response.data){
                        if(response.data.msg){
                            a=response.data.msg
                        }else {
                            a='服务器故障'
                        }
                    }else {
                        a="数据错误"
                    }
                    vm.$alert(a , {'title': '提示', 'type': 'warning', 'center': true, 'showClose': false});
                }
            }
        }).catch((e) => {
@@ -282,6 +304,72 @@
                    // vm.$router.push({'path': '/login'});
                }});
        })
    },
    exportData(vm, url, data, successCallBackFunction) {
        if (StringUtil.isNullOrEmpty(url)) {
            vm.$alert('请求地址不能为空', {'title': '提示', 'type': 'warning', 'center': true, 'showClose': false});
            return;
        }
        let callBackFunction = function (data) {
            vm.$message({message: data.message, type: 'success'});
            try {
                vm.showDialog(false);
            } catch (e) {
            }
            try {
                vm.loadData();
            } catch (e) {
            }
        }
        if (successCallBackFunction) {
            callBackFunction = successCallBackFunction;
        }
        // var token = "";
        // if(this.getUser()){
        //     token = this.getUser().token;
        // }
        // vm.$loading();
        vm.$axios({
            // headers: {
            //     'Content-Type': "application/json;charset=UTF-8"
            // },
            withCredentials: false,
            responseType: "blob",
            url: url,
            method: 'post',
            data: data
        }).then((response) => {
            //vm.$loading().close();
            let data = response.data;
        console.log(response,'response');
        if (data) {
            callBackFunction(data);
        } else {
            if(data.message=='-9999'){
                vm.$router.push({'path': '/login'});
                vm.$alert('会话结束,请重新登录', {'title': '提示', 'type': 'warning', 'center': true, 'showClose': false});
            }else{
                let a = '';
                if(response.data){
                    if(response.data.msg){
                        a=response.data.msg
                    }else {
                        a='服务器故障'
                    }
                }else {
                    a="数据错误"
                }
                vm.$alert(a , {'title': '提示', 'type': 'warning', 'center': true, 'showClose': false});
            }
        }
    }).catch((e) => {
            //vm.$loading().close();
            vm.$alert('操作出现异常:' + e, {'title': '错误', 'type': 'error', 'center': true, 'showClose': false,callback:action=> {
                // byUtils.setUser(null);
                // vm.$router.push({'path': '/login'});
            }});
    })
    },
    postData4(vm, url, data, successCallBackFunction) {
@@ -734,4 +822,34 @@
                }});
        })
    },
    dateFormat(date,f) {
        let format = 'yyyy-MM-dd hh:mm:ss'
        if(f){
            format = f;
        }
        if (date !== 'Invalid Date') {
            var o = {
                'M+': date.getMonth() + 1, // month
                'd+': date.getDate(), // day
                'h+': date.getHours(), // hour
                'm+': date.getMinutes(), // minute
                's+': date.getSeconds(), // second
                'q+': Math.floor((date.getMonth() + 3) / 3), // quarter
                'S': date.getMilliseconds() // millisecond
            }
            if (/(y+)/.test(format)) {
                format = format.replace(RegExp.$1,
                    (date.getFullYear() + '').substr(4 - RegExp.$1.length))
            }
            for (var k in o) {
                if (new RegExp('(' + k + ')').test(format)) {
                    format = format.replace(RegExp.$1,
                        RegExp.$1.length === 1 ? o[k]
                            : ('00' + o[k]).substr(('' + o[k]).length))
                }
            }
            return format
        }
        return ''
    },
}