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

點(diǎn)擊

失去焦點(diǎn)后變化平時(shí)的顯示
<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>
通過設(shè)置scope.row.isModifiy2的屬性判斷下拉框的顯示隱藏
通過插槽,獲取整個(gè)表格具體的某一個(gè)值

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


row獲取那一行的數(shù)據(jù),column獲取那一列的數(shù)據(jù),
const index = this.dataTable.findIndex((item) => { return column.property === item.prop })
//獲取點(diǎn)擊值那一列的索引
if (!this.dataTable[index]) return
if (this.dataTable[index].isModifiy !== undefined) {
row.isModifiy = true
this.dataTable[index].isModifiy = true
//上面的isModifiy是為了解決復(fù)雜的表單需要的設(shè)置
this.dataTable = Object.assign([], this.dataTable)
//要進(jìn)行數(shù)據(jù)的深拷貝,不然第一次點(diǎn)擊的時(shí)會(huì)有點(diǎn)問題
this.$nextTick(() => {
e為false時(shí),就是下拉框隱藏時(shí),就會(huì)執(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是因?yàn)閠his.$refs.vendorId只能清空展示的下拉框的數(shù)據(jù),不能清空底層的數(shù)據(jù)所以要.query清空底層數(shù)據(jù)
? ? ? ? this.tableData = []
? ? ? },總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
el-tree懶加載的實(shí)現(xiàn)以及局部刷新方式
這篇文章主要介紹了el-tree懶加載的實(shí)現(xiàn)以及局部刷新方式,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-04-04
Vue SPA單頁應(yīng)用首屏優(yōu)化實(shí)踐
這篇文章主要介紹了Vue SPA單頁應(yīng)用首屏優(yōu)化實(shí)踐,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-06-06
vue 監(jiān)聽 Treeselect 選擇項(xiàng)的改變操作
這篇文章主要介紹了vue 監(jiān)聽 Treeselect 選擇項(xiàng)的改變操作,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-08-08
vue中循環(huán)表格數(shù)據(jù)出現(xiàn)數(shù)據(jù)聯(lián)動(dòng)現(xiàn)象(示例代碼)
在Vue中循環(huán)生成表格數(shù)據(jù)時(shí),可能會(huì)遇到數(shù)據(jù)聯(lián)動(dòng)的現(xiàn)象,即修改一個(gè)表格中的數(shù)據(jù)后,其他表格的數(shù)據(jù)也會(huì)跟著變化,這種現(xiàn)象通常是因?yàn)樗斜砀竦臄?shù)據(jù)引用了同一個(gè)對象或數(shù)組導(dǎo)致的,本文介紹vue中循環(huán)表格數(shù)據(jù)出現(xiàn)數(shù)據(jù)聯(lián)動(dòng)現(xiàn)象,感興趣的朋友一起看看吧2024-11-11
解決vue中使用swiper插件問題及swiper在vue中的用法
Swiper是純javascript打造的滑動(dòng)特效插件,面向手機(jī)、平板電腦等移動(dòng)終端。這篇文章主要介紹了解決vue中使用swiper插件及swiper在vue中的用法,需要的朋友可以參考下2018-04-04
vue2.0 中使用transition實(shí)現(xiàn)動(dòng)畫效果使用心得
這篇文章主要介紹了vue2.0 中使用transition實(shí)現(xiàn)動(dòng)畫效果使用心得,本文通過案例知識(shí)給大家介紹的非常詳細(xì),需要的朋友參考下吧2018-08-08

