From b34c4bfb96b9517ca489982e94abf66e3d7c4b66 Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期一, 17 三月 2025 11:14:32 +0800
Subject: [PATCH] 检验任务代码迁移
---
src/views/CNAS/resourceDemand/device/component/calibration.vue | 156 ++++++++++++++++++++++++++++++++-------------------
1 files changed, 97 insertions(+), 59 deletions(-)
diff --git a/src/views/CNAS/resourceDemand/device/component/calibration.vue b/src/views/CNAS/resourceDemand/device/component/calibration.vue
index a64e14a..5f4fd0e 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"
>
@@ -233,23 +233,6 @@
</el-date-picker>
</el-form-item>
</el-col>
- <!-- <el-col :span="17">
- <el-form-item label="闄勪欢锛�" prop="fileName">
- <el-input v-model="calibrationRecord.fileName" :style="`width: ${operationType === 'add' ? '85%' : '100%'};}`" disabled
- size="small">
- <el-button v-if="operationType === 'add'" slot="append" icon="el-icon-delete-solid"
- @click="deleteFile"></el-button>
- </el-input>
- <el-upload v-if="operationType === 'add'" ref="upload" :action="action" :before-upload="beforeUpload" :headers="headers"
- :limit="1" :on-error="onError" :on-success="handleSuccessUp"
- :show-file-list="false"
- style="float: right;">
- <el-button :loading="upLoading" size="small" style="position: relative; top: -4px;"
- type="primary">闄勪欢涓婁紶
- </el-button>
- </el-upload>
- </el-form-item>
- </el-col> -->
<el-col :span="24">
<el-form-item label="澶囨敞:">
<el-input v-model="calibrationRecord.remark" :disabled="operationType === 'view'" :rows="3" size="small" style="width: 96%"
@@ -299,20 +282,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>
@@ -333,7 +302,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 +322,12 @@
calibrateParams: [],
calibrateParamsLoading: false,
addCalibrateLoading: false,
+ previewFile: '',
+ lookDialogVisible: false,
+ recordId: null,
+ uploadData: {},
+ fileData: [],
+ dialogVisibleFile: false,
calibrationRecord: {
unitOfMeasure: '', // 璁¢噺鍗曚綅
calibrationDate: null, // 鏍″噯鏃ユ湡
@@ -417,7 +392,7 @@
computed: {
...mapGetters(["nickName"]),
action() {
- return this.javaApi + '/personBasicInfo/saveCNASFile'
+ return this.javaApi + '/personBasicInfo/saveDeviceCalibrationFile'
}
},
mounted() {
@@ -425,6 +400,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)
@@ -463,7 +499,7 @@
this.dialogVisible1 = true
this.getXmsg()
},
- // 鏌ョ湅璇︽儏
+ // 鏌ョ湅缂栬緫璇︽儏
handleViewClick(type, row) {
showDeviceMetricsCopy({ id: row.id, type: 'calibrate' }).then(res => {
this.calibrateParams = res.data
@@ -490,9 +526,6 @@
});
})
},
- handleAttachmentClick(row) {
- this.$download.saveAs(row.systemFileName, row.systemFileName)
- },
//瀵煎嚭
handleDown() {
this.outLoading = true
@@ -504,27 +537,6 @@
const blob = new Blob([res], { type: 'application/octet-stream' });
this.$download.saveAs(blob, '璁惧鏍″噯.xlsx')
})
- },
- deleteFile() {
- this.$confirm('姝ゆ搷浣滃皢姘镐箙鍒犻櫎鏂囦欢, 鏄惁缁х画?', '鎻愮ず', {
- confirmButtonText: '纭畾',
- cancelButtonText: '鍙栨秷',
- type: 'warning'
- }).then(() => {
- deleteCNASFile({ fileName: this.calibrationRecord.systemFileName }).then(res => {
- this.calibrationRecord.fileName = ''
- this.$refs.upload.clearFiles()
- if (res.code == 200) {
- this.$message.success('鍒犻櫎鎴愬姛锛�')
- }
- })
- }).catch((err) => {
- console.log('err----', err)
- this.$message({
- type: 'info',
- message: '宸插彇娑堝垹闄�'
- });
- });
},
// 鏍″噯椤圭洰缁存姢
calibrationMaintenance() {
@@ -563,6 +575,7 @@
this.$message.info('宸插彇娑堝垹闄�');
})
},
+ // 鎻愪氦椤圭洰鏍″噯缁存姢
addCalibrate() {
this.$refs['form0'].validate((valid) => {
if (valid) {
@@ -580,6 +593,8 @@
}
this.calibrateParamsLoading = false
this.addCalibrateLoading = false
+ }).catch(() => {
+ this.addCalibrateLoading = false
})
} else {
this.addCalibrateLoading = false
@@ -587,6 +602,7 @@
}
})
},
+ // 鎻愪氦鏍″噯璁板綍
addRecord() {
this.$refs['calibrationRecord'].validate((valid) => {
if (valid) {
@@ -604,12 +620,18 @@
this.calibrationRecord.createUser = this.nickName
this.calibrationRecord.type = 'calibrate'
this.calibrationRecord.deviceMetricsCopyList = this.calibrateParams
+ this.calibrationRecord.deviceMetricsCopyList.forEach(m => {
+ delete m.creationTime
+ })
+ delete this.calibrationRecord.createTime
addOrUpdateDeviceMetricRecord(this.calibrationRecord).then(res => {
if (res.code == 200) {
this.$message.success('娣诲姞鎴愬姛')
this.dialogVisible1 = false
this.getTableList(this.clickNodeVal.value)
}
+ this.addRecordLoading = false
+ }).catch((err) => {
this.addRecordLoading = false
})
} catch (e) {
@@ -637,15 +659,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