|
@@ -0,0 +1,108 @@
|
|
|
+<template>
|
|
|
+ <div class="wmupload-page">
|
|
|
+ <div style="margin:10px 0px;">
|
|
|
+ <p style="margin:10px 0px;">计量数据文件<span style="font-size:12px;color:#999;">(大小不超过5M)</span></p>
|
|
|
+ <el-upload
|
|
|
+ v-model:file-list="fileList"
|
|
|
+ :action="api.getBasePath()+'/analysis/produce/importMeasure'"
|
|
|
+ :headers="{token:app.getToken()}"
|
|
|
+ :data="{config:JSON.stringify(api.getExcelImportConfig())}"
|
|
|
+ list-type="text"
|
|
|
+ :limit="1"
|
|
|
+ :on-preview="handleUploadPreview"
|
|
|
+ :on-remove="handleUploadRemove"
|
|
|
+ :before-upload="beforeAvatarUpload"
|
|
|
+ :on-exceed="handleUploadExceed"
|
|
|
+ :on-success="handleUploadSuccess"
|
|
|
+ :on-error="handleUploadError"
|
|
|
+
|
|
|
+ >
|
|
|
+ <el-icon><Plus /></el-icon>
|
|
|
+
|
|
|
+ </el-upload>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="upload-result-show">
|
|
|
+ <p v-for="(msg,index) in importedMsg" :key="index">{{msg}}</p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+ import {reactive,ref,onMounted,toRaw} from 'vue'
|
|
|
+ import app from '@/utils/app.js'
|
|
|
+ import api from '../../api/wellMeasure.js'
|
|
|
+ import {ElMessageBox,ElMessage} from 'element-plus'
|
|
|
+
|
|
|
+ const emit=defineEmits(['acceptMsg'])
|
|
|
+
|
|
|
+ const importedMsg=ref(null)
|
|
|
+
|
|
|
+ //上传组件配置
|
|
|
+
|
|
|
+ const fileList = ref([])
|
|
|
+
|
|
|
+ const handleUploadPreview=(uploadFile)=>{
|
|
|
+ //previewImageUrl.value = uploadFile.url
|
|
|
+ //previewDialogShow.value = true
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleUploadRemove=(uploadFile, uploadFiles)=>{
|
|
|
+ //console.log(uploadFile, uploadFiles)
|
|
|
+ importedMsg.value=null
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleUploadExceed=(files,uploadFiles)=>{
|
|
|
+ ElMessage.error('每次只能上传1个文件');
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleUploadSuccess=(resp,uploadFile,uploadFiles)=>{
|
|
|
+ if(resp.code!=0){
|
|
|
+ //ElMessage.error(resp.msg);
|
|
|
+ importedMsg.value=[resp.msg]
|
|
|
+ }
|
|
|
+ else{
|
|
|
+
|
|
|
+ let html=[`导入成功:${resp.data.successCount}条`]
|
|
|
+ if(resp.data.validateError&&resp.data.validateError.length>0){
|
|
|
+ html.push(`格式不符合要求:${resp.data.validateError}`)
|
|
|
+ }
|
|
|
+ if(resp.data.checkIgnor&&resp.data.checkIgnor.length>0){
|
|
|
+ html.push(`系统内无对应井名:${resp.data.checkIgnor}`)
|
|
|
+ }
|
|
|
+
|
|
|
+ importedMsg.value=html
|
|
|
+
|
|
|
+ if(resp.data.successCount){
|
|
|
+ emit("acceptMsg","tabQuery")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleUploadError=(error,uploadFile,uploadFiles)=>{
|
|
|
+ ElMessage.error('上传文件出错');
|
|
|
+ }
|
|
|
+
|
|
|
+ const beforeAvatarUpload=(rawFile)=>{
|
|
|
+ if (rawFile.name.indexOf('xls') < 0 && rawFile.name.indexOf('xlsx') < 0) {
|
|
|
+ ElMessage.error('请上传Excel文件!')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ else if(rawFile.size / 1024 /1024 > 5){
|
|
|
+ ElMessage.error('单张图片不能超过5M!')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ return true
|
|
|
+
|
|
|
+ }
|
|
|
+ //上传组件配置结束
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+ .upload-result-show{
|
|
|
+ height:100px;
|
|
|
+ overflow-y: auto;
|
|
|
+ }
|
|
|
+</style>
|