From 4cc738e535d1a20701d206e12cf9de8cc5a01170 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 01 六月 2024 15:24:12 +0800
Subject: [PATCH] Merge branch 'develop'

---
 src/menu/modalconfig/index.jsx |  137 +++++++--------------------------------------
 1 files changed, 22 insertions(+), 115 deletions(-)

diff --git a/src/menu/modalconfig/index.jsx b/src/menu/modalconfig/index.jsx
index 6388269..6f40e02 100644
--- a/src/menu/modalconfig/index.jsx
+++ b/src/menu/modalconfig/index.jsx
@@ -3,8 +3,8 @@
 import { is, fromJS } from 'immutable'
 import { DndProvider } from 'react-dnd'
 import HTML5Backend from 'react-dnd-html5-backend'
-import { Button, Card, Modal, Collapse, Switch, message } from 'antd'
-import { SettingOutlined, CopyOutlined } from '@ant-design/icons'
+import { Button, Card, Modal, Collapse, Switch, message, Popover } from 'antd'
+import { SettingOutlined, CopyOutlined, SwapOutlined, DeleteOutlined } from '@ant-design/icons'
 
 import { getModalForm } from '@/templates/zshare/formconfig'
 import SourceElement from '@/templates/modalconfig/dragelement/source'
@@ -21,6 +21,7 @@
 const TableComponent = asyncComponent(() => import('./tablecomponent'))
 const ModalForm = asyncComponent(() => import('@/templates/zshare/modalform'))
 const PasteForms = asyncComponent(() => import('@/menu/components/share/pasteforms'))
+const FormFork = asyncComponent(() => import('@/menu/modalconfig/formfork'))
 const DragElement = asyncComponent(() => import('@/templates/modalconfig/dragelement'))
 const FieldsComponent = asyncComponent(() => import('@/templates/sharecomponent/fieldscomponent'))
 
@@ -40,7 +41,6 @@
     originConfig: null,    // 鍘熷鑿滃崟
     sqlVerifing: false,    // sql楠岃瘉
     showField: false,      // 鏄剧ず琛ㄥ崟瀛楁鍊�
-    standardform: null,
     saving: false
   }
 
@@ -61,7 +61,6 @@
 
   componentDidMount () {
     MKEmitter.addListener('completeSave', this.completeSave)
-    MKEmitter.addListener('submitStyle', this.getStyle)
   }
 
   /**
@@ -72,7 +71,6 @@
       return
     }
     MKEmitter.removeListener('completeSave', this.completeSave)
-    MKEmitter.removeListener('submitStyle', this.getStyle)
   }
 
   /**
@@ -100,121 +98,21 @@
 
   /**
    * @description 琛ㄥ崟缂栬緫
-   * 1銆佹樉绀虹紪杈戝脊绐�-visible
-   * 2銆佷繚瀛樼紪杈戦」-card
-   * 3銆佽缃紪杈戝弬鏁伴」-formlist
    */
   handleForm = (_card) => {
     const { componentConfig, btn } = this.props
     const { config } = this.state
+
     let card = fromJS(_card).toJS()
-    let _inputfields = []
-    let _tabfields = []
-    let _linkableFields = []
-    let _linksupFields = []
-    let standardform = null
-    let index = null
-
-    config.fields.forEach((item, i) => {
-      if (card.uuid === item.uuid) {
-        index = i
-      }
-
-      if (!item.field || card.field === item.field) return
-
-      if (['text', 'number', 'textarea', 'color'].includes(item.type)) {
-        _inputfields.push({
-          field: item.field,
-          label: item.label
-        })
-      }
-      if (item.hidden !== 'true' && ['text', 'number', 'select', 'link'].includes(item.type)) {
-        _tabfields.push({
-          field: item.field,
-          label: item.label
-        })
-      }
-
-      if (['switch', 'check', 'popSelect'].includes(item.type)) {
-        _linksupFields.push({
-          field: item.field,
-          label: item.label
-        })
-      }
-
-      if (!['select', 'link', 'radio', 'checkcard', 'multiselect'].includes(item.type)) return
-
-      _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) {
-        standardform = config.fields[index + 1] || null
-      } else {
-        standardform = config.fields[index - 1] || null
-      }
-    }
-
     let columns = componentConfig.columns
     if (btn.$sub) {
       columns = componentConfig.subColumns || []
     }
 
-    let _fields = _linkableFields.map(cell => cell.field)
-    columns.forEach(col => {
-      if (col.field && !_fields.includes(col.field)) {
-        _linkableFields.push({
-          field: col.field,
-          label: col.label + '-鏄剧ず鍒�'
-        })
-      }
-    })
-
-    if (card.linkSubField && card.linkSubField.length > 0) {
-      let fields = _inputfields.map(item => item.field)
-      card.linkSubField = card.linkSubField.filter(item => fields.includes(item))
-    }
-
-    if (!card.span && standardform && standardform.span) {
-      card.span = standardform.span
-      card.labelwidth = standardform.labelwidth
-    } else if (!card.span) {
-      card.span = 12
-      card.labelwidth = 33.3
-    }
-
     this.setState({
-      standardform,
       visible: true,
       card: card,
-      formlist: getModalForm(card, _inputfields, _tabfields, _linkableFields, _linksupFields, columns)
-    })
-  }
-
-  getStyle = (comIds, style) => {
-    const { config } = this.state
-
-    if (comIds[0] !== 'form') return
-
-    let Index = config.fields.findIndex(n => n.uuid === comIds[1])
-
-    if (Index === -1) return
-    
-    let _config = fromJS(config).toJS()
-
-    _config.fields[Index].style = style
-
-    this.setState({
-      config: _config
+      formlist: getModalForm(card, config.fields, columns)
     })
   }
 
@@ -494,7 +392,6 @@
           <div className="setting">
             <Card title="琛ㄥ崟閰嶇疆" bordered={false} extra={
               <div>
-                <Button type="danger" onClick={this.clearConfig}>娓呯┖</Button>
                 <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>
@@ -504,12 +401,22 @@
               <div className="ant-modal-content" style={{width: config.setting.width > 100 ? config.setting.width : config.setting.width + '%'}}>
                 <div className="ant-modal-header">
                   <div className="ant-modal-title">{config.setting.icon ? <span className={'mk-modal-icon-' + config.setting.iconType} style={{background: config.setting.iconColor || 'unset', color: config.setting.iconColor || 'inherit'}}><MkIcon type={config.setting.icon}/></span> : null}{btn.label}</div>
-                  <Button className="mk-cols-change" onClick={() => this.changecols(1)}>1鍒�</Button>
-                  <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 className="mk-form-tool">
+                    <DeleteOutlined title="娓呯┖" onClick={this.clearConfig} />
+                    <Popover title="鍒囨崲甯冨眬" overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
+                      <>
+                        <Button style={{marginRight: '10px'}} onClick={() => this.changecols(1)}>1鍒�</Button>
+                        <Button style={{marginRight: '10px'}} onClick={() => this.changecols(2)}>2鍒�</Button>
+                        <Button style={{marginRight: '10px'}} onClick={() => this.changecols(3)}>3鍒�</Button>
+                        <Button onClick={() => this.changecols(4)}>4鍒�</Button>
+                      </>
+                    } trigger="hover">
+                      <SwapOutlined />
+                    </Popover>
+                    <FormFork forms={config.fields}/>
+                    <CopyOutlined title="澶嶅埗" onClick={this.triggerCopy} />
+                    <Switch checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={this.state.showField} onChange={(val) => this.setState({showField: val})} />
+                  </div>
                 </div>
                 <div className="ant-modal-body">
                   <div className="modal-form">
@@ -553,7 +460,7 @@
             card={card}
             formlist={this.state.formlist}
             inputSubmit={this.handleSubmit}
-            standardform={this.state.standardform}
+            fields={config.fields}
             wrappedComponentRef={(inst) => this.formRef = inst}
           />
         </Modal>

--
Gitblit v1.8.0