中扬CRM客户关系管理系统
whycq
2023-08-21 e62bcdc3d722bb81713ed43fb9e4b05a349ef098
src/main/webapp/static/js/plan/plan.js
@@ -588,30 +588,40 @@
    $('#data-btn-file3').on('click', 'a', function() {
        // var downloadUrl = $(this).attr('href');
        // console.log(downloadUrl)
        // console.log(baseUrl)
        // window.open("/\//"+downloadUrl);
        // return false;
        // // console.log(baseUrl)
        // // window.open("/\//"+downloadUrl);
        // // return false;
        // // var downloadUrl = $(this).attr('href');
        // // console.log(downloadUrl)
        // // // 发起 AJAX 请求,获取文件
        // $.ajax({
        //     url: '/plan/download/file/auth',
        //     type: 'POST',
        //     data: { downloadUrl: downloadUrl },  // 传递下载链接作为参数
        //     success: function(response) {
        //         // console.log(response)
        // //         // window.open(baseUrl+response.msg)
        // //         // 创建一个Blob对象
        // //         var blob = new Blob([response]);
        // //         // 使用FileSaver保存文件
        // //         var fileName = downloadUrl.substring(downloadUrl.lastIndexOf('\\') + 1);
        // //         console.log(fileName)
        // //         saveAs(blob, fileName);
        //         return false;
        //     },
        //     error: function() {
        //         layer.msg('请求文件下载失败');
        //     }
        // });
        var downloadUrl = $(this).attr('href');
        console.log(downloadUrl)
        // 发起 AJAX 请求,获取文件
        $.ajax({
            url: '/plan/download/file/auth',
            type: 'POST',
            data: { downloadUrl: downloadUrl },  // 传递下载链接作为参数
            success: function(response) {
                console.log(response)
                // window.open(baseUrl+response.msg)
                // 创建一个Blob对象
                var blob = new Blob([response]);
                // 使用FileSaver保存文件
                var fileName = downloadUrl.substring(downloadUrl.lastIndexOf('\\') + 1);
                console.log(fileName)
                saveAs(blob, fileName);
            },
            error: function() {
                layer.msg('请求文件下载失败');
            }
        });
        if (downloadUrl == "" || downloadUrl == null) {
            layer.msg('请先上传app文件',{time:1000},() => {
                parent.location.reload()
            })
        }else{
            window.open(downloadUrl);
        }
        return false;  // 阻止默认的链接跳转行为
    });