From 2e90ca02407b187a13efef0ffc2dcc6c9fca0c57 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 16 五月 2021 12:55:41 +0800
Subject: [PATCH] 2021-05-16

---
 src/menu/components/form/normal-form/index.jsx |   50 ++++++++++++++++++++++++++++++--------------------
 1 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/src/menu/components/form/normal-form/index.jsx b/src/menu/components/form/normal-form/index.jsx
index 697044f..1610711 100644
--- a/src/menu/components/form/normal-form/index.jsx
+++ b/src/menu/components/form/normal-form/index.jsx
@@ -1,6 +1,5 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
-import {connect} from 'react-redux'
 import { is, fromJS } from 'immutable'
 import { Icon, Popover, Modal, Button, Switch, notification } from 'antd'
 import moment from 'moment'
@@ -45,7 +44,8 @@
     visible: false,
     editform: null,
     formlist: null,
-    sqlVerifing: false
+    sqlVerifing: false,
+    standardform: null
   }
 
   UNSAFE_componentWillMount () {
@@ -66,7 +66,7 @@
         name: card.name,
         subtype: card.subtype,
         setting: { },
-        wrap: { name: card.name, width: card.width || 24, datatype: 'static' },
+        wrap: { name: card.name, width: card.width || 24, datatype: 'static', color: '#1890ff' },
         style: { marginLeft: '0px', marginRight: '0px', marginTop: '8px', marginBottom: '8px' },
         columns: [],
         scripts: [],
@@ -77,7 +77,7 @@
           style: {},
           fields: [],
           prevButton: {label: '涓婁竴姝�', type: 'prev'},
-          subButton: {label: '鎻愪氦', type: 'submit'},
+          subButton: {label: '鎻愪氦', type: 'submit', style: {backgroundColor: '#1890ff', color: '#ffffff', paddingLeft: '25px', paddingRight: '25px'}},
           nextButton: {label: '璺宠繃', type: 'next', enable: 'false'}
         }]
       }
@@ -118,7 +118,7 @@
   }
 
   shouldComponentUpdate (nextProps, nextState) {
-    return !is(fromJS(this.state), fromJS(nextState)) || (!this.props.menu && nextProps.menu)
+    return !is(fromJS(this.state), fromJS(nextState))
   }
 
   /**
@@ -236,7 +236,7 @@
       style: {},
       fields: [],
       prevButton: {label: '涓婁竴姝�', type: 'prev'},
-      subButton: {label: '鎻愪氦', type: 'submit'},
+      subButton: {label: '鎻愪氦', type: 'submit', style: {backgroundColor: '#1890ff', color: '#ffffff', paddingLeft: '25px', paddingRight: '25px'}},
       nextButton: {label: '璺宠繃', type: 'next', enable: 'false'}
     }
 
@@ -429,8 +429,9 @@
 
     group.fields.push(newcard)
 
-    this.setState({group})
-    this.handleForm(newcard)
+    this.setState({group}, () => {
+      this.handleForm(newcard)
+    })
   }
 
   editModalCancel = () => {
@@ -453,6 +454,7 @@
       value: '',
       text: '绌�'
     }]
+    let standardform = null
 
     _inputfields = group.fields.filter(item => item.type === 'text' || item.type === 'number' || item.type === 'textarea' || item.type === 'color')
     _tabfields = group.fields.filter(item => _form.field !== item.field && item.hidden !== 'true' && ['text', 'number', 'select', 'link'].includes(item.type))
@@ -460,7 +462,11 @@
 
     let uniq = new Map()
     uniq.set(_form.field, true)
-    group.fields.forEach(item => {
+    let index = null
+    group.fields.forEach((item, i) => {
+      if (_form.uuid === item.uuid) {
+        index = i
+      }
       if (item.type !== 'select' && item.type !== 'link' && item.type !== 'radio') return
       if (item.field && !uniq.has(item.field)) {
         uniq.set(item.field, true)
@@ -475,6 +481,13 @@
         })
       }
     })
+    if (index !== null) {
+      if (index === 0) {
+        standardform = group.fields[index + 1] || null
+      } else {
+        standardform = group.fields[index - 1] || null
+      }
+    }
 
     card.columns.forEach(col => {
       if (col.field && !uniq.has(col.field)) {
@@ -492,7 +505,13 @@
       _form.linkSubField = _form.linkSubField.filter(item => fields.includes(item))
     }
 
+    if (!_form.span && standardform && standardform.span) {
+      _form.span = standardform.span
+      _form.labelwidth = standardform.labelwidth
+    }
+
     this.setState({
+      standardform,
       visible: true,
       editform: _form,
       formlist: getModalForm(_form, _inputfields, _tabfields, _linkableFields, _linksupFields, false)
@@ -673,6 +692,7 @@
             card={this.state.editform}
             formlist={this.state.formlist}
             inputSubmit={this.handleSubmit}
+            standardform={this.state.standardform}
             wrappedComponentRef={(inst) => this.formRef = inst}
           />
         </Modal>
@@ -681,14 +701,4 @@
   }
 }
 
-const mapStateToProps = (state) => {
-  return {
-    menu: state.customMenu
-  }
-}
-
-const mapDispatchToProps = () => {
-  return {}
-}
-
-export default connect(mapStateToProps, mapDispatchToProps)(PropCardEditComponent)
\ No newline at end of file
+export default PropCardEditComponent
\ No newline at end of file

--
Gitblit v1.8.0