<template>
  <div class="rightFullPopUp" v-if="modelValue" @click="handleClose">
    <div class="container" @click.stop>
      <div class="headerTittle">物料采集</div>
      <div class="header">
        <div class="inputBox">
          <ScanCodeInput v-model="showSeqNo" />
        </div>
      </div>
      <el-scrollbar>
        <div class="body">
          <div
            class="infoBox"
            v-for="(item, index) in scanData"
            @click="setSelectIndex(index)"
            :key="index"
          >
            <div class="leftInfo">
              <div class="titleText">{{ item.materialName }}</div>
              <div class="describeText">{{ item.materialCode }}</div>
              <div class="describeText">规格:{{ item.spec }}</div>
              <!-- <div class="describeText">批次号:xxx</div>
              <div class="describeText">计划编号：xxx</div>
              <div class="describeText">订单编号：xxx</div>
              <div class="describeText">入库单号：xxx</div> -->
            </div>
            <div class="rightInput">
              <div></div>
              <div class="operate">
                <div class="describeText operateText">录入数量</div>
                <template v-if="selectIndex == index">
                  <NumberInput v-model="item.num" :max="item.needNum" />
                </template>
                <div v-else class="titleText">0</div>
              </div>
            </div>
          </div>
          <Empty v-if="scanData.length == 0" />
        </div>
      </el-scrollbar>
      <div class="bottomBtn">
        <el-button class="leftBtn" @click="handleClose">取消</el-button>
        <el-button class="rightBtn" @click="emits('submit')" type="primary"
          >确认</el-button
        >
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
const emits = defineEmits(["update:modelValue", "submit"]);
const props = defineProps({
  modelValue: {
    type: Boolean,
    default: false,
  },
  seqNo: {
    type: String,
    default: "",
  },
});
const selectIndex = ref();
const setSelectIndex = (index: number) => {
  selectIndex.value = index;
};
const scanData = inject("scanData");
const scanSum = ref(0);
const handleClose = () => {
  emits("update:modelValue", false);
};
const showSeqNo = computed(() => {
  return props.seqNo;
});
defineExpose({
  selectIndex,
});
</script>

<style lang="scss" scoped>
.header {
  @include flex;
  width: 100%;
  margin: $p10 0;

  .inputBox {
    width: 75%;
  }
}

.describeText {
  line-height: 25px !important;
}

.body {
  .infoBox {
    width: 100%;
    height: 200px;
    background-color: white;
    border-radius: 16px;
    display: flex;
    justify-content: space-between;
    padding: $p20;
    background-color: white;
    border-radius: 16px;
    margin-bottom: $f10;

    .leftInfo {
      display: flex;
      flex-direction: column;
      justify-content: space-between;

      div {
        text-align: left;
      }
    }

    .rightInput {
      display: flex;
      flex-direction: column;
      justify-content: space-between;

      .operate {
        .operateText {
          text-align: left;
        }
      }
    }
  }
}

.bottomBtn {
  width: 100%;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: $p10 10% 0 10%;

  .leftBtn {
    height: 55px;
    width: 45%;
    border-radius: 16px;
    font-size: $f20;
    color: #0a59f7;
    background-color: #00000015;
    border: 0px;
  }

  .rightBtn {
    height: 55px;
    width: 45%;
    border-radius: 16px;
    font-size: $f20;
    color: white;
  }
}
</style>
