From 4fc1eb4913f3302679d88ec01099fc8dd3a80f81 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 08 三月 2023 23:27:21 +0800
Subject: [PATCH] 2023-03-08

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

diff --git a/src/menu/components/form/step-form/index.jsx b/src/menu/components/form/step-form/index.jsx
index b16532c..9a38ddd 100644
--- a/src/menu/components/form/step-form/index.jsx
+++ b/src/menu/components/form/step-form/index.jsx
@@ -201,7 +201,7 @@
   changeStyle = () => {
     const { card } = this.state
 
-    MKEmitter.emit('changeStyle', ['height', 'background', 'border', 'padding', 'margin', 'shadow', 'clear', 'minHeight'], card.style, this.getStyle)
+    MKEmitter.emit('changeStyle', ['height', 'font1', 'background', 'border', 'padding', 'margin', 'shadow', 'clear', 'minHeight'], card.style, this.getStyle)
   }
 
   getStyle = (style) => {
@@ -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()
@@ -703,6 +795,11 @@
 
   render() {
     const { card, group, appType } = this.state
+
+    let labelSize = 14
+    if (card.style.fontSize) {
+      labelSize = parseInt(card.style.fontSize)
+    }
 
     return (
       <div className="menu-normal-form-edit-box" style={resetStyle(card.style)} onClick={this.clickComponent} id={card.uuid}>
@@ -725,15 +822,18 @@
         </Popover>
         <FormTitle
           list={card.subcards}
+          labelSize={labelSize}
           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