king
2021-06-24 95afd40fc2741ac0ce59c2091f6cfce1f98877d4
src/templates/sharecomponent/searchcomponent/dragsearch/index.jsx
@@ -2,14 +2,12 @@
import { useDrop } from 'react-dnd'
import { is, fromJS } from 'immutable'
import update from 'immutability-helper'
import { Col } from 'antd'
import { Col, Button } from 'antd'
import Utils from '@/utils/utils.js'
import Card from './card'
import './index.scss'
const Container = ({list, placeholder, handleList, handleMenu, deleteMenu }) => {
  let target = null
const Container = ({list, placeholder, showField, handleList, handleMenu, deleteMenu }) => {
  const [cards, setCards] = useState(list)
  const moveCard = (id, atIndex) => {
    const { card, index } = findCard(id)
@@ -47,7 +45,6 @@
    copycard.uuid = Utils.getuuid()
    copycard.origin = false
    copycard.copyType = 'search'
    copycard.label = copycard.label + '(copy)'
    copycard.focus = true
    let _val = fromJS(copycard).toJS()
@@ -76,10 +73,6 @@
    handleList(_cards, copycard)
  }
  const hasDrop = (item) => {
    target = item
  }
  const [, drop] = useDrop({
    accept: 'search',
    drop(item) {
@@ -90,16 +83,7 @@
      let newcard = {}
      newcard.uuid = Utils.getuuid()
      newcard.focus = true
      let _match = 'like'
      if (item.subType === 'select' || item.subType === 'link') {
        _match = '='
      } else if (item.subType === 'date' || item.subType === 'datemonth') {
        _match = '>='
      } else if (item.subType === 'dateweek' || item.subType === 'daterange') {
        _match = 'between'
      }
      newcard.label = 'label'
      newcard.initval = ''
      newcard.type = item.subType
@@ -107,23 +91,35 @@
      newcard.options = []
      newcard.setAll = 'false'
      newcard.orderType = 'asc'
      newcard.match = _match
      newcard.display = 'dropdown'
      
      let targetId = cards.length > 0 ? cards[cards.length - 1].uuid : 0
      if (target) {
        targetId = target.uuid
      let _match = 'like'
      if (item.subType === 'select' || item.subType === 'link' || item.subType === 'checkcard') {
        _match = '='
      } else if (item.subType === 'date' || item.subType === 'datemonth') {
        _match = '>='
      } else if (item.subType === 'dateweek' || item.subType === 'daterange') {
        _match = 'between'
      } else if (item.subType === 'group') {
        _match = 'between'
        newcard.items = ['day', 'week', 'month', 'quarter', 'year', 'customized']
      }
      newcard.match = _match
      let targetId = ''
      if (item.dropTargetId) {
        targetId = item.dropTargetId
        delete 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(_cards, newcard)
      target = null
    }
  })
@@ -134,16 +130,26 @@
          <Card
            id={`${card.uuid}`}
            card={card}
            showField={showField}
            moveCard={moveCard}
            copyCard={copyCard}
            editCard={editCard}
            delCard={delCard}
            findCard={findCard}
            hasDrop={hasDrop}
          />
        </Col>
      ))}
      {cards.length > 0 ? <Col key="action" className="action" span={6}>
        <div className="ant-row ant-form-item" style={{whiteSpace: 'nowrap', lineHeight: '40px', height: '55px', marginBottom: 0}}>
          <div className="ant-col ant-form-item-label ant-col-xs-24 ant-col-sm-8">
          </div>
          <div className="ant-col ant-form-item-control-wrapper ant-col-xs-24 ant-col-sm-16">
            <Button type="primary">搜索</Button>
            <Button style={{ marginLeft: 8 }}>重置</Button>
            <div style={{position: 'absolute', top: 0, bottom: 0, left: 0, right: 0}}></div>
          </div>
        </div>
      </Col> : null}
      {cards.length === 0 ?
        <div className="common-drawarea-placeholder">
          {placeholder}