king
2022-09-06 bdfec44c9f3a37dbbe05bf14a252ffec04132a86
src/menu/components/card/data-card/index.jsx
@@ -2,7 +2,7 @@
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Popover, Modal, Pagination } from 'antd'
import { PlusOutlined, PlusCircleOutlined, PlusSquareOutlined, EditOutlined, ToolOutlined, DeleteOutlined, FontColorsOutlined } from '@ant-design/icons'
import { PlusOutlined, PlusCircleOutlined, PlusSquareOutlined, EditOutlined, ToolOutlined, DeleteOutlined, FontColorsOutlined, DownOutlined } from '@ant-design/icons'
import asyncComponent from '@/utils/asyncComponent'
import asyncIconComponent from '@/utils/asyncIconComponent'
@@ -145,7 +145,6 @@
  }
  componentDidMount () {
    MKEmitter.addListener('submitStyle', this.getStyle)
    MKEmitter.addListener('submitModal', this.handleSave)
    // MKEmitter.addListener('logButton', this.logButton)
  }
@@ -161,7 +160,6 @@
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('submitStyle', this.getStyle)
    MKEmitter.removeListener('submitModal', this.handleSave)
    // MKEmitter.removeListener('logButton', this.logButton)
  }
@@ -198,7 +196,7 @@
    card.errors = []
    let columns = card.columns.map(c => c.field)
    let lowcols = card.columns.map(c => c.field.toLowerCase())
    // let lowcols = card.columns.map(c => c.field.toLowerCase())
    if (card.setting.interType === 'system' && card.setting.execute !== 'false' && !card.setting.dataresource) {
      card.errors.push({ level: 0, detail: '未设置数据源!'})
@@ -212,30 +210,30 @@
      card.errors.push({ level: 0, detail: '未设置上级组件!'})
    }
    let supModule = ''
    if (card.wrap.supType === 'multi') { // 数据卡多上级组件
      if (card.supNodes && card.supNodes[0]) {
        supModule = card.supNodes[0].componentId
      }
    } else if (card.setting.supModule) {
      supModule = card.setting.supModule[card.setting.supModule.length - 1] || ''
      if (supModule === 'empty') {
        supModule = ''
      }
    }
    // let supModule = ''
    // if (card.wrap.supType === 'multi') { // 数据卡多上级组件
    //   if (card.supNodes && card.supNodes[0]) {
    //     supModule = card.supNodes[0].componentId
    //   }
    // } else if (card.setting.supModule) {
    //   supModule = card.setting.supModule[card.setting.supModule.length - 1] || ''
    //   if (supModule === 'empty') {
    //     supModule = ''
    //   }
    // }
    card.action.forEach(cell => {
      if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) {
        if (!cell.modal || cell.modal.fields.length === 0) {
          card.errors.push({ level: 1, detail: `按钮“${cell.label}”中表单尚未添加`})
        } else {
          cell.modal.fields.forEach(m => {
            if (m.type === 'linkMain' && !supModule) {
              card.errors.push({ level: 1, detail: `按钮“${cell.label}”中关联主表表单“${m.label}”无效`})
            } else if (m.field && !columns.includes(m.field) && lowcols.includes(m.field.toLowerCase())) {
              card.errors.push({ level: 1, detail: `按钮“${cell.label}”中表单“${m.label}”大小写与字段集不一致`})
            }
          })
        // } else {
        //   cell.modal.fields.forEach(m => {
        //     if (m.type === 'linkMain' && !supModule) {
        //       card.errors.push({ level: 1, detail: `按钮“${cell.label}”中关联主表表单“${m.label}”无效`})
        //     } else if (m.field && !columns.includes(m.field) && lowcols.includes(m.field.toLowerCase())) {
        //       card.errors.push({ level: 1, detail: `按钮“${cell.label}”中表单“${m.label}”大小写与字段集不一致`})
        //     }
        //   })
        }
      }
      // $check@有效性检测
@@ -257,14 +255,14 @@
          if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) {
            if (!cell.modal || cell.modal.fields.length === 0) {
              card.errors.push({ level: 1, detail: `按钮“${cell.label}”中表单尚未添加`})
            } else {
              cell.modal.fields.forEach(m => {
                if (m.type === 'linkMain' && !supModule) {
                  card.errors.push({ level: 1, detail: `按钮“${cell.label}”中关联主表表单“${m.label}”无效`})
                } else if (m.field && !columns.includes(m.field) && lowcols.includes(m.field.toLowerCase())) {
                  card.errors.push({ level: 1, detail: `按钮“${cell.label}”中表单“${m.label}”大小写与字段集不一致`})
                }
              })
            // } else {
            //   cell.modal.fields.forEach(m => {
            //     if (m.type === 'linkMain' && !supModule) {
            //       card.errors.push({ level: 1, detail: `按钮“${cell.label}”中关联主表表单“${m.label}”无效`})
            //     } else if (m.field && !columns.includes(m.field) && lowcols.includes(m.field.toLowerCase())) {
            //       card.errors.push({ level: 1, detail: `按钮“${cell.label}”中表单“${m.label}”大小写与字段集不一致`})
            //     }
            //   })
            }
          }
          if (linkbtn && linkbtn === cell.uuid) {
@@ -281,14 +279,14 @@
            if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) {
              if (!cell.modal || cell.modal.fields.length === 0) {
                card.errors.push({ level: 1, detail: `按钮“${cell.label}”中表单尚未添加`})
              } else {
                cell.modal.fields.forEach(m => {
                  if (m.type === 'linkMain' && !supModule) {
                    card.errors.push({ level: 1, detail: `按钮“${cell.label}”中关联主表表单“${m.label}”无效`})
                  } else if (m.field && !columns.includes(m.field) && lowcols.includes(m.field.toLowerCase())) {
                    card.errors.push({ level: 1, detail: `按钮“${cell.label}”中表单“${m.label}”大小写与字段集不一致`})
                  }
                })
              // } else {
              //   cell.modal.fields.forEach(m => {
              //     if (m.type === 'linkMain' && !supModule) {
              //       card.errors.push({ level: 1, detail: `按钮“${cell.label}”中关联主表表单“${m.label}”无效`})
              //     } else if (m.field && !columns.includes(m.field) && lowcols.includes(m.field.toLowerCase())) {
              //       card.errors.push({ level: 1, detail: `按钮“${cell.label}”中表单“${m.label}”大小写与字段集不一致`})
              //     }
              //   })
              }
            }
            if (linkbtn && linkbtn === cell.uuid) {
@@ -375,15 +373,11 @@
  changeStyle = () => {
    const { card } = this.state
    MKEmitter.emit('changeStyle', [card.uuid], ['background', 'height', 'border', 'padding', 'margin', 'shadow'], card.style)
    MKEmitter.emit('changeStyle', ['background', 'height', 'border', 'padding', 'margin', 'shadow'], card.style, this.getStyle)
  }
  getStyle = (comIds, style) => {
    const { card } = this.state
    if (comIds.length !== 1 || comIds[0] !== card.uuid) return
    let _card = {...card, style}
  getStyle = (style) => {
    let _card = {...this.state.card, style}
    
    this.updateComponent(_card)
  }
@@ -799,6 +793,7 @@
        <div style={{clear: 'both'}}></div>
        {card.wrap.pagestyle === 'page' && card.setting.laypage === 'true' && appType !== 'mob' ? <Pagination total={85} size="small" showTotal={total => `共 ${total} 条`} pageSize={20} defaultCurrent={1}/> : null}
        {card.wrap.pagestyle === 'page' && card.setting.laypage === 'true' && appType === 'mob' ? <MobPagination /> : null}
        {card.wrap.pagestyle === 'more' && card.setting.laypage === 'true' ? <div className="mk-more">查看更多<DownOutlined/></div> : null}
        <div className="component-name">
          <div className="center">
            <div className="title">{card.name}</div>