index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <script setup lang='ts'>
  2. import { ref, onMounted, nextTick } from 'vue';
  3. import { useRoute } from 'vue-router';
  4. import { SheetApi } from '@/request/api';
  5. import sheet from '@/components/sheet.vue'
  6. import { IUnknowObject } from '@/types';
  7. import { ElMessage } from 'element-plus';
  8. const route = useRoute();
  9. const code = ref(route.query.code || '')
  10. // route.query.fromScene 1智能研报 2研报列表 3英文研报
  11. interface InfoType extends IUnknowObject {
  12. ExcelName: string;
  13. TableInfo: any;
  14. ExcelImage: string;
  15. UniqueCode: string;
  16. }
  17. const showData = ref(false);
  18. const info = ref<InfoType|any>({});
  19. const loading = ref(false);
  20. const setDefaultSource=(sourceText:string)=>{
  21. return JSON.stringify({
  22. isShow: true,
  23. text: sourceText,
  24. color: "#606266",
  25. fontSize: 9
  26. })
  27. }
  28. const getInfo = async(type='') => {
  29. loading.value = true;
  30. const { Data,Ret } = await SheetApi.getInfo({ UniqueCode: code.value, FromScene: Number(route.query.fromScene||'') });
  31. loading.value = false;
  32. if(Ret !== 200) return
  33. info.value = Data;
  34. if(!info.value.SourcesFrom){
  35. info.value.SourcesFrom = Data.ExcelSource?setDefaultSource(Data.ExcelSource):''
  36. }
  37. showData.value = true;
  38. type==='refresh'&&ElMessage.success('刷新成功')
  39. nextTick(() => {
  40. let ele = document.getElementsByClassName('sheet-show-wrapper')[0] as HTMLElement;
  41. let params = {
  42. height: ele.offsetHeight,
  43. code: info.value.UniqueCode
  44. }
  45. window.parent.postMessage(params,'*')
  46. })
  47. }
  48. getInfo()
  49. const refreshSheet = async()=>{
  50. loading.value = true;
  51. let res: any=null;
  52. res = await SheetApi.refreshInfo({UniqueCode: code.value})
  53. if(res.Ret!==200) return
  54. loading.value = false;
  55. getInfo('refresh')
  56. }
  57. </script>
  58. <template>
  59. <div
  60. v-if="showData"
  61. class="sheet-show-wrapper"
  62. v-loading="loading"
  63. element-loading-spinner="el-icon-loading"
  64. element-loading-text="加载中..."
  65. >
  66. <h3 class="title">{{info.ExcelName}}</h3>
  67. <sheet :data="info.TableInfo.TableDataList" :config="info.Config"/>
  68. <div class="tool sheet-bottom">
  69. <div class="sheet-source"
  70. v-if="info.SourcesFrom&&JSON.parse(info.SourcesFrom).isShow"
  71. :style="`
  72. color: ${ JSON.parse(info.SourcesFrom).color };
  73. font-size: ${ JSON.parse(info.SourcesFrom).fontSize }px;
  74. `"
  75. >
  76. source:<em>{{ JSON.parse(info.SourcesFrom).text}}</em>
  77. </div>
  78. <!-- 占位 -->
  79. <div v-else></div>
  80. <span @click="refreshSheet" style="color: #666;">刷新</span>
  81. </div>
  82. </div>
  83. </template>
  84. <style lang='less' scoped>
  85. .sheet-show-wrapper {
  86. max-width: 1200px;
  87. overflow: hidden;
  88. position: relative;
  89. margin: 0 auto;
  90. background: #fff;
  91. .title {
  92. font-size: 17px;
  93. font-weight: normal;
  94. padding: 0 10px;
  95. // text-align: center;
  96. margin-bottom: 8px;
  97. }
  98. .tool{
  99. // text-align: right;
  100. margin-top: 5px;
  101. span{
  102. cursor: pointer;
  103. }
  104. }
  105. .sheet-bottom{
  106. display: flex;
  107. align-items: center;
  108. justify-content: space-between;
  109. white-space: nowrap;
  110. padding: 0 10px;
  111. .sheet-source{
  112. width: 30%;
  113. min-width: 150px;
  114. overflow: hidden;
  115. text-overflow: ellipsis;
  116. }
  117. }
  118. }
  119. </style>