Browse Source

moduleView组件计算高度

ymy 1 year ago
parent
commit
c98efdaea7
2 changed files with 16 additions and 8 deletions
  1. 12 8
      src/benyun/components/moduleView/moduleView.vue
  2. 4 0
      src/views/oms/shop/index.vue

+ 12 - 8
src/benyun/components/moduleView/moduleView.vue

@@ -1,5 +1,6 @@
 <template>
 <template>
   <div class="module-view" 
   <div class="module-view" 
+    :style="{height:attrs.calculateH?'100%':'auto'}"
     v-loading="load"
     v-loading="load"
     :ref="viewID"
     :ref="viewID"
     element-loading-text="拼命加载中"
     element-loading-text="拼命加载中"
@@ -35,7 +36,9 @@ interface Page{
 }
 }
 @Component
 @Component
 export default class ModuleView extends ModuleViewHandle {
 export default class ModuleView extends ModuleViewHandle {
-  
+  get attrs(){
+    return this.config.attr ? this.config.attr : {};
+  }
   //搜索配置
   //搜索配置
   get searchConfig(){
   get searchConfig(){
     return this.config?.search ? this.config.search : null;
     return this.config?.search ? this.config.search : null;
@@ -59,10 +62,12 @@ export default class ModuleView extends ModuleViewHandle {
     }
     }
   }
   }
   mounted(){
   mounted(){
-    // this.getList() 
-    // this.$nextTick(()=>{
-    //   this.initTable();
-    // })
+    this.getList() 
+    this.$nextTick(()=>{
+      if(this.attrs.calculateH){
+        this.initTable();
+      }
+    })
   }
   }
   initTable(){
   initTable(){
     if(!this.$refs[this.tableID]){
     if(!this.$refs[this.tableID]){
@@ -79,12 +84,11 @@ export default class ModuleView extends ModuleViewHandle {
     let tHeight = 0;
     let tHeight = 0;
     let vHeight = (this as any).$el.offsetHeight;
     let vHeight = (this as any).$el.offsetHeight;
     if(this.$refs[this.searchID]){
     if(this.$refs[this.searchID]){
-      fHeight = (this.$refs[this.searchID] as any).$el.offsetHeight + 28;
+      fHeight = (this.$refs[this.searchID] as any).$el.offsetHeight + 28 + 8;
     }
     }
     if(this.$refs[this.toolID]){
     if(this.$refs[this.toolID]){
-      tHeight = (this.$refs[this.toolID] as any).$el.offsetHeight
+      tHeight = (this.$refs[this.toolID] as any).$el.offsetHeight + 16;
     }
     }
-    console.log('aaaaaaa',vHeight);
     if(this.config.table && vHeight > 0){
     if(this.config.table && vHeight > 0){
       const h = vHeight - 32 - fHeight - tHeight - 48;
       const h = vHeight - 32 - fHeight - tHeight - 48;
       this.config.table.attr.height = h;
       this.config.table.attr.height = h;

+ 4 - 0
src/views/oms/shop/index.vue

@@ -1,6 +1,7 @@
 <template>
 <template>
   <div class="shop">
   <div class="shop">
     <module-view :propConfig="config" ref="view" v-loading="load" style="height:100%" @pagination="pagination" />
     <module-view :propConfig="config" ref="view" v-loading="load" style="height:100%" @pagination="pagination" />
+    
   </div>
   </div>
 </template>
 </template>
 
 
@@ -13,6 +14,9 @@ export default class Shop extends Vue {
   time:any;
   time:any;
   timeNum = 0;
   timeNum = 0;
   config:any={
   config:any={
+    attr:{
+      calculateH:true
+    },
     search:{
     search:{
       attr:{
       attr:{
         size:'small'
         size:'small'