king
2023-08-27 da64ab0923bf8817fc8599a6e37b953ce38f64c8
src/menu/modalconfig/index.jsx
@@ -4,8 +4,8 @@
import { DndProvider } from 'react-dnd'
import HTML5Backend from 'react-dnd-html5-backend'
import moment from 'moment'
import { Button, Card, Modal, Collapse, notification, Switch } from 'antd'
import { SettingOutlined } from '@ant-design/icons'
import { Button, Card, Modal, Collapse, notification, Switch, message } from 'antd'
import { SettingOutlined, CopyOutlined } from '@ant-design/icons'
import Api from '@/api'
import Utils from '@/utils/utils.js'
@@ -20,8 +20,9 @@
const { Panel } = Collapse
const { confirm } = Modal
const TableComponent = asyncComponent(() => import('./tablecomponent'))
const ModalForm = asyncComponent(() => import('@/templates/zshare/modalform'))
const EditComponent = asyncComponent(() => import('@/templates/zshare/editcomponent'))
const PasteForms = asyncComponent(() => import('@/menu/components/share/pasteforms'))
const DragElement = asyncComponent(() => import('@/templates/modalconfig/dragelement'))
const FieldsComponent = asyncComponent(() => import('@/templates/sharecomponent/fieldscomponent'))
@@ -114,58 +115,48 @@
    let _linkableFields = []
    let _linksupFields = []
    let standardform = null
    let uniq = new Map()
    let index = null
    uniq.set(card.field, true)
    let _inputIndex = 1
    let _tabIndex = 1
    let _linkIndex = 1
    config.fields.forEach((item, i) => {
      if (card.uuid === item.uuid) {
        index = i
      }
      let label = `${item.field || ''}(${item.label})`
      if (!item.field || card.field === item.field) return
      if (['text', 'number', 'textarea', 'color'].includes(item.type) && card.field !== item.field) {
      if (['text', 'number', 'textarea', 'color'].includes(item.type)) {
        _inputfields.push({
          field: item.field,
          label: _inputIndex + '、' + label
          label: item.label
        })
        _inputIndex++
      }
      if (card.field !== item.field && item.hidden !== 'true' && ['text', 'number', 'select', 'link'].includes(item.type)) {
      if (item.hidden !== 'true' && ['text', 'number', 'select', 'link'].includes(item.type)) {
        _tabfields.push({
          field: item.field,
          label: _tabIndex + '、' + label
          label: item.label
        })
        _tabIndex++
      }
      if (item.type === 'switch') {
      if (item.type === 'switch' || item.type === 'check') {
        _linksupFields.push({
          field: item.field,
          label: _linkIndex + '、' + label
          label: item.label
        })
      }
      if (!['select', 'link', 'radio', 'checkcard'].includes(item.type)) return
      if (item.type === 'checkcard' && item.multiple === 'true') return // 选项卡多选
      if (item.field && !uniq.has(item.field)) {
        uniq.set(item.field, true)
      if (!['select', 'link', 'radio', 'checkcard', 'multiselect'].includes(item.type)) return
        _linkableFields.push({
          field: item.field,
          label: _linkIndex + '、' + item.label + ' (表单)'
        })
        _linksupFields.push({
          field: item.field,
          label: _linkIndex + '、' + label
        })
        _linkIndex++
      }
      _linksupFields.push({
        field: item.field,
        label: item.label
      })
      if (item.type === 'multiselect' || (item.type === 'checkcard' && item.multiple === 'true')) return
      _linkableFields.push({
        field: item.field,
        label: item.label + '-表单'
      })
    })
    if (index !== null) {
      if (index === 0) {
@@ -175,22 +166,18 @@
      }
    }
    _tabfields.unshift({field: '', label: '原表单'})
    let columns = componentConfig.columns
    if (btn.$sub) {
      columns = componentConfig.subColumns || []
    }
    let _fields = _linkableFields.map(cell => cell.field)
    columns.forEach(col => {
      if (col.field && !uniq.has(col.field)) {
        uniq.set(col.field, true)
      if (col.field && !_fields.includes(col.field)) {
        _linkableFields.push({
          field: col.field,
          label: _linkIndex + '、' + col.label + ' (显示列)'
          label: col.label + '-显示列'
        })
        _linkIndex++
      }
    })
@@ -249,6 +236,8 @@
          fieldrepet = true
        }
        delete item.focus
        if (item.uuid === res.uuid) {
          if (item.style) {
            res.style = item.style
@@ -268,6 +257,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({
          sqlVerifing: true
@@ -276,7 +267,7 @@
        let param = {
          func: 's_debug_sql',
          exec_type: 'y',
          LText: `declare @mk_organization nvarchar(512)
          LText: `declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20)
            ${res.dataSource}`
        }
@@ -481,15 +472,60 @@
    })
  }
  pasteFields = (items) => {
    let _config = fromJS(this.state.config).toJS()
    _config.fields = items
    this.setState({
      config: _config
    })
  }
  triggerCopy = () => {
    const { config } = this.state
    let val = {
      copyType: 'forms',
      fields: config.fields || []
    }
    if (val.fields.length === 0) {
      message.warning('表单元素不可为空!')
      return
    }
    try {
      val = window.btoa(window.encodeURIComponent(JSON.stringify(val)))
    } catch (e) {
      console.warn(e)
      message.warning('复制失败,请重试!')
      val = ''
    }
    if (val) {
      let oInput = document.createElement('input')
      oInput.value = val
      document.body.appendChild(oInput)
      oInput.select()
      document.execCommand('Copy')
      document.body.removeChild(oInput)
      message.success('复制成功。')
    }
  }
  render () {
    const { btn } = this.props
    const { config, saving } = this.state
    const { config, saving, card } = this.state
    return (
      <div className="modal-form-board">
        <DndProvider backend={HTML5Backend}>
          <div className="tools">
            <Collapse accordion defaultActiveKey="1" bordered={false}>
              <Panel header="基本信息" key="0">
                <TableComponent />
              </Panel>
              <Panel header="表单" key="1">
                <div className="search-element">
                  {SearchItems.map((item, index) => {
@@ -504,7 +540,7 @@
            <Card title="表单配置" bordered={false} extra={
              <div>
                <Button type="danger" onClick={this.clearConfig}>清空</Button>
                <EditComponent options={['form']} type="formboard" config={this.state.config} plusFields={this.plusFields}/>
                <PasteForms type="toolbar" config={config} update={this.pasteFields}/>
                <Button type="primary" id="save-modal-config" loading={saving} onClick={this.submitConfig}>保存</Button>
                <Button onClick={this.cancelConfig}>返回</Button>
              </div>
@@ -517,6 +553,7 @@
                  <Button className="mk-cols-change" onClick={() => this.changecols(2)}>2列</Button>
                  <Button className="mk-cols-change" onClick={() => this.changecols(3)}>3列</Button>
                  <Button className="mk-cols-change" onClick={() => this.changecols(4)}>4列</Button>
                  <CopyOutlined title="复制" onClick={this.triggerCopy} />
                  <Switch checkedChildren="开" unCheckedChildren="关" defaultChecked={this.state.showField} onChange={(val) => this.setState({showField: val})} />
                </div>
                <div className="ant-modal-body">
@@ -547,7 +584,8 @@
          </div>
        </DndProvider>
        <Modal
          title="编辑"
          title={card && card.$copy ? '复制' : '编辑'}
          wrapClassName="mk-scroll-modal"
          visible={this.state.visible}
          width={950}
          maskClosable={false}
@@ -557,7 +595,7 @@
          destroyOnClose
        >
          <ModalForm
            card={this.state.card}
            card={card}
            formlist={this.state.formlist}
            inputSubmit={this.handleSubmit}
            standardform={this.state.standardform}