根据不同的查询条件变换表头,且要求点击查询按钮后表头才进行变换。
例如:时间粒度引发的表头变换和省份查询引发的表头变换。
时间粒度在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=>{}) }