| | |
| | | this.getExcelFile(id).then(blob => { |
| | | this.$modal.closeLoading(); |
| | | // 保存文件信息并显示静态弹窗 |
| | | alert(23) |
| | | // alert(23) |
| | | this.currentExcelUrl = URL.createObjectURL(blob); |
| | | alert(this.currentExcelUrl) |
| | | // alert(this.currentExcelUrl) |
| | | this.currentExcelBlob = blob; |
| | | this.currentExcelId = id; |
| | | this.excelDialogVisible = true; |
| | |
| | | // 获取用户选择的选项 |
| | | const { includeQrCode, selectedAnnotations } = this.excelOptions; |
| | | console.log('下载选项:', { includeQrCode, selectedAnnotations }); |
| | | var id = this.recordId ; |
| | | this.getExcelFile(id).then(blob => { |
| | | this.$modal.closeLoading(); |
| | | // 保存文件信息并显示静态弹窗 |
| | | // alert(23) |
| | | this.currentExcelUrl = URL.createObjectURL(blob); |
| | | |
| | | const link = document.createElement('a'); |
| | | link.href = this.currentExcelUrl; |
| | | |
| | | // 构建文件名,包含选项信息 |
| | | let filename = `record_${this.currentExcelId}`; |
| | | if (includeQrCode) filename += '_qr'; |
| | | // if (selectedAnnotations.length > 0) { |
| | | // filename += `_anno${selectedAnnotations.join('')}`;x |
| | | // } |
| | | filename += `_${new Date().getTime()}.xls`; |
| | | |
| | | link.download = filename; |
| | | |
| | | // 触发下载 |
| | | document.body.appendChild(link); |
| | | link.click(); |
| | | document.body.removeChild(link); |
| | | |
| | | // 提示下载成功 |
| | | this.$modal.msgSuccess('Excel文件下载成功'); |
| | | // alert(this.currentExcelUrl) |
| | | // this.currentExcelBlob = blob; |
| | | // this.currentExcelId = id; |
| | | // this.excelDialogVisible = true; |
| | | // this.excelLoading = false; |
| | | }).catch(error => { |
| | | this.$modal.closeLoading(); |
| | | console.error('获取Excel文件失败:', error); |
| | | this.$modal.msgError('获取Excel文件失败,请稍后重试'); |
| | | |
| | | |
| | | this.showExcelPreview = false; |
| | | }); |
| | | // alert(this.excelOptions.includeQrCode) |
| | | // 创建下载链接,文件名包含选项信息 |
| | | const link = document.createElement('a'); |
| | | link.href = this.currentExcelUrl; |
| | | |
| | | // 构建文件名,包含选项信息 |
| | | let filename = `record_${this.currentExcelId}`; |
| | | if (includeQrCode) filename += '_qr'; |
| | | // if (selectedAnnotations.length > 0) { |
| | | // filename += `_anno${selectedAnnotations.join('')}`;x |
| | | // } |
| | | filename += `_${new Date().getTime()}.xls`; |
| | | |
| | | link.download = filename; |
| | | |
| | | // 触发下载 |
| | | document.body.appendChild(link); |
| | | link.click(); |
| | | document.body.removeChild(link); |
| | | |
| | | // 提示下载成功 |
| | | this.$modal.msgSuccess('Excel文件下载成功'); |
| | | } |
| | | }, |
| | | |
| | |
| | | /** 从后端获取Excel文件 */ |
| | | getExcelFile(id) { |
| | | var includeQrCode = this.excelOptions.includeQrCode; |
| | | var urls = `${process.env.VUE_APP_BASE_API}/system/records/recordFileList`+"/"+includeQrCode; |
| | | var urls = `${process.env.VUE_APP_BASE_API}/system/records/recordFileList` |
| | | //+"/"+includeQrCode; |
| | | |
| | | |
| | | if(this.excelOptions.subselectedSignatures.length!=0) |
| | | { |
| | | var selectedSignatures = this.excelOptions.subselectedSignatures |
| | | urls = urls +'/'+ selectedSignatures |
| | | } |
| | | if(this.excelOptions.subselectedAnnotations.length!=0) |
| | | { |
| | | var selectedAnnotations = this.excelOptions.subselectedAnnotations |
| | | urls = urls+"/"+selectedAnnotations |
| | | } |
| | | |
| | | // // if(this.excelOptions.subselectedSignatures.length!=0) |
| | | // // { |
| | | // // var selectedSignatures = this.excelOptions.subselectedSignatures |
| | | // // urls = urls +'/'+ selectedSignatures |
| | | // // // alert(urls) |
| | | // // } |
| | | // console.log(this.excelOptions.subselectedAnnotations) |
| | | // alert(234) |
| | | // if(this.excelOptions.subselectedAnnotations.length!=0) |
| | | // { |
| | | // var selectedAnnotations = this.excelOptions.subselectedAnnotations |
| | | // urls = urls+"/"+selectedAnnotations |
| | | // // alert(urls) |
| | | // } |
| | | // alert(urls) |
| | | return new Promise((resolve, reject) => { |
| | | // 首先尝试使用axios(项目已有的HTTP客户端) |
| | | try { |
| | |
| | | // 构建参数,包含注解内容 |
| | | const params = { |
| | | recordId: id, |
| | | |
| | | selectedSignatures: this.excelOptions.subselectedSignatures, |
| | | selectedAnnotations: this.excelOptions.subselectedAnnotations, |
| | | includeQrCode: this.excelOptions.includeQrCode |
| | | }; |
| | | console.log(params) |
| | | // alert(457) |
| | | |
| | | axios({ |
| | | method: 'Post', |
| | | url: urls, |
| | | params: params, |
| | | data: params, |
| | | responseType: 'blob', |
| | | headers: { 'Authorization': 'Bearer ' + getToken() } |
| | | }).then(response => { |