From 2aa5ab63b4bbce5c36dbb3511b205b3b5f6af9bd Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 07 五月 2024 11:34:20 +0800
Subject: [PATCH] 2024-05-07

---
 src/tabviews/zshare/mutilform/index.jsx |  141 +++++++++++++++++++++++++++++++++-------------
 1 files changed, 101 insertions(+), 40 deletions(-)

diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx
index eff2368..309cff6 100644
--- a/src/tabviews/zshare/mutilform/index.jsx
+++ b/src/tabviews/zshare/mutilform/index.jsx
@@ -47,7 +47,8 @@
     send_type: '',
     timestamp: '',
     n_id: '',
-    focusId: ''
+    focusId: '',
+    reFocusId: ''
   }
 
   record = {}
@@ -79,7 +80,18 @@
     }
 
     formlist = formlist.filter(item => {
+      if (item.type === 'hint') {
+        if (item.field && data[item.field.toLowerCase()]) {
+          item.message = data[item.field.toLowerCase()]
+        }
+        delete item.field
+      }
+
       if (item.supField) { // 澶氬眰琛ㄥ崟鎺у埗
+        if (['hint', 'split', 'formula'].includes(item.type)) {
+          item.field = item.uuid
+          fieldMap.set(item.field, item)
+        }
         let supvals = []
         if (item.supvalue) {
           item.supvalue.split(',').forEach(val => {
@@ -114,14 +126,8 @@
         }
       }
 
-      if (item.type === 'split' || item.type === 'formula') return true
-      if (item.type === 'hint') {
-        if (item.field && data[item.field.toLowerCase()]) {
-          item.message = data[item.field.toLowerCase()]
-        }
-        delete item.field
-        return true
-      } else if (item.type === 'date') {
+      if (['hint', 'split', 'formula'].includes(item.type)) return true
+      if (item.type === 'date') {
         item.precision = item.precision || 'day'
       } else if (item.type === 'datetime') {
         item.type = 'date'
@@ -142,6 +148,7 @@
       item.readin = item.readin !== 'false' && item.readin !== 'top'
       item.readonly = check || item.readonly === 'true'
       item.writein = item.writein !== 'false'
+      item.defHidden = item.hidden === 'true'
       item.hidden = item.hidden === 'true'
       item.fieldlength = item.fieldlength || 50
 
@@ -261,6 +268,12 @@
         } else {
           newval = item.closeVal
         }
+      } else if (item.type === 'popSelect') {
+        if (newval && newval !== '$empty') {
+          item.showValue = data[item.showField.toLowerCase()] || ''
+        } else {
+          item.showValue = ''
+        }
       }
 
       if (newval !== '$empty') {
@@ -310,8 +323,8 @@
           validator: (rule, value, callback) => {
             if (/'/.test(value)) {
               callback('涓嶅彲浣跨敤鑻辨枃鐘舵�佺殑鍗曞紩鍙凤紒')
-            } else if (/--/.test(value)) {
-              callback('涓嶅彲浣跨敤 -- 锛�')
+            // } else if (/--/.test(value)) {
+            //   callback('涓嶅彲浣跨敤 -- 锛�')
             } else {
               callback()
             }
@@ -425,8 +438,8 @@
           validator: (rule, value, callback) => {
             if (/'/.test(value)) {
               callback('涓嶅彲浣跨敤鑻辨枃鐘舵�佺殑鍗曞紩鍙凤紒')
-            } else if (/--/.test(value)) {
-              callback('涓嶅彲浣跨敤 -- 锛�')
+            // } else if (/--/.test(value)) {
+            //   callback('涓嶅彲浣跨敤 -- 锛�')
             } else {
               callback()
             }
@@ -485,7 +498,7 @@
 
         let _hidden = false
 
-        if (supItem.hidden) {
+        if (supItem.hidden && !supItem.defHidden) {
           _hidden = true
         } else {
           let box = [...item.values]
@@ -523,7 +536,7 @@
         cell.labelCol = {style: {width: cell.labelwidth + '%'}}
         cell.wrapperCol = {style: {width: (100 - cell.labelwidth) + '%'}}
       }
-      if (!cell.field || !fieldMap.has(cell.field)) return cell
+      if (!cell.field || !fieldMap.has(cell.field) || ['hint', 'split', 'formula'].includes(cell.type)) return cell
       let item = fieldMap.get(cell.field)
 
       // 涓嬬骇琛ㄥ崟鎺у埗-瀛楁鍐欏叆
@@ -680,14 +693,24 @@
       focusItem = fieldMap.get(action.setting.focus)
     }
 
-    this.setState({ formlist, ID, focusId: focusItem ? focusItem.uuid : '' }, () => {
+    let reFocusItem = null
+    if (action.setting.refocus && fieldMap.has(action.setting.refocus)) {
+      reFocusItem = fieldMap.get(action.setting.refocus)
+    }
+
+    this.setState({
+      formlist,
+      ID,
+      focusId: focusItem ? focusItem.uuid : '',
+      reFocusId: reFocusItem ? reFocusItem.uuid : ''
+    }, () => {
       if (unload) return
       
       if (focusItem) {
         if (focusItem.type === 'text' || focusItem.type === 'number') {
           setTimeout(() => {
             MKEmitter.emit('mkFC', 'focus', focusItem.uuid)
-          }, 50)
+          }, 20)
         } else {
           setTimeout(() => {
             MKEmitter.emit('mkFC', 'focus', focusItem.uuid)
@@ -722,9 +745,9 @@
     MKEmitter.removeListener('resetForms', this.resetForms)
   }
 
-  resetForms = (id) => {
+  resetForms = (id, data) => {
     const { action } = this.props
-    const { focusId } = this.state
+    const { focusId, reFocusId } = this.state
 
     if (id !== action.uuid) return
 
@@ -735,8 +758,14 @@
       if (item.type !== 'text' && item.type !== 'number') return item
 
       if (resetForms.includes(item.field)) {
-        item.initval = item.orgval
-        this.record[item.field] = item.orgval
+        let key = item.field.toLowerCase()
+        if (typeof(data[key]) !== 'undefined') {
+          item.initval = data[key]
+          this.record[item.field] = data[key]
+        } else {
+          item.initval = item.orgval
+          this.record[item.field] = item.orgval
+        }
       }
 
       return item
@@ -760,10 +789,10 @@
       })
     })
 
-    if (focusId || this.submitId) {
+    if (reFocusId || focusId || this.submitId) {
       setTimeout(() => {
-        MKEmitter.emit('mkFC', 'focus', this.submitId || focusId)
-      }, 50)
+        MKEmitter.emit('mkFC', 'focus', this.submitId || reFocusId || focusId)
+      }, 20)
     }
   }
 
@@ -834,9 +863,13 @@
     }
 
     if (param.LText) {
-      param.LText = Utils.formatOptions(param.LText)
+      if (window.GLOB.execType === 'x') {
+        param.exec_type = 'x'
+      }
+
+      param.LText = Utils.formatOptions(param.LText, param.exec_type)
       param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-      param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+      param.secretkey = Utils.encrypt(window.GLOB.execType === 'x' ? '' : param.LText, param.timestamp)
 
       if (window.GLOB.mkHS) { // 浜戠鏁版嵁楠岃瘉
         param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
@@ -869,9 +902,13 @@
     }
 
     if (mainparam.LText) {
-      mainparam.LText = Utils.formatOptions(mainparam.LText)
+      if (window.GLOB.execType === 'x') {
+        mainparam.exec_type = 'x'
+      }
+
+      mainparam.LText = Utils.formatOptions(mainparam.LText, mainparam.exec_type)
       mainparam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-      mainparam.secretkey = Utils.encrypt(mainparam.LText, mainparam.timestamp)
+      mainparam.secretkey = Utils.encrypt(window.GLOB.execType === 'x' ? '' : mainparam.LText, mainparam.timestamp)
 
       if (window.GLOB.mainSystemApi) {
         mainparam.rduri = window.GLOB.mainSystemApi
@@ -933,10 +970,14 @@
       if (window.GLOB.debugger) {
         console.info(param.LText)
       }
+
+      if (window.GLOB.execType === 'x') {
+        param.exec_type = 'x'
+      }
   
-      param.LText = Utils.formatOptions(param.LText)
+      param.LText = Utils.formatOptions(param.LText, param.exec_type)
       param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-      param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+      param.secretkey = Utils.encrypt(window.GLOB.execType === 'x' ? '' : param.LText, param.timestamp)
 
       if (form.database === 'sso' && window.GLOB.mainSystemApi) {
         param.rduri = window.GLOB.mainSystemApi
@@ -1188,11 +1229,17 @@
       if (item.hidden) return
 
       if (item.type === 'split') {
-        fields.push(
-          <Col span={24} key={index}>
-            <p className="mk-form-split-line" style={item.style}>{item.label}</p>
-          </Col>
-        )
+        if (item.opacity === 'false') {
+          fields.push(
+            <div key={index}></div>
+          )
+        } else {
+          fields.push(
+            <Col span={24} key={index}>
+              <p className="mk-form-split-line" style={item.style}>{item.label}</p>
+            </Col>
+          )
+        }
       } else if (item.type === 'hint') {
         fields.push(
           <Col span={item.span || 24} key={index}>
@@ -1232,19 +1279,19 @@
           className = 'checkcard'
           content = (<MKCheckCard config={item} onChange={(val, other) => this.recordChange({[item.field]: val, ...other}, item)}/>)
         } else if (item.type === 'switch') {
-          content = (<MKSwitch config={item} onChange={(val, other) => this.recordChange({[item.field]: val, ...other}, item)}/>)
+          content = (<MKSwitch config={item} onChange={(val, other) => this.recordChange({[item.field]: val, ...other}, item)} onSubmit={this.props.inputSubmit}/>)
         } else if (item.type === 'check') {
-          content = (<MKCheck config={item} onChange={(val) => this.recordChange({[item.field]: val}, item)}/>)
+          content = (<MKCheck config={item} onChange={(val) => this.recordChange({[item.field]: val}, item)} onSubmit={this.props.inputSubmit}/>)
         } else if (item.type === 'checkbox') {
           content = (<MKCheckbox config={item} onChange={(val) => this.recordChange({[item.field]: val})}/>)
         } else if (item.type === 'radio') {
           content = (<MKRadio config={item} onChange={(val, other) => this.recordChange({[item.field]: val, ...other}, item)}/>)
         } else if (item.type === 'date' || item.type === 'datemonth') {
-          content = (<MKDatePicker config={item} onChange={(val) => this.recordChange({[item.field]: val})} />)
+          content = (<MKDatePicker config={item} onChange={(val) => this.recordChange({[item.field]: val})} onSubmit={this.props.inputSubmit}/>)
         } else if (item.type === 'fileupload') {
           className = item.readonly ? 'readonly' : ''
           className += item.fileType === 'picture-card' ? ' file-upload' : ''
-          content = (<MKFileUpload config={item} onChange={(val, other = {}) => this.recordChange({[item.field]: val, ...other})} />)
+          content = (<MKFileUpload config={item} data={this.record} onChange={(val, other = {}) => this.recordChange({[item.field]: val, ...other})} />)
         } else if (item.type === 'textarea') {
           content = (<MKTextArea config={item} onChange={(val, defer) => !defer && this.recordChange({[item.field]: val})}/>)
         } else if (item.type === 'rate') {
@@ -1295,7 +1342,7 @@
         let record = {...this.record, ...values}
 
         formlist.forEach(item => {
-          if (!item.field) return
+          if (!item.field || ['hint', 'split', 'formula'].includes(item.type)) return
     
           let _item = {
             type: item.type,
@@ -1328,6 +1375,20 @@
                   console.warn(e)
                   _item.value = ''
                 }
+              } else if (item.interception === 'charTure') {
+                let str = _item.value.replace(/(^\s*|\s*$)/g, '')
+                let result = ''
+                for (let i = 0 ; i < str.length; i++) {
+                  let code = str.charCodeAt(i)
+                  if (code >= 65281 && code <= 65373) {
+                    result += String.fromCharCode(str.charCodeAt(i) - 65248)
+                  } else if (code === 12288) {
+                    result += String.fromCharCode(str.charCodeAt(i) - 12288 + 32)
+                  } else {
+                    result += str.charAt(i)
+                  }
+                }
+                _item.value = result
               } else {
                 _item.value = _item.value.replace(/(^\s*|\s*$)/g, '')
               }

--
Gitblit v1.8.0