export default {
    execute(context, param) {
        if (!param.imageId) {
            context.dom.$Message.info("下载影像按钮尚未配置按钮参数");
            return;
        }
        let imageId = context.selects[0][param.imageId]
        let yearFlag = context.selects[0][param.yearFlag]
        this.downloadImage(imageId,yearFlag)
    },

    downloadImage(imageId,yearFlag) {
        GMS.$http.post('/yxgl/downloadImageData', {"imageId": imageId,"yearFlag":yearFlag}, {
            responseType: 'blob'
        }).then(res => {
            let blob = new Blob([res.data], {type: res.data.type})
            let downloadElement = document.createElement('a')
            let href = window.URL.createObjectURL(blob)
            downloadElement.href = href
            let dis = res.headers['content-disposition']
            let fileName = dis.split("filename*=UTF-8''")[1]
            downloadElement.download = decodeURIComponent(fileName)
            document.body.appendChild(downloadElement)
            downloadElement.click()
            document.body.removeChild(downloadElement)
            window.URL.revokeObjectURL(href)
        })
    },
};
