| | |
| | | <el-table |
| | | class="command-table" |
| | | :data="list" |
| | | :key="tableKey" |
| | | row-key="id" |
| | | lazy |
| | | :load="loadChildren" |
| | |
| | | type: 1, |
| | | }) |
| | | ElMessage.success('删除成功') |
| | | refreshTable() |
| | | selectedIds.value = [] |
| | | selectedRows.value = [] |
| | | const parentIds = Array.from(new Set(rows.map(item => item.parentId).filter(parentId => !isRootParentId(parentId)))) |
| | |
| | | }) |
| | | } |
| | | |
| | | function refreshChildNodes(parentId) { |
| | | const tableKey = ref(0) |
| | | |
| | | function refreshTable() { |
| | | tableKey.value++ // 强制重新渲染整个表格 |
| | | } |
| | | |
| | | async function refreshChildNodes(parentId) { |
| | | const cache = treeResolveMap.get(parentId) |
| | | if (!cache?.resolve) return |
| | | |
| | | // 先清空 |
| | | cache.resolve([]) |
| | | await nextTick() |
| | | getChildLazyTree({ parentId }) |
| | | .then(res => { |
| | | .then(async res => { |
| | | const children = res?.data?.data ?? [] |
| | | if (cache.row) { |
| | | cache.row.hasChildren = children.length > 0 |
| | | } |
| | | // cache.resolve(children) |
| | | // 重新填充 |
| | | await nextTick() |
| | | cache.resolve(children) |
| | | }) |
| | | .catch(() => { |
| | |
| | | lastActionParentRow.value.hasChildren = true |
| | | } |
| | | lastActionParentRow.value = null |
| | | return |
| | | // return |
| | | } |
| | | lastActionParentRow.value = null |
| | | getList() |