From ac1d52c46ff9019fcc93cf3d5e7ab17cf850824e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 10 八月 2023 16:05:24 +0800
Subject: [PATCH] 2023-08-10

---
 src/templates/zshare/modalform/index.jsx |  190 ++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 152 insertions(+), 38 deletions(-)

diff --git a/src/templates/zshare/modalform/index.jsx b/src/templates/zshare/modalform/index.jsx
index 0865361..b49f28b 100644
--- a/src/templates/zshare/modalform/index.jsx
+++ b/src/templates/zshare/modalform/index.jsx
@@ -1,7 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { fromJS } from 'immutable'
-import { Form, Row, Col, Input, Select, Radio, notification, InputNumber, Tooltip, Checkbox } from 'antd'
+import { Form, Row, Col, Input, Select, Radio, notification, InputNumber, Tooltip, Checkbox, AutoComplete } from 'antd'
 import { QuestionCircleOutlined } from '@ant-design/icons'
 
 import { formRule } from '@/utils/option.js'
@@ -19,34 +19,35 @@
 const MkEditIcon = asyncComponent(() => import('@/components/mkIcon'))
 
 const modalTypeOptions = {
-  text: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'regular', 'interception', 'span', 'labelwidth', 'encryption', 'tooltip', 'extra', 'enter', 'cursor', 'scan', 'splitline', 'placeholder', 'place', 'marginTop', 'marginBottom', 'lenControl'],
+  text: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'regular', 'interception', 'span', 'labelwidth', 'encryption', 'tooltip', 'extra', 'enter', 'cursor', 'scan', 'splitline', 'placeholder', 'place', 'marginTop', 'marginBottom', 'lenControl', 'inputType', 'constant'],
   number: ['initval', 'readonly', 'hidden', 'decimal', 'min', 'max', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'enter', 'cursor', 'splitline', 'place', 'marginTop', 'marginBottom'],
-  select: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'declare', 'setAll', 'linkSubField', 'span', 'labelwidth', 'tooltip', 'extra', 'emptyText', 'enter', 'splitline', 'dropdown', 'marginTop', 'marginBottom'],
-  checkbox: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra', 'splitline', 'arrange', 'marginTop', 'marginBottom'],
-  radio: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'declare', 'linkSubField', 'span', 'labelwidth', 'tooltip', 'extra', 'setAll', 'emptyText', 'splitline', 'arrange', 'marginTop', 'marginBottom'],
-  checkcard: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'span', 'labelwidth', 'display', 'tooltip', 'extra', 'width', 'multiple', 'splitline', 'marginTop', 'marginBottom'],
+  select: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'declare', 'setAll', 'linkSubField', 'span', 'labelwidth', 'tooltip', 'extra', 'place', 'emptyText', 'enter', 'splitline', 'dropdown', 'marginTop', 'marginBottom', 'pickerMode'],
+  checkbox: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra', 'place', 'splitline', 'arrange', 'marginTop', 'marginBottom'],
+  radio: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'declare', 'linkSubField', 'span', 'labelwidth', 'tooltip', 'extra', 'place', 'setAll', 'emptyText', 'splitline', 'arrange', 'marginTop', 'marginBottom'],
+  checkcard: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'span', 'labelwidth', 'display', 'tooltip', 'extra', 'place', 'width', 'multiple', 'splitline', 'marginTop', 'marginBottom'],
   multiselect: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra', 'marginTop', 'marginBottom', 'dropdown'],
-  link: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'declare', 'setAll', 'linkField', 'linkSubField', 'span', 'labelwidth', 'tooltip', 'extra', 'emptyText', 'enter', 'splitline', 'dropdown', 'marginTop', 'marginBottom'],
+  link: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'declare', 'setAll', 'linkField', 'linkSubField', 'span', 'place', 'labelwidth', 'tooltip', 'extra', 'emptyText', 'enter', 'splitline', 'dropdown', 'marginTop', 'marginBottom', 'pickerMode'],
   fileupload: ['readonly', 'required', 'readin', 'fieldlength', 'maxfile', 'fileType', 'span', 'labelwidth', 'tooltip', 'extra', 'compress', 'miniSet', 'splitline', 'marginTop', 'marginBottom', 'maxSize'],
-  switch: ['initval', 'openVal', 'closeVal', 'openText', 'closeText', 'readonly', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'splitline', 'marginTop', 'marginBottom'],
-  date: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'declareType', 'mode', 'splitline', 'marginTop', 'marginBottom', 'minDate', 'maxDate', 'precision'],
-  datemonth: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'declareType', 'splitline', 'marginTop', 'marginBottom'],
+  switch: ['initval', 'openVal', 'closeVal', 'openText', 'closeText', 'readonly', 'hidden', 'readin', 'span', 'labelwidth', 'linkSubField', 'tooltip', 'extra', 'splitline', 'marginTop', 'marginBottom'],
+  check: ['initval', 'openVal', 'closeVal', 'readonly', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'splitline', 'marginTop', 'marginBottom', 'checkTip'],
+  date: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'declareType', 'mode', 'splitline', 'place', 'marginTop', 'marginBottom', 'minDate', 'maxDate', 'precision'],
+  datemonth: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'splitline', 'place', 'marginTop', 'marginBottom'],
   datetime: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'declareType', 'mode', 'splitline', 'marginTop', 'marginBottom', 'minDate', 'maxDate'],
-  textarea: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'span', 'labelwidth', 'maxRows', 'encryption', 'interception', 'tooltip', 'extra', 'count', 'placeholder', 'marginTop', 'marginBottom'],
-  cascader: ['readonly', 'required', 'hidden', 'readin', 'resourceType', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra', 'splitline', 'marginTop', 'marginBottom', 'separator'],
-  color: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'marginTop', 'marginBottom'],
+  textarea: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'span', 'labelwidth', 'maxRows', 'encryption', 'interception', 'tooltip', 'extra', 'place', 'count', 'placeholder', 'marginTop', 'marginBottom'],
+  cascader: ['readonly', 'required', 'hidden', 'readin', 'resourceType', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra', 'place', 'splitline', 'marginTop', 'marginBottom', 'separator'],
+  color: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'colorType', 'extra', 'marginTop', 'marginBottom'],
   rate: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'splitline', 'tooltip', 'extra', 'marginTop', 'marginBottom', 'allowHalf', 'color', 'rateCount', 'character', 'place'],
   hint: ['label', 'field', 'type', 'blacklist', 'message', 'span', 'labelwidth', 'splitline', 'marginTop', 'marginBottom'],
-  split: ['label', 'type', 'marginTop', 'marginBottom', 'splitline'],
+  split: ['label', 'type', 'marginTop', 'marginBottom', 'splitline', 'splitctrl'],
   formula: ['label', 'type', 'marginTop', 'marginBottom', 'splitline', 'span', 'labelwidth', 'formula', 'eval', 'postfix'],
   brafteditor: ['required', 'hidelabel', 'hidden', 'readin', 'fieldlength', 'readonly', 'span', 'labelwidth', 'tooltip', 'extra', 'encryption', 'marginTop', 'marginBottom'],
   funcvar: ['span', 'labelwidth', 'splitline', 'marginTop', 'marginBottom'],
-  linkMain: ['readonly', 'required', 'hidden', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra', 'marginTop', 'marginBottom']
+  linkMain: ['readonly', 'required', 'hidden','declare', 'span', 'labelwidth', 'tooltip', 'interception', 'extra', 'place', 'marginTop', 'marginBottom'],
+  vercode: ['label', 'field', 'type', 'blacklist', 'supField', 'readonly', 'required', 'hidden', 'span', 'labelwidth', 'tooltip', 'marginTop', 'marginBottom', 'placeholder', 'enter', 'smsId', 'phoneField', 'sendType']
 }
 
 class MainSearch extends Component {
   static propTpyes = {
-    dict: PropTypes.object,    // 瀛楀吀椤�
     formlist: PropTypes.any,
     standardform: PropTypes.any,
     card: PropTypes.object,
@@ -67,7 +68,7 @@
 
       if (item.key === 'linkSubField') {
         item.options.forEach(cell => {
-          transfield[cell.field] = cell.label
+          transfield[cell.field] = cell.label.replace(/^\d+銆�/, '')
         })
       }
     })
@@ -121,7 +122,7 @@
 
     reRequired.field = true
 
-    if (['hint', 'split', 'formula'].includes(type)) {
+    if (['hint', 'split', 'formula', 'vercode'].includes(type)) {
       reRequired.field = false
       shows = fromJS(modalTypeOptions[type]).toJS()
     }
@@ -140,6 +141,12 @@
       if (this.record.enter === 'tab' || this.record.enter === 'sub') {
         shows.push('tabField')
       }
+      if (this.record.regular !== '') {
+        shows.push('regularText')
+        if (this.record.regular !== 'phone' && this.record.regular !== 'email') {
+          shows.push('regularExtra')
+        }
+      }
     } else if (type === 'number') {
       reTypes.initval = 'number'
       reRequired.initval = true
@@ -148,6 +155,16 @@
       }
       if (sessionStorage.getItem('appType') === 'mob') { // 绉诲姩绔彸渚ф墿灞曚俊鎭�
         shows.push('placeholder')
+      }
+    } else if (type === 'vercode') {
+      if (this.record.enter === 'tab' || this.record.enter === 'sub') {
+        shows.push('tabField')
+      }
+    } else if (type === 'linkMain') {
+      if (this.record.declare === 'nvarchar') {
+        shows.push('fieldlength')
+      } else if (this.record.declare === 'decimal') {
+        shows.push('decimal')
       }
     } else if (['multiselect', 'select', 'link', 'radio', 'checkbox'].includes(type)) {
       if (this.record.resourceType === '0') {        // 鑷畾涔夎祫婧�
@@ -182,14 +199,14 @@
         if (this.record.resourceType === '0') {        // 鑷畾涔夎祫婧�
           shows.push('options', 'fields')
         } else if (this.record.resourceType === '1') { // 鏁版嵁婧�
-          shows.push('dataSource', 'cardValField', 'fields', 'orderBy', 'orderType', 'database')
+          shows.push('dataSource', 'cardValField', 'colorField', 'fields', 'orderBy', 'orderType', 'database')
         }
       } else {
         reRequired.fields = true
         if (this.record.resourceType === '0') {        // 鑷畾涔夎祫婧�
-          shows.push('options', 'fields', 'selectStyle')
+          shows.push('options', 'fields', 'selectStyle', 'border')
         } else if (this.record.resourceType === '1') { // 鏁版嵁婧�
-          shows.push('dataSource', 'cardValField', 'fields', 'orderBy', 'orderType', 'disableField', 'database', 'selectStyle')
+          shows.push('dataSource', 'cardValField', 'fields', 'orderBy', 'orderType', 'disableField', 'database', 'selectStyle', 'border')
         }
         if (this.record.selectStyle === 'custom') {
           shows.push('backgroundColor')
@@ -204,7 +221,7 @@
           shows.push('decimal')
         }
       } else {
-        shows.push('fieldlength')
+        shows.push('fieldlength', 'checkAll')
         reTooltip.initval = '娣诲姞澶氫釜鍒濆鍊艰浣跨敤閫楀彿鍒嗛殧銆�'
       }
 
@@ -214,10 +231,13 @@
       if (sessionStorage.getItem('appType') === 'mob') {
         shows.push('hidelabel')
       }
+      if (this.record.readonly === 'true' && this.record.hidden !== 'true') {
+        shows.push('unchecked')
+      }
     } else if (['date', 'datemonth', 'datetime'].includes(type)) {
       reOptions.initval = dateOptions[type]
       reTypes.initval = 'select'
-    } else if (type === 'switch') {
+    } else if (type === 'switch' || type === 'check') {
       reOptions.initval = [
         {value: true, text: '寮�'},
         {value: false, text: '鍏�'}
@@ -249,6 +269,12 @@
     } else if (type === 'textarea') {
       if (this.record.encryption === 'false') {
         shows.push('enterReplace')
+      }
+    }
+
+    if (['multiselect', 'select', 'link', 'radio', 'checkbox', 'checkcard', 'cascader'].includes(type)) {
+      if (this.record.hidden !== 'true') {
+        shows.push('empty')
       }
     }
 
@@ -313,6 +339,10 @@
       shows.push('supvalue')
     }
 
+    if (this.record.hidden === 'true') {
+      shows = shows.filter(s => !['supField', 'supvalue', 'tooltip', 'extra', 'enter', 'tabField'].includes(s))
+    }
+
     return {
       shows,
       reOptions,
@@ -341,7 +371,7 @@
       if (value === 'number' || value === 'rate') {
         this.record.initval = 0
         _fieldval.initval = 0
-      } else if (value === 'switch') {
+      } else if (value === 'switch' || value === 'check') {
         this.record.initval = false
         _fieldval.initval = false
       }
@@ -549,14 +579,23 @@
 
     let resource = this.props.form.getFieldValue('dataSource') || ''
 
-    resource = `select '' as ${field},'鍏ㄩ儴' as ${text} union all \n${resource}`
+    if (field === text) {
+      resource = `select '' as ${field} union all \n${resource}`
+    } else {
+      resource = `select '' as ${field},'鍏ㄩ儴' as ${text} union all \n${resource}`
+    }
 
     this.props.form.setFieldsValue({dataSource: resource})
   }
 
+  complete = (key, option) => {
+    let label = option.props.label
+
+    this.props.form.setFieldsValue({label: label})
+  }
+
   getFields() {
     const { getFieldDecorator } = this.props.form
-    const { dict } = this.props
     const { transfield } = this.state
     const fields = []
 
@@ -572,7 +611,7 @@
 
       if (item.type === 'text') {
         rules = [
-          { required: item.required, message: dict['form.required.input'] + item.label + '!' },
+          { required: item.required, message: '璇疯緭鍏�' + item.label + '!' },
           {
             pattern: /^[^']*$/ig,
             message: '涓嶅彲浣跨敤鑻辨枃鐘舵�佺殑鍗曞紩鍙凤紒'
@@ -586,6 +625,11 @@
             max: formRule.field.max,
             message: formRule.field.maxMessage
           })
+        } else if (item.key === 'regularExtra') {
+          rules.push({
+            pattern: /^[~!@#$%^&*()_+:;{}<>,.-]*$/,
+            message: '鎵╁睍绗﹀寘鎷瑍!@#$%^&*()_+:;{}<>,.-'
+          })
         } else if (item.max) {
           rules.push({
             max: item.max,
@@ -598,10 +642,23 @@
           })
         }
 
-        content = <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />
+        if (item.key === 'field' && item.options && item.options.length > 0) {
+          content = <AutoComplete
+            dataSource={item.options.map((cell) => <AutoComplete.Option label={cell.label} value={cell.field} key={cell.uuid}>
+              {cell.field}
+            </AutoComplete.Option>)}
+            filterOption={(input, option) => option.props.children.indexOf(input) > -1}
+            onSelect={this.complete}
+            placeholder=""
+          >
+            <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />
+          </AutoComplete>
+        } else {
+          content = <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />
+        }
       } else if (item.type === 'number') {
         rules = [
-          { required: item.required, message: dict['form.required.input'] + item.label + '!' }
+          { required: item.required, message: '璇疯緭鍏�' + item.label + '!' }
         ]
         initVal = item.initVal
 
@@ -612,7 +669,7 @@
         }
       } else if (item.type === 'select') {
         rules = [
-          { required: item.required, message: dict['form.required.select'] + item.label + '!' }
+          { required: item.required, message: '璇烽�夋嫨' + item.label + '!' }
         ]
         content = <Select
           showSearch
@@ -640,7 +697,7 @@
         </Select>
       } else if (item.type === 'radio') {
         rules = [
-          { required: item.required, message: dict['form.required.select'] + item.label + '!' }
+          { required: item.required, message: '璇烽�夋嫨' + item.label + '!' }
         ]
         initVal = item.initVal
 
@@ -653,7 +710,7 @@
         </Radio.Group>
       } else if (item.type === 'checkbox') {
         rules = [
-          { required: item.required, message: dict['form.required.select'] + item.label + '!' }
+          { required: item.required, message: '璇烽�夋嫨' + item.label + '!' }
         ]
         initVal = item.initVal
 
@@ -662,7 +719,7 @@
         </Checkbox.Group>
       } else if (item.type === 'codemirror') {
         rules = [
-          { required: item.required, message: dict['form.required.input'] + item.label + '!' }
+          { required: item.required, message: '璇疯緭鍏�' + item.label + '!' }
         ]
         span = 24
         className = 'text-area'
@@ -670,13 +727,16 @@
         if (this.record.type === 'select' || this.record.type === 'link') {
           extra = <span className="add-resource-empty" onClick={this.handleEmpty}>绌�</span>
         }
+        if (item.placeholder) {
+          extra = <><span className="resource-public-var">{item.placeholder}</span>{extra}</>
+        }
 
         content = <CodeMirror />
       } else if (item.type === 'textarea') {
         span = 24
         className = 'text-msg'
         rules = [
-          { required: item.required, message: dict['form.required.input'] + item.label + '!' }
+          { required: item.required, message: '璇疯緭鍏�' + item.label + '!' }
         ]
 
         content = <TextArea rows={item.rows || 4}/>
@@ -707,7 +767,7 @@
           if (this.record.linkField) {
             type = 'link'
           }
-          content = <DataTable dict={this.props.dict} type={type} display={this.record.display} linkSubFields={linkSubFields} transfield={transfield} fields={this.record.fields || []} onChange={this.changeOptions}/>
+          content = <DataTable type={type} display={this.record.display} linkSubFields={linkSubFields} transfield={transfield} fields={this.record.fields || []} onChange={this.changeOptions}/>
         }
       } else if (item.type === 'fields') {
         span = 24
@@ -720,13 +780,13 @@
       } else if (item.type === 'color') {
         className = 'color-form-item'
         rules = [
-          { required: item.required, message: dict['form.required.select'] + item.label + '!' }
+          { required: item.required, message: '璇烽�夋嫨' + item.label + '!' }
         ]
 
         content = <ColorSketch allowClear={true}/>
       } else if (item.type === 'icon') {
         rules = [
-          { required: item.required, message: dict['form.required.select'] + item.label + '!' }
+          { required: item.required, message: '璇烽�夋嫨' + item.label + '!' }
         ]
 
         content = <MkEditIcon allowClear />
@@ -752,6 +812,52 @@
     return fields
   }
 
+  transfer = (options) => {
+    if (options.length === 0) return options
+
+    let isNumber = true
+    options.forEach(item => {
+      if (!/^([0-9]|[1-9]\d{0,2})$/.test(item.Value)) {
+        isNumber = false
+      }
+    })
+
+    if (isNumber) {
+      return options.map(item => {
+        item.Value = +item.Value
+        return item
+      })
+    } else {
+      return options.map(item => {
+        item.Value = item.Value + ''
+        return item
+      })
+    }
+  }
+
+  transferCard = (options) => {
+    if (options.length === 0) return options
+
+    let isNumber = true
+    options.forEach(item => {
+      if (!/^([0-9]|[1-9]\d{0,2})$/.test(item.$value)) {
+        isNumber = false
+      }
+    })
+
+    if (isNumber) {
+      return options.map(item => {
+        item.$value = +item.$value
+        return item
+      })
+    } else {
+      return options.map(item => {
+        item.$value = item.$value + ''
+        return item
+      })
+    }
+  }
+
   handleConfirm = () => {
     // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭�
     return new Promise((resolve, reject) => {
@@ -767,6 +873,8 @@
               if (values.type === 'radio' && values.linkField) {
                 type = 'link'
               }
+
+              values.options = this.transfer(values.options)
 
               if (values.options.filter(op => op.Text === '').length > 0) {
                 notification.warning({
@@ -821,6 +929,8 @@
                 return m
               })
 
+              values.options = this.transferCard(values.options)
+
               let type = values.type
               if (values.linkField) {
                 type = 'link'
@@ -868,11 +978,15 @@
             values.initval = ''
           } else if (values.type === 'split') {
             values.span = 24
+          } else if (values.type === 'text') {
+            if (values.regularExtra) {
+              values.regularExtra = Array.from(new Set(values.regularExtra.split(''))).join('')
+            }
           }
 
           ['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, '')
             }
           })
 

--
Gitblit v1.8.0