helongyang
15 小时以前 06eb604f71605c47f015b88b1620b72b6f69df8c
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Client/src/views/deviceMonitoring/BoardWarehouse.vue
@@ -1,45 +1,341 @@
<template>
  <div class="message-container">
    <div class="item" v-for="(item, index) in list" :key="index">
      <div class="title">{{ item.title }}({{ item.date }})</div>
      <div class="content">{{ item.message }}</div>
  <div id="title">
    <div id="bkuang" style="border-top: none">
      <!-- BC仓堆垛机状态面板 -->
      <div class="skuang">
        <div class="bcuname">板料仓堆垛机</div>
        <div class="bcankuang">
          <div class="xname">堆垛机状态:</div>
          <div class="xbci" :title="bcData.R_BC_Status">{{ bcData.R_BC_Status || '-' }}</div>
        </div>
        <div class="bcankuang">
          <div class="xname">堆垛机手自动状态:</div>
          <div class="xbci" :title="bcData.R_BC_AutoStatus">{{ bcData.R_BC_AutoStatus || '-' }}</div>
        </div>
        <div class="bcankuang">
          <div class="xname">正在执行的任务号:</div>
          <div class="xbci" :title="bcData.R_BC_TaskNum">{{ bcData.R_BC_TaskNum || '-' }}</div>
        </div>
        <div class="bcankuang">
          <div class="xname">堆垛机工作状态:</div>
          <div class="xbci" :title="bcData.R_BC_WorkStatus">{{ bcData.R_BC_WorkStatus || '-' }}</div>
        </div>
        <div class="bcankuang">
          <div class="xname">作业类型:</div>
          <div class="xbci" :title="bcData.R_BC_WorkType">{{ bcData.R_BC_WorkType || '-' }}</div>
        </div>
        <div class="bcankuang">
          <div class="xname">托盘类型:</div>
          <div class="xbci" :title="bcData.R_BC_TrayType">{{ bcData.R_BC_TrayType || '-' }}</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { ref, nextTick, watch, onUnmounted } from "vue";
import { useStore } from "vuex";
import { onMounted } from "vue";
export default {
  props: {
    list: {
      type: Array,
      default: () => {
        return [];
      }
    }
  data() {
    return {
      xuan: 0
    };
  },
  created() {
    if (!this.list.length) {
      this.list.push({
        title: '消息测试标qweqweqweqw题',
        message: '消息测试内容消息测试内容消息测试内容消息测试内容',
        date: '2022-05-02 03:10'
  setup() {
    const store = useStore();
    // ä»…存储BC数据,与其他数据隔离
    const bcData = ref({});
    // å»¶è¿Ÿæ›´æ–°é…ç½®ï¼Œè§£å†³é—ªçƒé—®é¢˜
    const UPDATE_DELAY = 300; // å»¶è¿Ÿ300ms更新UI
    let updateTimer = null;   // å®šæ—¶å™¨å®žä¾‹
    // BC数据映射规则
    const bcStatusMap = {
      R_BC_Status: {
        1: "正常",
        2: "故障",
        3: "急停",
      },
      R_BC_AutoStatus: {
        0: "ç»´ä¿®",
        1: "手动",
        2: "半自动",
        3: "自动",
      },
      R_BC_WorkStatus: {
        0: "待机",
        1: "取货中",
        2: "取货完成",
        4: "放货中",
        5: "放货完成",
        6: "任务完成",
      },
      R_BC_WorkType: {
        0: "无作业任务(0)",
        1: "取放货作业(1)",
        2: "只取货作业(2)",
        3: "只放货作业(3)",
        4: "移动到指定位置"
      },
      R_BC_TrayType: {
        "-1": "空箱(-1)",
        1: "小托盘(1)",
        2: "中托盘(2)",
        3: "大托盘(3)",
        4: "特大托盘(4)",
      }
    };
    // BC字段分组
    const bcFieldGroups = {
      permissionFields: {
        keys: ["R_BC_IsCanPut1", "R_BC_IsCanTake1", "R_BC_IsCanPut2", "R_BC_IsCanTake2",
               "R_BC_IsCanPut3", "R_BC_IsCanTake3", "R_BC_IsCanPut4", "R_BC_IsCanTake4"],
        map: { true: "是", false: "否" }
      },
      requestFields: {
        keys: ["W_BC_PutRequest1", "W_BC_TakeRequest1", "W_BC_PutRequest2", "W_BC_TakeRequest2",
               "W_BC_PutRequest3", "W_BC_TakeRequest3", "W_BC_PutRequest4", "W_BC_TakeRequest4"],
        map: { true: "是", false: "否" }
      },
      finishFields: {
        keys: ["W_BC_PutFinish1", "W_BC_TakeFinish1", "W_BC_PutFinish2", "W_BC_TakeFinish2",
               "W_BC_PutFinish3", "W_BC_TakeFinish3", "W_BC_PutFinish4", "W_BC_TakeFinish4"],
        map: { true: "是", false: "否" }
      },
      palletTypeFields: {
        keys: ["R_BC_TakePalletType1", "R_BC_TakePalletType2", "R_BC_TakePalletType3", "R_BC_TakePalletType4",
               "W_BC_PutPalletType1", "W_BC_PutPalletType2", "W_BC_PutPalletType3", "W_BC_PutPalletType4"],
        map: { "-1": "空箱(-1)", 1: "小托盘(1)", 2: "中托盘(2)", 3: "大托盘(3)", 4: "特大托盘(4)" }
      }
    };
    // å¤„理BC原始数据
    const processBCData = (rawData) => {
      if (!rawData) return {};
      const processedData = { ...rawData };
      // å¤„理核心状态字段
      Object.keys(bcStatusMap).forEach(key => {
        if (processedData.hasOwnProperty(key)) {
          processedData[key] = bcStatusMap[key][processedData[key]] || processedData[key];
        }
      });
      // å¤„理分组字段
      Object.values(bcFieldGroups).forEach(group => {
        group.keys.forEach(key => {
          if (processedData.hasOwnProperty(key)) {
            processedData[key] = group.map[processedData[key]] || processedData[key];
          }
        });
      });
      return processedData;
    };
    // å»¶è¿Ÿæ›´æ–°BC数据,避免高频刷新
    const delayedUpdateBCData = (newRawData) => {
      if (updateTimer) {
        clearTimeout(updateTimer);
      }
      updateTimer = setTimeout(() => {
        // åªå¤„理包含BC特征字段的数据
        if (newRawData && newRawData.R_BC_Status !== undefined) {
          bcData.value = processBCData(newRawData);
          // æ›´æ–°æ ·å¼
          nextTick(() => {
            const valueElements = document.getElementsByClassName("xbci");
            for (let i = 0; i < valueElements.length; i++) {
              if (valueElements[i].innerHTML === "是") {
                valueElements[i].style.color = "yellow";
              } else if (valueElements[i].innerHTML === "否") {
                valueElements[i].style.color = "red";
              }
            }
      });
    }
      }, UPDATE_DELAY);
    };
    onMounted(() => {
      // åˆå§‹åŠ è½½æ•°æ®
      const initialData = store.state.homedata;
      if (initialData && initialData.R_BC_Status !== undefined) {
        bcData.value = processBCData(initialData);
      }
      // ç›‘听数据变化,只处理BC数据
      const unwatch = watch(
        () => store.state.homedata,
        (newData) => {
          if (newData && newData.R_BC_Status !== undefined) {
            delayedUpdateBCData(newData);
          }
        },
        { deep: true }
      );
      // ç»„件卸载时清理
      onUnmounted(() => {
        unwatch();
        if (updateTimer) {
          clearTimeout(updateTimer);
        }
      });
    });
    return {
      bcData
    };
  }
};
</script>
<style scoped lang="less">
.message-container {
  .title {
    padding-bottom: 10px;
<style scoped>
.ding {
  float: left;
  width: 20px;
  height: 20px;
  margin-top: 7px;
  }
  .item {
    border-bottom: 1px solid #eee;
    padding: 10px 20px;
.yan {
  color: white;
  float: left;
  font-size: 25px;
  }
  .content {
    color: #7e7e7e;
    font-size: 13px;
.dakuang {
  width: 250px;
  height: 50px;
  position: absolute;
  top: 150px;
  left: 200px;
  }
#xiugai {
  width: 100px;
  height: 30px;
  float: left;
  border-radius: 5px;
  text-align: center;
  line-height: 30px;
  cursor: pointer;
  border: 1px solid white;
  color: white;
  background: rgba(255, 255, 255, 0.5);
  font-size: 25px;
  position: absolute;
  top: 150px;
  left: 450px;
}
#xiugai:hover {
  background: #f60;
}
#shu1,
#shu2 {
  width: 200px;
  height: 30px;
  float: left;
  margin-top: 0px;
  margin-right: 0px;
  border-radius: 5px;
  border: 1px solid white;
}
#guan {
  width: 40px;
  height: 40px;
  float: left;
  font-size: 1.1cqw;
  text-align: center;
  line-height: 40px;
  cursor: pointer;
  margin-left: 560px;
  color: white;
  position: absolute;
}
#ti {
  width: 600px;
  height: 300px;
  position: relative;
  background: rgba(255, 255, 255, 1);
  border-radius: 10px;
  top: 230px;
  left: 35%;
  display: none;
  background-image: url("../../img/1.png");
  background-repeat: no-repeat;
  background-size: 170%;
  background-position: -220px 0px;
}
.bcuname {
  width: 100%;
  height: 5vh;
  float: left;
  text-align: center;
  line-height: 50px;
  font-weight: 700;
  font-size: 1.1cqw;
  color: white;
}
.xname {
  width: 70%;
  height: 80px;
  float: left;
  line-height: 7vh;
  font-size: 1.1cqw;
  color: white;
}
.xbci {
  width: 30%;
  height: 7vh;
  float: left;
  line-height: 50px;
  font-size: 1.1cqw;
  color: rgb(242, 242, 50);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bcankuang {
  width: 45%;
  height: 3vh;
  margin-top: 10px;
  margin-left: 5%;
  float: left;
}
#title {
  float: left;
  width: 95%;
  height: 88vh;
  margin-top: 40px;
  margin-left: 3%;
  background-image: url("../../img/1.png");
  background-repeat: no-repeat;
  background-size: 100%;
  container-type: inline-size;
}
#bkuang {
  width: 100%;
  height: 55vh;
  float: left;
}
.skuang {
  width: 31%;
  height: 55vh;
  float: left;
  border-top: none;
  border-left: none;
  border-bottom: none;
  background: rgba(255, 255, 255, 0.2);
  margin-left: 1.7%;
  border-radius: 10px;
}
</style>