设备列表上传

This commit is contained in:
白菜
2025-11-28 15:11:34 +08:00
parent 65f0e92296
commit 78eb81549b
2 changed files with 12 additions and 9 deletions

View File

@ -1,7 +1,7 @@
<template>
<el-dialog :visible.sync="show" class="ems-dialog" title="点位上传" width="400px" append-to-body :close-on-click-modal="false" :close-on-press-escape="false">
<!-- <file-upload :fileType='["xls", "xlsx"]' value="String" :limit="1" :drag="false" @input="updateFile"/>-->
<el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
<el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url" :data="upload.data" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div class="el-upload__tip text-center" slot="tip">
@ -27,22 +27,25 @@ export default {
show:false,
// 用户导入参数
upload: {
data:{},
// 是否禁用上传
isUploading: false,
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API + "/ems/pointMatch/importData"
url: process.env.VUE_APP_BASE_API + "/ems/pointMatch/importDataByDevice"
},
}
},
methods:{
showDialog(){
showDialog({siteId,deviceId,deviceCategory}){
this.upload.data={siteId,deviceId,deviceCategory}
this.show = true;
},
//关闭弹窗 重置数据
handleClosed(){
this.$refs.upload.clearFiles()//写在before-closed无效
this.upload.data={}
this.show=false
},
// updateFile(data){
@ -51,12 +54,12 @@ export default {
// saveDialog(){
// this.show=true
// },
// 文件上传中处理
handleFileUploadProgress(event, file, fileList) {
// 文件上传中处理 返回参数event, file, fileList
handleFileUploadProgress() {
this.upload.isUploading = true
},
// 文件上传成功处理
handleFileSuccess(response, file, fileList) {
// 文件上传成功处理 返回参数response, file, fileList
handleFileSuccess(response) {
console.log('上传文件结果',response)
this.upload.isUploading = false
if(response.code === 500 && !response.msg) response.msg = '上传失败'

View File

@ -184,8 +184,8 @@ export default {
}, `点位清单_${deviceName}_${new Date().getTime()}.xlsx`)
},
// 上传点位清单
uploadPointDetail(){
this.$refs.pointUpload.showDialog()
uploadPointDetail(row){
this.$refs.pointUpload.showDialog(row)
},
clearEditDeviceData(){
this.mode = '';