| | |
| | | <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", |
| | |
| | | width: "80", |
| | | }, |
| | | { |
| | | prop: "alarmLimithUpeper", |
| | | prop: "alarmLimithUpper", |
| | | label: "上上限", |
| | | width: "80", |
| | | }, |
| | |
| | | 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 { |
| | |
| | | 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); // 添加文件到FormData中 |
| | | 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); |
| | | }); |
| | |
| | | <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"> |
| | |
| | | <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> |
| | |
| | | <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> |
| | |
| | | <add-edit |
| | | v-model:close="addEditVisible" |
| | | :info="selectInfo" @success="changeAcButton(acButton)"></add-edit> |
| | | </el-dialog> |
| | | <el-dialog title="文件上传"> |
| | | |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | .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> |