From c726c8616f79ecd530e63a889f45b04898e3555b Mon Sep 17 00:00:00 2001 From: he wei <858544502@qq.com> Date: 星期六, 19 十月 2024 17:27:01 +0800 Subject: [PATCH] U 均衡仪电池组数设置 --- src/views/test/api.js | 43 +++++++- src/views/test/testBatch.vue | 28 +++++ src/views/test/battCountContent.vue | 136 +++++++++++++++++++++++++++ src/views/test/index.vue | 41 ++++++++ src/layout/index.vue | 35 ++++-- src/views/login/api.js | 10 ++ 6 files changed, 273 insertions(+), 20 deletions(-) diff --git a/src/layout/index.vue b/src/layout/index.vue index 8142b5a..89a52fe 100644 --- a/src/layout/index.vue +++ b/src/layout/index.vue @@ -4,6 +4,8 @@ import useElement from "@/hooks/useElement.js"; import { useTagsViewStore } from "@/stores/tagsView"; import { useRouter } from "vue-router"; +import { throttle } from "@/assets/js/tools/throttle.js"; +import { pingpong } from "@/views/login/api.js"; const $router = useRouter(); const { $alert } = useElement(); const { delAllViews, delCachedView, delView, delOthersViews } = @@ -33,20 +35,27 @@ // }); // } -// onMounted(() => { +const throttleConect = throttle(pingpong, 1000); +// function conect() { +// pingpong(); +// } -// // 寮�鍚秴鏃�30鍒嗛挓鏈搷浣滐紝閫�鍑虹櫥褰� -// resetTimeout(); -// // 缁戝畾鐢ㄦ埛浜や簰浜嬩欢浠ラ噸缃畾鏃跺櫒 -// document.addEventListener("click", resetTimeout); -// document.addEventListener("mousemove", resetTimeout); -// document.addEventListener("keydown", resetTimeout); -// }); -// onUnmounted(() => { -// document.removeEventListener("click", resetTimeout); -// document.removeEventListener("mousemove", resetTimeout); -// document.removeEventListener("keydown", resetTimeout); -// }); +onMounted(() => { + document.addEventListener("click", throttleConect); + document.addEventListener("mousemove", throttleConect); + document.addEventListener("keydown", throttleConect); + // 寮�鍚秴鏃�30鍒嗛挓鏈搷浣滐紝閫�鍑虹櫥褰� + // resetTimeout(); + // // 缁戝畾鐢ㄦ埛浜や簰浜嬩欢浠ラ噸缃畾鏃跺櫒 + // document.addEventListener("click", resetTimeout); + // document.addEventListener("mousemove", resetTimeout); + // document.addEventListener("keydown", resetTimeout); +}); +onUnmounted(() => { + document.removeEventListener("click", throttleConect); + document.removeEventListener("mousemove", throttleConect); + document.removeEventListener("keydown", throttleConect); +}); </script> <template> diff --git a/src/views/login/api.js b/src/views/login/api.js index 12a4785..31787b7 100644 --- a/src/views/login/api.js +++ b/src/views/login/api.js @@ -11,3 +11,13 @@ }, }); }; + +/** + * 绌烘帴鍙� 鐢ㄤ簬閲嶇疆浼氳瘽鏈夋晥鏈� + */ +export const pingpong = () => { + return axios({ + method: "GET", + url: "login/getCookie", + }); +}; \ No newline at end of file diff --git a/src/views/test/api.js b/src/views/test/api.js index 73a53d8..f86cb1b 100644 --- a/src/views/test/api.js +++ b/src/views/test/api.js @@ -89,7 +89,6 @@ }); }; - // ==================== /** * 鑾峰彇鍧囪 浠弬鏁� @@ -125,8 +124,41 @@ }; /** + * 璁剧疆鍧囪 浠數姹犵粍鏁� + */ +export const setActmBattCount = (groupCount, devId) => { + let data = { + batteryStorageNumber: groupCount == 0 ? 1 : 2, + batteryNumber: groupCount == 0 ? 24 : 12, + devId, + }; + + return axios({ + method: "POST", + url: "actmparam/setActmBatteryStorageNumber", + data, + }); +}; + +/** + * 鎵归噺璁剧疆鍧囪 浠數姹犵粍鏁� 鍙﹀姞涓�涓猟evIds + */ +export const setActmBattCountPl = (groupCount, devIds) => { + let data = { + batteryStorageNumber: groupCount == 0 ? 1 : 2, + batteryNumber: groupCount == 0 ? 24 : 12, + devIds, + }; + return axios({ + method: "POST", + url: "actmparam/setActmBatteryStorageNumberPl", + data, + }); +}; + +/** * 鍚姩鍧囪 浠� - * + * * 1 鍚姩 * 2鏆傚仠 * 3缁х画 @@ -148,10 +180,9 @@ method: "POST", url: "actmparam/controllActmParamPl", params: { index, type }, - data: devIds + data: devIds, }); }; - /** * 缁撴潫鎵归噺 娓呴櫎璁惧鐨勬壒閲忔爣璁� @@ -160,6 +191,6 @@ return axios({ method: "POST", url: "devInf/cancelContPl", - data: devIds + data: devIds, }); -}; \ No newline at end of file +}; diff --git a/src/views/test/battCountContent.vue b/src/views/test/battCountContent.vue new file mode 100644 index 0000000..a1b0648 --- /dev/null +++ b/src/views/test/battCountContent.vue @@ -0,0 +1,136 @@ +<script setup> +import { ref , onMounted } from "vue"; +import { setActmBattCount, setActmBattCountPl } from "./api"; +import useElement from "@/hooks/useElement.js"; +const { $alert, $loading, $message, $confirm } = useElement(); + +const $emit = defineEmits(["update:model-value"]); + +const battCount = ref(0); +const props = defineProps({ + modelValue: { + type: Boolean, + required: true, + }, + devs: { + type: [Object, Array], + required: true, + }, + isBatch: { + type: Boolean, + default: false, + }, + isOnlyOne: { + type: Boolean, + default: false, + } +}); + +function close() { + $emit("update:model-value", false); +} + +function setCount() { + if (props.isBatch) { + setCountBatch(); + } else { + setCountOne(); + } +} + +function setCountOne() { + let loading = $loading(); + setActmBattCount(battCount.value, props.devs.devId) + .then((res) => { + loading.close(); + let { code, data, msg } = res.data; + if (200 == code) { + $message.success("鎿嶄綔鎴愬姛"); + // console.log(data); + close(); + } else { + $message.error("鎿嶄綔澶辫触:" + msg); + } + }) + .catch((err) => { + loading.close(); + $message.error("鎿嶄綔澶辫触:" + err); + console.log(err); + }); +} + +function setCountBatch() { + let loading = $loading(); + setActmBattCountPl(battCount.value, props.devs.map((v) => v.devId)) + .then((res) => { + let { code, data, data2 } = res.data; + loading.close(); + let failList = []; + let successList = []; + Object.keys(data2).forEach((v) => { + if (200 == data2[v].code) { + successList.push(v); + } else { + failList.push(v); + } + }); + + if (code && data && successList.length) { + $message.success("鎿嶄綔鎴愬姛"); + if (failList.length) { + let failNames = props.devs + .filter((v) => failList.some((vv) => vv == v.devId)) + .map((v) => v.devIdcode); + + $alert(`鎿嶄綔澶辫触鐨勮澶囧垪琛細${failNames.join(", ")}銆俙); + } + close(); + } else { + $message.error("鎿嶄綔澶辫触"); + } + }) + .catch((err) => { + loading.close(); + $message.error("鎿嶄綔澶辫触"); + console.log(err); + }); +} + +onMounted(() => { + battCount.value = props.isOnlyOne ? 0 : 1; +}) +</script> + +<template> + <!-- <el-select v-model="battCount"> + <el-option + label="1缁�, 姣忕粍24鑺傚崟浣�" + :value="0" + /> + <el-option + label="2缁�, 姣忕粍12鑺傚崟浣�" + :value="1" + /> + </el-select> --> + <el-radio-group class="radio-group" v-model="battCount"> + <el-radio :value="0">1缁�, 姣忕粍24鑺傚崟浣�</el-radio> + <el-radio :value="1">2缁�, 姣忕粍12鑺傚崟浣�</el-radio> + </el-radio-group> + <div class="footer"> + <el-button @click="close">鍙栨秷</el-button> + <el-button type="primary" @click="setCount">纭畾</el-button> + </div> +</template> + +<style scoped lang="less"> +.radio-group { + display: flex; + flex-direction: column; + :deep(label) { + margin-right: 0; + } +} +.footer { + text-align: right; +} +</style> diff --git a/src/views/test/index.vue b/src/views/test/index.vue index 29632eb..5261729 100644 --- a/src/views/test/index.vue +++ b/src/views/test/index.vue @@ -5,6 +5,7 @@ import iconPower from "@/components/icons/iconPower.vue"; import useDevsRt from "@/hooks/useDevsRt.js"; import paramContent from "./paramContent.vue"; +import battCountContent from "./battCountContent.vue"; import useWebSocket from "@/hooks/useWebSocket.js"; import { getA200Param } from "./api.js"; import formatSeconds from "@/assets/js/tools/formatSeconds.js"; @@ -27,9 +28,16 @@ const currentDevId = ref(0); const testGroupIdx = ref(); +const jhyBattCountVisible = ref(false); // TODO 鏈夊嚑缁� -const onlyOneGroup = ref(false); +// const onlyOneGroup = ref(false); +const onlyOneGroup = computed(() => { + if (!currentDev.value.state) { + return false; + } + return currentDev.value.state[0].batteryCount == 1; +}); const resList = computed(() => { let _list = list.value[devType.value]; @@ -125,6 +133,13 @@ currentDevId.value = params.devId; } +function setBattCount() { + jhyBattCountVisible.value = true; + console.log('cur', currentDev, '============='); + + +} + function test(groupIdx) { testGroupIdx.value = groupIdx; testVisible.value = true; @@ -198,6 +213,14 @@ > </template> <template v-else-if="currentDev.state"> + <el-button + size="small" + :disabled="!currentDev.devOnline" + class="btn-start btn-grp1" + v-if="!currentDev.state[0].isTesting" + @click="setBattCount" + >璁剧疆缁勬暟</el-button + > <el-button size="small" :disabled="!currentDev.devOnline" @@ -332,6 +355,22 @@ ></jh-param-content> </template> </el-dialog> + <!-- 璁剧疆鍧囪 浠粍鏁� --> + <el-dialog + title="璁剧疆鍧囪 浠數姹犵粍鏁�" + v-model="jhyBattCountVisible" + :close-on-click-modal="false" + class="dialog-center" + width="600px" + center + > + <batt-count-content + v-model="jhyBattCountVisible" + v-if="jhyBattCountVisible" + :devs="currentDev" + :isOnlyOne="onlyOneGroup" + ></batt-count-content> + </el-dialog> </div> </template> diff --git a/src/views/test/testBatch.vue b/src/views/test/testBatch.vue index 1a452ae..9718954 100644 --- a/src/views/test/testBatch.vue +++ b/src/views/test/testBatch.vue @@ -5,6 +5,7 @@ import paramContent from "./paramContent.vue"; import jhParamContent from "./jhParamContent.vue"; import { useRoute, useRouter } from "vue-router"; +import battCountContent from "./battCountContent.vue"; import { cancelContPl, controllerActmParam, stopA200ParamPl } from "./api.js"; @@ -20,6 +21,7 @@ const keyWord = ref(""); const testVisible = ref(false); const testGroupIdx = ref(); +const jhyBattCountVisible = ref(false); const list = reactive({ // 鎬荤殑閫変腑 @@ -228,6 +230,10 @@ }); } +function setBattCount() { + jhyBattCountVisible.value = true; +} + onMounted(() => {}); onActivated(() => { if ($route.query.devType) { @@ -323,6 +329,12 @@ > </template> <template v-else> + <el-button + size="small" + class="btn-start btn-grp1" + @click="setBattCount" + >璁剧疆缁勬暟</el-button + > <el-button size="small" v-if="canStopBatch[2]" @@ -457,6 +469,22 @@ ></jh-param-content> </template> </el-dialog> + <!-- 璁剧疆鍧囪 浠粍鏁� --> + <el-dialog + title="璁剧疆鍧囪 浠數姹犵粍鏁�" + v-model="jhyBattCountVisible" + :close-on-click-modal="false" + class="dialog-center" + width="600px" + center + > + <batt-count-content + v-model="jhyBattCountVisible" + v-if="jhyBattCountVisible" + :isBatch="true" + :devs="devs" + ></batt-count-content> + </el-dialog> </div> </template> -- Gitblit v1.9.1