king
2023-06-14 08cce3334a2dc81d690b518136b0aaea64e48b0b
src/menu/components/card/balcony/index.jsx
@@ -6,7 +6,7 @@
import asyncComponent from '@/utils/asyncComponent'
import asyncIconComponent from '@/utils/asyncIconComponent'
import { resetStyle, getTables } from '@/utils/utils-custom.js'
import { resetStyle, getTables, checkComponent } from '@/utils/utils-custom.js'
import MKEmitter from '@/utils/events.js'
import Utils from '@/utils/utils.js'
import getWrapForm from './options'
@@ -126,51 +126,15 @@
      return
    }
    card.errors = []
    card.$c_ds = card.wrap.datatype === 'dynamic'
    card.$c_ac = false
    card.$c_sc = false
    card.$c_el = true
    if (card.wrap.datatype === 'static') {
      card.elements.forEach(cell => {
        if (cell.eleType === 'button') {
          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 if (cell.datatype === 'dynamic' && cell.field) {
          card.errors.push({ level: 1, detail: `卡片中动态字段“${cell.field}”无效`})
        }
      })
      card.$tables = getTables(card)
    } else {
      let columns = card.columns.map(c => c.field)
      if (card.wrap.datatype === 'dynamic') {
        if (card.setting.interType === 'system' && card.setting.execute !== 'false' && !card.setting.dataresource) {
          card.errors.push({ level: 0, detail: '未设置数据源!'})
        } else if (card.setting.interType === 'system' && card.setting.execute === 'false' && card.scripts.filter(script => script.status !== 'false').length === 0) {
          card.errors.push({ level: 0, detail: '数据源中无可用脚本!'})
        } else if (!card.setting.primaryKey) {
          card.errors.push({ level: 0, detail: '未设置主键!'})
        } else if (!columns.includes(card.setting.primaryKey)) {
          card.errors.push({ level: 0, detail: '主键已失效!'})
        }
      }
    card.errors = checkComponent(card)
      if (card.errors.length === 0) {
        card.$tables = getTables(card)
      }
      card.elements.forEach(cell => {
        if (cell.eleType === 'button') {
          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 if (cell.datatype === 'dynamic' && cell.field && !columns.includes(cell.field)) {
          card.errors.push({ level: 1, detail: `卡片中动态字段“${cell.field}”无效`})
        }
      })
    }
    this.setState({
@@ -211,6 +175,10 @@
    newcard.datatype = 'dynamic'
    newcard.height = 1
    if (card.wrap.datatype === 'static') {
      newcard.datatype = 'static'
    }
    // 注册事件-添加元素
    MKEmitter.emit('cardAddElement', card.uuid, newcard)
  }
@@ -239,6 +207,7 @@
      MKEmitter.emit('cardAddElement', card.uuid, res)
    } else {
      res.eleType = 'button'
      res.width = res.width || 12
      MKEmitter.emit('cardAddElement', card.uuid, res)
    }
    resolve({status: true})
@@ -272,6 +241,19 @@
      if (d) {
        _card.columns = fromJS(d.columns).toJS()
      }
    }
    if (_card.wrap.position === 'fixed') {
      if (_card.wrap.top && _card.wrap.bottom && _card.wrap.top.indexOf('vh') > -1 && _card.wrap.bottom.indexOf('vh') > -1) {
        if (parseFloat(_card.wrap.top) + parseFloat(_card.wrap.bottom) >= 100) {
          message.warning('元素距上距下之和超出100%,可能导致元素无法显示。')
        }
      }
      if (_card.wrap.left && _card.wrap.right && _card.wrap.left.indexOf('vw') > -1 && _card.wrap.right.indexOf('vw') > -1) {
        if (parseFloat(_card.wrap.left) + parseFloat(_card.wrap.right) >= 100) {
          message.warning('元素距左距右之和超出100%,可能导致元素无法显示。')
        }
      }
    }
@@ -310,7 +292,7 @@
          <div className="center">
            <div className="title" onDoubleClick={() => {
              let oInput = document.createElement('input')
              oInput.value = card.uuid
              oInput.value = 'anchor' + card.uuid
              document.body.appendChild(oInput)
              oInput.select()
              document.execCommand('Copy')