<script setup lang="ts">
defineOptions({
  name: "healthRank"
});
import rankTableDraw from "@/components/rankTable/index.vue";
import seachData from "./componements/seach.vue";
import { getChartsList } from "@/api/draw";

import { ref, nextTick } from "vue";
const rankTableRef = ref();
const seachParams = ref();
const lengthData = ref();
const getPersonDimensionChartsListApi = async () => {
  const { code, data } = await getChartsList({
    ...seachParams.value,
    type: 3
  });

  if (code == 200) {
    if (data.length > 0) {
      lengthData.value = data.length;
      setTimeout(() => {
        nextTick(() => {
          rankTableRef.value.init(data, "科室", "姓名");
        });
      }, 500);
    }
  }
};
const init = (item, type) => {
  seachParams.value = item;
  if (Number(type)) {
    getPersonDimensionChartsListApi();
  }
};
</script>

<template>
  <div class="w-full">
    <div class="mb-2 flex gap-2 justify-between flex-wrap">
      <seachData @handClick="init" />
    </div>
    <rankTableDraw v-if="lengthData > 0" ref="rankTableRef" />
  </div>
</template>
