king
2020-10-23 407c0f1765c7d085218a91ad8842784977383d05
src/menu/components/tabs/tabcomponents/index.jsx
@@ -11,8 +11,6 @@
const { confirm } = Modal
const Container = ({ config, handleList }) => {
  let target = null
  const [cards, setCards] = useState(config.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) => {
@@ -93,6 +87,7 @@
        bar: '柱状图',
        line: '折线图',
        tabs: '标签组',
        pie: '饼图',
        card: '卡片'
      }
      let i = 1
@@ -111,25 +106,25 @@
        parentId: config.parentId,
        type: item.component,
        subtype: item.subtype,
        config: item.config,
        width: item.width || 24,
        name: name,
        floor: config.floor ? (config.floor + 1) : 2, // 组件的层级
        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({...config, components: _cards})
      target = null
    }
  })
@@ -144,7 +139,6 @@
          moveCard={moveCard}
          delCard={deleteCard}
          findCard={findCard}
          hasDrop={hasDrop}
          updateConfig={updateConfig}
        />
      ))}