king
2020-10-23 407c0f1765c7d085218a91ad8842784977383d05
src/menu/menushell/index.jsx
@@ -10,9 +10,7 @@
const { confirm } = Modal
const Container = ({menu, handleList, doubleClickCard }) => {
  let target = null
const Container = ({menu, handleList }) => {
  const [cards, setCards] = useState(menu.components)
  const moveCard = (id, atIndex) => {
    const { card, index } = findCard(id)
@@ -30,10 +28,6 @@
      card,
      index: cards.indexOf(card),
    }
  }
  const hasDrop = (item) => {
    target = item
  }
  const updateConfig = (element) => {
@@ -85,6 +79,7 @@
        bar: '柱状图',
        line: '折线图',
        tabs: '标签组',
        pie: '饼图',
        card: '卡片'
      }
      let i = 1
@@ -101,25 +96,25 @@
        uuid: Utils.getuuid(),
        type: item.component,
        subtype: item.subtype,
        config: item.config,
        width: item.width || 24,
        name: name,
        floor: 1,   // 组件的层级
        isNew: true // 新添加标志,用于初始化
      }
      
      let targetId = cards.length > 0 ? cards[cards.length - 1].uuid : 0
      if (target) {
        targetId = target.uuid
      let targetId = '0'
      if (item.dropTargetId) {
        targetId = item.dropTargetId
      } else if (cards.length > 0) {
        targetId = cards[cards.length - 1].uuid
      }
      const { index: overIndex } = findCard(`${targetId}`)
      let targetIndex = overIndex
      targetIndex++
      const _cards = update(cards, { $splice: [[targetIndex, 0, newcard]] })
      const _cards = update(cards, { $splice: [[overIndex + 1, 0, newcard]] })
      handleList({...menu, components: _cards})
      target = null
    }
  })
@@ -134,9 +129,7 @@
            moveCard={moveCard}
            delCard={deleteCard}
            findCard={findCard}
            hasDrop={hasDrop}
            updateConfig={updateConfig}
            doubleClickCard={doubleClickCard}
          />
        ))}
      </div>