From da64ab0923bf8817fc8599a6e37b953ce38f64c8 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 27 八月 2023 18:37:36 +0800
Subject: [PATCH] 2023-08-27

---
 src/menu/components/form/tab-form/index.jsx |  197 +++++++++++--------------------------------------
 1 files changed, 44 insertions(+), 153 deletions(-)

diff --git a/src/menu/components/form/tab-form/index.jsx b/src/menu/components/form/tab-form/index.jsx
index 0f280e2..18b4656 100644
--- a/src/menu/components/form/tab-form/index.jsx
+++ b/src/menu/components/form/tab-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 '../step-form/options'
@@ -24,7 +24,6 @@
 const FormAction = asyncComponent(() => import('../formaction'))
 const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent'))
 const PasteComponent = asyncIconComponent(() => import('@/menu/components/share/pastecomponent'))
-const UserComponent = asyncIconComponent(() => import('@/menu/components/share/usercomponent'))
 const FieldsComponent = asyncComponent(() => import('@/templates/sharecomponent/fieldscomponent'))
 
 const { confirm } = Modal
@@ -91,26 +90,6 @@
         }]
       }
 
-      if (card.config) {
-        let config = fromJS(card.config).toJS()
-
-        _card.wrap = config.wrap
-        _card.wrap.name = card.name
-        _card.style = config.style
-
-        _card.setting = config.setting
-        _card.columns = config.columns
-        _card.scripts = config.scripts
-
-        _card.subcards = config.subcards.map(scard => {
-          scard.uuid = Utils.getuuid()
-          scard.fields = scard.fields.map(elem => {
-            elem.uuid = Utils.getuuid()
-            return elem
-          })
-          return scard
-        })
-      }
       this.setState({
         group: _card.subcards[0] || null
       })
@@ -151,19 +130,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)
@@ -451,50 +420,48 @@
     let _linkableFields = []
     let _linksupFields = []
     let standardform = null
-
-    let uniq = new Map()
     let index = null
-    uniq.set(_form.field, true)
 
     group.fields.forEach((item, i) => {
       if (_form.uuid === item.uuid) {
         index = i
       }
 
-      if (['text', 'number', 'textarea', 'color'].includes(item.type) && _item.field !== item.field) {
+      if (!item.field || _form.field === item.field) return
+
+      if (['text', 'number', 'textarea', 'color'].includes(item.type)) {
         _inputfields.push({
           field: item.field,
           label: item.label
         })
       }
-      if (_form.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: item.label
         })
       }
 
-      if (item.type === 'switch') {
+      if (item.type === 'switch' || item.type === 'check') {
         _linksupFields.push({
           field: item.field,
           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: item.label + '-琛ㄥ崟'
-        })
-        _linksupFields.push({
-          field: item.field,
-          label: item.label
-        })
-      }
+      _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) {
@@ -505,10 +472,9 @@
       }
     }
 
+    let _fields = _linkableFields.map(cell => cell.field)
     card.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: col.label + '-鏄剧ず鍒�'
@@ -549,6 +515,8 @@
         if (item.uuid !== res.uuid && res.field && item.field && item.field.toLowerCase() === res.field.toLowerCase()) {
           fieldrepet = true
         }
+
+        delete item.focus
 
         if (item.uuid === res.uuid) {
           if (item.style) {
@@ -624,56 +592,25 @@
     if (res.subtype === 'simpleform') {
       res = res.subcards[0]
     }
-    if (res.subButton) {
-      let card = fromJS(this.state.card).toJS()
 
-      res.uuid = Utils.getuuid()
-      res.sort = card.subcards.length + 1
+    let card = fromJS(this.state.card).toJS()
 
-      res.fields.forEach(item => {
-        item.uuid = Utils.getuuid()
-      })
+    res.uuid = Utils.getuuid()
+    res.sort = card.subcards.length + 1
 
-      delete res.prevButton
-      delete res.nextButton
-
-      card.subcards.push(res)
-      
-      this.setState({
-        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
-      }
+    res.fields.forEach(item => {
+      item.uuid = Utils.getuuid()
     })
 
-    if (fieldrepet) {
-      notification.warning({
-        top: 92,
-        message: '瀛楁宸插瓨鍦紒',
-        duration: 10
-      })
-      return
-    }
-    _config.fields.push(res)
+    delete res.prevButton
+    delete res.nextButton
 
-    this.updateGroup(_config)
-
-    this.handleForm(res)
+    card.subcards.push(res)
+    
+    this.setState({
+      group: res
+    })
+    this.updateComponent(card)
 
     notification.success({
       top: 92,
@@ -724,58 +661,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) {
@@ -822,9 +713,8 @@
               <EditOutlined style={{color: '#1890ff'}} title="缂栬緫"/>
             </NormalForm>
             <CopyComponent type="tabform" 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)} />
             {card.wrap.datatype !== 'static' ? <SettingComponent config={card} updateConfig={this.updateComponent} /> : null}
             {card.wrap.datatype === 'static' ? <SettingOutlined style={{color: '#eeeeee', cursor: 'not-allowed'}}/> : null}
@@ -874,7 +764,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')
@@ -894,6 +784,7 @@
         </div>
         <Modal
           title="缂栬緫"
+          wrapClassName="mk-scroll-modal"
           visible={this.state.visible}
           width={950}
           maskClosable={false}

--
Gitblit v1.8.0