vue中el-table多層級(jí)嵌套的具體實(shí)現(xiàn)
只要你后端可以查到數(shù)據(jù)這個(gè)層級(jí)可以無限嵌套
這里用了懶加載,每次點(diǎn)擊的時(shí)候?qū)?dāng)前點(diǎn)擊的父級(jí)id作為查詢條件,向后端發(fā)送請(qǐng)求,來獲取他子級(jí)的數(shù)據(jù),并不是將所有數(shù)據(jù)查出來拼接返回的。
前端代碼
<el-table :data="dataList" style="width: 100%" row-key="id" border :lazy="true" :load="load" :tree-props="{children: 'children', hasChildren: 'hasChildren'}"> <el-table-column prop="name" label="組織姓名" width="180"> </el-table-column> <el-table-column prop="natures" label="組織性質(zhì)" width="180"> </el-table-column> <el-table-column prop="dateEstablishment" label="成立時(shí)間"> </el-table-column> <el-table-column prop="leader" label="組織領(lǐng)導(dǎo)"> </el-table-column> <el-table-column prop="address" label="地址"> </el-table-column> </el-table>
data() { return { inputForm: { id: '', parentId: '', name: '', sort: '', natures: '', area: '', longitude: '', latitude: '', dateEstablishment: '', leader: '', address: '', regionId:'', regionParentIds:'' }, dataList: [], loading: false, } },
created() { // this.refreshList() this.initList() }, methods: { //獲取右邊樹表 initList() { this.inputForm.parentId=0 this.get(/organizationInfo/getOrganizationInfoByRegionId?parentId='+this.inputForm.parentId+'®ionId='+this.inputForm.regionId).then((res) => { this.dataList = res }) }, load(row, treeNode, resolve) { this.get(ctx + '/basicinfo/organizationInfo/getOrganizationInfoByRegionId?parent.id=' + row.id).then((res) => { resolve(res) }) }, }
后端代碼
/** * 通過地區(qū)id查詢當(dāng)前Parent的數(shù)據(jù) * * @param regionId * @return */ @Override public List<OrganizationInfo> getOrganizationInfoByRegionId(OrganizationInfo organizationInfo) { //1.查詢到所有該地區(qū)下的組織信息 List<OrganizationInfo> organizationInfos = organizationInfoMapper.getOrganizationInfoByRegionId(organizationInfo); return organizationInfos; }
到此這篇關(guān)于vue中el-table 多層級(jí)嵌套的具體實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)vue el-table 多層級(jí)嵌套內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
el-date-picker日期時(shí)間選擇器的選擇時(shí)間限制到分鐘級(jí)別
文章介紹了如何使用el-date-picker 組件來限制用戶選擇的時(shí)間,禁止選擇當(dāng)前時(shí)間的日期及時(shí)分,同時(shí)允許選擇其他日期的全天時(shí)分,通過設(shè)置 `pickerOptions` 對(duì)象的屬性,可以實(shí)現(xiàn)對(duì)日期和時(shí)間的精確控制,感興趣的朋友跟隨小編一起看看吧2025-01-01Vue生產(chǎn)環(huán)境如何自動(dòng)屏蔽console
這篇文章主要介紹了Vue生產(chǎn)環(huán)境如何自動(dòng)屏蔽console問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-06-06element-ui中el-upload多文件一次性上傳的實(shí)現(xiàn)
這篇文章主要介紹了element-ui中el-upload多文件一次性上傳的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-12-12Antd form表單的使用、設(shè)值、取值、清空值方式
這篇文章主要介紹了Antd form表單的使用、設(shè)值、取值、清空值方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-04-04vue-element-admin登錄攔截設(shè)置白名單方式
這篇文章主要介紹了vue-element-admin登錄攔截設(shè)置白名單方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-03-03