index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <script setup>
  2. import {fieldMap, tableMap} from './map';
  3. import {getCompanyDetail} from '@/api/companyDetail';
  4. import {onUnmounted, ref} from 'vue'
  5. import {useRoute} from "vue-router";
  6. import {ElMessage} from "element-plus";
  7. const activeNames = ref([])
  8. const showList = ref([])
  9. const route = useRoute();
  10. const detailContainer = ref(null);
  11. const loading = ref(true);
  12. const handleChange = (val) => {
  13. console.log(val)
  14. }
  15. const getTableLength = (tableObj) => {
  16. if (!tableObj) return null;
  17. let excludeList = ['id', 'update_time', 'create_time'];
  18. let newObj = {};
  19. for (let key in tableObj) {
  20. if (!excludeList.includes(key)) {
  21. newObj[key] = tableObj[key];
  22. }
  23. }
  24. return Object.keys(newObj);
  25. }
  26. getCompanyDetail(route.query.unifiedSocialCreditCode).then(res => {
  27. if (res.code == 200) {
  28. for (let i = 0; i < res.data.length; i++) {
  29. activeNames.value.push(i)
  30. }
  31. showList.value = res.data;
  32. }else {
  33. ElMessage.error(res.msg);
  34. }
  35. })
  36. const specialHanle = (rowProp, index, label) => {
  37. if (!rowProp) return;
  38. if (typeof rowProp == 'string') {
  39. if (rowProp.includes('script') || rowProp.includes("img")) {
  40. return "违禁词"
  41. }
  42. }
  43. if (index == 5 && label == '录入时间') {
  44. return rowProp.split('T')[0];
  45. }
  46. return rowProp;
  47. }
  48. // 定义定时器
  49. let timer;
  50. let timeoutTimer;
  51. timer = setInterval(() => {
  52. if (detailContainer.value.offsetHeight > 50) {
  53. loading.value = false;
  54. clearInterval(timer);
  55. timer = null;
  56. }
  57. }, 10);
  58. timeoutTimer = setTimeout(() => {
  59. if (timer) {
  60. clearInterval(timer);
  61. timer = null;
  62. }
  63. }, 5000);
  64. onUnmounted(() => {
  65. if (timer) {
  66. clearInterval(timer);
  67. }
  68. clearTimeout(timeoutTimer);
  69. timeoutTimer = null;
  70. });
  71. </script>
  72. <template>
  73. <div ref="detailContainer">
  74. <div style="font-size: 18px;font-weight: bold;">企业名称:{{ route.query.enterpriseName }}</div>
  75. <div style="font-size: 18px;font-weight: bold;">当前查询的统一信用代码是:{{ route.query.unifiedSocialCreditCode }}
  76. </div>
  77. <div class="demo-collapse" v-loading.fullscreen.lock="loading" element-loading-text="加载数据中...">
  78. <el-collapse v-model="activeNames" @change="handleChange">
  79. <el-collapse-item v-for="(item,index) in showList" :title="tableMap[item.tableName]" :name="index">
  80. <el-table :data="item.data" max-height="250">
  81. <template v-for="(t,i) in getTableLength(item.data[0])" :key="i">
  82. <el-table-column :prop="t" :label="fieldMap[t]" width="300">
  83. <template #default="scope">
  84. <div v-html="specialHanle(scope.row[t],i,fieldMap[t])"/>
  85. </template>
  86. </el-table-column>
  87. </template>
  88. </el-table>
  89. </el-collapse-item>
  90. </el-collapse>
  91. </div>
  92. </div>
  93. </template>
  94. <style lang="scss">
  95. .demo-collapse .el-collapse-item__header {
  96. font-size: 18px;
  97. font-weight: bold;
  98. }
  99. </style>