zhanghua
2022-10-25 c569fe2027abbcb85c1f7c817456ecf31301f36a
src/utils/helper.js
@@ -33,6 +33,42 @@
        })
    return arr;
}
// 获取字典表2
export async function getCodeList(code){
    let arr;
    await myrequest({
        method: 'get',
        url: `/sccg/dict/queryByCode?code=${code}`
    })
        .then(res => {
            arr = res.data;
        })
    return arr;
}
export async function myDownLoad(arr){
    let fileName = arr.headers['content-disposition'];
            console.log(fileName);
            if (fileName) {
                fileName = fileName.slice(fileName.indexOf('filename=') + 9);
            }
            const blob = new Blob([arr.data], {
                type: 'application/octet-stream'
            })
            // content-disposition
            const downloadElement = document.createElement('a')
            // 创建下载的链接
            const href = window.URL.createObjectURL(blob)
            downloadElement.href = href
            // // 下载后文件名
            downloadElement.download = fileName
            document.body.appendChild(downloadElement)
            // 点击下载
            downloadElement.click()
            // 下载完成移除元素
            document.body.removeChild(downloadElement)
            // 释放掉blob对象
            window.URL.revokeObjectURL(href)
}
// 获取token
export function getToken() {
    const token = sessionStorage.getItem('token');