guonan
2025-06-06 7909450b6142fd10c55690c5ce093137247310ef
src/components/menu/Device.vue
@@ -124,9 +124,11 @@
    removeEntities(item.deviceId);
  });
};
const initializeDevicePoints = (val) => {
// const initializeDevicePoints = (val) => {
const initializeDevicePoints = () => {
  const list = [];
  val.forEach((item, index) => {
  // val.forEach((item, index) => {
  deviceListAll.value.forEach((item, index) => {
    // 根据需求可增删
    item.type = getDictName(deviceDictList, item.dictDeviceType);
    item.name = item.deviceName.split(selectValue.value)[1] || item.deviceName;
@@ -154,33 +156,33 @@
    const devicesInArea = allDevices.value.filter((item) =>
      item.deviceName?.includes(areaName)
    );
    // deviceListAll.value = devicesInArea;
    getDeviceInfo().then((res) => {
      const list = res.data.pageData;
      deviceListAll.value = [];
    deviceListAll.value = devicesInArea;
    // getDeviceInfo().then((res) => {
    //   const list = res.data.pageData;
    //   deviceListAll.value = [];
      let index = 0;
      const batchSize = 50; // 每次处理的数量
      const delay = 100; // 每隔多少毫秒处理一次
    //   let index = 0;
    //   const batchSize = 50; // 每次处理的数量
    //   const delay = 100; // 每隔多少毫秒处理一次
      const intervalId = setInterval(() => {
        // 取出当前批次的数据
        const batch = list.slice(index, index + batchSize);
    //   const intervalId = setInterval(() => {
    //     // 取出当前批次的数据
    //     const batch = list.slice(index, index + batchSize);
        if (batch.length === 0) {
          clearInterval(intervalId); // 数据处理完了,停止定时器
          return;
        }
    //     if (batch.length === 0) {
    //       clearInterval(intervalId); // 数据处理完了,停止定时器
    //       return;
    //     }
        // 把当前批次的数据 push 到 deviceListAll
        deviceListAll.value = [...deviceListAll.value, ...batch];
    //     // 把当前批次的数据 push 到 deviceListAll
    //     deviceListAll.value = [...deviceListAll.value, ...batch];
        // 对当前批次执行初始化方法
        initializeDevicePoints(batch);
    //     // 对当前批次执行初始化方法
    //     initializeDevicePoints(batch);
        index += batchSize;
      }, delay);
    });
    //     index += batchSize;
    //   }, delay);
    // });
  } catch (error) {
    console.error("加载设备信息失败", error);
  } finally {