export default {
    execute(context, param) {
        let currentPage = param.currentPage||false;
        let queryParam = context.currentDataQueryConditionSet;
        if(!currentPage){//全部导出
            queryParam.page = {}
        }
        GMS.$http.post(`/rbcquery/exportExcel`, {
            queryParameter:  queryParam,
            queryViewVO: context.dom.queryBus.config,
            currentGroup: context.dom.queryBus.currGroup,
        },{
            responseType: 'blob'
        }).then((res) => {
            let blob = new Blob([res.data], {
                type: 'multipart/form-data;charset=utf-8'
            });
            //获取heads中的filename文件名
            let temp = res.headers['content-disposition'].split(';')[1].split('filename=')[1]
            //对文件名乱码转义--【Node.js】使用iconv-lite解决中文乱码
            let iconv = require('iconv-lite')
            iconv.skipDecodeWarning = true //忽略警告
            let fileName = iconv.decode(temp, 'utf-8')
            let downloadElement = document.createElement('a')
            let href = window.URL.createObjectURL(blob) // 创建下载的链接
            downloadElement.href = href
            downloadElement.download = fileName // 下载后文件名
            document.body.appendChild(downloadElement)
            downloadElement.click() // 点击下载
            document.body.removeChild(downloadElement) // 下载完成移除元素
            window.URL.revokeObjectURL(href) // 释放掉blob对象

        });
    }
}