国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

【VUE】使用elementUI tree組件根據(jù)所選id自動(dòng)回顯

這篇具有很好參考價(jià)值的文章主要介紹了【VUE】使用elementUI tree組件根據(jù)所選id自動(dòng)回顯。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

?需求如下:

1.點(diǎn)擊父級(jí)節(jié)點(diǎn)?將父級(jí)節(jié)點(diǎn)下children中所有id放入數(shù)組

2.點(diǎn)擊父級(jí)下的子節(jié)點(diǎn)?將點(diǎn)擊的子節(jié)點(diǎn)放入數(shù)組

3.取消選擇父節(jié)點(diǎn),將放入數(shù)組的所有子節(jié)點(diǎn)id刪除

4.根據(jù)選擇的子節(jié)點(diǎn)數(shù)組,匹配他所屬的父節(jié)點(diǎn)文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-610738.html

								<el-tree
									:data="treeDefaultData"
									:props="defaultProps"
									show-checkbox
									@check-change="handleCheckChange"
								>
								</el-tree>
	data() {
		return {
			defaultProps: {
				children: 'children',
				label: 'label',
			},
			treeDefaultData: [],
}
}
	methods: {
//點(diǎn)擊將選擇到子節(jié)點(diǎn)id傳入數(shù)組
		handleCheckChange(data, checked, indeterminate) {
			console.log(
				'該節(jié)點(diǎn)所對(duì)應(yīng)的對(duì)象:',
				data,
				'是否被選中:',
				checked,
				'節(jié)點(diǎn)的子樹中是否有被選中的節(jié)點(diǎn):',
				indeterminate
			);

			if (checked) {
				if (data.children) {
					for (let i in data.children) {
						const item = data.children[i];
						this.dataScopeList.push(item.id);
					}
				} else {
					this.dataScopeList.push(data.id);
				}
				this.dataScopeList = Array.from(new Set(this.dataScopeList));
			} else {
				if (data.children) {
					return;
				} else {
					this.dataScopeList = this.dataScopeList.filter(function (e) {
						return e !== data.id;
					});
				}
			}
			this.form.dataScopeList = this.dataScopeList;
			console.log(this.dataScopeList, 'dataScopeList');
		},
		// 將數(shù)組里的id 自動(dòng)查找父級(jí)id,將所屬的子項(xiàng)放入children 并組成新的數(shù)組對(duì)象
		calickDetails(row) {
			getDetails(row.userId).then((response) => {
				console.log(response.data);
				this.detailsData = response.data;
				this.detailsTreeShow = true;

				let detailsID = this.detailsData.dataScopeList;

				let result = this.treeDefaultData
					.filter((item) => {
						return (
							detailsID.includes(item.id) ||
							item.children.some((child) => detailsID.includes(child.id))
						);
					})
					.map((item) => {
						return {
							...item,
							children: item.children.filter((child) =>
								detailsID.includes(child.id)
							),
						};
					});

				this.detailsTreeData = result; 
			});
		},
}


	handleCheckChange(data, checked, indeterminate) {
			if (checked) {
				if (data.children) {
					this.menuIds.push(data.id);
					for (let i in data.children) {
						const item = data.children[i];
						this.menuIds.push(item.id);
						if (data.children[i].children) {
							for (let j in data.children[i].children) {
								const itemChildren = data.children[i].children[j];
								this.menuIds.push(itemChildren.id);
							}
						}
					}
				} else {
					this.menuIds.push(data.id);
				}
				this.menuIds = Array.from(new Set(this.menuIds));
			} else {
				// 取消勾選子節(jié)點(diǎn)
				if (indeterminate) {
					return;
				} else {
					if (data.id) {
						this.menuIds = this.menuIds.filter(function (e) {
							return e !== data.id;
						});
						if (data.children) {
							for (let i in data.children) {
								const item = data.children[i];
								this.menuIds = this.menuIds.filter(function (e) {
									return e !== item.id;
								});

								if (data.children[i].children) {
									for (let j in data.children[i].children) {
										const itemChildren = data.children[i].children[j];
										this.menuIds = this.menuIds.filter(function (e) {
											return e !== itemChildren.id;
										});
									}
								}
							}
						}
					}
				}
			}
		},

到了這里,關(guān)于【VUE】使用elementUI tree組件根據(jù)所選id自動(dòng)回顯的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 實(shí)現(xiàn)elementui-tree組件鼠標(biāo)滑過(guò)顯示標(biāo)簽信息

    項(xiàng)目中產(chǎn)品提了一個(gè)這樣的需求(鼠標(biāo)懸浮標(biāo)簽之上展示標(biāo)簽信息),老大一直問(wèn)能不能實(shí)現(xiàn)?其實(shí)很簡(jiǎn)單!他不確定的點(diǎn)是在他寫的位置不對(duì),還有取的定位值不對(duì),因?yàn)槿绻钦f(shuō)單純從樹節(jié)點(diǎn)自定義滑入滑出顯示定位標(biāo)簽的話當(dāng)列表內(nèi)容過(guò)多出現(xiàn)滾動(dòng)條的時(shí)候會(huì)導(dǎo)致標(biāo)簽

    2024年02月04日
    瀏覽(20)
  • 【VUE】使用elementUI上傳組件-提示不存在

    使用elementUI上傳組件上傳圖片后,表單驗(yàn)證還是提示不存在 主要是因?yàn)榻M件包的層級(jí)比較深,驗(yàn)證取不到值導(dǎo)致 可以通過(guò)綁定其他元素獲取到值進(jìn)行驗(yàn)證 比如增加el-checkbox-group元素,將值綁定到它上面

    2024年02月15日
    瀏覽(21)
  • 自定義el-tree復(fù)選框選中狀態(tài)vue elementUI

    :check-strictly屬性:該屬性默認(rèn)false,表示嚴(yán)格遵循父子相互關(guān)聯(lián)。父子相互關(guān)聯(lián)(即選中父節(jié)點(diǎn)其所有子節(jié)點(diǎn)全部選中,取消選中父節(jié)點(diǎn)其子節(jié)點(diǎn)全部取消,且折疊、展開狀態(tài)都一樣)。 Attributes屬性 參數(shù) 說(shuō)明 類型 可選值 默認(rèn)值 check-strictly 在顯示復(fù)選框的情況下,是否嚴(yán)格

    2023年04月09日
    瀏覽(29)
  • ElementUI之Tree樹形控件使用

    以下列出的屬性、事件、方法,可使用Tree控件實(shí)現(xiàn)節(jié)點(diǎn)的拖拽功能(可實(shí)現(xiàn)修改順序、更換父級(jí)節(jié)點(diǎn)功能)、點(diǎn)擊節(jié)點(diǎn)勾選復(fù)選框、只點(diǎn)擊箭頭圖標(biāo)展開和收縮節(jié)點(diǎn)、父子節(jié)點(diǎn)不級(jí)聯(lián)勾選、默認(rèn)展開全部節(jié)點(diǎn)功能 參數(shù) 說(shuō)明 類型 可選值 默認(rèn)值 data 展示數(shù)據(jù) array 是 無(wú) props 配

    2024年02月11日
    瀏覽(20)
  • vue3使用element-plus 樹組件(el-tree)數(shù)據(jù)回顯

    html搭建結(jié)構(gòu) js 非常好用,拿過(guò)來(lái)修改一下check事件,ref獲取就直接可以使用了?

    2024年04月09日
    瀏覽(99)
  • vue SKU已知sku.tree算出sku.list類目值和id
  • O2OA(翱途)開發(fā)平臺(tái)如何在流程表單中使用基于Vue的ElementUI組件?

    O2OA(翱途)開發(fā)平臺(tái)如何在流程表單中使用基于Vue的ElementUI組件?

    本文主要介紹如何在O2OA中進(jìn)行審批流程表單或者工作流表單設(shè)計(jì),O2OA主要采用拖拽可視化開發(fā)的方式完成流程表單的設(shè)計(jì)和配置,不需要過(guò)多的代碼編寫,業(yè)務(wù)人員可以直接進(jìn)行修改操作。 在流程表單設(shè)計(jì)界面,可以在左邊的工具欄找到ElementUI組件。 將對(duì)應(yīng)的組件拖動(dòng)到表

    2024年03月09日
    瀏覽(24)
  • vue3 elementplus table根據(jù)某id相同合并單元格

    vue3 elementplus table根據(jù)某id相同合并單元格

    1.標(biāo)簽上加入合并方法 2.他會(huì)根據(jù) pymt_pl_lmt_id 該值判斷,相同的合并單元格。

    2024年02月11日
    瀏覽(18)
  • 【el-tree查詢并高亮】vue使用el-tree組件,搜索展開并選中對(duì)應(yīng)節(jié)點(diǎn),高亮搜索的關(guān)鍵字,過(guò)濾后高亮關(guān)鍵字,兩種方法

    【el-tree查詢并高亮】vue使用el-tree組件,搜索展開并選中對(duì)應(yīng)節(jié)點(diǎn),高亮搜索的關(guān)鍵字,過(guò)濾后高亮關(guān)鍵字,兩種方法

    效果圖這樣的,會(huì)把所有的有這些的節(jié)點(diǎn)都展開 代碼: 這里的邏輯就是通過(guò)遞歸循環(huán)把所有和匹配的節(jié)點(diǎn)篩選出來(lái) 然后通過(guò)setCheckedKeys方法把他展開選中 然后通過(guò)filterReal把高亮標(biāo)藍(lán) 這個(gè)是用的官方文檔的那個(gè)過(guò)濾方式,可以參考官方文檔看一下。 只不

    2024年02月15日
    瀏覽(172)
  • ElementUI日期選擇器DatePicker限制所選時(shí)間范圍(例如限制前后時(shí)長(zhǎng)不超一個(gè)月)的實(shí)現(xiàn)

    ElementUI日期選擇器DatePicker限制所選時(shí)間范圍(例如限制前后時(shí)長(zhǎng)不超一個(gè)月)的實(shí)現(xiàn)

    未選擇時(shí)間時(shí),最初選擇時(shí)間不能超過(guò)今天 選擇初始時(shí)間后,第二個(gè)選擇的時(shí)間前后不能超過(guò)初始時(shí)間的一個(gè)月。且此時(shí)下拉框變成禁用狀態(tài)。 例如:點(diǎn)擊7月15日后,在8月14日往后的日期全部禁止選中 7月15日前一個(gè)月的6月15日之前的日期也全部禁止選中 選好起始時(shí)間和結(jié)束

    2024年02月14日
    瀏覽(21)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包