<script setup>
    import {tableMap,fieldMap} from './map';
    import {getCompanyDetail} from '@/api/companyDetail';
    import { ref } from 'vue'
    const activeNames = ref([])
    const showList = ref([])


    const handleChange = (val) => {
      console.log(val)
    }
    const getTableLength = (tableObj)=>{
      if(!tableObj)return null;
      let excludeList = ['id', 'update_time','create_time'];
      let newObj = {};
      for (let key in tableObj) {
        if (!excludeList.includes(key)) {
          newObj[key] = tableObj[key];
        }
      }
      return Object.keys(newObj);
    }
    getCompanyDetail().then(res=>{
      if(res.code == 200){
        console.log(res.data)
        showList.value = res.data;
        console.log(showList.value);
      }
    })

</script>

<template>
  <div>当前查询的统一信用代码是：91431200MA4TC4MB7J</div>
  <div class="demo-collapse">
    <el-collapse v-model="activeNames" @change="handleChange">
      <el-collapse-item v-for="(item,index) in showList" :title="tableMap[item.tableName]" :name="index">
        <el-table :data="item.data">
          <template v-for="(t,i) in getTableLength(item.data[0])" :key="i">
            <el-table-column :prop="t" :label="fieldMap[t]" width="300"></el-table-column>
          </template>
        </el-table>
      </el-collapse-item>
    </el-collapse>
  </div>
</template>

<style scoped lang="scss">

</style>