From b373b324b677d377abbcbefd7434e4af4d8f64cc Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 10 三月 2025 17:52:09 +0800
Subject: [PATCH] 设备搬迁
---
src/views/CNAS/resourceDemand/device/component/calibration.vue | 90 ++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 85 insertions(+), 5 deletions(-)
diff --git a/src/views/CNAS/resourceDemand/device/component/calibration.vue b/src/views/CNAS/resourceDemand/device/component/calibration.vue
index a64e14a..c522343 100644
--- a/src/views/CNAS/resourceDemand/device/component/calibration.vue
+++ b/src/views/CNAS/resourceDemand/device/component/calibration.vue
@@ -61,7 +61,7 @@
style="margin-top: 5px;margin-bottom: 10px;"
:action="action"
:data="uploadData"
- :headers="headers"
+ :headers="uploadHeader"
:before-upload="beforeUpload"
:on-success="onSuccess"
>
@@ -333,7 +333,7 @@
selectDeviceMetric,
deleteDeviceMetrics,
addOrUpdateDeviceMetricRecord,
- saveOrUpdateDeviceMetric
+ saveOrUpdateDeviceMetric, downLoadDeviceCalibrationFile, getDeviceCalibrationFile, delDeviceCalibrationFile
} from '@/api/cnas/resourceDemand/device.js'
import { mapGetters } from "vuex";
import filePreview from "@/components/Preview/filePreview.vue";
@@ -353,6 +353,12 @@
calibrateParams: [],
calibrateParamsLoading: false,
addCalibrateLoading: false,
+ previewFile: '',
+ lookDialogVisible: false,
+ recordId: null,
+ uploadData: {},
+ fileData: [],
+ dialogVisibleFile: false,
calibrationRecord: {
unitOfMeasure: '', // 璁¢噺鍗曚綅
calibrationDate: null, // 鏍″噯鏃ユ湡
@@ -425,6 +431,67 @@
this.getTableList(this.clickNodeVal.value) // 鑾峰彇璁惧鏍″噯鍒楄〃鏁版嵁
},
methods: {
+ preview(row) {
+ let list = row.fileUrl.split('.')
+ let suffix = list[list.length - 1]
+ if(suffix.toLowerCase().includes("pdf")) {
+ let link = document.createElement('a')
+ let url = this.javaApi + 'word' + row.fileUrl
+ console.log(url);
+ link.href = url
+ link.target= '_blank'
+ document.body.appendChild(link)
+ link.click()
+ document.body.removeChild(link)
+ }else{
+ let url = ''
+ if(suffix.toLowerCase().includes('docx')) {
+ url = this.javaApi + 'word' + row.fileUrl
+ }else if(suffix.toLowerCase().includes('xls')) {
+ url = this.javaApi + 'excel' + row.fileUrl
+ }else{
+ url = this.javaApi + 'img' + row.fileUrl
+ }
+ this.previewFile = url
+ this.$nextTick(() => {
+ this.lookDialogVisible = true
+ })
+ }
+ },
+ download(row) {
+ downLoadDeviceCalibrationFile({id: row.id}).then(res => {
+ const blob = new Blob([res],{type: row.mime})
+ this.$download.saveAs(blob, row.fileName)
+ })
+ },
+ delFile(row) {
+ this.$confirm('姝ゆ搷浣滃皢姘镐箙鍒犻櫎璇ユ枃浠�, 鏄惁缁х画?', '鎻愮ず', {
+ confirmButtonText: '纭畾',
+ cancelButtonText: '鍙栨秷',
+ type: 'warning'
+ }).then(() => {
+ delDeviceCalibrationFile({id: row.id}).then(res => {
+ this.$message({
+ type: 'success',
+ message: '鍒犻櫎鎴愬姛!'
+ });
+ this.getFileData(this.recordId);
+ })
+ })
+ },
+ handleAttachmentClick(row) {
+ // 妯℃嫙涓嬭浇闄勪欢
+ // const imageUrl = this.javaApi + '/img/' + row.systemFileName; // 鍥剧墖 URL
+ // file.downloadIamge(imageUrl,row.fileName)
+ this.recordId = row.id
+ this.dialogVisibleFile = true
+ this.getFileData(row.id)
+ },
+ getFileData(id) {
+ getDeviceCalibrationFile({id: id}).then(res =>{
+ this.fileData = res.data
+ })
+ },
//鐘舵�佸垽瀹�
checkRadio() {
let resultList = this.calibrateParams.map(ele => ele.result)
@@ -489,9 +556,6 @@
message: '宸插彇娑堝垹闄�'
});
})
- },
- handleAttachmentClick(row) {
- this.$download.saveAs(row.systemFileName, row.systemFileName)
},
//瀵煎嚭
handleDown() {
@@ -637,15 +701,31 @@
}
},
beforeUpload(file) {
+ let list = file.name.split('.')
+ let suffix = list[list.length - 1]
+
+ console.log(suffix);
if (file.size > 1024 * 1024 * 10) {
this.$message.error('涓婁紶鏂囦欢涓嶈秴杩�10M');
this.$refs.upload.clearFiles()
return false;
} else {
this.upLoading = true;
+ this.$set(this.uploadData,'id',this.recordId)
+ this.$set(this.uploadData,'suffix',suffix)
return true;
}
},
+ onSuccess(response,file,fileList) {
+ if(response.code == 200) {
+ this.$message.success("涓婁紶鎴愬姛")
+ this.upLoading = false
+ this.$refs.upload.clearFiles()
+ this.getFileData(this.recordId)
+ } else {
+ this.$message.error(response.msg)
+ }
+ },
onError(err, file, fileList) {
this.$message.error('涓婁紶澶辫触')
this.$refs.upload.clearFiles()
--
Gitblit v1.9.3