/**获取导出实例 */
async getAllInstances(SlotId) {
//SlotId 数据库词槽id
let result:any = [] //导出的数据模块
const allData = await this.getSimpleInstance(SlotId)//allData根据数据库词槽ID查询到的树状结构数据
let count = 1
//fn 是递归的函数
let fn = (data, objc,count) => {
let obj:any = {...objc}
obj[`name${count}`] = data.name
obj.otherName = data.otherName
result.push(obj)
count++
if (data.children) {
for (const val of data.children) {
fn(val, obj,count)
}
}
}
if (allData.length !== 0) {
for (const item of allData) {
fn(item, {}, count)
}
}
return result
}
树状结构导出到excel表格
最新推荐文章于 2024-03-19 14:27:53 发布