import utils from '../../utils/utils'
import _ from 'lodash'
const dragSelectMixins = {
    data() {
        return {
            dragDom: null,
            dropdom: null,
            contentRect: null,
            dragType: '',
            dragTarget: {},
            dragTargetItem: {}
        }
    },
    mounted: function() {
        this.$eventBus.$on('resetOtherActive', this.resetOtherActive)
        this.$eventBus.$on('optDel', this.optDel)
    },
    methods: {
        //清除其他高亮
        resetOtherActive() {
            let itemHandles = document.getElementsByClassName(
                'biUserDefined-item__handle'
            )
            for (let item of itemHandles) {
                item.style.height = '0'
                item.style.border = '0'
            }
            let screenActives = document.getElementsByClassName(
                'definedScreen__item_active'
            )
            for (let item of screenActives) {
                item.classList.remove('definedScreen__item_active')
            }
            let tableActive = document.getElementsByClassName(
                'biUserDefined-table__active'
            )
            for (let item of tableActive) {
                item.classList.remove('biUserDefined-table__active')
            }
            if (
                this.$refs.gridMainLayout &&
                this.$refs.gridMainLayout.$refs.tsTable &&
                this.$refs.gridMainLayout.$refs.tsTable.length > 0
            ) {
                for (let table of this.$refs.gridMainLayout.$refs.tsTable) {
                    for (let col of table.getTableColumn().tableColumn) {
                        col.headerClassName = ''
                    }
                }
            }
            if (
                this.$refs.gridMainLayout &&
                this.$refs.gridMainLayout.$refs.tabMainLayout
            ) {
                for (let gridMainItem of this.$refs.gridMainLayout.$refs
                        .tabMainLayout) {
                    if (
                        gridMainItem.$refs.tsTable &&
                        gridMainItem.$refs.tsTable.length > 0
                    ) {
                        for (let table of gridMainItem.$refs.tsTable) {
                            for (let col of table.getTableColumn().tableColumn) {
                                col.headerClassName = ''
                            }
                        }
                    }
                }
            }
        }
    },
    beforeDestroy() {
        this.$eventBus.$off('resetOtherActive', this.resetOtherActive)
        this.$eventBus.$off('optDel', this.optDel)
    }
}
export default dragSelectMixins