设备详情文件上传功能添加

This commit is contained in:
15133876896-BGG25 2023-06-29 17:36:32 +08:00
parent db13670743
commit b092545694
2 changed files with 290 additions and 3 deletions

View File

@ -9,6 +9,7 @@
<div class="info-header">
<h2>{{ prop.title }}</h2>
<span>设备详情 </span>
<el-button text circle type="" icon="CloseBold" size="small" class="closs-button" @click="handleClose"></el-button>
</div>
<div class="info-body">
<el-tabs v-model="activeinfo" class="demo-tabs" @tab-click="handleClick">
@ -31,21 +32,56 @@
:page="pageval"
></Wtable>
</el-tab-pane>
<el-tab-pane label="最新遥测数据" name="newDAata">Role</el-tab-pane>
<el-tab-pane label="pdf" name="pdf">Task</el-tab-pane>
<el-tab-pane label="最新遥测数据" name="newDAata">
<el-row style=" margin-bottom: 10px;">
<el-col :span="20"></el-col>
<el-col :span="2"><el-button :icon="Refresh" circle @click="researchtelemetrytable"/></el-col>
<el-col :span="2"></el-col>
</el-row>
<Wtable
:config="telemetrytableConfig"
:tableData="telemetrytableData"
@gettabellist="gettelemetryTableList"
:page="telemetrypageval"
></Wtable>
</el-tab-pane>
<el-tab-pane label="pdf" name="pdf">
<el-row style=" margin-bottom: 10px;">
<el-col :span="2"></el-col>
<el-col :span="18">
<el-button
type="info"
plain
icon="Upload"
@click="handleImportPDF"
>文件上传</el-button></el-col>
<el-col :span="2"><el-button :icon="Refresh" circle @click="researchPDFtable"/></el-col>
<el-col :span="2"></el-col>
</el-row>
<Wtable
:config="PDFConfig"
:tableData="PDFtableData"
@gettabellist="getPDFTableList"
:page="PDFpageval"
></Wtable>
</el-tab-pane>
</el-tabs>
</div>
<upLoad :uploadConfig="uploadConfig"></upLoad>
</el-drawer>
</template>
<script setup lang="ts">
import { ref } from "vue";
import { getCurrentInstance, ref } from "vue";
import Wform from "./Wform.vue";
import Wdescriptions from "./Wdescriptions.vue";
import upLoad from "./upLoad.vue";
import Wtable from "./Wtable.vue";
import type { TabsPaneContext } from "element-plus";
const { proxy } = getCurrentInstance() as any;
import {
Refresh,
CloseBold
} from '@element-plus/icons-vue'
const activeinfo = ref("info");
const prop = defineProps({
@ -143,6 +179,46 @@ const descriptionsData = ref({
remark: "说明",
});
//
const telemetrytableConfig = ref({
height: 430,
column: [
{
prop: "nowTime",
label: "最后更新时间",
width: "",
},
{
prop: "keyName",
label: "键名",
width: "",
},
{
prop: "keyValue",
label: "值",
width: "",
},
],
});
const telemetrytableData = ref([
{
nowTime: "1",
keyName: "1",
keyValue: "1",
},
{
nowTime: "2",
keyName: "2",
keyValue: "2",
},
{
nowTime: "3",
keyName: "3",
keyValue: "3",
},
]);
const telemetrypageval=ref({page:1,pageSize:5,total:1})
//
const tableConfig = ref({
height: 430,
@ -183,20 +259,114 @@ const tableData = ref([
]);
const pageval=ref({page:1,pageSize:5,total:1})
//pdf
const handleImportPDF=()=>{
uploadConfig.value.openDialog=true
console.log(uploadConfig.value);
}
//PDF
const PDFConfig = ref({
height: 430,
column: [
{
prop: "nowTime",
label: "最新时间",
width: "",
},
{
prop: "Name",
label: "名称",
width: "",
},
{
prop: "address",
label: "地址",
width: "",
},
{
prop: "more",
label: "更多",
width: "",
},
],
});
const PDFtableData = ref([
{
nowTime: "1",
Name: "1",
address: "1",
more: "1",
},
{
nowTime: "2",
Name: "2",
address: "2",
more: "1",
},
{
nowTime: "3",
Name: "3",
address: "3",
more: "1",
},
]);
const PDFpageval=ref({page:1,pageSize:5,total:1})
//
const handleClose = () => {
//baseFormRef.value.reset()
emit("closeDialog");
};
//tab
const handleClick = (tab: TabsPaneContext, event: Event) => {
// console.log(tab, event)
};
//
const researchtable=()=>{
pageval.value.page=1
pageval.value.pageSize=5
getTableList()
}
//
const getTableList = () => {
console.log(pageval.value);
};
//
const researchtelemetrytable=()=>{
telemetrypageval.value.page=1
telemetrypageval.value.pageSize=5
getTableList()
}
//
const gettelemetryTableList = () => {
console.log(telemetrypageval.value);
};
//PDF
const researchPDFtable=()=>{
PDFpageval.value.page=1
PDFpageval.value.pageSize=5
getTableList()
}
//DFT
const getPDFTableList = () => {
console.log(PDFpageval.value);
};
const uploadConfig=ref({
//
accept:[''],
//
title:"",
//
width:'400px',
//
openDialog:false,
//
limit:1,
multiple:false
})
//
const emit = defineEmits(["closeDialog"]);
</script>
@ -213,11 +383,18 @@ const emit = defineEmits(["closeDialog"]);
flex-direction: column;
align-items: flex-start;
justify-content: center;
position: relative;
& h2 {
margin: 0;
font-size: 30px;
font-weight: 600;
}
& .closs-button{
position: absolute;
top: 50%;
right: 10px;
margin-top: -10px
}
}
:deep(.el-tabs__nav) {
margin-left: 20px;

View File

@ -0,0 +1,110 @@
<!--
* @FilePath: \code\Goats-Cloud-ui\src\views\big\device\components\upLoad.vue
* @Author: 王路平
* @文件版本: V1.0.0
* @Date: 2023-06-29 08:42:02
* @Description:
*
* 版权信息 : 2023 by ${再登软件}, All Rights Reserved.
-->
<template>
<el-dialog :title="config.title" v-model="config.openDialog" :width="config.width" append-to-body>
<el-upload
ref="uploadRef"
:limit="config.limit"
:accept="config.accept.join(',')"
:headers="upload.headers"
:action="upload.url"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-error="handleUploadError"
:on-success="handleFileSuccess"
:auto-upload="false"
drag
>
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em>,文件大小不得超过5MB</div>
</el-upload>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submitFileForm"> </el-button>
<el-button @click="config.openDialog = false"> </el-button>
</div>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { computed, getCurrentInstance, reactive, ref} from "vue"
import type { UploadInstance } from 'element-plus'
import { getToken } from "@/utils/auth";
const { proxy } = getCurrentInstance() as any;
const prop = defineProps({
uploadConfig:{
type:Object,
default:{
//
accept:[''],
//
title:"",
//
width:'400px',
//
openDialog:false,
//
limit:1,
multiple:false
}
}
});
//
const config = computed({
get: () => prop.uploadConfig,
set: val => {
emit('update:uploadConfig', val)
},
})
const emit = defineEmits(['update:uploadConfig','uploadFileFun'])
let uploadRef = ref<UploadInstance | null>(null)
const upload = reactive({
//
isUploading: false,
//
headers:{ Authorization: "Bearer " + getToken() },
//
url: import.meta.env.VITE_APP_BASE_API + "/file/upload"
});
/**文件上传中处理 */
const handleFileUploadProgress = (event, file, fileList) => {
upload.isUploading = true;
};
const handleUploadError=()=>{
proxy.$modal.msgError("上传文件失败");
}
/** 文件上传成功处理 */
const handleFileSuccess = (response, file, fileList) => {
console.log("我成功了");
config.value.openDialog = false;
upload.isUploading = false;
proxy.$refs["uploadRef"].handleRemove(file);
proxy.$modal.msgSuccess("上传文件成功");
};
// //
// const handleExceed=(files, fileList)=>{
// }
// //
// const handleFileUpload=(file)=>{
// emit("uploadFileFun",file);
// }
//
const submitFileForm=()=>{
uploadRef.value?uploadRef.value.submit():''
}
</script>
<style lang="scss" scoped>
</style>