he wei
2024-10-19 c726c8616f79ecd530e63a889f45b04898e3555b
U 均衡仪电池组数设置
5个文件已修改
1个文件已添加
293 ■■■■■ 已修改文件
src/layout/index.vue 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/login/api.js 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/test/api.js 43 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/test/battCountContent.vue 136 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/test/index.vue 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/test/testBatch.vue 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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>
src/views/login/api.js
@@ -11,3 +11,13 @@
    },
  });
};
/**
 * 空接口 用于重置会话有效期
 */
export const pingpong = () => {
  return axios({
    method: "GET",
    url: "login/getCookie",
  });
};
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,
  });
};
/**
 * 批量设置均衡仪电池组数 另加一个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 启动
 * 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,
  });
};
};
src/views/test/battCountContent.vue
New file
@@ -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>
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>
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>