<template>
  <div class="numCard">
    <div
      class="cardItem"
      v-for="(item, i) in sdlist"
      :key="i"
      :class="`card${item.ctype}`"
      style="width: 29%"
      @click="emits('numclick', item.pro)"
    >
      <span
        :class="item.children ? 'cursor' : ''"
        @click="item.show = !item.show"
      >
        {{ item.name }}
        <el-icon class="el-icon--right" v-if="item.children">
          <caret-bottom />
        </el-icon>
      </span>
      <span>{{ sddata[item.propnum || `${item.pro}num`] || 0 }}个</span>
      <span>{{ sddata[item.propmj || `${item.pro}mj`] || 0 }}亩</span>
      <div
        class="cardItem acard"
        :class="`card${i}`"
        v-for="child in item.children"
        :key="child.name"
        v-if="item.show"
      >
        <span>{{ child.name }}</span>
        <span>{{ sddata[child.propnum || `${child.pro}num`] || 0 }}个</span>
        <span>{{ sddata[child.propmj || `${child.pro}mj`] || 0 }}亩</span>
      </div>
    </div>
  </div>
</template>
<script setup>
defineProps({
  sddata: {
    type: Object,
    default: {},
  },
  sdlist: {
    type: Array,
    default: () => [],
  },
});
const emits = defineEmits("numclick");
</script>
<style  lang="scss" scoped>
.numCard {
  width: 100%;
  height: 120px;
  display: flex;
  // background-color: rgba(255, 192, 203, 0.272);
  flex-direction: row;
  align-items: center;
  justify-content: space-between;

  .cardItem {
    position: relative;
    // width: 230px;
    width: 200px;
    height: 85px;
    max-width: 200px;
    display: inline-block;
    margin: 0 10px;
    cursor: pointer;
    background: linear-gradient(
      180deg,
      rgba(30, 198, 149, 1) 0%,
      rgba(30, 198, 149, 1) 0%,
      rgba(51, 204, 204, 1) 100%,
      rgba(51, 204, 204, 1) 100%
    );
    border: none;
    border-radius: 4px;
    -moz-box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.349019607843137);
    -webkit-box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.349019607843137);
    box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.349019607843137);
    font-family: "Arial Negreta", "Arial Normal", "Arial";
    font-weight: 700;
    font-style: normal;
    font-size: 14px;
    color: #ffffff;
    // display: flex;
    flex-direction: column;
    justify-content: center;

    span {
      display: inline-block;
      width: 100%;
      height: calc(100% / 3);
      // background: #faebd78c;
      text-align: center;
      line-height: 28px;
    }
  }
  .acard {
    margin-top: 20px;
    z-index: 10;
  }
  .cardblue {
    background: linear-gradient(
      180deg,
      #02a5ee 0%,
      #02a5ed 0%,
      #0280b9 100%,
      #027fb7 100%
    );
  }

  .cardred {
    background: linear-gradient(
      180deg,
      rgba(244, 174, 149, 1) 0%,
      rgba(244, 174, 149, 1) 0%,
      rgba(226, 113, 140, 1) 100%,
      rgba(226, 113, 140, 1) 100%
    );
  }
  .cursor {
    cursor: pointer;
  }
  .el-icon--right {
    font-size: 20px;
    line-height: 28px;
  }
}
</style>