Browse Source

接口对接

shanbinzhang 3 months ago
parent
commit
a9f0cce5e1
3 changed files with 38 additions and 11 deletions
  1. 4 1
      src/components/sheet.vue
  2. 10 2
      src/hooks/sheet/useResizeTable.js
  3. 24 8
      src/views/sheetShow/index.vue

+ 4 - 1
src/components/sheet.vue

@@ -27,6 +27,9 @@ const props = defineProps({
   },
   config: {
     type: Object
+  },
+  sceneConfig: {  //应用存储信息
+    type: Object
   }
 })
 
@@ -41,7 +44,7 @@ const HtObj=ref({
   2:'right'
 })
 
-initTableCellsWid()
+initTableCellsWid('init',props.sceneConfig)
 </script>
 
 <template>

+ 10 - 2
src/hooks/sheet/useResizeTable.js

@@ -158,11 +158,19 @@ export function useResizeTable(refName) {
   },20)
 
 
-  function initTableCellsWid(type='init') {
+  function initTableCellsWid(type='init',sceneConfig) {
     if(type=='init'){
+      const { HeightList,WidthList } = sceneConfig;
+
       nextTick(()=>{
         const table = refName.value;
         if (table) {
+          if(HeightList&&WidthList) {
+            columnsWArr.value = WidthList.split(',').map(_ =>Number(_));
+            rowsHArr.value = HeightList.split(',').map(_ =>Number(_));
+            return
+          }
+
           const rows=table.rows;
           const cells = table.rows[0].cells;
           let widthArr= Array.from(cells).map(cell => cell.offsetWidth);
@@ -200,7 +208,7 @@ export function useResizeTable(refName) {
       columnsWArr:columnsWArr.value.map(_ =>_),
       rowsHArr:rowsHArr.value.map(_=>_)
     }
-  
+    console.log(params)
     window.parent.postMessage(params,'*')
   }
 

+ 24 - 8
src/views/sheetShow/index.vue

@@ -50,8 +50,15 @@ const getInfo = async(type='') => {
   }
   showData.value = true; 
   type==='refresh'&&ElMessage.success('刷新成功')
-  nextTick(() => {
-    let ele = document.getElementsByClassName('sheet-show-wrapper')[0] as HTMLElement;
+  type!=='refresh'&&nextTick(() => {
+    updateToHeight()
+  })
+
+}
+getInfo()
+
+function updateToHeight() {
+  let ele = document.getElementsByClassName('sheet-show-wrapper')[0] as HTMLElement;
 
     let params = {
       height: ele.offsetHeight,
@@ -59,11 +66,7 @@ const getInfo = async(type='') => {
     }
   
     window.parent.postMessage(params,'*')
-
-  })
-
 }
-getInfo()
 
 const refreshSheet = async()=>{
     loading.value = true;
@@ -86,7 +89,11 @@ const refreshSheet = async()=>{
   >
     <!-- <h3 class="title">{{info.ExcelName}}</h3> -->
     
-    <sheet :data="info.TableInfo.TableDataList" :config="info.Config"/>
+    <sheet 
+      :data="info.TableInfo.TableDataList" 
+      :config="info.Config"
+      :sceneConfig="info.ReferencedExcelConfig"
+    />
     <div class="tool sheet-bottom">
       <div class="sheet-source" 
         v-if="info.SourcesFrom&&JSON.parse(info.SourcesFrom).isShow"
@@ -99,7 +106,10 @@ const refreshSheet = async()=>{
       </div>
       <!-- 占位 -->
       <div v-else></div>
-      <span @click="refreshSheet" style="color: #666;">刷新</span>
+      <div class="right-btns">
+        <span @click="updateToHeight" v-if="route.query.sourceId">更新样式</span>
+        <span @click="refreshSheet">刷新</span>
+      </div>
     </div>
   </div>
 </template>
@@ -137,6 +147,12 @@ const refreshSheet = async()=>{
       overflow: hidden;
       text-overflow: ellipsis;
     }
+    .right-btns {
+      display: flex;
+      align-items: center;
+      gap:15px;
+      color: #666;
+    }
   }
 }
 </style>