From 79006d19801eb10e7532eaf8478d1dd2c239954b Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 07 三月 2023 01:41:28 +0800
Subject: [PATCH] 2023-03-07

---
 src/menu/components/form/step-form/index.jsx |   94 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 94 insertions(+), 0 deletions(-)

diff --git a/src/menu/components/form/step-form/index.jsx b/src/menu/components/form/step-form/index.jsx
index 32bc1f9..9a38ddd 100644
--- a/src/menu/components/form/step-form/index.jsx
+++ b/src/menu/components/form/step-form/index.jsx
@@ -688,6 +688,98 @@
     this.updateComponent(_card)
   }
 
+  clearGroup = () => {
+    let group = fromJS(this.state.group).toJS()
+    let card = fromJS(this.state.card).toJS()
+    let _this = this
+
+    group.fields = []
+
+    card.subcards = card.subcards.map(item => {
+      if (item.uuid === group.uuid) {
+        return group
+      }
+      return item
+    })
+
+    confirm({
+      content: `纭畾娓呯┖琛ㄥ崟鍚楋紵`,
+      onOk() {
+        _this.setState({group})
+        _this.updateComponent(card)
+      },
+      onCancel() {}
+    })
+  }
+
+  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) => {
+    const { group } = this.state
+    let card = fromJS(this.state.card).toJS()
+
+    card.subcards = card.subcards.map(item => {
+      if (item.uuid === _group.uuid) {
+        return _group
+      }
+      return item
+    })
+
+    if (_group.uuid === group.uuid) {
+      this.setState({group: _group})
+      this.updateComponent(card)
+    } else {
+      this.updateComponent(card)
+    }
+  }
+
   clickComponent = (e) => {
     if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') {
       e.stopPropagation()
@@ -734,12 +826,14 @@
           selectId={group ? group.uuid : ''}
           handleList={this.changecards}
           handleGroup={this.changeGroup}
+          handleForm={this.parseForm}
           closeGroup={this.closeGroup}
           selectGroup={this.selectGroup}
         />
         {group ? <div className="form-area">
           <PlusOutlined className="plus" title="娣诲姞琛ㄥ崟" onClick={this.addForm}/>
           <FieldsComponent config={group} type="form" plusFields={this.plusFields} />
+          <span style={{color: 'red', marginLeft: '30px', cursor: 'pointer'}} onClick={this.clearGroup}>娓呯┖</span>
           <Switch checkedChildren="寮�" unCheckedChildren="鍏�" 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