From aa995b8564c6864d5c9f43273c0b303af8f9bd4d Mon Sep 17 00:00:00 2001 From: whychdw <496960745@qq.com> Date: 星期六, 21 六月 2025 09:16:53 +0800 Subject: [PATCH] 标准参数内容丰富 --- src/views/dcPowerStatus/standardParams.vue | 181 +++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 164 insertions(+), 17 deletions(-) diff --git a/src/views/dcPowerStatus/standardParams.vue b/src/views/dcPowerStatus/standardParams.vue index 57325ba..aa6dfca 100644 --- a/src/views/dcPowerStatus/standardParams.vue +++ b/src/views/dcPowerStatus/standardParams.vue @@ -1,13 +1,16 @@ <script setup name="StandardParams"> import {ref, onMounted, computed} from "vue"; -import {ElLoading} from "element-plus"; import ycCard from "@/components/ycCard/index.vue"; import TabButton from "@/components/TabButton/index.vue"; import HdwButton from "@/components/HdwButton/index.vue"; import NoData from "@/components/noData.vue"; -import {getPwrStandParamApi} from "@/api/standardParams.js"; +import {getPwrStandParamApi, getStandFileApi, uploadStandFileApi} from "@/api/standardParams.js"; import addEdit from "./dialog/addEdit.vue"; +import useElement from "@/hooks/useElement.js"; +import downloadFile from "@/utils/downloadFile.js"; +import {ExportFile} from "@/utils/exportFile.js"; +const {$loading, $message} = useElement(); const headers = [ { prop: "standName", @@ -30,7 +33,7 @@ width: "80", }, { - prop: "alarmLimithUpeper", + prop: "alarmLimithUpper", label: "涓婁笂闄�", width: "80", }, @@ -57,15 +60,9 @@ searchData(); } -const searchText = ref(""); -const downloadText =ref(""); -const fileList = ref([]); - async function searchData() { - const loading = ElLoading.service({ - lock: true, - text: '鏁版嵁鍔犺浇涓�...', - background: 'rgba(0, 0, 0, 0.7)', + const loading = $loading({ + text: "鏁版嵁鍔犺浇涓�..." }); try { @@ -91,6 +88,97 @@ selectInfo.value = info; addEditVisible.value = true; } + +const searchText = ref(""); +const downloadText =ref(""); +const fileList = ref([]); +const selectFile = ref({ + fileName: "", + standFilePath: "", +}); + +async function searchFileList() { + if(!searchText.value) { + $message.warning("璇疯緭鍏ユ枃浠跺悕绉�"); + return; + } + + const loading = $loading({ + text: "鏁版嵁鍔犺浇涓�..." + }); + try { + const rs = await getStandFileApi(searchText.value, acButton.value); + loading.close(); + if(rs.code === 1 && rs.data) { + fileList.value = rs.data2; + }else { + fileList.value = []; + } + }catch (e) { + console.log(e); + loading.close(); + } +} + +function handleSelectFile(info) { + console.log(info); + selectFile.value = info; +} + +function handleDownloadFile() { + if(selectFile.value.standFilePath) { + downloadFile(selectFile.value.standFilePath, ""); + }else { + $message.warning("璇烽�夋嫨涓嬭浇鐨勬枃浠�"); + } + +} + +function handleUploadFile(options) { + console.log(selectInfo.value); + const formData = new FormData(); + formData.append('multipartFile', options.file); // 娣诲姞鏂囦欢鍒癋ormData涓� + formData.append('num', selectInfo.value.num); // 娣诲姞棰濆鍙傛暟 + const loading = $loading(); + uploadStandFileApi(formData).then(res=>{ + loading.close(); + if(res.code === 1 && res.data) { + $message.success("涓婁紶鎴愬姛锛侊紒锛�"); + }else { + $message.warning("涓婁紶澶辫触锛侊紒锛�"); + } + searchData(); + }).catch(error=>{ + loading.close(); + console.log(error); + $message.warning("涓婁紶澶辫触锛岃鑱旂郴绠$悊鍛橈紒锛侊紒"); + }); +} + + +function changeSelectRow(info) { + selectInfo.value = info; +} + +/** + * 瀵煎嚭琛ㄦ牸鏁版嵁 + */ +function exportExcel() { + if(!listRef.value.length) { + $message.warning("鏃犳暟鎹紝涓嶇敤瀵煎嚭"); + return; + } + let _headers = headers.map(v => { + let prop = v.prop; + let label = v.label; + return { + prop, + label + }; + }); + ExportFile(_headers, listRef.value, "鏍囧噯鍙傛暟绠$悊"); +} + onMounted(()=>{ changeAcButton(acButton.value); }); @@ -107,7 +195,7 @@ <tab-button style="margin-left: 24px;" :active="acButton === 2" @click="changeAcButton(2)">閫氫俊鐢垫簮</tab-button> </div> <div class="tools-right"> - <hdw-button>瀵煎嚭</hdw-button> + <hdw-button @click="exportExcel">瀵煎嚭</hdw-button> </div> </div> <div class="page-content-table-wrapper"> @@ -121,7 +209,18 @@ <el-table-column label="鎿嶄綔" fixed="right" width="180" align="center"> <template #default="scope"> <el-button type="primary" size="small" @click="setParams(scope.row)">鍙傛暟璁惧畾</el-button> - <el-button type="success" size="small">涓婁紶</el-button> + <div class="upload-file"> + <el-upload + ref="uploadRef" + class="upload-demo" + action="" + :show-file-list="false" + :http-request="handleUploadFile"> + <template #trigger> + <el-button type="success" size="small" @click="changeSelectRow(scope.row)">涓婁紶</el-button> + </template> + </el-upload> + </div> </template> </el-table-column> </el-table> @@ -132,17 +231,40 @@ <div class="file-tools"> <div class="file-tools-item"> <input class="file-tools-input" type="text" v-model="searchText" /> - <hdw-button icon-class="search-data">鏌� 璇�</hdw-button> + <hdw-button icon-class="search-data" @click="searchFileList">鏌� 璇�</hdw-button> </div> <div class="file-tools-item bottom"> - <input disabled class="file-tools-input" type="text" v-model="downloadText" /> - <hdw-button type="warning" icon-class="download">涓� 杞�</hdw-button> + <input v-if="!selectFile.fileName" disabled class="file-tools-input" type="text" v-model="selectFile.fileName" /> + <el-tooltip + v-else + class="box-item" + effect="dark" + :content="selectFile.fileName" + placement="top"> + <input disabled class="file-tools-input" type="text" v-model="selectFile.fileName" /> + </el-tooltip> + <hdw-button type="warning" icon-class="download" @click="handleDownloadFile">涓� 杞�</hdw-button> </div> </div> <div class="file-list-content"> <div class="pos-rel"> <div class="pos-abs"> - <el-scrollbar v-if="fileList.length !== 0"></el-scrollbar> + <el-scrollbar v-if="fileList.length !== 0"> + <div class="file-list"> + <div + class="file-item-wrapper" + v-for="(item, key) in fileList" :key="'key'+key" + @click="handleSelectFile(item)"> + <el-tooltip + class="box-item" + effect="dark" + :content="item.fileName" + placement="left-start"> + <div class="file-item">{{ item.fileName }}</div> + </el-tooltip> + </div> + </div> + </el-scrollbar> <no-data v-else text="鏆傛棤瑙勮寖鏂囦欢"></no-data> </div> </div> @@ -165,6 +287,9 @@ <add-edit v-model:close="addEditVisible" :info="selectInfo" @success="changeAcButton(acButton)"></add-edit> + </el-dialog> + <el-dialog title="鏂囦欢涓婁紶"> + </el-dialog> </div> </template> @@ -267,4 +392,26 @@ } } } + +.file-list { + padding: 8px 0; + user-select: none; + .file-item-wrapper { + padding: 8px; + background-color: #1B4C79; + cursor: pointer; + margin-top: 4px; + &:hover { + font-weight: 700; + } + .file-item { + font-size: 14px; + white-space: nowrap; + } + } +} +.upload-file { + display: inline-block; + margin-left: 8px; +} </style> -- Gitblit v1.9.1