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í)會有點(diǎn)問題 this.$nextTick(() => {
e為false時(shí),就是下拉框隱藏時(shí),就會執(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)文章
vue3+echarts+折線投影(陰影)效果的實(shí)現(xiàn)
這篇文章主要介紹了vue3+echarts+折線投影(陰影)效果的實(shí)現(xiàn)方式,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-10-10使用 vue 實(shí)例更好的監(jiān)聽事件及vue實(shí)例的方法
這篇文章主要介紹了使用 vue 實(shí)例更好的監(jiān)聽事件及vue實(shí)例的方法,介紹了一種新增 vue 實(shí)例的方法,單獨(dú)監(jiān)聽事件,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-04-04基于Vue實(shí)現(xiàn)簡單的權(quán)限控制
這篇文章主要為大家學(xué)習(xí)介紹了如何基于Vue實(shí)現(xiàn)簡單的權(quán)限控制,文中的示例代碼講解詳細(xì),具有一定的參考價(jià)值,需要的小伙伴可以了解一下2023-07-07