zhangxiaoxu123
2022-12-31 9c095258e40d4cb38449c7aefe7c7b9d93d859a5
发票下载
2个文件已修改
80 ■■■■■ 已修改文件
src/assets/js/ByUtils.js 67 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/page/invoice/invoiceForm.vue 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/assets/js/ByUtils.js
@@ -265,7 +265,7 @@
        }).then((response) => {
            //vm.$loading().close();
            let data = response.data;
            if (data && data.code==0) {
        if (data && data.code==0) {
                callBackFunction(data);
            } else {
                if(data.message=='-9999'){
@@ -294,6 +294,71 @@
        })
    },
    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: {
            //     'token': token
            // },
            withCredentials: false,
            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) {
        if (StringUtil.isNullOrEmpty(url)) {
            vm.$alert('请求地址不能为空', {'title': '提示', 'type': 'warning', 'center': true, 'showClose': false});
src/components/page/invoice/invoiceForm.vue
@@ -167,8 +167,17 @@
                let param = {
                  fileIds : result
                }
                this.$byutil.postData(this,url,param,res => {
                this.$byutil.exportData(this,url,param,res => {
                    console.log(res,'res=========')
                    let blob = new Blob([res], {type: 'application/pdf'});
                    let downloadElement = document.createElement("a");
                    let href = window.URL.createObjectURL(blob); //创建下载的链接
                    downloadElement.href = href;
                    downloadElement.download = '发票下载'
                    document.body.appendChild(downloadElement);
                    downloadElement.click(); //点击下载
                    document.body.removeChild(downloadElement); //下载完成移除元素
                    window.URL.revokeObjectURL(href); //释放掉blob对象
                })
              }
            },