From 95afd40fc2741ac0ce59c2091f6cfce1f98877d4 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 24 六月 2021 09:15:45 +0800
Subject: [PATCH] 2021-06-24

---
 src/templates/zshare/modalform/index.jsx |  592 +++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 396 insertions(+), 196 deletions(-)

diff --git a/src/templates/zshare/modalform/index.jsx b/src/templates/zshare/modalform/index.jsx
index 701f2bc..2c30977 100644
--- a/src/templates/zshare/modalform/index.jsx
+++ b/src/templates/zshare/modalform/index.jsx
@@ -1,18 +1,48 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
+import { fromJS } from 'immutable'
 import { Form, Row, Col, Input, Select, Icon, Radio, notification, InputNumber, Tooltip } from 'antd'
 import { formRule } from '@/utils/option.js'
 import { dateOptions } from '@/utils/option.js'
-import EditTable from '../modaleditable'
+import Utils from '@/utils/utils.js'
+import EditTable from './modaleditable'
+import asyncComponent from '@/utils/asyncComponent'
+import CodeMirror from '@/templates/zshare/codemirror'
 import './index.scss'
 
 const { TextArea } = Input
+const ColorSketch = asyncComponent(() => import('@/mob/colorsketch'))
+const FieldsTable = asyncComponent(() => import('./fieldtable'))
+const DataTable = asyncComponent(() => import('./datatable'))
+
+const modalTypeOptions = {
+  text: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'regular', 'interception', 'span', 'labelwidth', 'tooltip', 'extra', 'enter', 'cursor', 'scan'],
+  number: ['initval', 'readonly', 'hidden', 'decimal', 'min', 'max', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'enter', 'cursor'],
+  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', 'borderColor'],
+  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', 'compress'],
+  switch: ['initval', 'openVal', 'closeVal', 'openText', 'closeText', 'readonly', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra'],
+  date: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'declareType', 'mode'],
+  datemonth: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'declareType'],
+  datetime: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'declareType', 'mode'],
+  textarea: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'span', 'labelwidth', 'maxRows', 'encryption', 'interception', 'tooltip', 'extra', 'count'],
+  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,    // 瀛楀吀椤�
-    optionLibs: PropTypes.any, // 鑷畾涔変笅鎷夐泦
     formlist: PropTypes.any,
+    standardform: PropTypes.any,
     card: PropTypes.object,
     inputSubmit: PropTypes.any
   }
@@ -21,22 +51,36 @@
     openType: null,
     resourceType: null,
     supField: '',
+    compress: 'false',
+    display: 'text',
+    enter: '',
+    cFields: [],
     formlist: null,
     linkSubFields: null
   }
 
   UNSAFE_componentWillMount () {
-    const { optionLibs } = this.props
-    let formlist = JSON.parse(JSON.stringify(this.props.formlist))
-
+    let formlist = fromJS(this.props.formlist).toJS()
     let type = ''
     let resourceType = ''
     let supField = ''
+    let display = ''
+    let compress = 'false'
+    let enter = ''
+    let cFields = []
     let linkSubFields = []
 
     formlist.forEach(cell => {
       if (cell.key === 'type') {
         type = cell.initVal
+      } else if (cell.key === 'compress') {
+        compress = cell.initVal
+      } else if (cell.key === 'display') {
+        display = cell.initVal
+      } else if (cell.key === 'enter') {
+        enter = cell.initVal
+      } else if (cell.key === 'fields') {
+        cFields = cell.initVal
       } else if (cell.key === 'resourceType') {
         resourceType = cell.initVal
       } else if (cell.key === 'linkSubField') {
@@ -54,62 +98,37 @@
       }
     })
     
-    let _options = ['label', 'field', 'initval', 'type', 'readonly', 'required', 'hidden', 'readin', 'blacklist'] // 榛樿鏄剧ず椤�
-
-    if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '0') { // 閫夋嫨绫诲瀷銆佽嚜瀹氫箟璧勬簮
-      _options = [..._options, 'resourceType', 'options', 'quick']
-    } else if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '1') { // 閫夋嫨绫诲瀷銆佹暟鎹簮
-      _options = [..._options, 'resourceType', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'database']
-    } else if (type === 'number') {
-      _options = ['label', 'field', 'initval', 'type', 'readonly', 'hidden', 'decimal', 'min', 'max', 'readin', 'blacklist']
-    } else if (type === 'fileupload') {
-      _options = ['label', 'field', 'type', 'readonly', 'required', 'readin', 'fieldlength', 'blacklist']
-    } else if (type === 'textarea') {
-      _options = [..._options, 'fieldlength', 'maxRows']
-    } else if (type === 'text') {
-      _options = [..._options, 'fieldlength', 'regular']
-    }
-
-    if (type === 'select') {
-      _options = [..._options, 'setAll', 'linkSubField']
-    } else if (type === 'multiselect') {
-      _options = [..._options, 'fieldlength']
-    } else if (type === 'link') {          // 鍏宠仈绫诲瀷銆佸鍔犲叧鑱斿瓧娈�
-      _options = [..._options, 'setAll', 'linkField']
-    } else if (type === 'funcvar') {       // 璁剧疆涓哄嚱鏁板彉閲忔椂锛屼笉闇�瑕佸叾浠栦俊鎭�
-      _options = ['label', 'field', 'type', 'blacklist']
-    } else if (type === 'linkMain') {
-      _options = ['label', 'field', 'type', 'readonly', 'required', 'hidden', 'fieldlength', 'blacklist']
-    }
-
-    if (type !== 'funcvar' && type !== 'linkMain') {
-      if (supField) {
-        _options.push('supField', 'supvalue')
-      } else {
-        _options.push('supField')
-      }
-    }
+    let _options = this.getOptions(type, resourceType, supField, display, enter, compress)
 
     this.setState({
+      enter: enter,
+      compress: compress,
       openType: type,
       supField: supField,
+      display: display,
+      cFields: cFields,
       resourceType: resourceType,
       linkSubFields: linkSubFields,
       formlist: formlist.map(form => {
         if (dateOptions.hasOwnProperty(type) && form.key === 'initval') {
           form.options = dateOptions[type]
           form.type = 'select'
+        } else if (type === 'switch' && form.key === 'initval') {
+          form.initVal = !!form.initVal
+          form.options = [
+            {value: true, text: '寮�'},
+            {value: false, text: '鍏�'}
+          ]
+          form.type = 'radio'
         } else if (type === 'number' && form.key === 'initval') {
           form.type = 'number'
           form.initVal = form.initVal || 0
           form.required = true
-        } else if (form.key === 'quick') {
-          form.options = [...optionLibs.values()].map(cell => {
-            return {
-              value: cell.uuid,
-              text: cell.label + '(' + cell.parname + ')'
-            }
-          })
+        } else if (form.key === 'label') {
+          form.required = true
+          if (type === 'hint') {
+            form.required = false
+          }
         }
 
         form.show = _options.includes(form.key)
@@ -131,47 +150,75 @@
     }
   }
 
-  openTypeChange = (key, value) => {
+  getOptions = (type, resourceType, supField, display, enter, compress) => {
+    let _options = ['label', 'field', 'type', 'blacklist', 'writein', ...fromJS(modalTypeOptions[type]).toJS()]
 
-    if (key === 'type') {
-      let _options = ['label', 'field', 'initval', 'type', 'readonly', 'required', 'hidden', 'readin', 'blacklist']
-
-      if ((value === 'multiselect' || value === 'select' || value === 'link') && this.state.resourceType === '0') { // 閫夋嫨绫诲瀷銆佽嚜瀹氫箟璧勬簮
-        _options = [..._options, 'resourceType', 'options', 'quick']
-      } else if ((value === 'multiselect' || value === 'select' || value === 'link') && this.state.resourceType === '1') { // 閫夋嫨绫诲瀷銆佹暟鎹簮
-        _options = [..._options, 'resourceType', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'database']
-      } else if (value === 'number') {
-        _options = ['label', 'field', 'initval', 'type', 'readonly', 'hidden', 'decimal', 'min', 'max', 'readin', 'blacklist']
-      } else if (value === 'fileupload') {
-        _options = ['label', 'field', 'type', 'readonly', 'required', 'readin', 'fieldlength', 'blacklist']
-      } else if (value === 'textarea') {
-        _options = [..._options, 'fieldlength', 'maxRows']
-      } else if (value === 'text') {
-        _options = [..._options, 'fieldlength', 'regular']
+    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')
+      } else if (resourceType === '1') { // 鏁版嵁婧�
+        _options.push('dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'database')
       }
-
-      if (value === 'select') {
-        _options = [..._options, 'setAll', 'linkSubField']
-      } else if (value === 'multiselect') {
-        _options = [..._options, 'fieldlength']
-      } else if (value === 'link') {
-        _options = [..._options, 'setAll', 'linkField']
-      } else if (value === 'funcvar') {
-        _options = ['label', 'field', 'type', 'blacklist']
-      } else if (value === 'linkMain') {
-        _options = ['label', 'field', 'type', 'readonly', 'required', 'hidden', 'fieldlength', 'blacklist']
-      }
-
-      if (value !== 'funcvar' && value !== 'linkMain') {
-        if (this.state.supField) {
-          _options.push('supField', 'supvalue')
-        } else {
-          _options.push('supField')
+    } else if (type === 'checkcard') {
+      if (display === 'picture') {
+        if (resourceType === '0') {        // 鑷畾涔夎祫婧�
+          _options.push('options', 'ratio')
+        } else if (resourceType === '1') { // 鏁版嵁婧�
+          _options.push('dataSource', 'cardValField', 'urlField', 'orderBy', 'orderType', 'database', 'ratio')
+        }
+      } else {
+        if (resourceType === '0') {        // 鑷畾涔夎祫婧�
+          _options.push('options', 'fields', 'backgroundColor')
+        } else if (resourceType === '1') { // 鏁版嵁婧�
+          _options.push('dataSource', 'cardValField', 'fields', 'orderBy', 'orderType', 'database', 'backgroundColor')
         }
       }
+    } else if (type === 'fileupload') {
+      if (compress === 'true') {
+        _options.push('limit', 'rduri', 'proRduri')
+      } else {
+        _options.push('suffix')
+      }
+    }
+
+    if (type === 'text' || type === 'number' || type === 'select' || type === 'link') {
+      if (enter === 'tab' || enter === 'sub') {
+        _options.push('tabField')
+      }
+    }
+
+    if (type !== 'funcvar' && type !== 'linkMain') {
+      if (supField) {
+        _options.push('supField', 'supvalue')
+      } else {
+        _options.push('supField')
+      }
+    }
+
+    return _options
+  }
+
+  openTypeChange = (key, value) => {
+    if (key === 'type') {
+      let enter = 'false'
+      let fieldValue = {}
+
+      if (value === 'text' || value === 'number') {
+        enter = 'sub'
+        fieldValue.enter = 'sub'
+      } else if (value === 'select' || value === 'link') {
+        fieldValue.enter = 'false'
+      }
+
+      let _options = this.getOptions(value, this.state.resourceType, this.state.supField, this.state.display, enter, this.state.compress)
       
       this.setState({
         openType: value,
+        enter: enter,
         formlist: this.state.formlist.map(form => {
           form.show = _options.includes(form.key)
           if (form.key === 'initval') {
@@ -180,6 +227,13 @@
             if (dateOptions.hasOwnProperty(value)) {
               form.options = dateOptions[value]
               form.type = 'select'
+            } else if (value === 'switch') {
+              form.initVal = false
+              form.options = [
+                {value: true, text: '寮�'},
+                {value: false, text: '鍏�'}
+              ]
+              form.type = 'radio'
             } else if (value === 'number') {
               form.type = 'number'
               form.required = true
@@ -187,43 +241,52 @@
             } else {
               form.type = 'text'
             }
-            form.show = false
+
+            if (form.show) {
+              fieldValue.initval = form.initVal
+            }
           } else if (form.key === 'fieldlength') {
             form.initVal = 50
-            if (value === 'textarea' || value === 'fileupload') {
+            if (value === 'textarea' || value === 'brafteditor') {
+              form.initVal = 8000
+            } else if (value === 'fileupload' || value === 'multiselect' || value === 'checkbox') {
               form.initVal = 512
             }
-            form.show = false
+
+            if (form.show) {
+              fieldValue.fieldlength = form.initVal
+            }
           } else if (form.key === 'resourceType') {
             form.initVal = this.state.resourceType
+
+            if (form.show) {
+              fieldValue.resourceType = form.initVal
+            }
           } else if (form.key === 'linkSubField') {
             form.initVal = this.state.linkSubFields.map(_field => _field.field)
+
+            if (form.show) {
+              fieldValue.linkSubField = form.initVal
+            }
+          } else if (form.key === 'label') {
+            form.required = true
+            if (value === 'hint') {
+              form.required = false
+            }
+          } else if (form.key === 'encryption') {
+            if (value === 'brafteditor') {
+              fieldValue.encryption = 'true'
+            }
+          } else if (form.key === 'hidden') {
+            if (value === 'linkMain') {
+              fieldValue.hidden = 'true'
+            }
           }
+
           return form
         })
       }, () => {
-        this.setState({
-          formlist: this.state.formlist.map(form => {
-            if (form.key === 'initval' && value !== 'fileupload' && value !== 'funcvar' && value !== 'linkMain') {
-              form.show = true
-            } else if (form.key === 'fieldlength' && (value === 'fileupload' || value === 'multiselect' || value === 'text' || value === 'textarea' || value === 'linkMain')) {
-              form.show = true
-            }
-            return form
-          })
-        })
-      })
-    } else if (key === 'quick') {
-      let option = this.props.optionLibs.get(value)
-
-      this.setState({
-        formlist: this.state.formlist.map(form => {
-          if (form.key === 'options') {
-            form.initVal = option.options
-          }
-
-          return form
-        })
+        this.props.form.setFieldsValue(fieldValue)
       })
     } else if (key === 'supField') {
       this.setState({
@@ -264,23 +327,10 @@
   }
 
   onChange = (e, key) => {
-    const { openType } = this.state
+    const { openType, compress } = this.state
     let value = e.target.value
     if (key === 'resourceType') {
-      let _options = ['label', 'field', 'initval', 'type', 'resourceType', 'readonly', 'required', 'hidden', 'readin', 'blacklist']
-      if (value === '0') {
-        _options = [..._options, 'options', 'quick']
-      } else if (value === '1') {
-        _options = [..._options, 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'database']
-      }
-
-      if (openType === 'select') {
-        _options = [..._options, 'setAll', 'linkSubField']
-      } else if (openType === 'link') {
-        _options = [..._options, 'setAll', 'linkField']
-      } else if (openType === 'multiselect') {
-        _options = [..._options, 'fieldlength']
-      }
+      let _options = this.getOptions(openType, value, this.state.supField, this.state.display, this.state.enter, compress)
       
       this.setState({
         resourceType: value,
@@ -289,6 +339,98 @@
           return form
         })
       })
+    } else if (key === 'display') {
+      let _options = this.getOptions(openType, this.state.resourceType, this.state.supField, value, this.state.enter, compress)
+      
+      this.setState({
+        display: value,
+        formlist: this.state.formlist.map(form => {
+          form.show = _options.includes(form.key)
+          return form
+        })
+      })
+    } else if (key === 'compress') {
+      let _options = this.getOptions(openType, this.state.resourceType, this.state.supField, this.state.display, this.state.enter, value)
+      
+      this.setState({
+        compress: value,
+        formlist: this.state.formlist.map(form => {
+          form.show = _options.includes(form.key)
+          return form
+        })
+      })
+    } else if (key === 'enter') {
+      let _options = this.getOptions(openType, this.state.resourceType, this.state.supField, this.state.display, value, compress)
+      
+      this.setState({
+        enter: value,
+        formlist: this.state.formlist.map(form => {
+          form.show = _options.includes(form.key)
+          return form
+        })
+      })
+    } else if (key === 'multiple') {
+      if (value === 'true') {
+        this.props.form.setFieldsValue({fieldlength: 512})
+      } else {
+        this.props.form.setFieldsValue({fieldlength: 50})
+      }
+    }
+  }
+
+  changeField = (data) => {
+    this.setState({
+      cFields: data,
+      formlist: this.state.formlist.map(form => {
+        if (form.key === 'fields') {
+          form.initVal = data
+        }
+        return form
+      })
+    })
+  }
+
+  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})
     }
   }
 
@@ -302,10 +444,11 @@
 
   getFields() {
     const { getFieldDecorator } = this.props.form
+    const { openType } = this.state
     const fields = []
 
     this.state.formlist.forEach((item, index) => {
-      if (!item.show) return
+      if (!item.show || item.forbid) return null
 
       if (item.type === 'text') { // 鏂囨湰鎼滅储
         let rules = []
@@ -347,10 +490,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: [
@@ -359,46 +507,19 @@
                       message: this.props.dict['form.required.input'] + item.label + '!'
                     }
                   ]
-                })(<InputNumber min={0} max={18} precision={0} />)}
-              </Form.Item>
-            </Col>
-          )
-        } else if (item.key === 'fieldlength') {
-          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} />)}
+                })(<InputNumber onChange={(value) => this.changeVal(value, item.key)} min={item.min} max={item.max} precision={item.precision} onPressEnter={this.handleSubmit}/>)}
               </Form.Item>
             </Col>
           )
         } else {
           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,
                   rules: [
@@ -407,7 +528,7 @@
                       message: this.props.dict['form.required.input'] + item.label + '!'
                     }
                   ]
-                })(<InputNumber />)}
+                })(<InputNumber onPressEnter={this.handleSubmit}/>)}
               </Form.Item>
             </Col>
           )
@@ -436,9 +557,9 @@
                   onChange={(value) => {this.openTypeChange(item.key, value)}}
                   getPopupContainer={() => document.getElementById('modal-fields-form-box')}
                 >
-                  {item.options.map(option =>
-                    <Select.Option id={option.value} title={option.text} key={option.value} value={option.value}>
-                      {item.key === 'icon' && <Icon type={option.text} />} {option.text}
+                  {item.options.map((option, i) =>
+                    <Select.Option key={`${i}`} value={option.value || option.field || ''}>
+                      {item.key === 'icon' && <Icon type={option.text} />} {option.text || option.label}
                     </Select.Option>
                   )}
                 </Select>
@@ -449,7 +570,12 @@
       } else if (item.type === 'multiselect') { // 澶氶��
         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
               })(
@@ -498,10 +624,10 @@
             </Form.Item>
           </Col>
         )
-      } else if (item.type === 'textarea') {
+      } else if (item.type === 'codemirror') {
         fields.push(
-          <Col span={20} offset={4} key={index}>
-            <Form.Item className="text-area">
+          <Col span={24} key={index}>
+            <Form.Item className="text-area" label={item.label}>
               {getFieldDecorator(item.key, {
                 initialValue: item.initVal,
                 rules: [
@@ -510,14 +636,71 @@
                     message: this.props.dict['form.required.input'] + item.label + '!'
                   }
                 ]
-              })(<TextArea rows={4} />)}
+              })(<CodeMirror />)}
+            </Form.Item>
+          </Col>
+        )
+      } else if (item.type === 'textarea') {
+        fields.push(
+          <Col span={24} key={index}>
+            <Form.Item className="text-msg" label={item.tooltip ?
+              <Tooltip placement="topLeft" overlayClassName={item.tooltipClass} title={item.tooltip}>
+                <Icon type="question-circle" />
+                {item.label}
+              </Tooltip> : item.label
+            }>
+              {getFieldDecorator(item.key, {
+                initialValue: item.initVal,
+                rules: [
+                  {
+                    required: !!item.required,
+                    message: this.props.dict['form.required.input'] + item.label + '!'
+                  }
+                ]
+              })(<TextArea rows={item.rows || 4} />)}
             </Form.Item>
           </Col>
         )
       } else if (item.type === 'options') {
+        if (openType !== 'checkcard') {
+          fields.push(
+            <Col span={24} key={index}>
+              <Form.Item label={item.label} className="text-area">
+                {getFieldDecorator(item.key, {
+                  initialValue: item.initVal
+                })(<EditTable dict={this.props.dict} type={openType} linkSubFields={this.state.linkSubFields}/>)}
+              </Form.Item>
+            </Col>
+          )
+        } else {
+          fields.push(
+            <Col span={24} key={index}>
+              <Form.Item label={item.label} className="text-area">
+                {getFieldDecorator(item.key, {
+                  initialValue: item.initVal
+                })(<DataTable dict={this.props.dict} type={this.state.display} fields={this.state.cFields}/>)}
+              </Form.Item>
+            </Col>
+          )
+        }
+      } else if (item.type === 'fields') {
         fields.push(
-          <Col span={20} offset={4} key={index}>
-            <EditTable data={item.initVal} dict={this.props.dict} type={this.state.openType} linkSubFields={this.state.linkSubFields} ref="editTable"/>
+          <Col span={24} key={index}>
+            <Form.Item label={item.label} className="text-area">
+              {getFieldDecorator(item.key, {
+                initialValue: item.initVal
+              })(<FieldsTable dict={this.props.dict} onChange={this.changeField}/>)}
+            </Form.Item>
+          </Col>
+        )
+      } else if (item.type === 'color') {
+        fields.push(
+          <Col span={12} key={index}>
+            <Form.Item label={item.label} className="color-form-item">
+              {getFieldDecorator(item.key, {
+                initialValue: item.initVal
+              })(<ColorSketch allowClear={true}/>)}
+            </Form.Item>
           </Col>
         )
       }
@@ -531,52 +714,69 @@
     return new Promise((resolve, reject) => {
       this.props.form.validateFieldsAndScroll((err, values) => {
         if (!err) {
-          let isvalid = true
           values.uuid = this.props.card.uuid
-          // 涓嬫媺鑿滃崟鎴栧叧鑱旇彍鍗�
-          if ((values.type === 'multiselect' || values.type === 'select' || values.type === 'link') && values.resourceType === '0') {
-            values.options = this.refs.editTable.state.dataSource
-            values.dataSource = ''
-            let emptys = []
-            if (values.type === 'multiselect' || values.type === 'select') {
-              emptys = values.options.filter(op => !(op.Value && op.Text))
-            } else {
-              emptys = values.options.filter(op => !(op.Value && op.Text && op.ParentID))
-            }
-            if (emptys.length > 0) {
-              isvalid = false
-              notification.warning({
-                top: 92,
-                message: this.props.dict['header.form.selectItem.error'],
-                duration: 10
+          // 涓嬫媺鑿滃崟鎴栬仈鍔ㄨ彍鍗�
+          if (['multiselect', 'select', 'link', 'radio', 'checkbox'].includes(values.type)) {
+            if (values.resourceType === '0') {
+              values.options = values.options || []
+              values.dataSource = ''
+              let empty = false
+
+              values.options.forEach(op => {
+                if (!((op.Value || op.Value === 0) && (op.Text || op.Text === 0))) {
+                  empty = true
+                } else if (values.type === 'link' && !(op.ParentID || op.ParentID === 0)) {
+                  empty = true
+                }
               })
+
+              if (empty) {
+                notification.warning({
+                  top: 92,
+                  message: this.props.dict['model.form.selectItem.error'],
+                  duration: 5
+                })
+                return
+              }
+            } else {
+              values.options = []
             }
-          } else if ((values.type === 'multiselect' || values.type === 'select' || values.type === 'link') && values.resourceType === '1') {
-            values.options = []
           } else if (values.type === 'funcvar') { // 鍑芥暟鍙橀噺涓哄彧璇诲厓绱�
             values.readonly = 'true'
-          } else if (values.type === 'number' && (values.min || values.min === 0) && (values.max || values.max === 0)) { // 鏁板�煎瀷楠岃瘉鏈�灏忔渶澶у��
-            if (values.min > values.max) {
-              isvalid = false
+          } else if (values.type === 'number') {  // 鏁板�煎瀷楠岃瘉鏈�灏忔渶澶у��
+            values.required = 'true'
+            if ((values.min || values.min === 0) && (values.max || values.max === 0) && values.min > values.max) {
               notification.warning({
                 top: 92,
                 message: '鏈�灏忓�间笉鍙ぇ浜庢渶澶у�硷紒',
-                duration: 10
+                duration: 5
               })
+              return
             }
           } else if (values.type === 'linkMain') {
             values.initval = ''
+          } else if (values.type === 'split') {
+            values.span = 24
           }
 
           ['linkField', 'valueField', 'valueText', 'orderBy'].forEach(item => {
             if (values[item]) {
-              values[item] = values[item].replace(/\s* | \t* | \v* | \r*/ig, '')
+              values[item] = values[item].replace(/\s*|\t*|\v*|\r*/ig, '')
             }
           })
 
-          if (isvalid) {
-            resolve(values)
+          let error = Utils.verifySql(values.dataSource)
+
+          if (error) {
+            notification.warning({
+              top: 92,
+              message: '鏁版嵁婧愪腑涓嶅彲浣跨敤' + error,
+              duration: 5
+            })
+            return
           }
+
+          resolve(values)
         } else {
           reject(err)
         }
@@ -596,7 +796,7 @@
       }
     }
     return (
-      <Form {...formItemLayout} className="ant-advanced-search-form modal-fields-form" id="modal-fields-form-box">
+      <Form {...formItemLayout} className="modal-fields-form" id="modal-fields-form-box">
         <Row gutter={24}>{this.getFields()}</Row>
       </Form>
     )

--
Gitblit v1.8.0