From 2f54651464414059b224181d713af2980e76d095 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 09 十月 2022 19:35:39 +0800
Subject: [PATCH] 2020-10-09

---
 src/tabviews/zshare/actionList/normalbutton/index.jsx |  147 +++++++++++++++++++++++++++----------------------
 1 files changed, 81 insertions(+), 66 deletions(-)

diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx
index 2df4e43..c5ca987 100644
--- a/src/tabviews/zshare/actionList/normalbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx
@@ -376,7 +376,6 @@
         
         let item = {
           type: type,
-          readonly: false,
           readin: true,
           writein: true,
           fieldlen: fieldlen,
@@ -806,14 +805,11 @@
   
         if (form.type === 'number' || form.type === 'rate') {
           let val = form.value
-          if (typeof(val) !== 'number') {
-            val = parseFloat(val)
-            if (isNaN(val)) {
-              val = 0
-            }
+          if (isNaN(val)) {
+            val = 0
           }
           _initFormfields.push(`@${_key}=${val}`)
-        } else if (['date', 'datemonth', 'datetime'].includes(form.type)) {
+        } else if (['date', 'datemonth'].includes(form.type)) {
           _initFormfields.push(`@${_key}='${form.value || '1949-10-01'}'`)
         } else {
           _initFormfields.push(`@${_key}='${form.value}'`)
@@ -848,7 +844,7 @@
     }
   
     // 娣诲姞鏁版嵁涓瓧娈碉紝琛ㄥ崟鍊间紭鍏�(鎸夐挳涓嶉�夎鎴栧琛屾嫾鎺ユ椂璺宠繃)
-    if (data && btn.Ot !== 'notRequired' && btn.Ot !== 'requiredOnce') {
+    if (data && btn.Ot !== 'notRequired' && btn.Ot !== 'requiredOnce' && columns && columns.length > 0) {
       datavars = {...data, ...datavars}
   
       const setField = (col) => {
@@ -890,17 +886,15 @@
         }
       }
   
-      if (columns && columns.length > 0) {
-        columns.forEach(col => {
-          if (col.type === 'colspan' || col.type === 'old_colspan') {
-            col.subcols.forEach(cell => {
-              setField(cell)
-            })
-          } else {
-            setField(col)
-          }
-        })
-      }
+      columns.forEach(col => {
+        if (col.type === 'colspan' || col.type === 'old_colspan') {
+          col.subcols.forEach(cell => {
+            setField(cell)
+          })
+        } else {
+          setField(col)
+        }
+      })
     }
   
     // 鍙橀噺澹版槑
@@ -1890,6 +1884,10 @@
     } else if (btn.execSuccess !== 'never') {
       MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, id, this.state.selines)
     }
+
+    if (window.GLOB.breakpoint) {
+      MKEmitter.emit('refreshDebugTable')
+    }
     
     btn.syncComponentId && MKEmitter.emit('reloadData', btn.syncComponentId)
 
@@ -2279,6 +2277,10 @@
       let data = this.props.selectedData && this.props.selectedData[0] ? this.props.selectedData[0] : null
       this.setState({check: data && data[btn.field] === btn.openVal})
     }
+
+    if (window.GLOB.breakpoint) {
+      MKEmitter.emit('refreshDebugTable')
+    }
   }
 
   handleModelConfig = (config) => {
@@ -2415,73 +2417,86 @@
 
     btnconfig.fields.forEach(item => {
       if (!item.field) return
-      let _readin = item.readin !== 'false'
-      let _initval = item.initval
+      let _item = {
+        key: item.field,
+        readin: item.readin !== 'false' && item.readin !== 'top',
+        fieldlen: item.fieldlength || 50,
+        writein: item.writein !== 'false',
+        type: item.type
+      }
 
-      if (item.type === 'linkMain' || item.type === 'funcvar') {
+      let _initval = item.initval
+      let _readin = item.readin !== 'false'
+      let _format = item.precision || 'day' // 鏃堕棿鏍煎紡鍖�
+
+      if (item.type === 'funcvar') {
+        _initval = ''
         _readin = false
+        _item.readin = false
+      } else if (item.type === 'linkMain') {
+        _readin = false
+        _item.readin = false
+      } else if (item.type === 'date') {
+        if (_format !== 'day') {
+          _format = 'YYYY-MM-DD HH:mm:ss'
+        } else {
+          _format = 'YYYY-MM-DD'
+        }
+      } else if (item.type === 'datetime') {
+        _item.type = 'date'
+        _format = 'YYYY-MM-DD HH:mm:ss'
       }
 
       let key = item.field.toLowerCase()
 
-      if (item.type === 'linkMain' && BData.hasOwnProperty(key)) {
+      if (_item.type === 'linkMain' && BData.hasOwnProperty(key)) {
         _initval = BData[key]
       } else if (_readin && _data.hasOwnProperty(key)) {
         _initval = _data[key]
-      } else if (item.type === 'date' && _initval) {
-        _initval = moment().subtract(_initval, 'days').format('YYYY-MM-DD')
-      } else if (item.type === 'datemonth' && _initval) {
+      } else if (_item.type === 'date' && _initval) {
+        _initval = moment().subtract(_initval, 'days').format(_format)
+      } else if (_item.type === 'datemonth' && _initval) {
         _initval = moment().subtract(_initval, 'month').format('YYYY-MM')
-      } else if (item.type === 'datetime' && _initval) {
-        _initval = moment().subtract(_initval, 'days').format('YYYY-MM-DD HH:mm:ss')
       }
 
-      if (_initval === undefined) {
-        _initval = ''
-      }
+      _item.value = _initval === undefined ? '' : _initval
 
-      let _fieldlen = item.fieldlength || 50
-      if (item.type === 'textarea' || item.type === 'fileupload' || item.type === 'multiselect') {
-        _fieldlen = item.fieldlength || 512
-      } else if (item.type === 'number') {
-        _fieldlen = item.decimal ? item.decimal : 0
-      } else if (item.type === 'text' && /@appkey@|@SessionUid@|@bid@/ig.test(_initval)) { // 鐗规畩瀛楁鏇挎崲
-        _initval = _initval.replace(/^(\s*)@appkey@(\s*)$/ig, window.GLOB.appkey).replace(/^(\s*)@SessionUid@(\s*)$/ig, (localStorage.getItem('SessionUid') || '')).replace(/^(\s*)@bid@(\s*)$/ig, (BID || ''))
-      }
+      if (_item.type === 'number' || 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, '')       // 鍘婚櫎鍒惰〃绗�
 
-      let _type = item.type
-
-      if (['date', 'datemonth', 'datetime'].includes(_type) && item.declareType === 'nvarchar(50)') {
-        _type = 'text'
-      } else if (item.type === 'rate') {
-        item.rateCount = item.rateCount || 5
-        let allowHalf = item.allowHalf === 'true'
-
-        if (allowHalf) {
-          _initval = parseFloat(_initval)
-          if (_initval % 0.5 !== 0) {
-            _initval = parseInt(_initval)
+        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, (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 {
-          _initval = parseInt(_initval)
         }
+      } else if (_item.type.indexOf('date') > -1) {
+        if (item.declareType === 'nvarchar(50)') {
+          _item.type = 'text'
+        }
+      } else if (_item.type === 'rate') {
+        let count = item.rateCount || 5
+        _item.value = parseInt(_item.value)
 
-        if (isNaN(_initval) || _initval < 0) {
-          _initval = 0
-        } else if (_initval > item.rateCount) {
-          _initval = item.rateCount
+        if (isNaN(_item.value) || _item.value < 0) {
+          _item.value = 0
+        } else if (_item.value > count) {
+          _item.value = count
         }
       }
 
-      result.push({
-        key: item.field,
-        readonly: item.readonly === 'true',
-        readin: item.readin !== 'false' && item.readin !== 'top',
-        fieldlen: _fieldlen,
-        writein: item.writein !== 'false',
-        type: _type,
-        value: _initval
-      })
+      result.push(_item)
     })
 
     if (btnconfig.setting.display === 'exec') {

--
Gitblit v1.8.0