From d68c5a3ef7025d67a2d92ea3aa84f73ec77ddd5f Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期一, 03 三月 2025 16:36:50 +0800
Subject: [PATCH] 文件下载失败统一拦截
---
src/views/CNAS/resourceDemand/device/component/calibration.vue | 58 ++++++++++++----------------------------------------------
1 files changed, 12 insertions(+), 46 deletions(-)
diff --git a/src/views/CNAS/resourceDemand/device/component/calibration.vue b/src/views/CNAS/resourceDemand/device/component/calibration.vue
index 655c2b4..df025bd 100644
--- a/src/views/CNAS/resourceDemand/device/component/calibration.vue
+++ b/src/views/CNAS/resourceDemand/device/component/calibration.vue
@@ -4,7 +4,7 @@
<div class="btnS">
<el-button size="small" type="primary" @click="calibrationMaintenance()">鏍″噯椤圭洰缁存姢</el-button>
<el-button size="small" type="primary" @click="add('add')">娣诲姞鏍″噯璁板綍</el-button>
- <el-button size="small" type="primary" @click="handleDown">瀵煎嚭Excel</el-button>
+ <!-- <el-button size="small" type="primary" @click="handleDown">瀵煎嚭Excel</el-button> -->
</div>
<div class="tables" style="margin-top: 10px;">
<el-table :data="tableData" height="calc(100vh - 20em)">
@@ -240,20 +240,6 @@
</template>
</el-table-column>
</el-table>
- <!-- 鎿嶄綔鏃ュ織 -->
- <!-- <h4>-->
- <!-- <div style="display: flex;-->
- <!-- align-items: center;">-->
- <!-- <span class="line"></span><span>鏈褰曠姸鎬佸拰鎿嶄綔鏃ュ織</span>-->
- <!-- </div>-->
- <!-- </h4>-->
- <!-- <el-table :data="tableDataOperate" style="width: 100%">-->
- <!-- <el-table-column type="index" label="搴忓彿" width="100"></el-table-column>-->
- <!-- <el-table-column prop="operator" label="鎿嶄綔浜�" width="120"></el-table-column>-->
- <!-- <el-table-column prop="operationTime" label="鎿嶄綔鏃堕棿" width="180"></el-table-column>-->
- <!-- <el-table-column prop="operationType" label="鎿嶄綔绫诲瀷" width="120"></el-table-column>-->
- <!-- <el-table-column prop="operationContent" label="鎿嶄綔鍐呭"></el-table-column>-->
- <!-- </el-table>-->
</div>
<span slot="footer" class="dialog-footer">
<el-button v-if="operationType === 'add'" @click="dialogVisible1 = false">鍙� 娑�</el-button>
@@ -265,10 +251,8 @@
</template>
<script>
-import fileDownload from "@/utils/file";
import {
deviceMetricRecordPage,
- deviceLog,
showDeviceMetricsCopy,
deleteDeviceMetricRecord,
deviceMetricRecordExport,
@@ -276,7 +260,9 @@
selectDeviceMetric,
deleteDeviceMetrics,
addOrUpdateDeviceMetricRecord,
+ saveOrUpdateDeviceMetric
} from '@/api/cnas/resourceDemand/device.js'
+import { mapGetters } from "vuex";
export default {
props: {
clickNodeVal: {
@@ -343,7 +329,6 @@
],
},
addRecordLoading: false,
- tableDataOperate: [], // 鏈褰曠姸鎬佸拰鎿嶄綔鏃ュ織
upLoading: false,
operationType: '',
search: {
@@ -355,13 +340,13 @@
},
// 鐢ㄤ簬涓婁紶鏂囦欢鐨勪俊鎭�
computed: {
+ ...mapGetters(["nickName"]),
action() {
return this.javaApi + '/personBasicInfo/saveCNASFile'
}
},
mounted() {
//鑾峰彇鎿嶄綔璁板綍淇℃伅
- this.getOperateMsg();
this.getTableList(this.clickNodeVal.value) // 鑾峰彇璁惧鏍″噯鍒楄〃鏁版嵁
},
methods: {
@@ -397,11 +382,6 @@
this.search.total = res.data.total
})
},
- getOperateMsg() {
- deviceLog(this.clickNodeVal.value).then(res => {
- this.tableDataOperate = res.data
- })
- },
// 娣诲姞鏍告煡璁板綍
add(type) {
this.operationType = type
@@ -410,7 +390,7 @@
},
// 鏌ョ湅璇︽儏
handleViewClick(type, row) {
- showDeviceMetricsCopy({ id: row.id, type: calibrate }).then(res => {
+ showDeviceMetricsCopy({ id: row.id, type: 'calibrate' }).then(res => {
this.calibrateParams = res.data
})
this.calibrationRecord = { ...row }
@@ -439,13 +419,11 @@
let state = /\.(jpg|jpeg|png|gif)$/i.test(row.systemFileName)
if (state) {
let url = this.javaApi + '/img/' + row.systemFileName;
- fileDownload.downloadIamge(url, row.systemFileName)
+ this.$download.saveAs(url, row.systemFileName)
+ this.$message.success('涓嬭浇鎴愬姛')
} else {
const url = this.javaApi + '/word/' + row.systemFileName
- const link = document.createElement('a');
- link.href = url;
- link.download = row.systemFileName;
- link.click();
+ this.$download.saveAs(url, row.systemFileName)
this.$message.success('涓嬭浇鎴愬姛')
}
},
@@ -454,7 +432,7 @@
this.outLoading = true
deviceMetricRecordExport({
deviceId: this.clickNodeVal.value,
- type: calibrate
+ type: 'calibrate'
}).then(res => {
this.outLoading = false
const blob = new Blob([res], { type: 'application/octet-stream' });
@@ -527,10 +505,9 @@
this.calibrateParamsLoading = true
this.addCalibrateLoading = true
this.form0.deviceId = this.clickNodeVal.value;
- const user = JSON.parse(localStorage.getItem('user'))
- this.form0.createdBy = user.name;
+ this.form0.createdBy = this.nickName;
this.form0.type = 'calibrate'
- deleteDeviceMetrics(this.form0).then(res => {
+ saveOrUpdateDeviceMetric(this.form0).then(res => {
if (res.code == 200) {
this.$message.success('淇濆瓨鎴愬姛')
this.$refs['form0'].resetFields()
@@ -559,8 +536,7 @@
}
this.addRecordLoading = true
this.calibrationRecord.deviceId = this.clickNodeVal.value;
- let user = JSON.parse(localStorage.getItem('user'))
- this.calibrationRecord.createUser = user.name
+ this.calibrationRecord.createUser = this.nickName
this.calibrationRecord.type = 'calibrate'
this.calibrationRecord.deviceMetricsCopyList = this.calibrateParams
addOrUpdateDeviceMetricRecord(this.calibrationRecord).then(res => {
@@ -636,16 +612,6 @@
}
}
}
-}
-
-function downloadImage(url) {
- const link = document.createElement('a');
- link.href = url;
- link.target = "_blank"
- link.download = 'attachment.jpg'; // 鏂囦欢鍚�
- document.body.appendChild(link);
- link.click();
- document.body.removeChild(link);
}
</script>
--
Gitblit v1.9.3