From d0a1fff347476b7deb83b4656acb08a8af67a351 Mon Sep 17 00:00:00 2001 From: gaoluyang <2820782392@qq.com> Date: 星期二, 29 七月 2025 16:03:24 +0800 Subject: [PATCH] 1.能源管理-开发、联调 --- src/api/energyManagement/index.js | 50 ++++++ src/views/energyManagement/energyPower/index.vue | 291 ++++++++++++++++++++++++++++++++++++ src/views/energyManagement/energyTrends/index.vue | 116 ++++++++++++++ 3 files changed, 457 insertions(+), 0 deletions(-) diff --git a/src/api/energyManagement/index.js b/src/api/energyManagement/index.js new file mode 100644 index 0000000..4c061e6 --- /dev/null +++ b/src/api/energyManagement/index.js @@ -0,0 +1,50 @@ +// 鑳芥簮绠$悊 +import request from "@/utils/request"; + +// 璁惧鑳借��-鍒嗛〉鏌ヨ +export function equipmentEnergyListPage(query) { + return request({ + url: '/equipmentEnergyConsumption/listPage', + method: 'get', + params: query, + }) +} +// -鑳芥簮瓒嬪娍-鍒嗛〉鏌ヨ +export function listPageByTrend(query) { + return request({ + url: '/equipmentEnergyConsumption/listPageByTrend', + method: 'get', + params: query, + }) +} +// 璁惧鑳借��-鍒犻櫎 +export function equipmentEnergyDelete(query) { + return request({ + url: '/equipmentEnergyConsumption/delete', + method: 'delete', + data: query, + }) +} +// 璁惧鑳借��-鏂板 +export function equipmentEnergyAdd(query) { + return request({ + url: '/equipmentEnergyConsumption/add', + method: 'post', + data: query, + }) +} +// 璁惧鑳借��-淇敼 +export function equipmentEnergyUpdate(query) { + return request({ + url: '/equipmentEnergyConsumption/update', + method: 'post', + data: query, + }) +} +// 璁惧涓嬫媺妗嗘煡璇� +export function deviceList(query) { + return request({ + url: '/equipmentEnergyConsumption/deviceList', + method: 'get', + }) +} \ No newline at end of file diff --git a/src/views/energyManagement/energyPower/index.vue b/src/views/energyManagement/energyPower/index.vue new file mode 100644 index 0000000..0e29e21 --- /dev/null +++ b/src/views/energyManagement/energyPower/index.vue @@ -0,0 +1,291 @@ +<template> + <div class="app-container"> + <div class="search_form"> + <div> + <span class="search_title">璁惧鍚嶇О锛�</span> + <el-input + v-model="searchForm.name" + style="width: 240px" + placeholder="璇疯緭鍏�" + @change="handleQuery" + clearable + :prefix-icon="Search" + /> + <el-button type="primary" @click="handleQuery" style="margin-left: 10px" + >鎼滅储</el-button + > + </div> + <div> + <el-button type="primary" @click="openForm('add')">鏂板</el-button> + <el-button type="info" plain icon="Upload" @click="handleImport">瀵煎叆</el-button> + <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button> + </div> + </div> + <div class="table_list"> + <PIMTable + rowKey="id" + :column="tableColumn" + :tableData="tableData" + :page="page" + :isSelection="true" + @selection-change="handleSelectionChange" + :tableLoading="tableLoading" + @pagination="pagination" + ></PIMTable> + </div> + <form-dia ref="formDia" @close="handleQuery"></form-dia> + <el-dialog + :title="upload.title" + v-model="upload.open" + width="400px" + append-to-body + > + <el-upload + ref="uploadRef" + :limit="1" + accept=".xlsx, .xls" + :headers="upload.headers" + :action="upload.url + '?updateSupport=' + upload.updateSupport" + :disabled="upload.isUploading" + :before-upload="upload.beforeUpload" + :on-progress="upload.onProgress" + :on-success="upload.onSuccess" + :on-error="upload.onError" + :on-change="upload.onChange" + :auto-upload="false" + drag + > + <el-icon class="el-icon--upload"><upload-filled /></el-icon> + <div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div> + <template #tip> + <div class="el-upload__tip text-center"> + <span>浠呭厑璁稿鍏ls銆亁lsx鏍煎紡鏂囦欢銆�</span> + <!-- <el-link--> + <!-- type="primary"--> + <!-- :underline="false"--> + <!-- style="font-size: 12px; vertical-align: baseline"--> + <!-- @click="importTemplate"--> + <!-- >涓嬭浇妯℃澘</el-link--> + <!-- >--> + </div> + </template> + </el-upload> + <template #footer> + <div class="dialog-footer"> + <el-button type="primary" @click="submitFileForm">纭� 瀹�</el-button> + <el-button @click="upload.open = false">鍙� 娑�</el-button> + </div> + </template> + </el-dialog> + </div> +</template> + +<script setup> +import {Search} from "@element-plus/icons-vue"; +import {onMounted, ref} from "vue"; +import FormDia from "@/views/energyManagement/energyPower/components/formDia.vue"; +import {ElMessageBox} from "element-plus"; +import {getToken} from "@/utils/auth.js"; +import {equipmentEnergyDelete, equipmentEnergyListPage} from "@/api/energyManagement/index.js"; +const { proxy } = getCurrentInstance(); + +const data = reactive({ + searchForm: { + name: "", + }, +}); +const { searchForm } = toRefs(data); + +const tableColumn = ref([ + { + label: "璁惧鍚嶇О", + prop: "name", + width: 200, + }, + { + label: "瑙勬牸鍨嬪彿", + prop: "code", + width: 200, + }, + { + label: "棰濆畾鍔熺巼", + prop: "powerRating", + }, + { + label: "瀹為檯鍔熺巼", + prop: "powerActual", + }, + { + label: "杩愯鏃堕棿", + prop: "runDate", + width:150 + }, + { + label: "褰撴棩鐢ㄧ數閲�", + prop: "dayNum", + width: 150, + }, + { + label: "绱鐢ㄧ數閲�", + prop: "sumNum", + width: 150, + }, + { + label: "姣忔棩闄愬埗鐢甸噺", + prop: "everyNum", + width:220 + }, + { + dataType: "action", + label: "鎿嶄綔", + align: "center", + fixed: 'right', + operation: [ + { + name: "缂栬緫", + type: "text", + clickFun: (row) => { + openForm("edit", row); + }, + }, + ], + }, +]); +const tableData = ref([]); +const tableLoading = ref(false); +const page = reactive({ + current: 1, + size: 100, + total: 0, +}); +// 琛ㄦ牸閫夋嫨鏁版嵁 +const handleSelectionChange = (selection) => { + selectedRows.value = selection; +}; +const formDia = ref() +const upload = reactive({ + // 鏄惁鏄剧ず寮瑰嚭灞傦紙瀹㈡埛瀵煎叆锛� + open: false, + // 寮瑰嚭灞傛爣棰橈紙瀹㈡埛瀵煎叆锛� + title: "", + // 鏄惁绂佺敤涓婁紶 + isUploading: false, + // 璁剧疆涓婁紶鐨勮姹傚ご閮� + headers: { Authorization: "Bearer " + getToken() }, + // 涓婁紶鐨勫湴鍧� + url: import.meta.env.VITE_APP_BASE_API + "/basic/customer/importData", + // 鏂囦欢涓婁紶鍓嶇殑鍥炶皟 + beforeUpload: (file) => { + console.log('鏂囦欢鍗冲皢涓婁紶', file); + // 鍙互鍦ㄦ澶勫仛鏂囦欢绫诲瀷鎴栧ぇ灏忔牎楠� + const isValid = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.name.endsWith('.xlsx') || file.name.endsWith('.xls'); + if (!isValid) { + proxy.$modal.msgError("鍙兘涓婁紶 Excel 鏂囦欢"); + } + return isValid; + }, + // 鏂囦欢鐘舵�佹敼鍙樻椂鐨勫洖璋� + onChange: (file, fileList) => { + console.log('鏂囦欢鐘舵�佹敼鍙�', file, fileList); + }, + // 鏂囦欢涓婁紶鎴愬姛鏃剁殑鍥炶皟 + onSuccess: (response, file, fileList) => { + console.log('涓婁紶鎴愬姛', response, file, fileList); + if(response.code === 200){ + proxy.$modal.msgSuccess("鏂囦欢涓婁紶鎴愬姛"); + }else if(response.code === 500){ + proxy.$modal.msgError(response.msg); + }else{ + proxy.$modal.msgWarning(response.msg); + } + }, + // 鏂囦欢涓婁紶澶辫触鏃剁殑鍥炶皟 + onError: (error, file, fileList) => { + console.error('涓婁紶澶辫触', error, file, fileList); + proxy.$modal.msgError("鏂囦欢涓婁紶澶辫触"); + }, + // 鏂囦欢涓婁紶杩涘害鍥炶皟 + onProgress: (event, file, fileList) => { + console.log('涓婁紶涓�...', event.percent); + } +}); + +// 鏌ヨ鍒楄〃 +/** 鎼滅储鎸夐挳鎿嶄綔 */ +const handleQuery = () => { + page.current = 1; + getList(); +}; +const pagination = (obj) => { + page.current = obj.page; + page.size = obj.limit; + getList(); +}; +const getList = () => { + tableLoading.value = true; + equipmentEnergyListPage({ ...searchForm.value, ...page }).then((res) => { + tableLoading.value = false; + tableData.value = res.data.records; + page.total = res.data.total; + }); +}; + +// 鎵撳紑寮规 +const openForm = (type, row) => { + nextTick(() => { + formDia.value?.openDialog(type, row) + }) +}; + +/** 瀵煎叆鎸夐挳鎿嶄綔 */ +function handleImport() { + upload.title = "璁惧鑳借��"; + upload.open = true; +} +/** 鎻愪氦涓婁紶鏂囦欢 */ +function submitFileForm() { + proxy.$refs["uploadRef"].submit(); +} + +const handleDelete = () => { + let ids = []; + if (selectedRows.value.length > 0) { + // 妫�鏌ユ槸鍚︽湁浠栦汉缁存姢鐨勬暟鎹� + const unauthorizedData = selectedRows.value.filter(item => item.maintainer !== userStore.nickName); + if (unauthorizedData.length > 0) { + proxy.$modal.msgWarning("涓嶅彲鍒犻櫎浠栦汉缁存姢鐨勬暟鎹�"); + return; + } + ids = selectedRows.value.map((item) => item.id); + } else { + proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁"); + return; + } + ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚垹闄わ紝鏄惁纭鍒犻櫎锛�", "鍒犻櫎鎻愮ず", { + confirmButtonText: "纭", + cancelButtonText: "鍙栨秷", + type: "warning", + }) + .then(() => { + tableLoading.value = true; + equipmentEnergyDelete(ids) + .then((res) => { + proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛"); + getList(); + }) + .finally(() => { + tableLoading.value = false; + }); + }) + .catch(() => { + proxy.$modal.msg("宸插彇娑�"); + }); +}; +onMounted(() => { + getList(); +}); +</script> + +<style scoped> + +</style> \ No newline at end of file diff --git a/src/views/energyManagement/energyTrends/index.vue b/src/views/energyManagement/energyTrends/index.vue new file mode 100644 index 0000000..6429023 --- /dev/null +++ b/src/views/energyManagement/energyTrends/index.vue @@ -0,0 +1,116 @@ +<template> + <div class="app-container"> + <div class="search_form"> + <div> + <span class="search_title">璁惧鍚嶇О锛�</span> + <el-input + v-model="searchForm.customerName" + style="width: 240px" + placeholder="璇疯緭鍏�" + @change="handleQuery" + clearable + :prefix-icon="Search" + /> + <el-button type="primary" @click="handleQuery" style="margin-left: 10px" + >鎼滅储</el-button + > + </div> + </div> + <div class="table_list"> + <PIMTable + rowKey="id" + :column="tableColumn" + :tableData="tableData" + :page="page" + :isSelection="true" + @selection-change="handleSelectionChange" + :tableLoading="tableLoading" + @pagination="pagination" + ></PIMTable> + </div> + + </div> +</template> + +<script setup> +import {Search} from "@element-plus/icons-vue"; +import {onMounted, ref} from "vue"; +import {listPageByTrend} from "@/api/energyManagement/index.js"; + +const data = reactive({ + searchForm: { + customerName: "", + }, +}); +const { searchForm } = toRefs(data); + +const tableColumn = ref([ + { + label: "璁惧鍚嶇О", + prop: "name", + width: 220, + }, + { + label: "瑙勬牸鍨嬪彿", + prop: "code", + width: 220, + }, + { + label: "杩愯鏃堕棿", + prop: "runDate", + width: 250, + }, + { + label: "鏄ㄦ棩鐢ㄧ數閲�", + prop: "toDayNum", + }, + { + label: "鏈湀骞冲潎鐢甸噺", + prop: "avgNum", + width:150 + }, + { + label: "瓒嬪娍", + prop: "trend", + width: 220, + }, +]); +const tableData = ref([]); +const tableLoading = ref(false); +const page = reactive({ + current: 1, + size: 100, + total: 0, +}); +// 琛ㄦ牸閫夋嫨鏁版嵁 +const handleSelectionChange = (selection) => { + selectedRows.value = selection; +}; + +// 鏌ヨ鍒楄〃 +/** 鎼滅储鎸夐挳鎿嶄綔 */ +const handleQuery = () => { + page.current = 1; + getList(); +}; +const pagination = (obj) => { + page.current = obj.page; + page.size = obj.limit; + getList(); +}; +const getList = () => { + tableLoading.value = true; + listPageByTrend({ ...searchForm.value, ...page }).then((res) => { + tableLoading.value = false; + tableData.value = res.data.records; + page.total = res.data.total; + }); +}; +onMounted(() => { + getList(); +}); +</script> + +<style scoped> + +</style> \ No newline at end of file -- Gitblit v1.9.3