vxetable 表头字段在查询后变换

5 篇文章 0 订阅
1 篇文章 0 订阅

根据不同的查询条件变换表头,且要求点击查询按钮后表头才进行变换。

例如:时间粒度引发的表头变换和省份查询引发的表头变换。 

时间粒度在15分钟、1小时、天之间切换:

  • 查询 15分钟的时间格式为YYYY-MM-DD HH:mm
  • 查询1小时的时间格式为YYYY-MM-DD HH:00
  • 查询天的时间格式为YYYY-MM-DD
  • 代码实现: 
    //html容器用v-if根据各自状态决定显示与否 
    <vxe-column
              v-if="formatMC"
              field="min"
              title="时间"
              min-width="50"
              :formatter="formatMinString"
            ></vxe-column>
            <vxe-column
              v-if="!formatHC"
              field="hour"
              title="时间"
              min-width="50"
              :formatter="formatHourString"
            ></vxe-column>
            <vxe-column
              v-if="!formatDC"
              field="day"
              title="时间"
              min-width="50"
              :formatter="formatDayString"
    ></vxe-column>
    
    //初始化3个状态
    formatMC: true,
    formatHC: true,
    formatDC: true,
    
    queryData(){
        if (this.form.type == '15M') {
            this.formatMC = true
          } else {
            this.formatMC = false
          }
          if (this.form.type == 'H') {
            this.formatHC = false
          } else {
            this.formatHC = true
          }
          if (this.form.type == 'D') {
            this.formatDC = false
          } else {
            this.formatDC = true
          }
    param={}
    queryDataApi(param).then(res=>{})
    }

查询全国和查询省份,

  • 查询全国则只显示省份不显示地市、区县
  • 查询省份则只显示地市不显示区县 
     <vxe-column field="province" title="省份"></vxe-column>  
     <vxe-column
              v-if="visibleCity"
              field="city"
              title="地市"
            ></vxe-column>
            <vxe-column
              v-if="visibleCounty"
              field="county"
              title="区县"
    ></vxe-column>
    
    visibleCity: false,
    visibleCounty: false,
    
    queryData(){
      if (this.form.province == '全国') {
            this.visibleCity = false
            this.visibleCounty = false
          } else {
            this.visibleCity = true
            if (this.form.city) {
              this.visibleCounty = true
            } else {
              this.visibleCounty = false
            }
          }
    param = {}
    queryDataApi(param).then(res=>{})
    }

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值