From f3167f8371d19d0ea8fe7d0e7af5517ff0b08cd2 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 07 四月 2021 23:25:29 +0800
Subject: [PATCH] 2021-04-07

---
 src/templates/zshare/modalform/index.jsx |  158 +++++++++++++++++++++++++++-------------------------
 1 files changed, 82 insertions(+), 76 deletions(-)

diff --git a/src/templates/zshare/modalform/index.jsx b/src/templates/zshare/modalform/index.jsx
index b871d33..dd53a73 100644
--- a/src/templates/zshare/modalform/index.jsx
+++ b/src/templates/zshare/modalform/index.jsx
@@ -14,31 +14,33 @@
 const { TextArea } = Input
 
 const modalTypeOptions = {
-  text: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'regular', 'interception', 'entireLine', 'tooltip', 'enter'],
-  number: ['initval', 'readonly', 'hidden', 'decimal', 'min', 'max', 'readin', 'entireLine', 'tooltip', 'enter'],
-  select: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'setAll', 'linkSubField', 'entireLine', 'tooltip', 'emptyText', 'enter'],
-  checkbox: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'entireLine', 'tooltip'],
-  radio: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'linkSubField', 'entireLine', 'tooltip', 'setAll', 'emptyText'],
-  checkcard: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'linkSubField', 'fieldlength', 'display', 'tooltip', 'width', 'multiple'],
-  multiselect: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'fieldlength', 'entireLine', 'tooltip'],
-  link: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'setAll', 'linkField', 'entireLine', 'tooltip', 'emptyText', 'enter'],
-  fileupload: ['readonly', 'required', 'readin', 'fieldlength', 'maxfile', 'fileType', 'entireLine', 'tooltip', 'suffix'],
-  switch: ['initval', 'openVal', 'closeVal', 'openText', 'closeText', 'readonly', 'hidden', 'readin', 'entireLine', 'tooltip'],
-  date: ['initval', 'readonly', 'required', 'hidden', 'readin', 'entireLine', 'tooltip'],
-  datemonth: ['initval', 'readonly', 'required', 'hidden', 'readin', 'entireLine', 'tooltip'],
-  datetime: ['initval', 'readonly', 'required', 'hidden', 'readin', 'entireLine', 'tooltip'],
-  textarea: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'maxRows', 'encryption', 'interception', 'tooltip'],
-  color: ['initval', 'readonly', 'required', 'hidden', 'readin', 'entireLine', 'tooltip'],
-  hint: ['label', 'type', 'blacklist', 'message'],
-  brafteditor: ['required', 'hidelabel', 'hidden', 'readin', 'fieldlength', 'readonly', 'tooltip', 'encryption'],
-  funcvar: [],
-  linkMain: ['readonly', 'required', 'hidden', 'fieldlength', 'entireLine', 'tooltip']
+  text: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'regular', 'interception', 'span', 'labelwidth', 'tooltip', 'extra', 'enter'],
+  number: ['initval', 'readonly', 'hidden', 'decimal', 'min', 'max', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'enter'],
+  select: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'setAll', 'linkSubField', 'span', 'labelwidth', 'tooltip', 'extra', 'emptyText', 'enter'],
+  checkbox: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'span', 'labelwidth', 'tooltip', 'extra'],
+  radio: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'linkSubField', 'span', 'labelwidth', 'tooltip', 'extra', 'setAll', 'emptyText'],
+  checkcard: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'linkSubField', 'fieldlength', 'span', 'labelwidth', 'display', 'tooltip', 'extra', 'width', 'multiple'],
+  multiselect: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra'],
+  link: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'setAll', 'linkField', 'span', 'labelwidth', 'tooltip', 'extra', 'emptyText', 'enter'],
+  fileupload: ['readonly', 'required', 'readin', 'fieldlength', 'maxfile', 'fileType', 'span', 'labelwidth', 'tooltip', 'extra', 'suffix'],
+  switch: ['initval', 'openVal', 'closeVal', 'openText', 'closeText', 'readonly', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra'],
+  date: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra'],
+  datemonth: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra'],
+  datetime: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra'],
+  textarea: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'span', 'labelwidth', 'maxRows', 'encryption', 'interception', 'tooltip', 'extra'],
+  color: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra'],
+  hint: ['label', 'type', 'blacklist', 'message', 'span', 'labelwidth'],
+  split: ['label', 'type'],
+  brafteditor: ['required', 'hidelabel', 'hidden', 'readin', 'fieldlength', 'readonly', 'span', 'labelwidth', 'tooltip', 'extra', 'encryption'],
+  funcvar: ['span', 'labelwidth'],
+  linkMain: ['readonly', 'required', 'hidden', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra']
 }
 
 class MainSearch extends Component {
   static propTpyes = {
     dict: PropTypes.object,    // 瀛楀吀椤�
     formlist: PropTypes.any,
+    standardform: PropTypes.any,
     card: PropTypes.object,
     inputSubmit: PropTypes.any
   }
@@ -56,7 +58,6 @@
 
   UNSAFE_componentWillMount () {
     let formlist = fromJS(this.props.formlist).toJS()
-
     let type = ''
     let resourceType = ''
     let supField = ''
@@ -147,6 +148,8 @@
 
     if (type === 'hint') {
       _options = fromJS(modalTypeOptions[type]).toJS()
+    } else if (type === 'split') {
+      return fromJS(modalTypeOptions[type]).toJS()
     } else if (['multiselect', 'select', 'link', 'radio', 'checkbox'].includes(type)) {
       if (resourceType === '0') {        // 鑷畾涔夎祫婧�
         _options.push('options')
@@ -232,7 +235,7 @@
             }
           } else if (form.key === 'fieldlength') {
             form.initVal = 50
-            if (value === 'textarea') {
+            if (value === 'textarea' || value === 'brafteditor') {
               form.initVal = 8000
             } else if (value === 'fileupload' || value === 'multiselect' || value === 'checkbox') {
               form.initVal = 512
@@ -361,6 +364,50 @@
     })
   }
 
+  changeVal = (val, type) => {
+    if (type !== 'span' || ![24, 12, 8, 6].includes(val)) return
+
+    const { standardform } = this.props
+
+    if (!standardform || ![24, 12, 8, 6].includes(standardform.span) || !standardform.labelwidth) return
+
+    let labelwidth = null
+
+    if (standardform.span === val) {
+      labelwidth = standardform.labelwidth
+    } else if (standardform.span > val) {
+      labelwidth = 33.3
+    } else {
+      switch(standardform.span) {
+        case 12:
+          labelwidth = 16.2
+          break;
+        case 8:
+          if (val === 12) {
+            labelwidth = 21.6
+          } else {
+            labelwidth = 10.5
+          }
+          break;
+        case 6:
+          if (val === 8) {
+            labelwidth = 24.3
+          } else if (val === 12) {
+            labelwidth = 15.8
+          } else {
+            labelwidth = 7.7
+          }
+          break;
+        default:
+      }
+    } 
+
+
+    if (labelwidth) {
+      this.props.form.setFieldsValue({labelwidth})
+    }
+  }
+
   handleSubmit = (e) => {
     e.preventDefault()
 
@@ -417,10 +464,15 @@
           </Col>
         )
       } else if (item.type === 'number') {
-        if (item.key === 'decimal') {
+        if (item.max) {
           fields.push(
             <Col span={12} key={index}>
-              <Form.Item label={item.label}>
+              <Form.Item label={item.tooltip ?
+                <Tooltip placement="topLeft" title={item.tooltip}>
+                  <Icon type="question-circle" />
+                  {item.label}
+                </Tooltip> : item.label
+              }>
                 {getFieldDecorator(item.key, {
                   initialValue: item.initVal || 0,
                   rules: [
@@ -429,50 +481,18 @@
                       message: this.props.dict['form.required.input'] + item.label + '!'
                     }
                   ]
-                })(<InputNumber min={0} max={18} precision={0} />)}
+                })(<InputNumber onChange={(value) => this.changeVal(value, item.key)} min={item.min} max={item.max} precision={item.precision} onPressEnter={this.handleSubmit}/>)}
               </Form.Item>
             </Col>
           )
-        } else if (item.key === 'fieldlength' || item.key === 'maxfile') {
+        } else {
           fields.push(
             <Col span={12} key={index}>
-              <Form.Item label={item.label}>
-                {getFieldDecorator(item.key, {
-                  initialValue: item.initVal,
-                  rules: [
-                    {
-                      required: !!item.required,
-                      message: this.props.dict['form.required.input'] + item.label + '!'
-                    }
-                  ]
-                })(<InputNumber min={1} precision={0} />)}
-              </Form.Item>
-            </Col>
-          )
-        } else if (item.key === 'maxRows') {
-          fields.push(
-            <Col span={12} key={index}>
-              <Form.Item label={item.label}>
-                {getFieldDecorator(item.key, {
-                  initialValue: item.initVal,
-                  rules: [
-                    {
-                      required: !!item.required,
-                      message: this.props.dict['form.required.input'] + item.label + '!'
-                    }
-                  ]
-                })(<InputNumber min={2} max={100} precision={0} />)}
-              </Form.Item>
-            </Col>
-          )
-        } else if (item.key === 'width') {
-          fields.push(
-            <Col span={12} key={index}>
-              <Form.Item label={
+              <Form.Item label={item.tooltip ?
                 <Tooltip placement="topLeft" title={item.tooltip}>
                   <Icon type="question-circle" />
                   {item.label}
-                </Tooltip>
+                </Tooltip> : item.label
               }>
                 {getFieldDecorator(item.key, {
                   initialValue: item.initVal,
@@ -482,23 +502,7 @@
                       message: this.props.dict['form.required.input'] + item.label + '!'
                     }
                   ]
-                })(<InputNumber min={1} max={24} precision={0} />)}
-              </Form.Item>
-            </Col>
-          )
-        } else {
-          fields.push(
-            <Col span={12} key={index}>
-              <Form.Item label={item.label}>
-                {getFieldDecorator(item.key, {
-                  initialValue: item.initVal,
-                  rules: [
-                    {
-                      required: !!item.required,
-                      message: this.props.dict['form.required.input'] + item.label + '!'
-                    }
-                  ]
-                })(<InputNumber />)}
+                })(<InputNumber onPressEnter={this.handleSubmit}/>)}
               </Form.Item>
             </Col>
           )
@@ -710,6 +714,8 @@
             }
           } else if (values.type === 'linkMain') {
             values.initval = ''
+          } else if (values.type === 'split') {
+            values.span = 24
           }
 
           ['linkField', 'valueField', 'valueText', 'orderBy'].forEach(item => {

--
Gitblit v1.8.0