vue?table表格中如何控制下拉框的顯示隱藏
vue table表格控制下拉框的顯示隱藏
需求:點擊表格的某一個列的嗎某個值,顯示那值得下拉框,失去焦點時則隱藏
平時

點擊

失去焦點后變化平時的顯示
<vxe-table-column align="center" title="類型" width="270" style="height:40px;" field="collectionType">
<template slot-scope="scope">
<!-- @change="changeSelect(scope,$event)"
@visible-change="handleBlur(scope,$event)" -->
<el-select v-if="scope.row.isModifiy2" ref="goodsSelect" v-model="scope.row.collectionType" size="mini" placeholder="請選擇" @visible-change="handleBlur(scope,$event)" @change="changeSelect(scope.row,$event)">
<el-option v-for="item in selectData" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
<template v-else><div style="cursor:pointer">{{ scope.row.collectionType }}</div></template>
</template>
通過設置scope.row.isModifiy2的屬性判斷下拉框的顯示隱藏
通過插槽,獲取整個表格具體的某一個值

![]()
通過這三個屬性來獲取到點擊的某個值,


row獲取那一行的數(shù)據(jù),column獲取那一列的數(shù)據(jù),
const index = this.dataTable.findIndex((item) => { return column.property === item.prop })
//獲取點擊值那一列的索引
if (!this.dataTable[index]) return
if (this.dataTable[index].isModifiy !== undefined) {
row.isModifiy = true
this.dataTable[index].isModifiy = true
//上面的isModifiy是為了解決復雜的表單需要的設置
this.dataTable = Object.assign([], this.dataTable)
//要進行數(shù)據(jù)的深拷貝,不然第一次點擊的時會有點問題
this.$nextTick(() => {
e為false時,就是下拉框隱藏時,就會執(zhí)行下面操作,讓下拉框隱藏

vue下拉框清空
<Select ref="vendorId" v-model="formInline.vendorId" @on-open-change="venSelect" filterable style="width: 162px;" @on-change="vendorChange"
? ? ? ? ? ? v-if="vendorShow">
? ? ? ? ? ? <Option v-for="item in vendorList" :value="item.vendorId" :key="item.vendorId">{{ item.venAbbName + '-' + item.vendorCode }}</Option>
? </Select>要重置查詢的數(shù)據(jù)。在重置中清空refs
// 重置
? ? ? reloadFun() {
? ? ? ? this.formInline = {
? ? ? ? ? vendorId: '',
? ? ? ? ? productCode: '',
? ? ? ? ? inventoryCode: '',
? ? ? ? ? sendDate: '',
? ? ? ? ? remark: '',
? ? ? ? ? cwhCode:''
? ? ? ? }
? ? ? ? this.$refs.vendorId.query = ''//.query是因為this.$refs.vendorId只能清空展示的下拉框的數(shù)據(jù),不能清空底層的數(shù)據(jù)所以要.query清空底層數(shù)據(jù)
? ? ? ? this.tableData = []
? ? ? },總結
以上為個人經驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
vue 監(jiān)聽 Treeselect 選擇項的改變操作
這篇文章主要介紹了vue 監(jiān)聽 Treeselect 選擇項的改變操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-08-08
vue中循環(huán)表格數(shù)據(jù)出現(xiàn)數(shù)據(jù)聯(lián)動現(xiàn)象(示例代碼)
在Vue中循環(huán)生成表格數(shù)據(jù)時,可能會遇到數(shù)據(jù)聯(lián)動的現(xiàn)象,即修改一個表格中的數(shù)據(jù)后,其他表格的數(shù)據(jù)也會跟著變化,這種現(xiàn)象通常是因為所有表格的數(shù)據(jù)引用了同一個對象或數(shù)組導致的,本文介紹vue中循環(huán)表格數(shù)據(jù)出現(xiàn)數(shù)據(jù)聯(lián)動現(xiàn)象,感興趣的朋友一起看看吧2024-11-11
解決vue中使用swiper插件問題及swiper在vue中的用法
Swiper是純javascript打造的滑動特效插件,面向手機、平板電腦等移動終端。這篇文章主要介紹了解決vue中使用swiper插件及swiper在vue中的用法,需要的朋友可以參考下2018-04-04
vue2.0 中使用transition實現(xiàn)動畫效果使用心得
這篇文章主要介紹了vue2.0 中使用transition實現(xiàn)動畫效果使用心得,本文通過案例知識給大家介紹的非常詳細,需要的朋友參考下吧2018-08-08

