<template>
  <div class="info-grid">
    <table class="info-table">
      <tbody>
        <tr>
          <td>项目编号</td>
          <td>{{ nodeInfo.projectNum }}</td>
        </tr>
        <tr>
          <td>项目名称</td>
          <td>{{ nodeInfo.projectName }}</td>
        </tr>
        <tr>
          <td>客户名称</td>
          <td>{{ nodeInfo.clientName }}</td>
        </tr>
        <tr>
          <td>项目类型</td>
          <td>{{ nodeInfo.difficultyType }}</td>
        </tr>
        <tr>
          <td>异常率</td>
          <td>{{ nodeInfo.abnormalRate }}</td>
        </tr>
        <tr>
          <td>产品线</td>
          <td>{{ nodeInfo.productLine }}</td>
        </tr>
        <tr>
          <td>产品组</td>
          <td>{{ nodeInfo.processSection }}</td>
        </tr>
        <tr>
          <td>方案管理人</td>
          <td>{{ nodeInfo.programManager }}</td>
        </tr>
        <tr>
          <td>方案制作部门</td>
          <td>{{ nodeInfo.programTeam }}</td>
        </tr>
        <tr>
          <td>参考项目</td>
          <td>{{ nodeInfo.referenceItem }}</td>
        </tr>
        <tr>
          <td>方案成交或关闭日期</td>
          <td>{{ nodeInfo.schemesFinishOrCloseTime }}</td>
        </tr>
        <tr>
          <td>营销实际签单数量</td>
          <td>{{ nodeInfo?.signNum }}</td>
        </tr>
      </tbody>
    </table>

    <table class="info-table">
      <tbody>
        <tr>
          <td>阶段</td>
          <td>{{ nodeInfo.stage }}</td>
        </tr>
        <tr>
          <td>领域</td>
          <td>{{ nodeInfo.domain }}</td>
        </tr>
        <tr>
          <td>方案关闭原因</td>
          <td>{{ nodeInfo.schemesClosingReasons }}</td>
        </tr>
        <tr>
          <td>预估图纸数</td>
          <td>{{ nodeInfo?.drawings }}</td>
        </tr>
        <tr>
          <td>预估零件数</td>
          <td>{{ nodeInfo.reuseDrawings }}</td>
        </tr>
        <tr>
          <td>io数量</td>
          <td>{{ nodeInfo.planIo }}</td>
        </tr>
        <tr>
          <td>外够件材质要求</td>
          <td>{{ nodeInfo.materialQuality }}</td>
        </tr>

        <tr>
          <td>输入输出方式</td>
          <td>{{ nodeInfo.putMode }}</td>
        </tr>
        <tr>
          <td>螺钉材质</td>
          <td>{{ nodeInfo.screwMaterial }}</td>
        </tr>
        <tr>
          <td>机型</td>
          <td>{{ nodeInfo.machineType }}</td>
        </tr>
        <tr>
          <td>订单量</td>
          <td>{{ nodeInfo?.orderQuantity }}</td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script lang="ts" setup>
import { queryProjectInfoApi } from '@/api/project/node';
import { ref, watch } from 'vue';

const props = defineProps({
  nodeId: {
    type: String,
    default: '',
  },
});

const nodeInfo = ref<any>({
  projectNum: '',
  projectName: '',
  stage: '',
  domain: '',
  clientName: '', //  客户名称
  difficultyType: '', // 项目类型
  abnormalRate: '', // 异常率
  productLine: '', // 产品线
  processSection: '', // 产品组
  programManager: '', // 方案管理人
  programTeam: '', // 方案制作部门
  referenceItem: '', // 参考项目
  schemesFinishOrCloseTime: '', // 方案成交或关闭日期
  signNum: '', // 营销实际签单数量

  schemesClosingReasons: '', // 方案关闭原因
  drawings: '', // 预估图纸数
  reuseDrawings: '', // 预估零件数
  part: '', // 预估零件数量
  planIo: '', // io数量
  materialQuality: '', // 外够件材质要求
  putMode: '', // 输入输出方式
  screwMaterial: '', // 螺钉材质
  machineType: '', // 机型
  orderQuantity: '', // 订单量
});

const getNodeDetailFun = async () => {
  const res: any = await queryProjectInfoApi({ projectId: props.nodeId });
  if (res.code === 200) {
    if (res.data) {
      nodeInfo.value = res.data;
    }
  }
};

watch(
  () => props.nodeId,
  () => {
    getNodeDetailFun();
  },
  { immediate: true }
);
</script>

<style scoped>
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-top: 20px;
}

.info-table {
  width: 100%;
  border-collapse: collapse;
}

.info-table tr {
  border-bottom: 1px solid #e9ecef;
  transition: background-color 0.2s;
}

.info-table tr:last-child {
  border-bottom: none;
}

.info-table tr:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

.info-table td {
  padding: 12px 8px;
  vertical-align: middle;
}

.info-table td:first-child {
  width: 150px;
  color: #8d99ae;
  font-weight: 500;
  font-size: 14px;
}

.info-table td:nth-child(2) {
  color: #2b2d42;
  font-weight: 500;
  font-size: 14px;
}

.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.status-3 {
  background-color: rgba(76, 201, 240, 0.1);
  color: #4cc9f0;
}

.status-1 {
  background-color: rgba(67, 97, 238, 0.1);
  color: #4361ee;
}

.status-5 {
  background-color: rgba(248, 37, 133, 0.1);
  color: #f72585;
}

.status-2 {
  background-color: rgba(248, 150, 30, 0.1);
  color: #f8961e;
}
.status-0 {
  background-color: rgba(248, 150, 30, 0.1);
  color: #8d99ae;
}

.empty-value {
  color: #8d99ae !important;
  font-style: italic;
}
</style>
