• 导出excel


    export function handerFillZero(num){
        return num>=10 ? num : '0'+num;
    }
    export function exportExcel(vm, params) {
        if (vm.choosedResumeIds.length == 0) return;
        vm.$http.get(url_exportCsv, {
            params: {
                resumes: vm.choosedResumeIds.join(','),
                response: true,
                t:Date.now()
            }
        }).then((res) => {
            // console.log('excel-res:', res);
            // console.log('excel-res:',res.request.getAllResponseHeaders());
            // console.log("res.headers['content-type']", res.headers['content-type']);
            let _file = new Blob([new Uint8Array([0xEF, 0xBB, 0xBF]),res.data], {
                type: 'text/plain;charset=utf-8'
            }),
            _date = new Date(),
            _year = _date.getFullYear(),
            _month = _date.getMonth()+1,
            _day = _date.getDate(),
            _hour = _date.getHours(),
            _min = _date.getMinutes(),
            _sec = _date.getSeconds();
            // console.log('_file',_file);
            var href = window.URL.createObjectURL(_file);
            // console.log('href', href)
            var downloadElement = document.createElement('a');
            downloadElement.href = href;
            downloadElement.download = `导出的List ${_year}-${handerFillZero(_month)}-${handerFillZero(_day)}.csv`; //下载后文件名
            document.body.appendChild(downloadElement);
            downloadElement.click(); //点击下载
            document.body.removeChild(downloadElement); //下载完成移除元素
            window.URL.revokeObjectURL(href); //释放掉blob对象 
            ipcRenderer.removeAllListeners('exprot-excel-success');
            ipcRenderer.on('exprot-excel-success',(e,params)=>{
                if(params.state=='completed'){
                    vm.$message({
                        type:'success',
                        message:'Excel导出成功'
                    })
                    vm.clearChoosedIds();
                }
            })
        })
    }
  • 相关阅读:
    归并排序
    快速排序
    冒泡排序
    排序算法复杂度
    [LeetCode] 20. Valid Parentheses ☆(括号匹配问题)
    makefile编写helloworld
    shell的通俗理解
    PID三种参数的理解
    PID的原理
    PID控制温度
  • 原文地址:https://www.cnblogs.com/zfdai/p/9983337.html
Copyright © 2020-2023  润新知