helongyang
2025-11-17 291067c13bfe8fb9c876e3764a828dc3ddd22f99
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Client/src/views/deviceMonitoring/DryFilmWarehouse.vue
@@ -28,6 +28,11 @@
          <div class="xname">托盘类型:</div>
          <div class="xzhi" :title="gmData.R_GM_TrayType">{{ gmData.R_GM_TrayType || '-' }}</div>
        </div>
        <!-- æ–°å¢žï¼šå½“前列状态显示 -->
        <div class="zhankuang">
          <div class="xname">当前所在列:</div>
          <div class="xzhi" :title="gmData.R_GM_Column">{{ gmData.R_GM_Column || '未知' }}</div>
        </div>
      </div>
      <!-- GM关联站台(入库7003) -->
@@ -154,6 +159,41 @@
        </div>
      </div>
    </div>
    <!-- æ–°å¢žï¼šå †åž›æœºå½“前列文字显示 -->
    <div id="gm-nowcolumn" :class="{ 'abnormal-column': gmData.R_GM_Status !== '正常' }">
      <div>干膜堆垛机当前所在列:
        <span :title="gmData.R_GM_Column">{{ gmData.R_GM_Column || '未知' }}</span>
      </div>
    </div>
    <!-- æ–°å¢žï¼šåˆ—方格展示区域 -->
    <div class="gm-column-container" :class="{ 'pp-status-abnormal': gmData.R_GM_Status !== '正常' }">
      <!-- ä¸Šæ–¹1-24列 -->
      <div class="column-grid-container">
        <div
          v-for="num in 20"
          :key="num"
          class="column-grid-item"
          :class="{ 'active': num == gmData.R_GM_Column }"
          :title="`列号: ${num}`"
        >
          {{ num }}
        </div>
      </div>
      <!-- ä¸‹æ–¹25-47列 (23个) -->
      <div class="column-grid-container">
        <div
          v-for="i in 19"
          :key="'gm-lower-' + i"
          class="column-grid-item"
          :class="{ 'active': (20 + i) == gmData.R_GM_Column }"
          :title="`列号: ${20 + i}`"
        >
          {{ 20 + i }}
        </div>
      </div>
    </div>
  </div>
</template>
@@ -170,21 +210,21 @@
  },
  setup() {
    const store = useStore();
    // ä»…存储GM数据,与其他仓数据隔离
    const gmData = ref({});
    // å»¶è¿Ÿæ›´æ–°é…ç½®ï¼Œè§£å†³é—ªçƒé—®é¢˜
    const UPDATE_DELAY = 300; // 300ms延迟,平衡实时性和界面稳定性
    let updateTimer = null;   // å®šæ—¶å™¨å®žä¾‹
    const UPDATE_DELAY = 300;
    let updateTimer = null;
    // GM数据映射规则配置(按功能分组)
    // GM数据映射规则(新增列号处理)
    const gmStatusConfig = {
      coreStatus: {
        R_GM_Status: { 1: "正常", 2: "故障", 3: "急停" },
        R_GM_Status: { 0: "正常", 1: "故障", 2: "急停", 3: "未知" },
        R_GM_AutoStatus: { 0: "ç»´ä¿®", 1: "手动", 2: "半自动", 3: "自动" },
        R_GM_WorkStatus: { 0: "待机", 1: "取货中", 2: "取货完成", 4: "放货中", 5: "放货完成", 6: "任务完成" },
        R_GM_WorkType: { 0: "无作业任务(0)", 1: "取放货作业(1)", 2: "只取货作业(2)", 3: "只放货作业(3)", 4: "移动到指定位置" },
        R_GM_TrayType: { "-1": "空箱(-1)", 1: "小托盘(1)", 2: "中托盘(2)", 3: "大托盘(3)", 4: "特大托盘(4)" }
        R_GM_TrayType: { "-1": "空箱(-1)", 1: "小托盘(1)", 2: "中托盘(2)", 3: "大托盘(3)", 4: "特大托盘(4)" },
        // æ–°å¢žï¼šåˆ—号映射处理
        R_GM_Column: (val) => val !== undefined ? val : "未知"
      },
      onlineStatus: {
        keys: ["R_GM_Online3", "R_GM_Online4", "R_GM_Online5"],
@@ -212,15 +252,18 @@
      }
    };
    // å¤„理GM原始数据
    // å¤„理GM原始数据(包含列号处理)
    const processGMData = (rawData) => {
      if (!rawData) return {};
      const processed = { ...rawData };
      // å¤„理核心状态字段
      Object.entries(gmStatusConfig.coreStatus).forEach(([key, map]) => {
      Object.entries(gmStatusConfig.coreStatus).forEach(([key, handler]) => {
        if (processed.hasOwnProperty(key)) {
          processed[key] = map[processed[key]] || processed[key];
          // åˆ—号字段使用函数处理,其他使用映射表
          processed[key] = typeof handler === 'function'
            ? handler(processed[key])
            : (handler[processed[key]] || processed[key]);
        }
      });
@@ -242,16 +285,13 @@
      return processed;
    };
    // å»¶è¿Ÿæ›´æ–°GM数据,避免高频刷新导致的闪烁
    const delayedUpdateGMData = (newRawData) => {
      if (updateTimer) clearTimeout(updateTimer);
      updateTimer = setTimeout(() => {
        // ä»…处理包含GM特征字段的数据
        if (newRawData && newRawData.R_GM_Status !== undefined) {
          gmData.value = processGMData(newRawData);
          
          // æ›´æ–°æ ·å¼
          nextTick(() => {
            const valueElements = document.getElementsByClassName("xzhi");
            for (let i = 0; i < valueElements.length; i++) {
@@ -268,13 +308,11 @@
    };
    onMounted(() => {
      // åˆå§‹åŠ è½½æ•°æ®
      const initialData = store.state.homedata;
      if (initialData && initialData.R_GM_Status !== undefined) {
        gmData.value = processGMData(initialData);
      }
      // ç›‘听数据变化,只处理GM数据
      const unwatch = watch(
        () => store.state.homedata,
        (newData) => {
@@ -285,7 +323,6 @@
        { deep: true }
      );
      // ç»„件卸载时清理资源
      onUnmounted(() => {
        unwatch();
        if (updateTimer) clearTimeout(updateTimer);
@@ -300,6 +337,7 @@
</script>
<style scoped>
/* åŽŸæœ‰æ ·å¼ä¿æŒä¸å˜ */
.ding {
  float: left;
  width: 20px;
@@ -436,5 +474,76 @@
  margin-left: 1.7%;
  border-radius: 10px;
}
</style>
/* æ–°å¢žï¼šGM堆垛机当前列样式 */
#gm-nowcolumn {
  width: 100%;
  height: 70px;
  float: left;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.5cqw;
  font-weight: bold;
  color: #00ff4c;
}
/* å¼‚常状态文字变色 */
#gm-nowcolumn.abnormal-column {
  color: red !important;
}
#gm-nowcolumn.abnormal-column span {
  color: red !important;
}
/* åˆ—容器样式 */
.gm-column-container {
  width: 95%;
  margin: 0 auto;
  position: relative;
  clear: both;
  padding-top: 15px;
}
/* æ–¹æ ¼å®¹å™¨æ ·å¼ */
.column-grid-container {
  width: 100%;
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: center;
  gap: 2px;
  position: relative;
  z-index: 2;
  margin-bottom: 10px;
  padding: 0 2px;
}
/* æ–¹æ ¼æ ·å¼ */
.column-grid-item {
  flex: 1;
  min-width: 24px;
  max-width: 60px;
  height: 30px;
  border: 1px solid #fff;
  border-radius: 8px 8px 0 0;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(8px, 1vw, 14px);
  box-sizing: border-box;
  transition: background-color 0.3s ease;
}
/* å½“前列高亮 */
.column-grid-item.active {
  background-color: green;
  font-weight: bold;
}
/* å¼‚常状态下当前列红色高亮 */
.pp-status-abnormal .column-grid-item.active {
  background-color: red !important;
}
</style>