<template>
  <div class="container">
    <div
      v-for="(item, index) in stepComponents"
      :key="index"
      :class="selectIndex == index ? 'operator active' : 'operator'"
      @click="setIndex(index)"
    >
      <div class="operatorText">{{ item.compentName }}</div>
      <div class="operatorIcon">
        <svg-icon :icon-class="item.compentType" size="45" />
      </div>
    </div>

    <ReportBreak ref="reportBreakRef" />
    <ReportWork ref="reportWorkRef" />
  </div>
</template>

<script lang="ts" setup>
import ReportBreak from "@/views/pro-operation/report-break/index.vue"; // ================ 报故
import ReportWork from "@/views/pro-operation/report-work/index.vue"; // = 报工
// ================ 报故
const reportBreakRef = ref<InstanceType<typeof ReportBreak>>();

// ================ 报工
const reportWorkRef = ref<InstanceType<typeof ReportWork>>();

const selectIndex = ref(0);
const setIndex = (index: number) => {
  selectIndex.value = index;
  switch (stepComponents.value[index].compentType) {
    case "baogu":
      reportBreakRef.value?.openReportBreakDrawer();
      break;
    case "gongweishangliao":
      break;
    case "liuzhuan":
      break;
    case "tuzhi":
      break;
    case "weiwai":
      break;
    case "baogong":
      reportWorkRef.value?.openReportWorkDrawer();
      break;
    default:
      break;
  }
};

const stepComponents = ref([
  {
    compentName: "叫料",
    compentType: "jiaoliao",
  },
  {
    compentName: "工位上料",
    compentType: "gongweishangliao",
  },
  {
    compentName: "物料流转",
    compentType: "liuzhuan",
  },
  {
    compentName: "图纸",
    compentType: "tuzhi",
  },
  {
    compentName: "委外",
    compentType: "weiwai",
  },
  {
    compentName: "报故",
    compentType: "baogu",
  },
  {
    compentName: "报工",
    compentType: "baogong",
  },
]);
</script>

<style lang="scss" scoped>
.container {
  width: 100%;
  font-weight: $Medium;

  .operator {
    width: 100%;
    height: 88px;
    border-radius: 16px;
    background-color: white;
    margin-top: 20px;
    display: flex;
    padding: 20px;
    justify-content: space-between;
    align-items: center;

    .operatorText {
      font-size: $f24;
    }

    .operatorIcon {
      font-weight: 800;
    }
  }
}

.active {
  background-color: #64bb5c !important;
  color: white;
}
</style>
