<template>
  <div class="pda-container">
    <div class="header-bar">
      <div class="header-left" @click="$router.back()">
        <i class="el-icon-arrow-left"></i>
        <span>生产订单入库</span>
      </div>
      <div class="header-right" @click="$router.push({ path: '/' })">首页</div>
    </div>

    <!-- 功能菜单 -->
    <div class="menu-grid">
      <div
        class="menu-item"
        v-for="(btn, index) in buttons"
        :key="index"
        :class="{ disabled: btn.disabled }"
        @click="handleButtonClick(btn)"
      >
        <div class="menu-icon" :class="btn.iconClass">
          <van-icon :name="btn.icon" size="24" />
        </div>
        <div class="menu-text">{{ btn.label }}</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      buttons: [
        {
          icon: "passed",
          label: "生产入库",
          iconClass: "qualified",
          to: "/productionInboundRegister",
          disabled: false,
        },
        {
          icon: "revoke",
          label: "生产退库",
          iconClass: "qualified",
          to: "/productionWithdrawalOrderList",
          disabled: false,
        },
      ],
    };
  },
  methods: {
    handleButtonClick(btn) {
      if (btn.disabled) {
        this.$message.warning("正在开发中，敬请期待...");
      } else {
        this.$router.push(btn.to);
      }
    },
  },
};
</script>

<style>
:root {
  --columns: 3;
  --button-size: calc(100vw / var(--columns) - 20px);
}

/* 头部栏 */
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: #17b3a3;
  color: white;
  height: 40px;
  min-height: 40px;
  max-height: 40px;
}

.header-left {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
}

.header-left i {
  margin-right: 8px;
  font-size: 18px;
}

.header-right {
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  padding: 20px;
  justify-content: center; /* 水平居中 */
  align-content: center; /* 垂直居中 */
  width: 100%; /* 确保占满容器宽度 */
}

.menu-item {
  background: white;
  border-radius: 12px;
  padding: 12px 6px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s;
  cursor: pointer;
}

.menu-item:active {
  transform: scale(0.95);
}

.menu-item.disabled {
  opacity: 0.6;
  position: relative;
}

.menu-item.disabled::after {
  content: "开发中";
  position: absolute;
  top: 8px;
  right: 8px;
  background: #ff9500;
  color: white;
  font-size: 8px;
  padding: 2px 4px;
  border-radius: 8px;
  font-weight: bold;
}

.menu-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 6px;
  color: white;
}

.menu-icon.purchase {
  background: linear-gradient(135deg, #17b3a3 0%, #1dc5ef 100%);
}

.menu-icon.inspection {
  background: linear-gradient(135deg, #17b3a3 0%, #1dc5ef 100%);
}

.menu-icon.qualified {
  background: linear-gradient(135deg, #17b3a3 0%, #1dc5ef 100%);
}

.menu-text {
  font-size: 10px;
  color: #333;
  font-weight: bold; /* 加粗字体 */
  white-space: nowrap; /* 防止文字换行 */
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
</style>
