From 9ee3d1f9a09a865188baffdffb85f6ad329c7b09 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 19 十二月 2021 01:09:20 +0800
Subject: [PATCH] 2021-12-19

---
 src/menu/components/form/normal-form/index.jsx |   92 ++++++++++++++++++++++++++-------------------
 1 files changed, 53 insertions(+), 39 deletions(-)

diff --git a/src/menu/components/form/normal-form/index.jsx b/src/menu/components/form/normal-form/index.jsx
index 4444f91..16de6bf 100644
--- a/src/menu/components/form/normal-form/index.jsx
+++ b/src/menu/components/form/normal-form/index.jsx
@@ -282,6 +282,14 @@
     this.props.updateConfig(card)
   }
 
+  plusFields = (items) => {
+    let _group = fromJS(this.state.group).toJS()
+
+    _group.fields.push(...items)
+
+    this.updateGroup(_group)
+  }
+
   changecols = (type) => {
     let card = fromJS(this.state.card).toJS()
     let config = fromJS(this.state.group).toJS()
@@ -422,25 +430,46 @@
     let _tabfields = []
     let _linkableFields = []
     let _linksupFields = [{
-      value: '',
-      text: '绌�'
+      field: '',
+      label: '绌�'
     }]
     let standardform = null
 
-    _inputfields = group.fields.filter(item => ['text', 'number', 'textarea', 'color'].includes(item.type) && _item.field !== item.field)
-    if (appType === 'mob') {
-      _tabfields = group.fields.filter(item => _form.field !== item.field && item.hidden !== 'true' && ['text', 'number'].includes(item.type))
-    } else {
-      _tabfields = group.fields.filter(item => _form.field !== item.field && item.hidden !== 'true' && ['text', 'number', 'select', 'link'].includes(item.type))
-    }
-    _tabfields.unshift({field: '', text: '鍘熻〃鍗�'})
-
     let uniq = new Map()
-    uniq.set(_form.field, true)
     let index = null
+    uniq.set(_form.field, true)
+
+    let _inputIndex = 1
+    let _tabIndex = 1
+    let _linkIndex = 1
     group.fields.forEach((item, i) => {
       if (_form.uuid === item.uuid) {
         index = i
+      }
+
+      if (['text', 'number', 'textarea', 'color'].includes(item.type) && _item.field !== item.field) {
+        _inputfields.push({
+          field: item.field,
+          label: _inputIndex + '銆�' + item.label
+        })
+        _inputIndex++
+      }
+      if (appType === 'mob') {
+        if (_form.field !== item.field && item.hidden !== 'true' && ['text', 'number'].includes(item.type)) {
+          _tabfields.push({
+            field: item.field,
+            label: _tabIndex + '銆�' + item.label
+          })
+          _tabIndex++
+        }
+      } else {
+        if (_form.field !== item.field && item.hidden !== 'true' && ['text', 'number', 'select', 'link'].includes(item.type)) {
+          _tabfields.push({
+            field: item.field,
+            label: _tabIndex + '銆�' + item.label
+          })
+          _tabIndex++
+        }
       }
       
       if (!['select', 'link', 'radio', 'checkcard'].includes(item.type)) return
@@ -448,15 +477,19 @@
         uniq.set(item.field, true)
 
         _linkableFields.push({
-          value: item.field,
-          text: item.label + ' (琛ㄥ崟)'
+          field: item.field,
+          label: _linkIndex + '銆�' + item.label + ' (琛ㄥ崟)'
         })
         _linksupFields.push({
-          value: item.field,
-          text: item.label
+          field: item.field,
+          label: _linkIndex + '銆�' + item.label
         })
+        _linkIndex++
       }
     })
+
+    _tabfields.unshift({field: '', label: '鍘熻〃鍗�'})
+
     if (index !== null) {
       if (index === 0) {
         standardform = group.fields[index + 1] || null
@@ -470,9 +503,10 @@
         uniq.set(col.field, true)
 
         _linkableFields.push({
-          value: col.field,
-          text: col.label + ' (鏄剧ず鍒�)'
+          field: col.field,
+          label: _linkIndex + '銆�' + col.label + ' (鏄剧ず鍒�)'
         })
+        _linkIndex++
       }
     })
 
@@ -490,7 +524,7 @@
       standardform,
       visible: true,
       editform: _form,
-      formlist: getModalForm(_form, _inputfields, _tabfields, _linkableFields, _linksupFields, false)
+      formlist: getModalForm(_form, _inputfields, _tabfields, _linkableFields, _linksupFields)
     })
   }
 
@@ -504,13 +538,10 @@
     this.formRef.handleConfirm().then(res => {
       let _config = fromJS(this.state.group).toJS()
       let fieldrepet = false // 瀛楁閲嶅
-      let labelrepet = false // 鎻愮ず鏂囧瓧閲嶅
 
       _config.fields = _config.fields.map(item => {
         if (item.uuid !== res.uuid && res.field && item.field && item.field.toLowerCase() === res.field.toLowerCase()) {
           fieldrepet = true
-        } else if (res.label && item.uuid !== res.uuid && item.label === res.label) {
-          labelrepet = true
         }
 
         if (item.uuid === res.uuid) {
@@ -524,13 +555,6 @@
         notification.warning({
           top: 92,
           message: '瀛楁宸插瓨鍦紒',
-          duration: 10
-        })
-        return
-      } else if (labelrepet) {
-        notification.warning({
-          top: 92,
-          message: '鍚嶇О宸插瓨鍦紒',
           duration: 10
         })
         return
@@ -586,13 +610,10 @@
   pasteForm = (res) => {
     let _config = fromJS(this.state.group).toJS()
     let fieldrepet = false // 瀛楁閲嶅
-    let labelrepet = false // 鎻愮ず鏂囧瓧閲嶅
 
     _config.fields.forEach(item => {
       if (res.field && item.field && item.field.toLowerCase() === res.field.toLowerCase()) {
         fieldrepet = true
-      } else if (res.label && item.label === res.label) {
-        labelrepet = true
       }
     })
 
@@ -600,13 +621,6 @@
       notification.warning({
         top: 92,
         message: '瀛楁宸插瓨鍦紒',
-        duration: 10
-      })
-      return
-    } else if (labelrepet) {
-      notification.warning({
-        top: 92,
-        message: '鍚嶇О宸插瓨鍦紒',
         duration: 10
       })
       return
@@ -671,7 +685,7 @@
         />
         {group ? <div className="form-area">
           <Icon className="plus" title="娣诲姞琛ㄥ崟" onClick={this.addForm} type="plus" />
-          <FieldsComponent config={group} type="form" updatefield={this.updateGroup} />
+          <FieldsComponent config={group} type="form" plusFields={this.plusFields} />
           <Switch checkedChildren={dict['model.switch.open']} unCheckedChildren={dict['model.switch.close']} defaultChecked={this.state.showField} onChange={(val) => this.setState({showField: val})} />
           {appType !== 'mob' ? <Button className="mk-cols-change" onClick={() => this.changecols(1)}>1鍒�</Button> : null}
           {appType !== 'mob' ? <Button className="mk-cols-change" onClick={() => this.changecols(2)}>2鍒�</Button> : null}

--
Gitblit v1.8.0