import { toRaw } from 'vue' ; import { Row } from '@/models/data/row' ; import { useStore } from '@/store' ; import { useGetRootEmit } from './useInitEvent' ; export default ( ) => { const store = useStore ( ) ; const rootEmit = useGetRootEmit ( ) ; function stopClickPropagation ( ) { store . stopClickEvent . value = true ; setTimeout ( ( ) => { store . stopClickEvent . value = false ; } ) ; } /**
     * 单击行
     */ function IFClickRow ( data ) { if ( store . stopClickEvent . value ) return ; rootEmit . value ( 'row-click' , data ? { ... toRaw ( data . data ) } : undefined ) ; } /**
     * 双击行
     */ function IFDblClickRow ( data ) { rootEmit . value ( 'row-dbl-click' , { ... toRaw ( data ?. data ) } ) ; } /**
     * 点击checkbox
     */ function IFCheckedRow ( state , data , checkedList ) { stopClickPropagation ( ) ; rootEmit . value ( 'row-checked' , state , { ... toRaw ( data ?. data ) } , checkedList . map ( item => ( { ... toRaw ( item . data ) } ) ) ) ; } /**
     * 移动甘特滑块
     */ function IFMoveSlider ( data , old ) { stopClickPropagation ( ) ; rootEmit . value ( 'move-slider' , data . map ( d => toRaw ( d . data ) ) , old ) ; } function IFMoveProgress ( data , old ) { stopClickPropagation ( ) ; rootEmit . value ( 'move-progress' , { ... toRaw ( data . data ) } , old ) ; } /**
     * 如果跳转的日期不在甘特范围内，跳转时触发该异常
     */ function INoDateError ( date ) { rootEmit . value ( 'no-date-error' , date ) ; } return { IFClickRow , IFDblClickRow , IFCheckedRow , IFMoveSlider , IFMoveProgress , INoDateError } ; } ;