import * as React from 'react'; import { WeaPopoverHrm } from 'ecCom'; import { Tooltip, Button, Icon } from 'antd'; import QueueAnim from 'rc-queue-anim'; import { WeaLocaleProvider } from 'ecCom'; const getLabel = WeaLocaleProvider.getLabel; export default class Item extends React.Component { constructor(props) { super(props); this.state = { show: false } } handleMouseDown = (ev) => { const { canEditBoard } = this.props; this.offset = { left: this.container.offsetLeft, top: this.container.offsetTop - jQuery(this.container).closest('.kanban-group-body')[0].scrollTop, height: this.container.clientHeight, width: this.container.clientWidth, startX: ev.clientX, startY: ev.clientY }; this.startScrollX = jQuery(this.container).closest('.kanban-group-body')[0].scrollLeft; this.startScrollY = {}; jQuery(this.container).closest('.kanban-container').find('kanban-group').each((index, ele) => { const dataValue = jQuery(ele).attr('data-value'); this.startScrollY[dataValue] = jQuery(ele).find('.kanban-group-body').scrollTop(); }); canEditBoard && document.addEventListener('mousemove', this.handleMouseMove); canEditBoard && document.addEventListener('mouseup', this.handleMouseUp); } handleMouseMove = (ev) => { const diffX = ev.clientX - this.offset.startX; const diffY = ev.clientY - this.offset.startY; const fy = jQuery(this.container).closest('.kanban-group-body')[0].scrollHeight / jQuery(this.container).closest('.kanban-group-body')[0].clientHeight; if (Math.abs(diffX) > 5 || Math.abs(diffY) > 5) { this.moving = true; this.props.root.moving = true; this.container.style.position = 'absolute'; this.container.style.width = this.offset.width + 'px'; this.container.style.height = this.offset.height + 'px'; this.container.style.left = (this.offset.left - 10 + diffX) + 'px'; this.container.style.top = (this.offset.top - 10 + diffY) + 'px'; this.container.style.zIndex = 1000; this.container.style.transform = "rotate(5deg)"; jQuery(this.container).addClass('moving'); this.props.root.showItemPlace(this.offset, this.container); let isFound = false; let currentGroup = null; if (diffX < 0) { const thisGroup = jQuery(this.container).closest('.kanban-group'); const prevAll = thisGroup.prevAll('.kanban-group'); prevAll.each((index, ele) => { const offset = jQuery(ele).offset(); const width = jQuery(ele).width(); const offset1 = jQuery(this.container).offset(); const width1 = jQuery(this.container).width(); const middle = offset.left + width / 2 - offset1.left; if (middle > 0 && (middle < width1 || index === 0)) { isFound = true; currentGroup = jQuery(ele); } }); } else { const nextAll = jQuery(this.container).closest('.kanban-group').nextAll('.kanban-group'); nextAll.each((index, ele) => { const offset = jQuery(ele).offset(); const width = jQuery(ele).width(); const offset1 = jQuery(this.container).offset(); const width1 = jQuery(this.container).width(); const middle = offset1.left + width1/2 - offset.left - width/2; if (middle > 0 && (middle < width / 2 || index === nextAll.length - 1)) { isFound = true; currentGroup = jQuery(ele); } }) } if (!isFound || !currentGroup) { currentGroup = jQuery(this.container).closest('.kanban-group'); isFound = true; } if (isFound && currentGroup) { const items = currentGroup.find('.kanban-item'); if (items.length === 0) { //this.props.root.showItemPlace(this.offset, currentGroup); currentGroup.find('.kanban-group-body').append(this.props.root.itemPlace); } items.each((i, item) => { const itemOffset = jQuery(item).offset(); const itemHeight = jQuery(item).height(); const itemOffset1 = jQuery(this.container).offset(); const top = itemOffset.top - itemOffset1.top; if (top > 0 && (top < itemHeight || i === 0)) { this.props.root.showItemPlace(this.offset, item); } else { if (top < 0 && i < items.length) { this.props.root.showItemPlace(this.offset, item, true); } } }) const dataValue = currentGroup.attr('data-value'); currentGroup.find('.kanban-group-body')[0].scrollTop = (this.startScrollY[dataValue] || 0) + diffY * fy; } } } handleMouseUp = () => { document.removeEventListener('mousemove', this.handleMouseMove); document.removeEventListener('mouseup', this.handleMouseUp); if (this.moving) { this.container.style.removeProperty('position'); this.container.style.removeProperty('width'); this.container.style.removeProperty('height'); this.container.style.removeProperty('left'); this.container.style.removeProperty('top'); this.container.style.removeProperty('z-index'); this.container.style.removeProperty("transform"); this.props.root.moving = false; this.moving = false; jQuery(this.container).removeClass('moving'); jQuery(this.props.root.itemPlace).before(this.container); this.props.root.hidePlace(); this.props.root.onChange(); } } setLandMark = (id, value, e) => { this.props.setLandMark(id, value); e.stopPropagation(); } onTaskClick = (value, e) => { this.props.onTaskClick(value); e.stopPropagation(); } render() { const { value, prefix, avatar, title, description, islandmark, action, finish, colors, managerid, managericon, managername, allnum, finishnum, status } = this.props; return (