<template>
  <div class="midPopUp" v-if="modelValue">
    <div class="container">
      <div class="headerTittle">{{ title }}</div>
      <el-scrollbar style="padding: 0 20px">
        <div class="infoBox" v-if="title == '绑定确认'" v-for="(item, index) in selectedItem" :key="index">
          <div>
            料箱名称：
            <div>{{ item.name }}</div>
          </div>

          <div>
            料箱编号：
            <div>{{ item.code }}</div>
          </div>
        </div>
        <div class="infoBox" v-if="title == '确认出库'">
          <div>
            料箱名称：
            <div>{{ selectedIndexItem.name }}</div>
          </div>

          <div>
            料箱编号：
            <div>{{ selectedIndexItem.code }}</div>
          </div>
        </div>
      </el-scrollbar>
      <div class="bottomBtn">
        <el-button class="leftBtn" @click="handleClose">取消</el-button>
        <el-button class="rightBtn" @click="emits('submit')" type="primary">{{
          title == "绑定确认" ? "绑定" : "出库"
        }}</el-button>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
const props = defineProps({
  modelValue: {
    type: Boolean,
    default: 0,
  },
  title: {
    type: String,
    default: "",
  },
  outboundIndex: {
    type: Number,
  },
});
const emits = defineEmits(["update:modelValue"]);
const materialData = inject("materialData");
//显示绑定
const selectedItem = computed(() =>
  materialData.value.filter((item) => item.selected == true)
);
//显示出库
const selectedIndexItem = computed(
  () => materialData.value[props.outboundIndex]
);
const handleClose = () => emits("update:modelValue", false);
</script>

<style lang="scss" scoped>
.midPopUp {
  z-index: 4;
}

.container {
  background-color: #f1f3f5;
}

.infoBox {
  width: 100%;
  height: 80px;
  background-color: white;
  border-radius: 16px;
  margin-bottom: $p10;
  padding: 20px;
  display: flex;
  justify-content: space-evenly;
}

.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: black;
    background-color: #00000015;
    border: 0px;
  }

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