king
2025-02-06 d1cd5af5adb53e91efdd278328e1b6f8ad834fb5
src/menu/modalconfig/index.jsx
@@ -4,7 +4,7 @@
import { DndProvider } from 'react-dnd'
import HTML5Backend from 'react-dnd-html5-backend'
import { Button, Card, Modal, Collapse, Switch, message, Popover } from 'antd'
import { SettingOutlined, CopyOutlined, SwapOutlined, DeleteOutlined, VerticalRightOutlined } from '@ant-design/icons'
import { SettingOutlined, CopyOutlined, SwapOutlined, DeleteOutlined } from '@ant-design/icons'
import { getModalForm } from '@/templates/zshare/formconfig'
import SourceElement from '@/templates/modalconfig/dragelement/source'
@@ -19,6 +19,7 @@
const MkIcon = asyncComponent(() => import('@/components/mk-icon'))
const TableComponent = asyncComponent(() => import('./tablecomponent'))
const NormalCopy = asyncComponent(() => import('@/menu/normalCopy'))
const ModalForm = asyncComponent(() => import('@/templates/zshare/modalform'))
const PasteForms = asyncComponent(() => import('@/menu/components/share/pasteforms'))
const FormFork = asyncComponent(() => import('@/menu/modalconfig/formfork'))
@@ -181,15 +182,21 @@
    })
  }
  submitConfig = () => {
  submitConfig = (type) => {
    const { config } = this.state
    this.setState({originConfig: fromJS(config).toJS(), saving: true})
    this.props.handleSave(config)
    if (type === 'cache') {
      this.setState({originConfig: fromJS(config).toJS()})
      this.props.handleSave(config)
    setTimeout(() => {
      MKEmitter.emit('triggerMenuSave')
    }, 100)
      message.success(<span>表单配置已保存至本地(<span style={{color: 'red'}}>尚未提交至云端</span>)。</span>)
    } else {
      this.setState({originConfig: fromJS(config).toJS(), saving: true})
      this.props.handleSave(config)
      setTimeout(() => {
        MKEmitter.emit('triggerMenuSave')
      }, 100)
    }
  }
  clearConfig = () => {
@@ -334,28 +341,6 @@
    })
  }
  toLower = () => {
    let _config = fromJS(this.state.config).toJS()
    let that = this
    _config.fields = _config.fields.map(item => {
      if (item.field) {
        item.field = item.field.toLowerCase()
      }
      return item
    })
    confirm({
      content: `确定将字段转为小写吗?`,
      onOk() {
        that.setState({
          config: _config
        })
      },
      onCancel() {}
    })
  }
  triggerCopy = () => {
    const { config } = this.state
@@ -400,6 +385,7 @@
            <Collapse accordion defaultActiveKey="1" bordered={false}>
              <Panel header="基本信息" key="0">
                <TableComponent />
                <NormalCopy />
              </Panel>
              <Panel header="表单" key="1">
                <div className="search-element">
@@ -414,8 +400,9 @@
          <div className="setting">
            <Card title="表单配置" bordered={false} extra={
              <div>
                <Button className="mk-border-green" onClick={() => this.submitConfig('cache')}>存草稿</Button>
                <PasteForms type="toolbar" config={config} update={this.pasteFields}/>
                <Button type="primary" id="save-modal-config" loading={saving} onClick={this.submitConfig}>保存</Button>
                <Button type="primary" id="save-modal-config" loading={saving} onClick={() => this.submitConfig()}>保存</Button>
                <Button disabled={saving} onClick={this.cancelConfig}>返回</Button>
              </div>
            } style={{ width: '100%' }}>
@@ -435,7 +422,6 @@
                    } trigger="hover">
                      <SwapOutlined />
                    </Popover>
                    <VerticalRightOutlined style={{color: 'orange', transform: 'rotate(270deg)'}} title="字段转小写" onClick={this.toLower}/>
                    <FormFork forms={config.fields}/>
                    <CopyOutlined title="复制" onClick={this.triggerCopy} />
                    <Switch checkedChildren="开" unCheckedChildren="关" defaultChecked={this.state.showField} onChange={(val) => this.setState({showField: val})} />