leiqunqing
2026-01-19 ba8aa925e7901381ceb394adb53eca8723d1c4c5
´úÂë¹ÜÀí/WIDESEAWCS_Client/src/views/Home.vue
@@ -1,24 +1,1094 @@
<template>
  <div class="title"></div>
  <div class="container">
    <!-- å·¦ä¾§åŒºåŸŸ - æ— ä»»ä½•标题标注 -->
    <div class="left-area">
      <div class="left-top">
        <!-- æŒ‰é’®+信号 æ¨ªå‘排列容器 -->
        <div class="btn-signal-group">
          <!-- æŒ‰é’®ç»„ - ä¿®æ”¹ä¸ºä¸Šä¸‹æŽ’列 -->
          <div class="btn-group">
            <button
              class="btn"
              :class="isPLCStarted ? 'stop-btn' : 'start-btn'"
              @click="handleToggle"
            >
              <i class="icon" :class="isPLCStarted ? 'icon-stop' : 'icon-start'"></i>
              {{ isPLCStarted ? "关闭" : "启动" }}
            </button>
            <button
              class="btn"
              :class="isPLCPaused ? 'resume-btn' : 'pause-btn'"
              @click="handlePauseToggle"
              :disabled="!isPLCStarted"
            >
              <i class="icon" :class="isPLCPaused ? 'icon-resume' : 'icon-pause'"></i>
              {{ isPLCPaused ? "恢复" : "暂停" }}
            </button>
          </div>
          <!-- ä¿¡å·ç¯ç»„ å ä¸¤ä¸ªæŒ‰é’®å®½åº¦ + æ•´ä½“放大 -->
          <div class="signal-status">
            <div class="signal-item" v-for="(signal, index) in signalStates" :key="index">
              <div
                class="signal-light"
                :class="signal ? 'signal-active' : 'signal-inactive'"
              >
                <div class="signal-light-inner"></div>
              </div>
              <span class="signal-label">{{ signalLabels[index] }}</span>
            </div>
          </div>
        </div>
      </div>
      <div class="left-bottom">
        <div class="form-row finished-product-row">
          <span class="label">成品编号:</span>
          <input type="text" class="input-box" v-model="finishedProduct" disabled />
        </div>
        <div class="parts-list">
          <div
            class="form-row part-item"
            v-for="(item, index) in leftPartCodes"
            :key="index"
          >
            <span class="label">零件{{ index + 1 }}:</span>
            <input
              type="text"
              class="input-box"
              v-model="leftPartCodes[index]"
              disabled
            />
            <label class="checkbox-container">
              <input
                type="checkbox"
                class="part-checkbox"
                v-model="leftPartChecked[index]"
                @change="handlePartCheck(index)"
              />
              <span class="checkmark"></span>
              <span class="checkbox-label">{{
                leftPartChecked[index] ? "扫码" : "不扫"
              }}</span>
            </label>
          </div>
        </div>
      </div>
    </div>
    <!-- å³ä¾§åŒºåŸŸ - æ— ä»»ä½•标题标注 ã€å·²åˆ é™¤æ¸…空+保存按钮】 -->
    <div class="right-area">
      <div class="right-top">
        <div class="form-row">
          <span class="label">录入框:</span>
          <!-- âœ… åªä¿ç•™çº¯å½•入框,清空/保存按钮已删除 -->
          <input type="text" class="input-box" v-model="rightTopInput" />
        </div>
      </div>
      <div class="right-bottom">
        <div class="form-row tooling-board-row">
          <span class="short-label">工装板编号:</span>
          <input
            type="text"
            class="input-box short-input"
            v-model="toolingBoardNo"
            placeholder="请输入工装板编号"
          />
          <button class="btn clear-btn" @click="clearToolingBoardNo">
            <i class="icon icon-clear"></i>清除
          </button>
          <button class="btn save-btn" @click="saveToolingBoardNo">
            <i class="icon icon-submit"></i>提交
          </button>
        </div>
        <div class="parts-list">
          <div class="form-row part-item finished-product-row">
            <span class="label">成品编号:</span>
            <input
              type="text"
              class="input-box"
              v-model="finishedProductCode"
              placeholder="请输入成品编号"
            />
            <button class="btn clear-btn" @click="clearFinishedProductCode">
              <i class="icon icon-clear"></i>清除
            </button>
          </div>
          <div
            class="form-row part-item"
            v-for="(item, index) in rightPartCodes"
            :key="index"
          >
            <span class="label">零件{{ index + 1 }}:</span>
            <input
              type="text"
              class="input-box"
              v-model="rightPartCodes[index]"
              placeholder="请输入零件编号"
            />
            <button class="btn clear-btn" @click="clearRightPart(index)">
              <i class="icon icon-clear"></i>清除
            </button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { ref, reactive } from 'vue'
import { ref, onMounted, onUnmounted, watch, computed } from "vue";
import axios from "axios";
export default {
  setup() {
    return {
    // åŸºç¡€æ•°æ®å®šä¹‰ - 1:1精准对接后端 æˆå“ç¼–号+零件编号 æ— å†—余兼容
    const finishedProduct = ref(""); // å·¦ä¾§æˆå“ç¼–号(GetLeftInitialData接口返回)
    const finishedProductId = ref("");
    const rightTopInput = ref("");
    const leftPartCodes = ref(Array(10).fill("")); // å·¦ä¾§é›¶ä»¶ç¼–号数组
    const rightPartCodes = ref(Array(10).fill("")); // å³ä¾§é›¶ä»¶ç¼–号数组
    const leftPartChecked = ref(Array(10).fill(false));
    const toolingBoardNo = ref("");
    const fillIndex = ref(-1);
    const leftPartIds = ref(Array(10).fill(""));
    const finishedProductCode = ref(""); // å³ä¾§æˆå“ç¼–号(工装板接口返回)
    }
  }
}
    // PLC状态
    const isPLCStarted = ref(false);
    const isPLCPaused = ref(false);
    // ä¿¡å·ç›¸å…³
    const signalStates = ref([false, false, false, false, false]);
    const signalLabels = ref([
      "心跳信号",
      "急停信号",
      "自动运行信号",
      "在线模式信号",
      "故障信号",
    ]);
    // å®šæ—¶è½®è¯¢æ ¸å¿ƒé…ç½®
    let pollingTimer = null;
    const pollingInterval = 5000;
    let checkDebounceTimer = null;
    let destroyDelayTimer = null;
    const destroyDelayTime = 500; // âœ… æ ¸å¿ƒï¼šå¡«å……+清空 éƒ½å»¶è¿Ÿ500毫秒
    let boardCodeDebounceTimer = null;
    // âœ… æ–°å¢žï¼šè‡ªåŠ¨æäº¤é˜²æŠ–å®šæ—¶å™¨ï¼Œé˜²æ­¢é‡å¤æäº¤
    let autoSubmitDebounceTimer = null;
    // âœ… æ–°å¢žï¼šæäº¤é”ï¼Œé˜²æ­¢æ— å‹¾é€‰æ—¶é‡å¤è§¦å‘提交
    let submitLock = ref(false);
    // âœ… âœ… âœ… æ ¸å¿ƒæ–°å¢ž1:计算属性 - å®žæ—¶ç»Ÿè®¡å·¦ä¾§å‹¾é€‰çš„复选框数量 (自动更新)
    const checkedCount = computed(() => {
      // ç»Ÿè®¡leftPartChecked数组中为true的数量
      return leftPartChecked.value.filter((checked) => checked === true).length;
    });
    // âœ… âœ… âœ… æ ¸å¿ƒæ–°å¢ž2:计算属性 - å®žæ—¶ç»Ÿè®¡å³ä¾§å·²å¡«å……的零件数量 (自动更新)
    const filledPartCount = computed(() => {
      // ç»Ÿè®¡rightPartCodes数组中有值(非空)的零件数量
      return rightPartCodes.value.filter((code) => code.trim() !== "").length;
    });
    // âœ… èŽ·å–å·¦ä¾§åˆå§‹æ•°æ® - å¯¹æŽ¥ /api/scanStation/GetLeftInitialData
    const fetchLeftInitialData = async () => {
      try {
        console.log("正在获取左侧初始数据(成品编号+零件编号+勾选状态+零件ID)...");
        const response = await axios.get("/api/scanStation/GetLeftInitialData", {
          timeout: 5000,
        });
        const resData = response.data;
        const isSuccess = resData.Status === true || resData.status === true;
        if (isSuccess) {
          const data = resData.Data || resData.data || {};
          if (data.finishedProductId) finishedProductId.value = data.finishedProductId;
          if (data.finishedProduct) finishedProduct.value = data.finishedProduct;
          // èµ‹å€¼å·¦ä¾§é›¶ä»¶ç¼–号
          if (Array.isArray(data.leftPartCodes) && data.leftPartCodes.length >= 10) {
            for (let i = 0; i < 10; i++) {
              leftPartCodes.value[i] = data.leftPartCodes[i] || "";
              leftPartIds.value[i] = data.leftPartIds?.[i] || "";
            }
          }
          // èµ‹å€¼å‹¾é€‰çŠ¶æ€
          if (Array.isArray(data.leftPartChecked) && data.leftPartChecked.length >= 10) {
            for (let i = 0; i < 10; i++) {
              leftPartChecked.value[i] = !!data.leftPartChecked[i];
            }
          }
        }
      } catch (error) {
        console.error("获取左侧初始数据失败:", error);
      }
    };
    // âœ… èŽ·å–ä¿¡å·+PLC状态
    const fetchSignalAndPLCStates = async () => {
      try {
        const response = await axios.get("/api/scanStation/GetSignalStates", {
          timeout: 5000,
        });
        const resData = response.data;
        const isSuccess = resData.Status === true || resData.status === true;
        if (isSuccess) {
          const data = resData.Data || resData.data || {};
          const newSignalStates = data.signalStates || [];
          for (let i = 0; i < 5; i++) signalStates.value[i] = newSignalStates[i] ?? false;
          const plcStatus = data.plcStatus || data.plc_status || {};
          isPLCStarted.value = plcStatus.isStarted ?? isPLCStarted.value;
          // âœ… ä¿®å¤BUG:原代码是 isPLCStarted.value å¯¼è‡´æš‚停状态赋值错误
          isPLCPaused.value = plcStatus.isPaused ?? isPLCPaused.value;
        }
      } catch (error) {
        console.error("获取信号和PLC状态失败:", error);
      }
    };
    // âœ… ã€æ ¸å¿ƒä¿®æ”¹ã€‘工装板查询接口 - æœ‰æ•°æ®å°±å¡«å……,无数据/失败 å®Œå…¨ä¿ç•™åŽŸæœ‰å†…å®¹ï¼Œä¸åšä»»ä½•æ¸…ç©ºæ“ä½œ
    const fetchProductAndPartsByBoardCode = async (boardCode) => {
      if (!boardCode.trim()) return;
      try {
        console.log(`工装板编号变更,请求数据:${boardCode}`);
        const response = await axios.get(
          "/api/boxingDetail/GetProductAndPartsByBoardNo",
          {
            params: { palletCode: boardCode.trim() },
            timeout: 5000,
          }
        );
        const resData = response.data;
        const isSuccess = resData.Status === true || resData.status === true;
        // âœ… åªæœ‰ã€æŽ¥å£æˆåŠŸ+有返回数据】的时候,才执行赋值覆盖
        if (isSuccess) {
          const data = resData.Data || resData.data || {};
          // æœ‰æˆå“ç¼–号就赋值,没有就不操作
          if (data.finishedProductCode) {
            finishedProductCode.value = data.finishedProductCode;
          }
          // æœ‰é›¶ä»¶åˆ—表就填充,没有就不操作
          const partsList = Array.isArray(data.partsList) ? data.partsList : [];
          if (partsList.length > 0) {
            for (let i = 0; i < 10; i++) {
              if (partsList[i]) {
                rightPartCodes.value[i] = partsList[i];
              }
            }
          }
          console.log("✅ å·¥è£…板查询成功,成品编号+零件编号填充完成");
        } else {
          // âœ… æ— å¯¹åº”数据:只弹提示,不清空任何内容
          alert(
            "获取数据失败:" + (resData.Message || resData.message || "无对应工装板数据")
          );
        }
      } catch (error) {
        // âœ… è¯·æ±‚失败:只弹提示,不清空任何内容
        alert("工装板数据请求失败,请检查网络或接口!");
        console.error("工装板接口请求失败:", error);
      } finally {
        boardCodeDebounceTimer = null;
      }
    };
    // å¯åЍ/停止定时轮询
    const startPolling = () => {
      if (pollingTimer) clearInterval(pollingTimer);
      fetchSignalAndPLCStates();
      pollingTimer = setInterval(fetchSignalAndPLCStates, pollingInterval);
    };
    const stopPolling = () => {
      if (pollingTimer) clearInterval(pollingTimer);
      pollingTimer = null;
    };
    // PLC启动/关闭逻辑
    const handleToggle = async () => {
      try {
        const response = await axios.get("/api/scanStation/StartPLC", {
          params: { isStop: isPLCStarted.value },
          timeout: 5000,
        });
        const resData = response.data;
        const isSuccess = resData.Status === true || resData.status === true;
        if (isSuccess) {
          isPLCStarted.value = !isPLCStarted.value;
          isPLCPaused.value = false;
          fetchSignalAndPLCStates();
        } else {
          alert(
            resData.Message ||
              resData.message ||
              (isPLCStarted.value ? "关闭失败" : "启动失败")
          );
        }
      } catch (error) {
        alert(isPLCStarted.value ? "关闭PLC失败" : "启动PLC失败");
        console.error("PLC启停失败:", error);
      }
    };
    // PLC暂停/恢复逻辑
    const handlePauseToggle = async () => {
      try {
        const response = await axios.get("/api/scanStation/PausePLC", {
          params: { isPause: !isPLCPaused.value },
          timeout: 5000,
        });
        const resData = response.data;
        const isSuccess = resData.Status === true || resData.status === true;
        if (isSuccess) {
          isPLCPaused.value = !isPLCPaused.value;
          fetchSignalAndPLCStates();
        } else {
          alert(
            resData.Message ||
              resData.message ||
              (isPLCPaused.value ? "恢复失败" : "暂停失败")
          );
        }
      } catch (error) {
        alert(isPLCPaused.value ? "恢复PLC失败" : "暂停PLC失败");
        console.error("PLC暂停恢复失败:", error);
      }
    };
    // é›¶ä»¶å‹¾é€‰çŠ¶æ€å˜æ›´å¤„ç†
    const handlePartCheck = async (index) => {
      const isChecked = leftPartChecked.value[index];
      const partCode = leftPartCodes.value[index];
      const partId = leftPartIds.value[index];
      if (!finishedProductId.value) {
        alert("成品ID不存在,无法更新零件扫码状态!");
        leftPartChecked.value[index] = !isChecked;
        return;
      }
      if (!partId) {
        alert(`零件${index + 1}数据库ID不存在,无法更新扫码状态!`);
        leftPartChecked.value[index] = !isChecked;
        return;
      }
      if (!partCode.trim()) {
        alert(`零件${index + 1}编号为空,无法更新扫码状态!`);
        leftPartChecked.value[index] = !isChecked;
        return;
      }
      if (checkDebounceTimer) clearTimeout(checkDebounceTimer);
      checkDebounceTimer = setTimeout(async () => {
        try {
          const response = await axios.post(
            "/api/scanStation/UpdatePartScannedStatus",
            { Id: partId, IsScanned: isChecked ? 1 : 0 },
            { timeout: 5000 }
          );
          const resData = response.data;
          const isSuccess = resData.Status === true || resData.status === true;
          if (isSuccess) {
            console.log(`零件${index + 1}扫码状态更新成功`);
            // âœ… å‹¾é€‰çŠ¶æ€å˜åŒ–æ—¶ï¼Œé‡ç½®æäº¤é”
            submitLock.value = false;
          } else {
            leftPartChecked.value[index] = !isChecked;
            alert(
              `零件${index + 1}状态更新失败:${
                resData.Message || resData.message || "未知错误"
              }`
            );
          }
        } catch (error) {
          leftPartChecked.value[index] = !isChecked;
          alert(`零件${index + 1}状态更新请求失败,请检查网络或接口!`);
          console.error(`更新零件${index + 1}扫码状态失败:`, error);
        } finally {
          checkDebounceTimer = null;
        }
      }, 500);
    };
    // âœ… æ ¸å¿ƒä¿®æ”¹ï¼šå»¶è¿Ÿ0.5秒填充 + å»¶è¿Ÿ0.5秒清空 åŒæ­¥æ‰§è¡Œ æ— éœ€æ‰‹åŠ¨æŒ‰é’®
    const fillContent = () => {
      if (!rightTopInput.value.trim()) return;
      const inputValue = rightTopInput.value.trim();
      // æ¸…除旧定时器,防止重复执行
      if (destroyDelayTimer) clearTimeout(destroyDelayTimer);
      // ç»Ÿä¸€å»¶è¿Ÿ500ms执行【填充+清空】
      destroyDelayTimer = setTimeout(() => {
        if (!toolingBoardNo.value.trim()) {
          toolingBoardNo.value = inputValue;
        } else if (!finishedProductCode.value.trim()) {
          finishedProductCode.value = inputValue;
        } else if (fillIndex.value < 10) {
          rightPartCodes.value[fillIndex.value] = inputValue;
          fillIndex.value++;
        } else {
          alert("工装板编号、成品编号和零件1-10已全部填充完成,无法继续录入!");
          rightTopInput.value = "";
          destroyDelayTimer = null;
          return;
        }
        // å¡«å……完成后 è‡ªåŠ¨æ¸…ç©ºå½•å…¥æ¡†
        rightTopInput.value = "";
        destroyDelayTimer = null;
      }, destroyDelayTime);
    };
    // âœ… ç›‘听录入框内容变化自动触发填充逻辑
    watch(
      rightTopInput,
      (newVal) => {
        if (newVal.trim()) fillContent();
      },
      { immediate: false }
    );
    // ç›‘听工装板编号变化查询数据
    watch(
      toolingBoardNo,
      (newVal) => {
        const boardCode = newVal.trim();
        if (boardCode) {
          if (boardCodeDebounceTimer) clearTimeout(boardCodeDebounceTimer);
          boardCodeDebounceTimer = setTimeout(
            () => fetchProductAndPartsByBoardCode(boardCode),
            300
          );
        } else {
          if (boardCodeDebounceTimer) clearTimeout(boardCodeDebounceTimer);
        }
      },
      { immediate: false }
    );
    // å³ä¾§é¡µé¢æ“ä½œæ–¹æ³• (已删除清空/保存录入框的方法,无冗余)
    const clearToolingBoardNo = () => (toolingBoardNo.value = "");
    const clearRightPart = (index) => (rightPartCodes.value[index] = "");
    const clearFinishedProductCode = () => (finishedProductCode.value = "");
    // æäº¤å·¥è£…板数据到后端
    const saveToolingBoardNo = async () => {
      if (!toolingBoardNo.value.trim()) {
        alert("工装板编号不能为空,请输入后再提交!");
        return;
      }
      if (!finishedProductCode.value.trim()) {
        alert("成品编号不能为空,请输入后再提交!");
        return;
      }
      try {
        const submitData = {
          toolingBoardNo: toolingBoardNo.value.trim(),
          finishedProductCode: finishedProductCode.value.trim(),
          partsList: rightPartCodes.value.map((item) => item.trim()),
        };
        console.log("✅ æäº¤å·¥è£…板数据:", submitData);
        const response = await axios.post(
          "/api/boxingDetail/SaveToolingBoardNo",
          submitData,
          { timeout: 5000 }
        );
        const resData = response.data;
        const isSuccess = resData.Status === true || resData.status === true;
        if (isSuccess) {
          alert("✅ æäº¤æˆåŠŸï¼");
          toolingBoardNo.value = "";
          finishedProductCode.value = "";
          rightPartCodes.value = Array(10).fill("");
          rightTopInput.value = "";
          fillIndex.value = -1;
          // âœ… æäº¤æˆåŠŸåŽï¼Œé‡ç½®æäº¤é”
          submitLock.value = false;
        } else {
          alert("提交失败:" + (resData.Message || resData.message || "未知错误"));
        }
      } catch (error) {
        alert("提交请求失败,请检查网络或接口!");
        console.error("提交接口失败:", error);
        // âœ… è¯·æ±‚失败也重置锁
        submitLock.value = false;
      }
    };
    // âœ… âœ… âœ… æ ¸å¿ƒå‡çº§ï¼šè‡ªåŠ¨æäº¤åˆ¤æ–­é€»è¾‘ - æ–°å¢žæ— å‹¾é€‰æ—¶æˆå“ç¼–号填充即提交
    const checkAutoSubmit = () => {
      // é˜²æŠ–:防止短时间内多次触发提交
      if (autoSubmitDebounceTimer) clearTimeout(autoSubmitDebounceTimer);
      autoSubmitDebounceTimer = setTimeout(() => {
        const needCheckNum = checkedCount.value; // å·¦ä¾§å‹¾é€‰çš„æ•°é‡
        const filledNum = filledPartCount.value; // å³ä¾§å¡«å……的零件数量
        const hasBoardNo = toolingBoardNo.value.trim() !== ""; // å·¥è£…板有值
        const hasProductCode = finishedProductCode.value.trim() !== ""; // æˆå“æœ‰å€¼
        console.log(`✅ è‡ªåŠ¨æäº¤æ ¡éªŒï¼šå·¦ä¾§å‹¾é€‰${needCheckNum}个,右侧填充${filledNum}个`);
        // åˆ†æ”¯1:左侧有勾选 â†’ åŽŸæœ‰é€»è¾‘ï¼šé›¶ä»¶å¡«å……æ•°â‰¥å‹¾é€‰æ•° æ‰æäº¤
        if (needCheckNum > 0) {
          if (hasBoardNo && hasProductCode && filledNum >= needCheckNum) {
            console.log("✅ æ»¡è¶³å‹¾é€‰æ•°é‡æ¡ä»¶ï¼Œæ‰§è¡Œè‡ªåŠ¨æäº¤ï¼");
            saveToolingBoardNo();
          }
        }
        // åˆ†æ”¯2:左侧无勾选 â†’ æ–°å¢žé€»è¾‘:工装板+成品都有值 å°±æäº¤ (加锁防重复)
        else {
          if (hasBoardNo && hasProductCode && !submitLock.value) {
            console.log("✅ å·¦ä¾§æ— å‹¾é€‰ï¼Œæˆå“ç¼–号填充完成,执行自动提交!");
            submitLock.value = true; // åŠ é”é˜²æ­¢é‡å¤æäº¤
            saveToolingBoardNo();
          }
        }
        autoSubmitDebounceTimer = null;
      }, 300);
    };
    // âœ… âœ… âœ… æ ¸å¿ƒæ–°å¢ž4:监听关键数据变化,触发自动提交校验
    watch(
      [checkedCount, filledPartCount, toolingBoardNo, finishedProductCode],
      () => {
        checkAutoSubmit();
      },
      { deep: true, immediate: false }
    );
    // è‡ªåŠ¨æ£€æµ‹å¡«å……ç´¢å¼•é€»è¾‘
    const detectFillIndex = () => {
      if (!toolingBoardNo.value.trim() || !finishedProductCode.value.trim()) {
        fillIndex.value = -1;
        return;
      }
      for (let i = 0; i < 10; i++) {
        if (!rightPartCodes.value[i].trim()) {
          fillIndex.value = i;
          return;
        }
      }
      fillIndex.value = 10;
    };
    watch(
      [toolingBoardNo, finishedProductCode, () => [...rightPartCodes.value]],
      detectFillIndex,
      {
        immediate: true,
        deep: true,
      }
    );
    // é¡µé¢æŒ‚è½½/卸载生命周期
    onMounted(async () => {
      await fetchLeftInitialData();
      startPolling();
      detectFillIndex();
    });
    onUnmounted(() => {
      stopPolling();
      if (checkDebounceTimer) clearTimeout(checkDebounceTimer);
      if (destroyDelayTimer) clearTimeout(destroyDelayTimer);
      if (boardCodeDebounceTimer) clearTimeout(boardCodeDebounceTimer);
      if (autoSubmitDebounceTimer) clearTimeout(autoSubmitDebounceTimer);
    });
    return {
      finishedProduct,
      finishedProductId,
      rightTopInput,
      leftPartCodes,
      rightPartCodes,
      leftPartChecked,
      leftPartIds,
      toolingBoardNo,
      isPLCStarted,
      isPLCPaused,
      signalStates,
      signalLabels,
      finishedProductCode,
      handleToggle,
      handlePauseToggle,
      handlePartCheck,
      clearToolingBoardNo,
      saveToolingBoardNo,
      clearRightPart,
      clearFinishedProductCode,
    };
  },
};
</script>
<style scoped>
.title {
  line-height: 70vh;
  text-align: center;
  font-size: 28px;
  color: orange;
/* åŸºç¡€æ ·å¼é‡ç½®ä¸Žå…¨å±€æ ·å¼ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Microsoft Yahei", "PingFang SC", "Inter", sans-serif;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
</style>
*::-webkit-scrollbar {
  display: none;
}
body {
  background: linear-gradient(135deg, #f0f4f8 0%, #e9ecef 100%);
  min-height: 100vh;
  overflow: hidden;
  font-size: 14px;
}
/* å®¹å™¨æ ·å¼ - æ”¾å¤§ é—´è·åР宽 */
.container {
  display: flex;
  width: 100%;
  height: 100vh;
  margin: 0;
  gap: 15px;
  padding: 15px;
  overflow: hidden;
}
/* é¢æ¿é€šç”¨æ ·å¼ - ç»Ÿä¸€å†…边距 ç¡®ä¿å·¦å³å¯¹é½ */
.left-area,
.right-area {
  flex: 1;
  width: 50%;
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 18px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 15px;
  box-shadow: 0 6px 16px rgba(149, 157, 165, 0.15);
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
/* æŒ‰é’®+信号 æ¨ªå‘排列容器 - æ ¸å¿ƒå¸ƒå±€ */
.btn-signal-group {
  display: flex;
  align-items: center;
  gap: 20px;
  width: 100%;
}
.btn-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}
.signal-status {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 18px;
  flex-shrink: 0;
  padding: 0;
}
.left-top {
  background: #f8fafc;
  padding: 15px;
  border-radius: 12px;
  flex-shrink: 0;
  width: 100%;
}
.left-bottom,
.right-bottom {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  overflow: hidden !important;
}
.right-top {
  padding: 15px;
  background: #f8fafc;
  border-radius: 12px;
  flex-shrink: 0;
}
/* è¡¨å•行样式 - ç»Ÿä¸€é«˜åº¦å’Œé—´è· ç¡®ä¿å·¦å³å¯¹é½ */
.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
  padding: 6px 10px;
  border-radius: 8px;
  transition: all 0.2s ease;
  height: 48px;
  line-height: 48px;
  flex-shrink: 0;
  width: 100%;
}
.form-row:hover {
  background: #f8fafc;
}
.finished-product-row {
  background: #eff6ff;
  border-left: 4px solid #3b82f6;
}
.tooling-board-row {
  background: #f0fdf4;
  border-left: 4px solid #22c55e;
}
.part-item {
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 3px;
}
.part-item:last-child {
  border-bottom: none;
}
/* æ ‡ç­¾æ ·å¼ - ç»Ÿä¸€å®½åº¦ ç¡®ä¿å·¦å³å¯¹é½ */
.label {
  width: 90px;
  text-align: right;
  color: #334155;
  font-size: 15px;
  font-weight: 600;
  flex-shrink: 0;
}
.short-label {
  width: 110px;
  text-align: right;
  color: #334155;
  font-size: 15px;
  font-weight: 600;
  flex-shrink: 0;
}
/* è¾“入框样式 - ç»Ÿä¸€å°ºå¯¸ ç¡®ä¿å·¦å³å¯¹é½ */
.input-box {
  flex: 1;
  min-width: 100px;
  height: 42px;
  padding: 0 15px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  outline: none;
  font-size: 15px;
  transition: all 0.2s ease;
  background-color: #ffffff;
}
.short-input {
  width: 150px !important;
  flex: none !important;
}
.input-box:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
.input-box:disabled {
  background-color: #f1f5f9;
  color: #64748b;
  cursor: not-allowed;
}
.input-box::placeholder {
  color: #94a3b8;
  font-size: 14px;
}
/* æŒ‰é’®æ ·å¼ - å›ºå®šå®½åº¦ ä¸å˜ */
.btn {
  width: 120px;
  height: 42px;
  padding: 0 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
}
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}
.btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: all 0.5s ease;
}
.btn:hover::after {
  left: 100%;
}
/* å›¾æ ‡æ ·å¼ - å›¾æ ‡æ”¾å¤§ */
.icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}
.icon-start {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E");
}
.icon-stop {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M6 6h12v12H6z'/%3E%3C/svg%3E");
}
.icon-pause {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M6 19h4V5H6v14zm8-14v14h4V5h-4z'/%3E%3C/svg%3E");
}
.icon-resume {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M11 5L6 9H2v6h4l5 4V5zm7 0v14c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2z'/%3E%3C/svg%3E");
}
.icon-clear {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z'/%3E%3C/svg%3E");
}
.icon-submit {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M2.01 21L15 13.4 23 21V5H2.01V21zM17 15l-5-5-5 5V7h10v8z'/%3E%3C/svg%3E");
}
/* æŒ‰é’®ç±»åž‹æ ·å¼ - ä¸å˜ */
.start-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
}
.start-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(16, 185, 129, 0.2);
}
.stop-btn {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
}
.stop-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(239, 68, 68, 0.2);
}
.pause-btn {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #fff;
}
.pause-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(245, 158, 11, 0.2);
}
.resume-btn {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  color: #fff;
}
.resume-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(139, 92, 246, 0.2);
}
.clear-btn {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  padding: 0 12px;
}
.clear-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(239, 68, 68, 0.15);
}
.save-btn {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  padding: 0 12px;
}
.save-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(59, 130, 246, 0.15);
}
/* ä¿¡å·ç¯æ ·å¼ é†’目放大 */
.signal-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 60px;
}
.signal-label {
  font-size: 14px;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  text-align: center;
  font-weight: 600;
}
.signal-light {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.signal-light-inner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  opacity: 0.9;
  transition: all 0.3s ease;
}
.signal-active {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 0 18px rgba(16, 185, 129, 0.7);
  animation: pulse 2s infinite;
}
.signal-inactive {
  background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
}
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.8);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}
/* è‡ªå®šä¹‰å¤é€‰æ¡†æ ·å¼ - æ”¾å¤§ ç‚¹å‡»åŒºåŸŸæ›´å¤§ */
.checkbox-container {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 14px;
  color: #334155;
  flex-shrink: 0;
}
.part-checkbox {
  display: none;
}
.checkmark {
  width: 22px;
  height: 22px;
  background-color: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  transition: all 0.2s ease;
  position: relative;
}
.part-checkbox:checked ~ .checkmark {
  background-color: #3b82f6;
  border-color: #3b82f6;
}
.checkmark:after {
  content: "";
  position: absolute;
  display: none;
  left: 7px;
  top: 2px;
  width: 6px;
  height: 12px;
  border: solid white;
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}
.part-checkbox:checked ~ .checkmark:after {
  display: block;
}
.checkbox-label {
  font-size: 13px;
  color: #475569;
  width: 50px;
}
/* å“åº”式适配 */
@media (max-width: 1200px) {
  .container {
    flex-direction: column;
    height: auto;
  }
  .left-area,
  .right-area {
    width: 100%;
    flex: none;
  }
  .btn-signal-group {
    flex-direction: column;
    align-items: flex-start;
  }
  .signal-status {
    width: 100%;
    justify-content: flex-start;
  }
}
@media (max-width: 768px) {
  .form-row {
    flex-direction: column;
    align-items: flex-start;
    height: auto;
    line-height: normal;
  }
  .label,
  .short-label {
    width: 100%;
    text-align: left;
    margin-bottom: 6px;
  }
  .input-box {
    width: 100%;
  }
  .short-input {
    width: 100% !important;
  }
  .btn {
    width: 100%;
    margin-top: 6px;
  }
  .btn-group {
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }
}
</style>