| | |
| | | <div class="option-group"> |
| | | <div class="option-label">选择注解:</div> |
| | | <div class="annotation-options"> |
| | | <label v-for="i in 5" :key="i" class="annotation-checkbox"> |
| | | <input type="checkbox" v-model="excelOptions.selectedAnnotations" :value="i"> |
| | | <span>注解{{ i }}</span> |
| | | </label> |
| | | <label v-for="(annotation, index) in excelOptions.selectedAnnotations" :key="index" class="signature-checkbox"> |
| | | <input type="checkbox" v-model="excelOptions.subselectedAnnotations" :value="index"> |
| | | <span>{{ annotation }} |
| | | </span> |
| | | </label> |
| | | </div> |
| | | </div> |
| | | |
| | |
| | | <div class="option-label">签名栏设置:</div> |
| | | <div class="signature-options"> |
| | | <div class="signature-checkboxes"> |
| | | <label v-for="i in 3" :key="i" class="signature-checkbox"> |
| | | <input type="checkbox" v-model="excelOptions.selectedSignatures" :value="i"> |
| | | <span>签名栏{{ i }}</span> |
| | | <label v-for="(signature, index) in excelOptions.selectedSignatures" :key="index" class="signature-checkbox"> |
| | | <input type="checkbox" v-model="excelOptions.subselectedSignatures" :value="index"> |
| | | <span>{{ signature }}</span> |
| | | </label> |
| | | |
| | | |
| | | |
| | | </div> |
| | | <!-- <p v-if="excelOptions.selectedSignatures.length === 0" class="option-tip">请选择至少一个签名栏</p> --> |
| | | </div> |
| | |
| | | </div> |
| | | </div> |
| | | <!-- 优化的Excel预览组件 --> |
| | | <div class="excel-preview-wrapper" v-if="excelDialogVisible"> |
| | | <el-dialog class="excel-preview-wrapper" :visible.sync="showExcelPreview" :modal="false" width="80%"> |
| | | |
| | | <div > |
| | | <!-- 主要预览组件 --> |
| | | <vue-office-excel |
| | | v-if="currentExcelUrl" |
| | |
| | | <button class="excel-dialog-btn download-btn" @click="handleDownloadClick">下载Excel文件</button> |
| | | </div> |
| | | </div> |
| | | |
| | | </el-dialog> |
| | | <div class="excel-dialog-footer"> |
| | | <button class="excel-dialog-btn preview-btn" @click="handlePreviewClick">预览</button> |
| | | <button class="excel-dialog-btn print-btn" @click="handlePrintClick">打印</button> |
| | |
| | | // Excel选项配置 |
| | | excelOptions: { |
| | | includeQrCode: false, // 是否包含二维码 |
| | | selectedAnnotations: [], // 选中的注解列表 |
| | | selectedAnnotations: ["本清单由档案形成部门完成", |
| | | "文件类型必须录入,包括结论材料、过程材料、申请材料,其他材料", |
| | | "公开属性必须录入,主动公开、依申请公开、免予公开", |
| | | "保管期限:30年或永久", |
| | | "页号按照正式录入页码为准"], // 选中的注解列表 |
| | | includeSignature: false, // 是否包含签名栏 |
| | | selectedSignatures: ['业务科室移交人:', '审批科移交人:', '档案整理公司:'], // 选中的签名栏列表 |
| | | subselectedSignatures: [], |
| | | subselectedAnnotations: [], |
| | | signaturePosition: 'bottom' // 签名栏位置:top/bottom |
| | | }, |
| | | // 表单参数 |
| | |
| | | /** 查看并打印Excel文件 */ |
| | | viewAndPrintExcel(row) { |
| | | const id = row.id || this.ids; |
| | | // alert(id) |
| | | this.recordId = id; |
| | | this.$modal.loading('正在获取Excel文件,请稍候...'); |
| | | |
| | | // 从后端获取Excel文件 |
| | |
| | | |
| | | /** 处理预览按钮点击 */ |
| | | handlePreviewClick() { |
| | | this.excelLoading = true; |
| | | this.showExcelPreview = true; |
| | | this.excelRenderError = ''; |
| | | |
| | | var id = this.recordId ; |
| | | this.$modal.loading('正在获取Excel文件,请稍候...'); |
| | | alert(id) |
| | | // 从后端获取Excel文件 |
| | | this.getExcelFile(id).then(blob => { |
| | | this.$modal.closeLoading(); |
| | | // 保存文件信息并显示静态弹窗 |
| | | this.currentExcelUrl = URL.createObjectURL(blob); |
| | | 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文件失败,请稍后重试'); |
| | | }); |
| | | // 重置vue-office-excel组件 |
| | | if (this.currentExcelUrl) { |
| | | const tempUrl = this.currentExcelUrl; |
| | |
| | | |
| | | /** 从后端获取Excel文件 */ |
| | | getExcelFile(id) { |
| | | var includeQrCode = this.excelOptions.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 |
| | | } |
| | | |
| | | return new Promise((resolve, reject) => { |
| | | // 首先尝试使用axios(项目已有的HTTP客户端) |
| | | try { |
| | | // 获取用户选择的注解 |
| | | const { selectedAnnotations } = this.excelOptions; |
| | | |
| | | // 构建参数,包含注解内容 |
| | | const params = { |
| | | recordId: id, |
| | | |
| | | }; |
| | | |
| | | axios({ |
| | | method: 'Post', |
| | | url: `${process.env.VUE_APP_BASE_API}/system/records/model`, |
| | | params: { id: id }, |
| | | url: urls, |
| | | params: params, |
| | | responseType: 'blob', |
| | | headers: { 'Authorization': 'Bearer ' + getToken() } |
| | | }).then(response => { |
| | |
| | | fallbackGetExcelFile(id, resolve, reject) { |
| | | try { |
| | | const xhr = new XMLHttpRequest(); |
| | | |
| | | // 构建查询参数,包含注解内容 |
| | | const queryParams = new URLSearchParams({ |
| | | id: id, |
| | | annotation1: "本清单由档案形成部门完成", |
| | | annotation2: "文件类型必须录入,包括结论材料、过程材料、申请材料,其他材料", |
| | | annotation3: "公开属性必须录入,主动公开、依申请公开、免予公开", |
| | | annotation4: "保管期限:30年或永久", |
| | | annotation5: "页号按照正式录入页码为准" |
| | | }).toString(); |
| | | |
| | | // 尝试不同的API路径,以适应可能的后端实现 |
| | | const apiUrls = [ |
| | | `${process.env.VUE_APP_BASE_API}/system/records/model?id=${id}`, |
| | | `${process.env.VUE_APP_BASE_API}/system/records/model?${queryParams}`, |
| | | `${process.env.VUE_APP_BASE_API}/system/records/model` |
| | | ]; |
| | | |