import { RenderContext } from "vue" ; import { ColumnRow , ColumnScope } from "." ; import { ElTableTreeColumnPropsInner , ElTableType } from "./props" ; export class ElTableInject { private Injected : { [ key ] : boolean ; } = { } ; private InjectedTable : { [ key ] : ElTableType < any > ; } = { } ; isInjected ( scope ) { return this . Injected [ scope . store . table . tableId ] ; } Inject ( context , scope ) { if ( this . isInjected ( scope ) ) return ; this . InjectedTable [ scope . store . table . tableId ] = scope . store . table ; this . Injected [ scope . store . table . tableId ] = true ; let key = context . props . treeKey , parentKey = context . props . parentKey ; const table = scope . store . table ; scope . store . table . $on ( "current-change" , ( ) => { validateAllExpanded ( table , key ) ; } ) ; scope . store . states . _treeRowExpanded = [ ] ; scope . store . states . _treeRowLoading = [ ] ; scope . store . states . _treeCachedExpanded = [ ] ; scope . store . states . _treeInitedExpanded = [ ] ; } } const validateAllExpanded = ( table , key ) => { let data = table . store . states . _data , _treeRowExpanded = table . store . states . _treeRowExpanded ; const IsDataListChanged = _treeRowExpanded . every ( expanded => data . every ( row => row [ key ] != expanded [ key ] ) ) ; if ( IsDataListChanged ) { table . store . states . _treeRowExpanded = [ ] ; } } ; export default new ElTableInject ( ) ;