king
2021-01-04 c986f2f56bb153a9b6cebc74b4d9334c85ddfdda
src/menu/components/card/cardcellcomponent/dragaction/card.jsx
@@ -9,13 +9,16 @@
import demo4 from '@/assets/img/demo4.jpg'
import demo5 from '@/assets/img/demo5.jpg'
import asyncComponent from '@/utils/asyncComponent'
import asyncIconComponent from '@/utils/asyncIconComponent'
import './index.scss'
const BarCode = asyncComponent(() => import('@/components/barcode'))
const QrCode = asyncComponent(() => import('@/components/qrcode'))
const Video = asyncComponent(() => import('@/components/video'))
const MarkColumn = asyncIconComponent(() => import('@/menu/components/table/normal-table/columns/markcolumn'))
const Card = ({ id, cardIds, card, moveCard, findCard, editCard, delCard, copyCard, changeStyle }) => {
const Card = ({ id, fields, card, moveCard, findCard, editCard, delCard, copyCard, changeStyle, updateMarks }) => {
  const originalIndex = findCard(id).index
  const [{ isDragging }, drag] = useDrag({
    item: { type: 'action', id, originalIndex },
@@ -27,13 +30,13 @@
    accept: 'action',
    canDrop: () => true,
    drop({ id: draggedId }) {
      if (!draggedId) return
      if (!cardIds.includes(draggedId)) return
      if (!draggedId || draggedId === id) return
      if (draggedId !== id) {
        const { index: overIndex } = findCard(id)
        moveCard(draggedId, overIndex)
      }
      const { index: originIndex } = findCard(draggedId)
      if (originIndex === -1) return
      const { index: overIndex } = findCard(id)
      moveCard(draggedId, overIndex)
    },
  })
@@ -50,11 +53,6 @@
      )
    } else if (card.eleType === 'text' || card.eleType === 'number') {
      let val = `${card.prefix || ''}${card.datatype === 'static' ? (card.value || '') : (card.field || '')}${card.postfix || ''}`
      return (
        <div className={'ant-mk-text line' + card.height} style={{height: card.innerHeight || 21}}>{val}</div>
      )
    } else if (card.eleType === 'link') {
      let val = card.label || card.value || card.field
      return (
        <div className={'ant-mk-text line' + card.height} style={{height: card.innerHeight || 21}}>{val}</div>
      )
@@ -76,7 +74,7 @@
        _imagestyle = {backgroundImage: `url('${card.url}')`}
      } else {
        let index = card.uuid.match(/\d{1}/g)
        index = index[index.length - 1] % 5
        index = index.slice(-1)[0] % 5
        let demos = [demo1, demo2, demo3, demo4, demo5]
        _imagestyle = {backgroundImage: `url('${demos[index]}')`}
@@ -118,6 +116,12 @@
          <QrCode card={card} value={card.value || 'mksoft'}/>
        </div>
      )
    } else if (card.eleType === 'video') {
      return (
        <div>
          <Video card={card} value={card.url || 'http://qingqiumarket.cn/mkwms/Content/images/upload/20210104/trailer.mp4'}/>
        </div>
      )
    } else if (card.eleType === 'currentDate') {
      return (
        <div className="ant-mk-date">
@@ -134,6 +138,7 @@
        <Icon className="copy" title="复制" type="copy" onClick={() => copyCard(id)} />
        <Icon className="close" title="删除" type="close" onClick={() => delCard(id)} />
        <Icon className="style" title="调整样式" onClick={() => changeStyle(id)} type="font-colors" />
        {['text', 'number'].includes(card.eleType) ? <MarkColumn columns={fields} marks={card.marks} onSubmit={(vals) => updateMarks({...card, marks: vals})} /> : null }
      </div>
    } trigger="hover">
      <div ref={node => drag(drop(node))} className={'ant-col card-cell ant-col-' + card.width}>