import { ComputedRef , Ref , computed , watch } from 'vue' ; import { Row } from '@/models/data/row' ; import { useStore } from '@/store' ; import { useSetGanttHeader } from '../useParam' ; import useRootEmit from '../event/useRootEmit' ; export default ( ) => { const store = useStore ( ) ; return { GtData : store . GtData } ; } ; export function useInitData ( data , options ) { const store = useStore ( ) ; const { GtData } = store ; const { setHeaders } = useSetGanttHeader ( ) ; const { IFClickRow } = useRootEmit ( ) ; GtData . initData ( data . value , options . value ) ; const allData = computed ( ( ) => GtData . flatData as Row [ ] ) ; watch ( ( ) => data , val => { let item = null as Row | null ; const select = GtData . selected . index ; if ( select > - 1 ) item = allData . value [ select ] ; GtData . update ( val . value , item , options . value ) ; setHeaders ( ) ; if ( select > - 1 && GtData . selected . index === - 1 ) { IFClickRow ( undefined ) ; } } , { deep : true } ) ; return { allData } ; }