From cc53c43e2088ac208d6d7ebbd0b0932fca24916b Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 13 一月 2023 12:52:19 +0800
Subject: [PATCH] 2023-01-13

---
 src/tabviews/zshare/mutilform/index.jsx |  164 ++++++++++++++++++++++++++++++++----------------------
 1 files changed, 97 insertions(+), 67 deletions(-)

diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx
index 81536d8..e69e00d 100644
--- a/src/tabviews/zshare/mutilform/index.jsx
+++ b/src/tabviews/zshare/mutilform/index.jsx
@@ -35,6 +35,7 @@
     data: PropTypes.any,         // 琛ㄦ牸鏁版嵁
     BID: PropTypes.any,          // 涓昏〃ID
     BData: PropTypes.any,        // 涓昏〃鏁版嵁
+    unload: PropTypes.any,       // 涓嬫媺鑿滃崟涓嶅姞杞芥暟鎹�
     inputSubmit: PropTypes.func  // input鍥炶溅鎻愪氦
   }
 
@@ -45,7 +46,7 @@
   record = {}
 
   componentDidMount () {
-    const { action } = this.props
+    const { action, unload } = this.props
 
     let data = {}
     let BData = {}
@@ -133,6 +134,9 @@
         readin = false
         item.readin = false
         item.hidden = true
+      } else if (item.type === 'linkMain') {
+        readin = false
+        item.readin = false
       } else if (item.type === 'number') {
         item.decimal = item.decimal || 0
         item.fieldlength = item.decimal
@@ -163,23 +167,16 @@
       if (readin && data.hasOwnProperty(key)) {
         newval = data[key]
       }
-      if (item.type === 'linkMain') {
-        newval = BData[key] || '$empty'
-      } else if (item.type === 'date') { // 鏃堕棿鎼滅储
-        let format = 'YYYY-MM-DD'
+      if (item.type === 'linkMain' && BData.hasOwnProperty(key)) {
+        newval = BData[key]
+      } else if (item.type === 'date') { // 鏃堕棿琛ㄥ崟锛屾彁浜ゅ�间负澶╂垨绉�
         let _format = 'YYYY-MM-DD HH:mm:ss'
         if (item.precision === 'day') {
           _format = 'YYYY-MM-DD'
-        } else if (item.precision === 'hour') {
-          format = 'YYYY-MM-DD HH'
-        } else if (item.precision === 'minute') {
-          format = 'YYYY-MM-DD HH:mm'
-        } else if (item.precision === 'second') {
-          format = 'YYYY-MM-DD HH:mm:ss'
         }
 
         if (newval !== '$empty') {
-          newval = moment(newval, format).format(_format)
+          newval = moment(newval, 'YYYY-MM-DD HH:mm:ss').format(_format)
           newval = newval === 'Invalid date' ? '$empty' : newval
         }
         if (newval === '$empty' && item.initval) {
@@ -193,18 +190,6 @@
         if (newval === '$empty' && item.initval) {
           newval = moment().subtract(item.initval, 'month').format('YYYY-MM')
         }
-      // } else if (item.type === 'datetime') {
-      //   if (newval !== '$empty') {
-      //     newval = moment(newval, 'YYYY-MM-DD HH:mm:ss').format('YYYY-MM-DD HH:mm:ss')
-      //     newval = newval === 'Invalid date' ? '$empty' : newval
-      //   }
-      //   if (newval === '$empty' && item.initval) {
-      //     if (item.initval === '0') {
-      //       newval = moment().format('YYYY-MM-DD HH:mm:ss')
-      //     } else {
-      //       newval = moment().subtract(item.initval, 'days').format('YYYY-MM-DD') + ' 00:00:00'
-      //     }
-      //   }
       } else if (item.type === 'switch') { // 寮�鍏冲彧鎺ユ敹鍥哄畾鍊�
         if (newval !== '$empty' && (newval === item.closeVal || newval === item.openVal)) {
 
@@ -221,7 +206,11 @@
         item.initval = ''
       }
 
-      if (['select', 'link', 'radio', 'checkbox', 'checkcard', 'multiselect', 'cascader'].includes(item.type) && item.resourceType === '1') {
+      if (item.type === 'number') {
+        if (isNaN(item.initval)) {
+          item.initval = 0
+        }
+      } else if (['select', 'link', 'radio', 'checkbox', 'checkcard', 'multiselect', 'cascader'].includes(item.type) && item.resourceType === '1') {
         deForms.push(item)
       } else if (item.type === 'rate') {
         item.rateCount = item.rateCount || 5
@@ -244,9 +233,7 @@
       }
 
       if (item.type === 'text') {
-        if (typeof(item.initval) === 'number') {
-          item.initval = item.initval + ''
-        }
+        item.initval = item.initval + ''
         let _rules = [{
           pattern: /^[^']*$/ig,
           message: '涓嶅彲浣跨敤鑻辨枃鐘舵�佺殑鍗曞紩鍙凤紒'
@@ -272,39 +259,50 @@
 
         if (item.regular) {
           if (item.regular === 'number') {
+            let reg = /^[0-9.-]*$/
+            if (item.regularExtra) {
+              reg = new RegExp('^[0-9.-' + item.regularExtra.replace(/\.|-/g, '') + ']*$')
+            }
             _rules.push({
-              pattern: /^[0-9.-]*$/,
-              message: formRule.input.numbermsg
+              pattern: reg,
+              message: item.regularText || formRule.input.numbermsg
             })
           } else if (item.regular === 'letter') {
+            let reg = /^[a-zA-Z]*$/
+            if (item.regularExtra) {
+              reg = new RegExp('^[a-zA-Z' + item.regularExtra + ']*$')
+            }
             _rules.push({
-              pattern: /^[a-zA-Z]*$/,
-              message: formRule.input.lettermsg
+              pattern: reg,
+              message: item.regularText || formRule.input.lettermsg
             })
           } else if (item.regular === 'letter_number') {
+            let reg = /^[a-zA-Z0-9]*$/
+            if (item.regularExtra) {
+              reg = new RegExp('^[a-zA-Z0-9' + item.regularExtra + ']*$')
+            }
             _rules.push({
-              pattern: /^[a-zA-Z0-9]*$/,
-              message: '璇疯緭鍏ユ暟瀛楁垨瀛楁瘝'
+              pattern: reg,
+              message: item.regularText || '璇疯緭鍏ユ暟瀛楁垨瀛楁瘝'
             })
           } else if (item.regular === 'letter&number') {
+            let reg = /^[a-zA-Z0-9@_.]*$/
+            if (item.regularExtra) {
+              reg = new RegExp('^[a-zA-Z0-9@_.' + item.regularExtra.replace(/\.|_|@/g, '') + ']*$')
+            }
             _rules.push({
-              pattern: /^[a-zA-Z0-9@_.]*$/,
-              message: '璇疯緭鍏ユ暟瀛椼�佸瓧姣嶄互鍙夽_.'
+              pattern: reg,
+              message: item.regularText || '璇疯緭鍏ユ暟瀛椼�佸瓧姣嶄互鍙夽_.'
             })
           } else if (item.regular === 'phone') {
             _rules.push({
               pattern: /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/,
-              message: '璇锋纭緭鍏ユ墜鏈哄彿'
+              message: item.regularText || '璇锋纭緭鍏ユ墜鏈哄彿'
             })
           } else if (item.regular === 'email') {
             _rules.push({
-              pattern: /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/,
-              message: '璇锋纭緭鍏ラ偖绠卞湴鍧�'
-            })
-          } else if (item.regular === 'funcname') {
-            _rules.push({
-              pattern: /^[\u4E00-\u9FA50-9a-zA-Z_]*$/,
-              message: formRule.input.funcname
+              pattern: /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/,
+              message: item.regularText || '璇锋纭緭鍏ラ偖绠卞湴鍧�'
             })
           }
         }
@@ -509,6 +507,8 @@
     this.record = record
 
     this.setState({ formlist }, () => {
+      if (unload) return
+      
       if (action.setting && action.setting.focus && fieldMap.has(action.setting.focus)) {
         setTimeout(() => {
           MKEmitter.emit('mkFC', 'focus', fieldMap.get(action.setting.focus).uuid)
@@ -535,19 +535,28 @@
     let mainItems = []  // 浜戠鎴栧崟鐐规暟鎹�
     let localItems = [] // 鏈湴鏁版嵁
     let cache = action.setting.cache !== 'false'
+    let debug = window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')
+
+    let _sql = `Declare @mk_organization nvarchar(512)  select @mk_organization='${sessionStorage.getItem('organization') || ''}'\n`
+    let _sso = _sql
 
     deForms.forEach(item => {
       if (item.database === 'sso') {
-        mainItems.push(`select '${item.field}' as obj_name,'${item.arr_field}' as arr_field,'${item.base_sql}' as LText`)
+        let sql = _sso + item.base_sql
+        _sso = ''
+        if (debug) {
+          console.info(sql)
+        }
+        mainItems.push(`select '${item.field}' as obj_name,'${item.arr_field}' as arr_field,'${window.btoa(window.encodeURIComponent(sql))}' as LText`)
       } else {
-        localItems.push(`select '${item.field}' as obj_name,'${item.arr_field}' as arr_field,'${item.base_sql}' as LText`)
+        let sql = _sql + item.base_sql
+        _sql = ''
+        if (debug) {
+          console.info(sql)
+        }
+        localItems.push(`select '${item.field}' as obj_name,'${item.arr_field}' as arr_field,'${window.btoa(window.encodeURIComponent(sql))}' as LText`)
       }
     })
-    
-    if (!window.GLOB.mkHS && options.sysType !== 'local') {
-      localItems = [...localItems, ...mainItems]
-      mainItems = []
-    }
 
     // 鏈湴璇锋眰
     let param = {
@@ -643,16 +652,23 @@
    */
   improveSimpleActionForm = (deForms) => {
     let cache = this.props.action.setting.cache !== 'false'
+    let debug = window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')
+    let _sql = `Declare @mk_organization nvarchar(512)  select @mk_organization='${sessionStorage.getItem('organization') || ''}'\n`
 
     let deffers = deForms.map((form, index) => {
       let param = {
         func: 'sPC_Get_SelectedList',
-        LText: form.data_sql,
+        LText: _sql + form.base_sql,
         obj_name: form.field,
         arr_field: form.arr_field,
         BID: this.props.BID || ''
       }
+
+      if (debug) {
+        console.info(param.LText)
+      }
   
+      param.LText = Utils.formatOptions(param.LText)
       param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
       param.secretkey = Utils.encrypt(param.LText, param.timestamp)
 
@@ -699,6 +715,7 @@
       if (['select', 'link', 'radio', 'checkbox', 'checkcard', 'multiselect', 'cascader'].includes(item.type) && result[item.field] && result[item.field].length > 0) {
         let options = []
         let map = new Map()
+        let all = false
         result[item.field].forEach(cell => {
           let _cell = { key: Utils.getuuid() , ParentID: ''}
 
@@ -709,12 +726,26 @@
           if (item.type !== 'checkcard') {
             _cell.value = cell[item.valueField]
             _cell.label = cell[item.valueText] + ''
-            if (!_cell.label || map.has(_cell.ParentID + _cell.value)) return
+            if (map.has(_cell.ParentID + _cell.value)) return
+            if (!_cell.label) {
+              if (!all) {
+                _cell.label = '鍏ㄩ儴'
+                all = true
+              } else {
+                return
+              }
+            }
             
             map.set(_cell.ParentID + _cell.value, 0)
           } else {
             _cell.$value = cell[item.cardValField]
             _cell = {..._cell, ...cell}
+
+            if (item.urlField) {
+              _cell.$url = cell[item.urlField] || ''
+            } else if (item.colorField) {
+              _cell.$color = cell[item.colorField] || ''
+            }
 
             if (map.has(_cell.ParentID + _cell.$value)) return
             
@@ -962,7 +993,6 @@
     
           let _item = {
             type: item.type,
-            readonly: item.readonly,
             readin: item.readin,
             writein: item.writein,
             fieldlen: item.fieldlength,
@@ -973,29 +1003,29 @@
     
           if (item.type === 'funcvar') {
             _item.value = ''
-          } else if (_item.value && (item.type === 'text' || item.type === 'textarea' || item.type === 'linkMain') && typeof(_item.value) === 'string') {
+          } else if (item.declare === 'decimal') {
+            _item.type = 'number'
+            _item.fieldlen = item.decimal || 0
+          } else if (['text', 'textarea', 'linkMain'].includes(item.type)) {
+            _item.value = _item.value + ''
             _item.value = _item.value.replace(/\t*|\v*/g, '')       // 鍘婚櫎鍒惰〃绗�
     
-            if (item.interception !== 'false') {           // 鍘婚櫎棣栧熬绌烘牸
+            if (item.interception !== 'false') {                    // 鍘婚櫎棣栧熬绌烘牸
               _item.value = _item.value.replace(/(^\s*|\s*$)/g, '')
             }
             if (item.type === 'text' && /@appkey@|@SessionUid@|@bid@/ig.test(_item.value)) { // 鐗规畩瀛楁鏇挎崲
               _item.value = _item.value.replace(/^(\s*)@appkey@(\s*)$/ig, window.GLOB.appkey).replace(/^(\s*)@SessionUid@(\s*)$/ig, (localStorage.getItem('SessionUid') || '')).replace(/^(\s*)@bid@(\s*)$/ig, (this.props.BID || ''))
             }
+            if (item.type === 'text' && item.lenControl && item.lenControl !== 'limit') {
+              if (item.lenControl === 'left') {
+                _item.value = _item.value.substr(0, item.fieldlength)
+              } else {
+                _item.value = _item.value.slice(-item.fieldlength)
+              }
+            }
           } else if (item.type.indexOf('date') > -1) {
             if (item.declareType === 'nvarchar(50)') {
               _item.type = 'text'
-            }
-          } else if (item.declare === 'decimal' && ['select', 'link', 'radio', 'checkcard'].includes(item.type)) {
-            _item.type = 'number'
-            _item.fieldlen = item.decimal || 0
-          }
-
-          if (item.type === 'text' && item.lenControl && item.lenControl !== 'limit') {
-            if (item.lenControl === 'left') {
-              _item.value = _item.value.substr(0, item.fieldlength)
-            } else {
-              _item.value = _item.value.slice(-item.fieldlength)
             }
           }
     

--
Gitblit v1.8.0