<script setup lang="ts">
import { Events } from "~/dim/event";
const props = defineProps<{
  presaleData: any;
}>();
const emit = defineEmits([Events.reset]);
import { SpuAttrDim } from "~/dim/spu";
onMounted(() => {});
async function copyToClipboard(code: string) {
  try {
    await navigator.clipboard.writeText(code); // 将内容写入剪贴板
    ElMessage.success("复制成功");
  } catch (err: any) {
    ElMessage.error("复制失败");
  }
}
</script>
<template>
  <ul class="restock-box">
    <li v-for="(item) in presaleData" :key="item.skuCode">
      <div class="img-wrap">
        <div class="img">
          <NuxtImg format="webp" :src="item.skuImageUrl" loading="lazy" placeholder="https://io.house-tk.com/hop/pro/other/images/cd6fddec6ee4f5be04d29a934a0c05a4" />
        </div>
        <div class="sku-info">
          <h3 @click="copyToClipboard(item.skuCode)">{{ item.skuCode }}
            <span>
              <NuxtImg src="https://io.house-tk.com/hop/pro/other/images/501820d1e24926c011df500216557cdb" loading="lazy" placeholder="https://io.house-tk.com/hop/pro/other/images/cd6fddec6ee4f5be04d29a934a0c05a4" />
            </span>
          </h3>
          <p v-if="item.cnName">{{ item.cnName }}</p>
          <div class="attr-info">
            <span v-for="(value, keys,index) in item.attr" :key="index">
              {{ value }}
            </span>
          </div>
        </div>
      </div>
      <div class="restock-wrap">
        <div class="info-number">
          <p>
            <NuxtImg src="https://io.house-tk.com/hop/pro/other/images/fbcb7016dfb0ccd16f1d17120ea48a16" loading="lazy" placeholder="https://io.house-tk.com/hop/pro/other/images/cd6fddec6ee4f5be04d29a934a0c05a4" />补货数量
          </p>
          <p>{{ item.stockIncoming }}</p>
        </div>
        <div class="info-info">
          <p>补货仓库：<span>{{ item.warehouseName }}</span></p>
          <p>预计到仓：<template v-if="item.leftDays==0">
              即将上架
            </template>
            <template v-else>
              {{ item.presaleTime }}&nbsp;({{ item.leftDays }}天)
            </template>
          </p>

        </div>
      </div>
    </li>
  </ul>
</template>
<style lang="scss">
.restock-drawer {
  .el-drawer__header {
    margin: 0;
    justify-content: space-between;
    font-size: 15px;
    font-weight: bold;
    color: #222222;
    padding: 18px 12px 15px !important;
    .el-drawer__close-btn {
      flex: unset;
      color: #999999;
      padding-right: 0;
    }
  }
  .el-drawer__body {
    padding: 0px 12px 12px 12px;
  }
}
</style>
<style lang="scss" scoped>
.restock-box {
  li {
    background: #ffffff;
    border-radius: 8px 8px 8px 8px;
    border: 1px solid #efefef;
    padding: 0 10px;
    & + li {
      margin-top: 12px;
    }
  }
  .img-wrap {
    padding: 10px 0;
    display: flex;
    align-items: center;
    .img {
      width: 72px;
      height: 72px;
      min-width: 72px;
      display: flex;
      align-items: center;
    }
    img {
      max-height: 100%;
      border-radius: 4px 4px 4px 4px;
      margin: 0 auto;
    }
    .sku-info {
      margin-left: 8px;
      h3 {
        font-size: 16px;
        color: #222222;
        line-height: 22px;
        margin-bottom: 2px;
        display: flex;
        align-items: center;
        span {
          margin-left: 10px;
          padding: 0px;
          border: none;
          width: 17px;
        }
      }
      p {
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        word-wrap: break-word;
        word-break: break-all;
      }
      .attr-info {
        display: flex;
        margin-top: 7px;
      }
      span {
        border-radius: 2px 2px 2px 2px;
        border: 1px solid #e7e7e7;
        height: 20px;
        line-height: 20px;
        font-size: 12px;
        color: #666666;
        margin-right: 8px;
        padding: 0 4px;
      }
    }
  }
  .restock-wrap {
    padding: 8px 0;
    border-top: 1px dashed #eaeaea;
    display: flex;
  }
  .info-number {
    padding-right: 15px;
    padding-left: 10px;
    border-right: 1px dashed #eaeaea;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-top: 2px;
    p {
      display: flex;
      align-items: center;
      font-size: 14px;
      color: #444444;
      min-width: max-content;
      img {
        margin-right: 4px;
        width: 20px;
        height: 20px;
      }
      &:last-child {
        padding-left: 24px;
        font-size: 20px;
        color: #ff004f;
        line-height: 24px;
        letter-spacing: 1px;
      }
    }
  }
  .info-info {
    padding: 0 0px 0 18px;
    font-size: 14px;
    color: #777777;
    display: flex;
    justify-content: center;
    flex-direction: column;
    p {
      line-height: 20px;
      span {
        color: #444444;
      }
    }
  }
}
</style>
  