<!--
 * @Author: zhanghaifeng
 * @Date: 2024-11-27 15:44:12
 * @LastEditors: zhanghaifeng
 * @LastEditTime: 2025-07-15 17:10:09
 * @Description:
 * @FilePath: /hospital-project/src/components/personList/index.vue
-->
<template>
  <div class="mr-8">
    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="title" width="100">
        <template #default="scope">
          <div class="text-black">{{ scope.row.quotaName }}</div>
        </template>
      </el-table-column>
      <el-table-column
        v-if="showList?.showIndicRemark"
        prop="remark"
        label="指标说明"
      />
      <el-table-column
        v-if="showList?.showScoreRule"
        prop="scoreRule"
        label="评价标准"
      />
      <el-table-column
        v-if="showList?.showDatasource"
        prop="datasoure"
        label="数据来源"
      />
      <el-table-column
        v-if="showList?.showTargetValue"
        prop="targetValue"
        label="目标值"
      />
      <el-table-column prop="finalValue" label="完成值" />
      <el-table-column prop="startValue" label="门槛值" />
      <el-table-column prop="challengeValue" label="挑战值" />
      <el-table-column prop="ranking" label="排名" />
      <el-table-column prop="quotaScore" label="得分" />
    </el-table>
  </div>
</template>

<script lang="ts" setup>
import { ref, nextTick, watch } from "vue";
const tableData = ref([]);
const showList = ref();
const watchData = ref();
const props = defineProps({
  paramsIndex: {
    type: Object,
    default: () => ({})
  },
  detailData: {
    type: Array,
    default: () => []
  }
});
watch(props, newVal => {
  showList.value = newVal.detailData[0]?.dimensionList[0];
  tableData.value = newVal.detailData[0]?.dimensionList[0]?.quotaList;
  console.log(newVal, tableData.value, "11111111");
});
const init = (data?: any, id?: any) => {
  if (data) {
    tableData.value = [];
    console.log(tableData.value, "22222222");
    watchData.value = data;
    setTimeout(() => {
      nextTick(() => {
        if (id) {
          data[0]?.dimensionList.map(it => {
            if (it.dimId == id) {
              showList.value = it;
              tableData.value = it.quotaList;
            }
          });
          console.log(tableData.value, "33333333");
        } else {
          showList.value = data[0]?.dimensionList[0];
          tableData.value = data[0]?.dimensionList[0].quotaList;
          console.log(tableData.value, "44444444");
        }
      });
    }, 0);
  }
};
watch(
  () => watchData.value,
  newVal => {
    showList.value = newVal[0]?.dimensionList[0];
    tableData.value = newVal[0]?.dimensionList[0].quotaList;
    console.log(tableData.value, "55555555");
  },
  { deep: true }
);
defineExpose({
  init
});
</script>
