king
2022-09-06 b8e1395f02c929eaa96b949cf6027ee2a43856a6
src/menu/components/card/cardcellcomponent/dragaction/card.jsx
@@ -1,6 +1,9 @@
import React from 'react'
import { useDrag, useDrop } from 'react-dnd'
import { Icon, Popover } from 'antd'
import { Popover } from 'antd'
import { EditOutlined, CopyOutlined, CloseOutlined, FontColorsOutlined } from '@ant-design/icons'
import MkIcon from '@/components/mk-icon'
import moment from 'moment'
import demo1 from '@/assets/img/demo1.jpg'
@@ -15,6 +18,7 @@
import './index.scss'
const BarCode = asyncComponent(() => import('@/components/barcode'))
const MkProgress = asyncComponent(() => import('./mkProgress'))
const QrCode = asyncComponent(() => import('@/components/qrcode'))
const Video = asyncComponent(() => import('@/components/video'))
const MarkColumn = asyncIconComponent(() => import('@/menu/components/share/markcomponent'))
@@ -23,6 +27,7 @@
  '5:1': '20%', '6:1': '16.67%', '7:1': '14.29%', '8:1': '12.5%', '9:1': '11.11%',
  '10:1': '10%', '3:4': '133.33%', '2:3': '150%', '9:16': '177.78%'
}
const appType = sessionStorage.getItem('appType')
const Card = ({ id, parent, fields, card, moveCard, findCard, editCard, delCard, copyCard, changeStyle, updateMarks }) => {
  const originalIndex = findCard(id).index
@@ -70,25 +75,42 @@
      )
    } else if (card.eleType === 'text' || card.eleType === 'number') {
      let val = `${card.prefix || ''}${card.datatype === 'static' ? (card.value || '') : (card.field || '')}${card.postfix || ''}`
      if (card.fixStyle === 'alone') {
        let _s = {fontSize: card.fixSize, color: card.fixColor, marginLeft: card.fixLeft, marginRight: card.fixRight}
        val = <><span style={_s}>{card.prefix || ''}</span>{`${card.datatype === 'static' ? (card.value || '') : (card.field || '')}`}<span style={_s}>{card.postfix || ''}</span></>
      }
      return (
        <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight || 'auto'}}>{val}</div>
      )
    } else if (card.eleType === 'icon') {
      return (<Icon type={card.icon}/>)
      let fontSize = 14
      let lineHeight = 1.5
      if (card.style.fontSize) {
        fontSize = parseInt(card.style.fontSize)
      }
      if (card.style.lineHeight) {
        lineHeight = parseFloat(card.style.lineHeight)
      }
      let innerHeight = fontSize * lineHeight
      return (<MkIcon style={{height: innerHeight}} className="ant-mk-icon" type={card.icon}/>)
    } else if (card.eleType === 'slider') {
      let val = card.value ? (card.value / card.maxValue) * 100 : 30
      return (
        <div className="ant-mk-slider">
          <div className="ant-mk-slider-rail"></div>
          <div className="ant-mk-slider-track" style={{width: `${val}%`, backgroundColor: card.color}}></div>
          <div className="ant-mk-slider-handle" style={{left: `${val}%`, borderColor: card.color}}></div>
        </div>
      )
      return <MkProgress value={val} config={card}/>
      // return (
      //   <div className="ant-mk-slider">
      //     <div className="ant-mk-slider-rail"></div>
      //     <div className="ant-mk-slider-track" style={{width: `${val}%`, backgroundColor: card.color}}></div>
      //     <div className="ant-mk-slider-handle" style={{left: `${val}%`, borderColor: card.color}}></div>
      //   </div>
      // )
    } else if (card.eleType === 'picture') {
      let _imagestyle = {}
      let url = card.url !== '@icon@' ? card.url : sessionStorage.getItem('CloudAvatar')
      if (card.url) {
        _imagestyle = {backgroundImage: `url('${card.url}')`}
      if (url) {
        _imagestyle = {backgroundImage: `url('${url}')`}
      } else {
        let index = card.uuid.match(/\d{1}/g)
        index = index.slice(-1)[0] % 5
@@ -113,7 +135,7 @@
    } else if (card.eleType === 'splitline') {
      let _borderWidth = card.borderWidth === undefined ? 1 : card.borderWidth
      return (
        <div style={{paddingTop: '1px'}}>
        <div style={{paddingTop: _borderWidth ? '1px' : '10px'}}>
          <div className="ant-mk-splitline" style={{borderColor: card.color, borderWidth: _borderWidth}}></div>
        </div>
      )
@@ -130,21 +152,32 @@
        </div>
      )
    } else if (card.eleType === 'video') {
      _style.overflow = 'hidden'
      return (
        <div>
          <Video card={card} value={card.url || 'http://qingqiumarket.cn/mkwms/Content/images/upload/20210104/trailer.mp4'}/>
        <div className="video-wrap">
          <Video card={card} poster={card.posterUrl || ''} value={card.url || 'http://qingqiumarket.cn/mkwms/Content/images/upload/20210104/trailer.mp4'}/>
        </div>
      )
    } else if (card.eleType === 'currentDate') {
      let val = `${card.prefix || ''}${moment().format(card.dateFormat)}${card.postfix || ''}`
      if (card.fixStyle === 'alone') {
        let _s = {fontSize: card.fixSize, color: card.fixColor, marginLeft: card.fixLeft, marginRight: card.fixRight}
        val = <><span style={_s}>{card.prefix || ''}</span>{moment().format(card.dateFormat)}<span style={_s}>{card.postfix || ''}</span></>
      }
      return (
        <div className="ant-mk-date">
          {`${card.prefix || ''}${moment().format(card.dateFormat)}${card.postfix || ''}`}
          {val}
        </div>
      )
    } else if (card.eleType === 'formula') {
      let val = `${card.prefix || ''}${card.formula}${card.postfix || ''}`
      if (card.fixStyle === 'alone') {
        let _s = {fontSize: card.fixSize, color: card.fixColor, marginLeft: card.fixLeft, marginRight: card.fixRight}
        val = <><span style={_s}>{card.prefix || ''}</span>{card.formula}<span style={_s}>{card.postfix || ''}</span></>
      }
      return (
        <div className="ant-mk-date">
          {`${card.prefix || ''}${card.formula}${card.postfix || ''}`}
          {val}
        </div>
      )
    }
@@ -157,18 +190,24 @@
    }
  }
  let able = true
  if ((appType === 'mob' || appType === 'pc') && parent && (parent.setting.click === 'menu' || parent.setting.click === 'menus')) {
  // if ((appType === 'mob' || appType === 'pc') && parent && parent.setting.click === 'menu') {
    able = false
  }
  return (
    <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
      <div className="mk-popover-control" onDoubleClick={(e) => e.stopPropagation()}>
        <Icon className="edit" title="编辑" type="edit" onClick={() => editCard(id)} />
        <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', 'slider', 'sequence', 'formula'].includes(card.eleType) ? <MarkColumn columns={fields} type={card.eleType} marks={card.marks} onSubmit={(vals) => updateMarks({...card, marks: vals})} /> : null }
        <EditOutlined className="edit" title="编辑" onClick={() => editCard(id)} />
        <CopyOutlined className="copy" title="复制" onClick={() => copyCard(id)} />
        <CloseOutlined className="close" title="删除" onClick={() => delCard(id)} />
        <FontColorsOutlined className="style" title="调整样式" onClick={() => changeStyle(id)}/>
        {['text', 'number', 'slider', 'sequence', 'formula'].includes(card.eleType) ? <MarkColumn field={card.field || ''} columns={fields} type={card.eleType} 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}>
        <div style={_style} onClick={clickComponent} id={card.uuid}>
        <div style={_style} onClick={clickComponent} onDoubleClick={() => able && editCard(id)} id={card.uuid}>
          {getContent()}
        </div>
      </div>