From a8e94242166881639cecf3809e45ca527233ebd7 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 23 三月 2021 16:42:20 +0800
Subject: [PATCH] 2021-03-23

---
 src/tabviews/zshare/mutilform/index.jsx |  140 +++++++++++++++-------------------------------
 1 files changed, 45 insertions(+), 95 deletions(-)

diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx
index 2647c0c..56b78f9 100644
--- a/src/tabviews/zshare/mutilform/index.jsx
+++ b/src/tabviews/zshare/mutilform/index.jsx
@@ -33,7 +33,6 @@
   }
 
   state = {
-    cols: 2,         // 鏄剧ず涓哄灏戝垪
     datatype: null,  // 鏁版嵁绫诲瀷
     readtype: null,  // 鏄惁鍙
     readin: null,    // 琛屾暟鎹槸鍚﹀啓鍏�
@@ -44,20 +43,6 @@
     record: {}       // 璁板綍涓嬫媺琛ㄥ崟鍏宠仈瀛楁锛岀敤浜庢暟鎹啓鍏�
   }
 
-  UNSAFE_componentWillMount () {
-    let cols = 2
-    if (this.props.action.setting && this.props.action.setting.cols) {
-      cols = parseInt(this.props.action.setting.cols)
-      if (cols > 4 || cols < 1) {
-        cols = 2
-      }
-    }
-
-    this.setState({
-      cols: cols
-    })
-  }
-
   componentDidMount () {
     const { data, BData, action } = this.props
     
@@ -66,34 +51,13 @@
     let readin = {}
     let writein = {}
     let fieldlen = {}
-    let formlist = []
     let intercepts = []
     let _inputfields = []
-
-    if (action.groups && action.groups.length > 0) {
-      let groups = fromJS(action.groups).toJS()
-      groups.forEach(group => {
-        if (group.sublist.length === 0) return
-
-        if (!group.default) {
-          formlist.push({
-            type: 'title',
-            label: group.label,
-            uuid: group.uuid
-          })
-        }
-
-        formlist.push(...group.sublist)
-      })
-    } else {
-      formlist = fromJS(action.fields).toJS()
-    }
-
     let linkFields = {} // 鍏宠仈鑿滃崟
     let supItemVal = {} // 涓婄骇鑿滃崟鍒濆鍊�
     let deForms = []    // 闇�瑕佸姩鎬佽幏鍙栦笅鎷夎彍鍗曠殑琛ㄥ崟
 
-    formlist.forEach(item => {
+    action.fields.forEach(item => {
       if (item.type === 'text' || item.type === 'number') {              // 鐢ㄤ簬杩囨护涓嬫媺鑿滃崟鍏宠仈琛ㄥ崟
         _inputfields.push(item.field)
       } else if (item.type === 'textarea') {
@@ -107,8 +71,11 @@
       }
     })
 
-    formlist = formlist.map(item => {
-      if (item.type === 'title') return item
+    let formlist = action.fields.map(item => {
+      if (item.labelwidth) {
+        item.labelCol = {style: {width: item.labelwidth + '%'}}
+      }
+      if (item.type === 'split' || item.type === 'hint') return item
 
       // 鏁版嵁鑷姩濉厖
       let _readin = item.readin !== 'false'
@@ -716,13 +683,13 @@
 
   getFields() {
     const { getFieldDecorator } = this.props.form
-    const { cols, formlist } = this.state
+    const { formlist } = this.state
 
     const fields = []
     let filtration = {}
 
     formlist.forEach((item, index) => {
-      if ((!item.field && item.type !== 'title' && item.type !== 'hint') || item.hidden === 'true' || item.type === 'funcvar') return
+      if ((!item.field && item.type !== 'split' && item.type !== 'hint') || item.hidden === 'true' || item.type === 'funcvar') return
       if (item.supField) { // 澶氬眰琛ㄥ崟鎺у埗
         let _supVal = this.props.form.getFieldValue(item.supField)
 
@@ -738,12 +705,7 @@
         }
       }
 
-      let _colspan = 24 / cols
-      if (item.entireLine === 'true') {
-        _colspan = 24
-      }
-
-      if (item.type === 'title') {
+      if (item.type === 'split') {
         fields.push(
           <Col span={24} key={index}>
             <p>{item.label}</p>
@@ -751,8 +713,8 @@
         )
       } else if (item.type === 'hint') {
         fields.push(
-          <Col span={24} key={index}>
-            <Form.Item colon={!!item.label} label={item.label || ' '} className="hint">
+          <Col span={item.span || 24} key={index}>
+            <Form.Item colon={!!item.label} label={item.label || ' '} labelCol={item.labelCol} className="hint">
               <div className="message">{item.message}</div>
             </Form.Item>
           </Col>
@@ -789,8 +751,8 @@
         }
 
         fields.push(
-          <Col span={_colspan} key={index}>
-            <Form.Item label={item.tooltip ?
+          <Col span={item.span || 24} key={index}>
+            <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ?
               <Tooltip placement="topLeft" title={item.tooltip}>
                 <Icon type="question-circle" />
                 {item.label}
@@ -817,8 +779,8 @@
         let precision = (item.decimal || item.decimal === 0) ? item.decimal : null
 
         fields.push(
-          <Col span={_colspan} key={index}>
-            <Form.Item label={item.tooltip ?
+          <Col span={item.span || 24} key={index}>
+            <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ?
               <Tooltip placement="topLeft" title={item.tooltip}>
                 <Icon type="question-circle" />
                 {item.label}
@@ -845,8 +807,8 @@
         )
       } else if (item.type === 'color') { // 棰滆壊閫夋嫨
         fields.push(
-          <Col span={_colspan} key={index}>
-            <Form.Item label={item.tooltip ?
+          <Col span={item.span || 24} key={index}>
+            <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ?
               <Tooltip placement="topLeft" title={item.tooltip}>
                 <Icon type="question-circle" />
                 {item.label}
@@ -868,8 +830,8 @@
         )
       } else if (item.type === 'checkcard') { // 澶氶�夋
         fields.push(
-          <Col span={24} key={index}>
-            <Form.Item label={item.tooltip ?
+          <Col span={item.span || 24} key={index}>
+            <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ?
               <Tooltip placement="topLeft" title={item.tooltip}>
                 <Icon type="question-circle" />
                 {item.label}
@@ -889,8 +851,8 @@
         )
       } else if (item.type === 'switch') { // 澶氶�夋
         fields.push(
-          <Col span={_colspan} key={index}>
-            <Form.Item label={item.tooltip ?
+          <Col span={item.span || 24} key={index}>
+            <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ?
               <Tooltip placement="topLeft" title={item.tooltip}>
                 <Icon type="question-circle" />
                 {item.label}
@@ -912,8 +874,8 @@
         let _initval = item.initval ? item.initval.split(',').filter(Boolean) : []
         
         fields.push(
-          <Col span={_colspan} key={index}>
-            <Form.Item label={item.tooltip ?
+          <Col span={item.span || 24} key={index}>
+            <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ?
               <Tooltip placement="topLeft" title={item.tooltip}>
                 <Icon type="question-circle" />
                 {item.label}
@@ -937,8 +899,8 @@
         )
       } else if (item.type === 'radio') { // 鍗曢�夋
         fields.push(
-          <Col span={_colspan} key={index}>
-            <Form.Item label={item.tooltip ?
+          <Col span={item.span || 24} key={index}>
+            <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ?
               <Tooltip placement="topLeft" title={item.tooltip}>
                 <Icon type="question-circle" />
                 {item.label}
@@ -962,8 +924,8 @@
         )
       } else if (item.type === 'select' || item.type === 'link') { // 涓嬫媺鎼滅储
         fields.push(
-          <Col span={_colspan} key={index}>
-            <Form.Item label={item.tooltip ?
+          <Col span={item.span || 24} key={index}>
+            <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ?
               <Tooltip placement="topLeft" title={item.tooltip}>
                 <Icon type="question-circle" />
                 {item.label}
@@ -996,8 +958,8 @@
       } else if (item.type === 'multiselect') { // 澶氶��
         let _initval = item.initval ? item.initval.split(',').filter(Boolean) : []
         fields.push(
-          <Col span={_colspan} key={index}>
-            <Form.Item label={item.tooltip ?
+          <Col span={item.span || 24} key={index}>
+            <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ?
               <Tooltip placement="topLeft" title={item.tooltip}>
                 <Icon type="question-circle" />
                 {item.label}
@@ -1028,8 +990,8 @@
         )
       } else if (item.type === 'date') { // 鏃堕棿鎼滅储
         fields.push(
-          <Col span={_colspan} key={index}>
-            <Form.Item label={item.tooltip ?
+          <Col span={item.span || 24} key={index}>
+            <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ?
               <Tooltip placement="topLeft" title={item.tooltip}>
                 <Icon type="question-circle" />
                 {item.label}
@@ -1051,8 +1013,8 @@
         )
       } else if (item.type === 'datemonth') {
         fields.push(
-          <Col span={_colspan} key={index}>
-            <Form.Item label={item.tooltip ?
+          <Col span={item.span || 24} key={index}>
+            <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ?
               <Tooltip placement="topLeft" title={item.tooltip}>
                 <Icon type="question-circle" />
                 {item.label}
@@ -1074,8 +1036,8 @@
         )
       } else if (item.type === 'datetime') {
         fields.push(
-          <Col span={_colspan} key={index}>
-            <Form.Item label={item.tooltip ?
+          <Col span={item.span || 24} key={index}>
+            <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ?
               <Tooltip placement="topLeft" title={item.tooltip}>
                 <Icon type="question-circle" />
                 {item.label}
@@ -1116,8 +1078,8 @@
         }
 
         fields.push(
-          <Col span={_colspan} key={index}>
-            <Form.Item label={item.tooltip ?
+          <Col span={item.span || 24} key={index}>
+            <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ?
               <Tooltip placement="topLeft" title={item.tooltip}>
                 <Icon type="question-circle" />
                 {item.label}
@@ -1139,8 +1101,8 @@
         )
       } else if (item.type === 'linkMain') {
         fields.push(
-          <Col span={_colspan} key={index}>
-            <Form.Item label={item.tooltip ?
+          <Col span={item.span || 24} key={index}>
+            <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ?
               <Tooltip placement="topLeft" title={item.tooltip}>
                 <Icon type="question-circle" />
                 {item.label}
@@ -1170,8 +1132,8 @@
           }]
         }
         fields.push(
-          <Col span={24} key={index}>
-            <Form.Item label={item.tooltip ?
+          <Col span={item.span || 24} key={index}>
+            <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.tooltip ?
               <Tooltip placement="topLeft" title={item.tooltip}>
                 <Icon type="question-circle" />
                 {item.label}
@@ -1198,8 +1160,8 @@
         let _max = item.fieldlength || 512
 
         fields.push(
-          <Col span={24} key={index}>
-            <Form.Item label={item.hidelabel !== 'true' && item.tooltip ?
+          <Col span={item.span || 24} key={index}>
+            <Form.Item extra={item.extra || null} labelCol={item.labelCol} label={item.hidelabel !== 'true' && item.tooltip ?
               <Tooltip placement="topLeft" title={item.tooltip}>
                 <Icon type="question-circle" />
                 {item.label}
@@ -1389,21 +1351,9 @@
   }
 
   render() {
-    const { cols } = this.state
-    const formItemLayout = {
-      // labelCol: {
-      //   xs: { span: 24 },
-      //   sm: { span: 8 }
-      // },
-      // wrapperCol: {
-      //   xs: { span: 24 },
-      //   sm: { span: 16 }
-      // }
-    }
-
     return (
-      <Form {...formItemLayout} className="main-form-field" id="main-form-box">
-        <Row className={'cols' + cols} gutter={24}>{this.getFields()}</Row>
+      <Form className="main-form-field" id="main-form-box">
+        <Row gutter={24}>{this.getFields()}</Row>
       </Form>
     )
   }

--
Gitblit v1.8.0