当前位置:   article > 正文

vue中控制element表格列的显示与隐藏_vue table表格控制下拉框的显示隐藏

vue table表格控制下拉框的显示隐藏

背景

根据‘执行进度计算方式’的单选框里面的选项不同,展示不同的column
在这里插入图片描述
按最小制剂单位统计:
在这里插入图片描述
按含量统计:
在这里插入图片描述

实现方式

就是拿到选项框里面的值,再根据里面的值来判断哪些column显示和隐藏;关于显示和隐藏可以设置变量;

<-----主要代码部分----->
 <el-table-column
   label="任务量(片/粒/支)"
    min-width="160"
    prop="taskNum"
    show-overflow-tooltip
    v-if="showColumn.taskNum">
 </el-table-column>
 <el-table-column
	label="任务量(按含量计)"
    min-width="150"
    prop="deliveryNumMg"
    show-overflow-tooltip
    v-if="showColumn.deliveryNumMg"
 ></el-table-column>
   label="执行进度(%)(按最小制剂单位统计)"
    min-width="160"
    prop="executionProgressNumDelivery"
    show-overflow-tooltip
    v-if="showColumn.executionProgressNumDelivery">
 </el-table-column>
 <el-table-column
	label="执行进度(%)(按含量统计)"
    min-width="150"
    prop="executionProgressSpecDelivery"
    show-overflow-tooltip
    v-if="showColumn.executionProgressSpecDelivery"
 ></el-table-column>

<script>
const showColumn={
    taskNum:true,
    deliveryNumMg:true,
    executionProgressNumDelivery:true,
    executionProgressSpecDelivery:true,
  };
export default {
  data() {
    return {
      showColumn,//定义一个变量
      }
   },
 methods: {
    //根据执行进度计算方式条件不同显示column
    changeTableShow(val){
     if(val==='按最小制剂单位统计'){
      this.showColumn.taskNum=true;
      this.showColumn.deliveryNumMg=false;
      this.showColumn.executionProgressNumDelivery=true;
      this.showColumn.executionProgressSpecDelivery=false;
     } else if(val==='按含量统计'){
      this.showColumn.taskNum=false;
      this.showColumn.deliveryNumMg=true;
      this.showColumn.executionProgressNumDelivery=false;
      this.showColumn.executionProgressSpecDelivery=true;
     }else{
      this.showColumn.taskNum=true;
      this.showColumn.deliveryNumMg=true;
      this.showColumn.executionProgressNumDelivery=true;
      this.showColumn.executionProgressSpecDelivery=true;
     }
    },
   } 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/420207
推荐阅读
相关标签
  

闽ICP备14008679号