<script setup>
import request from "@/utils/request.js";
import {detailMap, limitMap, titleMap} from "@/views/qyxypj/qypjdf/detailMap.js";
import {onMounted, ref} from 'vue';
import {useRoute} from "vue-router";

const route = useRoute();

const show = ref();
const data = ref([]);

const getData = async () => {
  const res = await request('/basicData/xcrEBaseinfo/getCreditScoreMostDetailsByUniCode', {
    params: {
      uniCode: show.value.uniCode
    }
  });

  const dataList = [];
  for (let dataKey in res.data) {
    const temp = {
      key: dataKey,
      label: detailMap.get(dataKey),
      value: res.data[dataKey]
    };
    dataList.push(temp);
  }

  data.value = [
    dataList.slice(0, 14),
    dataList.slice(14, 21),
    dataList.slice(21, 30)
  ];

};

const init = () => {
  show.value = JSON.parse(route.query.row)
  getData();
};

onMounted(() => {
  init();
});
</script>

<template>
  <div>
    <div class="p-10px">
      <div>当前查询的企业:{{show?.enterpriseName}}</div>
      <div>当前查询的统一社会信用代码:{{show?.uniCode}}</div>
      <div>信用等级为:{{show?.grade}}</div>
      <div>总分为:{{show?.total.toFixed(2)}}</div>
    </div>
    <div v-for="(group, groupIndex) in data" :key="groupIndex" class="mb-20px">
      <el-descriptions :title="titleMap.get(groupIndex+1)+show[limitMap.get(groupIndex+1)]" :column="4" border>
        <el-descriptions-item v-for="(item, itemIndex) in group" :key="itemIndex" :label="item.label" width="100px">
          {{ item.value }}
        </el-descriptions-item>
      </el-descriptions>
    </div>
  </div>
</template>

<style scoped lang="scss">
/* 你的样式 */
</style>
