| | |
| | | </el-dialog> |
| | | <el-dialog v-model="downloadDialog" title="导出" width="600px"> |
| | | <span> |
| | | <el-button :loading="outLoading" plain type="primary" @click="controlDown">核查记录</el-button> |
| | | <el-button :loading="outLoading" plain type="primary" @click="processingDown">核查比对记录</el-button> |
| | | <el-button :loading="outLoading" type="primary" :disabled="!downRow.recordStatus" @click="controlDown">核查记录</el-button> |
| | | <el-button :loading="outLoading" type="primary" :disabled="!downRow.recordContrastStatus" @click="processingDown">核查比对记录</el-button> |
| | | </span> |
| | | <template #footer><span class="dialog-footer"> |
| | | <el-button @click="downloadDialog = false">取 消</el-button> |
| | |
| | | } from '@/api/cnas/resourceDemand/device.js' |
| | | import { selectUserCondition } from "@/api/performance/class"; |
| | | import { mapGetters } from "@/utils/store-compat"; |
| | | import draftSave from '@/mixins/draftSave' |
| | | export default { |
| | | name: "equipment-verification-plan", |
| | | // import 引入的组件需要注入到对象中才能使用 |
| | | components: { AddVerificationYearPlanDia, CheckRecord, EquipmentCheck }, |
| | | mixins: [draftSave], |
| | | props: { |
| | | clickNodeVal: { |
| | | type: Object, |
| | |
| | | if (this.operationType !== 'add') { |
| | | this.$nextTick(() => { |
| | | this.form = this.HaveJson(row) |
| | | if (this.operationType !== 'view') { |
| | | this.draftRestore('equipmentVerificationPlan', 'form', this.form.planDetailsId, 'dialogVisible') |
| | | } |
| | | }) |
| | | } else { |
| | | this.form = { |
| | |
| | | planId: this.currentRow.planId, |
| | | planDetailsId: '', |
| | | } |
| | | this.draftRestore('equipmentVerificationPlan', 'form', this.form.planId, 'dialogVisible') |
| | | } |
| | | }, |
| | | // 提交表单 |
| | |
| | | addDeviceExaminePlanDetail(this.form).then(res => { |
| | | if (res.code == 200) { |
| | | this.$message.success('新增成功') |
| | | this.draftClear('equipmentVerificationPlan') |
| | | this.dialogVisible = false |
| | | this.getYearTableData() |
| | | } |
| | |
| | | updateDeviceExaminePlanDetail(this.form).then(res => { |
| | | if (res.code == 200) { |
| | | this.$message.success('新增成功') |
| | | this.draftClear('equipmentVerificationPlan') |
| | | this.dialogVisible = false |
| | | this.getYearTableData() |
| | | } |
| | |
| | | }) |
| | | }, |
| | | resetForm() { |
| | | this.draftStop('equipmentVerificationPlan') |
| | | this.$refs.modelForm.resetFields(); |
| | | this.dialogVisible = false |
| | | }, |
| | |
| | | this.downRow = row |
| | | this.downloadDialog = true |
| | | }, |
| | | // 导出结果拦截: 后端返回错误 JSON 时提示错误, 不存成坏文件 |
| | | saveDocx(res, filename) { |
| | | const reader = new FileReader(); |
| | | reader.readAsText(res, 'utf-8'); |
| | | reader.onload = () => { |
| | | const text = (reader.result || '').trim(); |
| | | if (text.startsWith('{') || text.startsWith('[')) { |
| | | let msg = '导出失败'; |
| | | try { msg = JSON.parse(text).msg || msg; } catch (e) {} |
| | | this.$message.error(msg); |
| | | } else { |
| | | this.$download.saveAs(new Blob([res], { type: 'application/msword' }), filename); |
| | | } |
| | | }; |
| | | reader.onerror = () => { |
| | | this.$download.saveAs(new Blob([res], { type: 'application/msword' }), filename); |
| | | }; |
| | | }, |
| | | // 核查记录导出 |
| | | controlDown() { |
| | | this.outLoading = true |
| | | exportReviewExamineRecordDetail({ planDetailsId: this.downRow.planDetailsId }).then(res => { |
| | | this.outLoading = false |
| | | const blob = new Blob([res], { type: 'application/octet-stream' }); |
| | | this.$download.saveAs(blob, '仪器设备期间核查记录表.doc') |
| | | this.saveDocx(res, '仪器设备期间核查记录表.doc') |
| | | }).catch(() => { |
| | | this.outLoading = false |
| | | }) |
| | | }, |
| | | // 核查对比导出 |
| | |
| | | this.outLoading = true |
| | | exportReviewExamineRecordContrast({ planDetailsId: this.downRow.planDetailsId }).then(res => { |
| | | this.outLoading = false |
| | | const blob = new Blob([res], { type: 'application/octet-stream' }); |
| | | this.$download.saveAs(blob, '仪器设备期间核查比对记录表.doc') |
| | | this.saveDocx(res, '仪器设备期间核查比对记录表.doc') |
| | | }).catch(() => { |
| | | this.outLoading = false |
| | | }) |
| | | }, |
| | | // 导入流程 |