<template>
  <div class="demo health-status-charts" style="height: 90%">
    <div class="list-item-header item-warp" :style="{ flex: listKeys.length }">
      <template v-for="(h, indexh) in listKeys" :key="indexh">
        <div class="item-td" :style="{ width: 'calc(100% / ' + listKeys.length + ')' }">{{ listKeysHeader[h] }}</div>
      </template>
    </div>
    <vue3ScrollSeamless class="scroll-wrap" :class-options="classOptions" :data-list="list">
      <div v-for="(item, index) in list" :key="index" class="list-item">
        <div class="list-item-content">
          <div class="list-item-boday item-warp" :style="{ flex: listKeys.length }">
            <template v-for="(b, indexb) in listKeys" :key="indexb">
              <div class="item-td" :class="item.status == 1 ? 'td-title' : 'td-warn'" :style="{ width: 'calc(100% / ' + listKeys.length + ')' }">
                <span v-if="b != 'status'">
                  {{ item[b] }}
                </span>
                <el-icon v-else>
                  <Bell></Bell>
                </el-icon>
              </div>
            </template>
          </div>
        </div>
      </div>
    </vue3ScrollSeamless>
  </div>
  <!-- </div> -->
</template>

<script setup>
import { ref, onMounted, onUnmounted, computed, reactive } from 'vue';
import { vue3ScrollSeamless } from 'vue3-scroll-seamless';
const props = defineProps({
  //   items: {
  //     type: Array,
  //     default: () => [],
  //   },
});

let list = reactive([
  { diseaseType: '瘟疫', incidenceRate: '23%', coverage: '84%', status: 1 },
  { diseaseType: '蓝耳病', incidenceRate: '19%', coverage: '88%', status: 1 },
  { diseaseType: '口蹄疫', incidenceRate: '45%', coverage: '68%', status: 1 },
  { diseaseType: '链球病菌', incidenceRate: '35%', coverage: '88%', status: 1 },
  { diseaseType: '炎症', incidenceRate: '8%', coverage: '98%', status: 1 },
  { diseaseType: '寄生虫', incidenceRate: '11%', coverage: '99%', status: 1 },
]);

const listKeys = reactive(['diseaseType', 'incidenceRate', 'coverage', 'status']);
const listKeysHeader = reactive({
  diseaseType: '疾病种类',
  incidenceRate: '发病率',
  coverage: '疫苗接种率',
  status: '预警',
});

const classOptions = {
  singleHeight: 48,
};
</script>

<style scoped lang="scss">
.health-status-charts {
  margin-top: 8px;
  .scroll-wrap {
    height: 80%;
    width: 100%;
    margin: 4px auto;
    overflow: hidden;
  }
  .list-item-header {
    background: #144482;
    font-size: 10px;
    width: 100%;
    .item-td {
      padding: 8px 6px;
    }
  }
  .list-item-boday {
    background: transparent;
    width: 100%;
    .item-td {
      padding: 4px 6px;
      &.td-title {
        color: #6beff9 !important;
      }

      &.td-warn {
        color: red !important;
      }
    }
  }
  .item-warp {
    display: inline-flex;
    justify-content: space-around;
    .item-td {
      display: inline-block;
      vertical-align: middle;

      text-align: center;
      color: #fff;
    }
  }
  .list-item {
    // border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
    line-height: 18px;

    .list-item-content {
      display: inline-flex;
      width: 100%;
      justify-content: space-around;
      position: relative;
    }
  }
}
.demo {
  //   display: flex;
  //   align-items: center;
  //   justify-content: center;
  //   margin-top: 10px;
}
</style>
