king
2023-06-14 08cce3334a2dc81d690b518136b0aaea64e48b0b
src/menu/components/form/step-form/index.jsx
@@ -9,7 +9,7 @@
import asyncComponent from '@/utils/asyncComponent'
import asyncIconComponent from '@/utils/asyncIconComponent'
import { getModalForm } from '@/templates/zshare/formconfig'
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'
@@ -139,19 +139,9 @@
      if (supModule === 'empty') {
        supModule = ''
      }
      let columns = card.columns.map(c => c.field)
      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: '主键已失效!'})
      } else if (!card.setting.supModule) {
        card.errors.push({ level: 0, detail: '未设置上级组件!'})
      }
      card.$c_ds = true
      card.errors = checkComponent(card)
      if (card.errors.length === 0) {
        card.$tables = getTables(card)
@@ -469,7 +459,7 @@
        })
      }
      if (item.type === 'switch') {
      if (item.type === 'switch' || item.type === 'check') {
        _linksupFields.push({
          field: item.field,
          label: item.label
@@ -545,6 +535,8 @@
          fieldrepet = true
        }
        delete item.focus
        if (item.uuid === res.uuid) {
          if (item.style) {
            res.style = item.style
@@ -563,6 +555,8 @@
        })
        return
      }
      window.GLOB.formId = res.uuid
      if (['select', 'multiselect', 'link', 'checkbox', 'radio', 'checkcard'].includes(res.type) && res.resourceType === '1' && /\s/.test(res.dataSource)) {
        this.setState({
@@ -617,7 +611,7 @@
    if (res.subtype === 'simpleform') {
      res = res.subcards[0]
    }
    if (res.subButton) {
      let card = fromJS(this.state.card).toJS()
      res.uuid = Utils.getuuid()
@@ -640,37 +634,6 @@
        group: res
      })
      this.updateComponent(card)
      notification.success({
        top: 92,
        message: '粘贴成功!',
        duration: 2
      })
      return
    }
    let _config = fromJS(this.state.group).toJS()
    let fieldrepet = false // 字段重复
    _config.fields.forEach(item => {
      if (res.field && item.field && item.field.toLowerCase() === res.field.toLowerCase()) {
        fieldrepet = true
      }
    })
    if (fieldrepet) {
      notification.warning({
        top: 92,
        message: '字段已存在!',
        duration: 10
      })
      return
    }
    _config.fields.push(res)
    this.updateGroup(_config)
    this.handleForm(res)
    notification.success({
      top: 92,
@@ -721,58 +684,12 @@
    })
  }
  parseForm = (g, res) => {
    let _group = fromJS(g).toJS()
    let _confirm = false
    if (res.copyType === 'form') {
      let fieldrepet = false // 字段重复
      res.uuid = Utils.getuuid()
      _group.fields.forEach(item => {
        if (res.field && item.field && item.field.toLowerCase() === res.field.toLowerCase()) {
          fieldrepet = true
        }
      })
      if (fieldrepet) {
        notification.warning({
          top: 92,
          message: '字段已存在!',
          duration: 10
        })
        return
      }
      _group.fields.push(res)
    } else {
      if (_group.fields.length > 0) {
        _confirm = true
      }
      _group.fields = res.fields.map(item => {
        item.uuid = Utils.getuuid()
        return item
      })
    }
    if (_confirm) {
      let that = this
      confirm({
        title: '确定替换表单吗?',
        content: '原表单将删除。',
        onOk() {
          that.updateForms(_group)
        },
        onCancel() {}
      })
    } else {
      this.updateForms(_group)
    }
  }
  updateForms = (_group) => {
  parseForm = (g, forms) => {
    const { group } = this.state
    let card = fromJS(this.state.card).toJS()
    let _group = fromJS(g).toJS()
    _group.fields = forms
    card.subcards = card.subcards.map(item => {
      if (item.uuid === _group.uuid) {
@@ -819,7 +736,7 @@
              <EditOutlined style={{color: '#1890ff'}} title="编辑"/>
            </NormalForm>
            <CopyComponent type="stepform" card={card}/>
            <PasteComponent config={card} options={['form', 'formgroup', 'simpleform']} updateConfig={this.pasteForm} />
            <PasteComponent config={card} options={['formgroup', 'simpleform']} updateConfig={this.pasteForm} />
            <FontColorsOutlined className="style" title="调整样式" onClick={this.changeStyle}/>
            <UserComponent config={card}/>
            <DeleteOutlined className="close" title="删除组件" onClick={() => this.props.deletecomponent(card.uuid)} />
@@ -870,7 +787,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')