<script setup lang="ts">
const props = defineProps({
  idCodeList: {
    type: Array,
    default: () => []
  }
})
</script>

<template>
  <el-popover
      title="已关联的追溯码产品标识码："
      placement="bottom-start"
      trigger="hover"
      width="218px"
      popper-class="id-code-popper"
      style="max-height: 221px"
  >
    <template #reference>
      <div class="id-code-panel">
        <div class="code" v-if="props.idCodeList.length >0">{{props.idCodeList[0]}}</div>
        <div class="number" v-if="props.idCodeList.length >1">
          +{{props.idCodeList.length-1}}
        </div>
      </div>
    </template>
    <template #default>
      <div class="id-code-detail">
        <div class="item" v-for="(item,index) in props.idCodeList" :key="index">
          {{index+1}}.{{item}}
        </div>
      </div>
    </template>
  </el-popover>

</template>

<style scoped lang="scss">
.id-code-panel{
  display: flex;
  .number{
    margin-left: 10px;
    color: #4D6DE4;
  }
}
.id-code-detail{
  .item{
    height: 35px;
    line-height: 35px;
    border-bottom: 1px  solid #DCDFE6;
    padding-left: 24px;
    &:last-child{
      border-bottom: none;
    }
  }
}
</style>