| | |
| | | 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 } = |
| | |
| | | // }); |
| | | // } |
| | | |
| | | // onMounted(() => { |
| | | const throttleConect = throttle(pingpong, 1000); |
| | | // function conect() { |
| | | // pingpong(); |
| | | // } |
| | | |
| | | // // 开启超时30分钟未操作,退出登录 |
| | | 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", resetTimeout); |
| | | // document.removeEventListener("mousemove", resetTimeout); |
| | | // document.removeEventListener("keydown", resetTimeout); |
| | | // }); |
| | | }); |
| | | onUnmounted(() => { |
| | | document.removeEventListener("click", throttleConect); |
| | | document.removeEventListener("mousemove", throttleConect); |
| | | document.removeEventListener("keydown", throttleConect); |
| | | }); |
| | | </script> |
| | | |
| | | <template> |
| | |
| | | }, |
| | | }); |
| | | }; |
| | | |
| | | /** |
| | | * 空接口 用于重置会话有效期 |
| | | */ |
| | | export const pingpong = () => { |
| | | return axios({ |
| | | method: "GET", |
| | | url: "login/getCookie", |
| | | }); |
| | | }; |
| | |
| | | }); |
| | | }; |
| | | |
| | | |
| | | // ==================== |
| | | /** |
| | | * 获取均衡仪参数 |
| | |
| | | }; |
| | | |
| | | /** |
| | | * 设置均衡仪电池组数 |
| | | */ |
| | | 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, |
| | | }); |
| | | }; |
| | | |
| | | /** |
| | | * 批量设置均衡仪电池组数 另加一个devIds |
| | | */ |
| | | 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 启动 |
| | |
| | | method: "POST", |
| | | url: "actmparam/controllActmParamPl", |
| | | params: { index, type }, |
| | | data: devIds |
| | | data: devIds, |
| | | }); |
| | | }; |
| | | |
| | | |
| | | /** |
| | | * 结束批量 清除设备的批量标记 |
| | |
| | | return axios({ |
| | | method: "POST", |
| | | url: "devInf/cancelContPl", |
| | | data: devIds |
| | | data: devIds, |
| | | }); |
| | | }; |
New file |
| | |
| | | <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> |
| | |
| | | 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"; |
| | |
| | | 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]; |
| | |
| | | currentDevId.value = params.devId; |
| | | } |
| | | |
| | | function setBattCount() { |
| | | jhyBattCountVisible.value = true; |
| | | console.log('cur', currentDev, '============='); |
| | | |
| | | |
| | | } |
| | | |
| | | function test(groupIdx) { |
| | | testGroupIdx.value = groupIdx; |
| | | testVisible.value = true; |
| | |
| | | > |
| | | </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" |
| | |
| | | ></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> |
| | | |
| | |
| | | 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"; |
| | | |
| | |
| | | const keyWord = ref(""); |
| | | const testVisible = ref(false); |
| | | const testGroupIdx = ref(); |
| | | const jhyBattCountVisible = ref(false); |
| | | |
| | | const list = reactive({ |
| | | // 总的选中 |
| | |
| | | }); |
| | | } |
| | | |
| | | function setBattCount() { |
| | | jhyBattCountVisible.value = true; |
| | | } |
| | | |
| | | onMounted(() => {}); |
| | | onActivated(() => { |
| | | if ($route.query.devType) { |
| | |
| | | > |
| | | </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]" |
| | |
| | | ></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> |
| | | |