From 407c0f1765c7d085218a91ad8842784977383d05 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 23 十月 2020 00:18:13 +0800
Subject: [PATCH] 2020-10-23

---
 src/templates/zshare/verifycard/index.jsx |  637 ++++++++++++++++-----------------------------------------
 1 files changed, 185 insertions(+), 452 deletions(-)

diff --git a/src/templates/zshare/verifycard/index.jsx b/src/templates/zshare/verifycard/index.jsx
index bf578fe..4a557df 100644
--- a/src/templates/zshare/verifycard/index.jsx
+++ b/src/templates/zshare/verifycard/index.jsx
@@ -21,7 +21,6 @@
 
 class VerifyCard extends Component {
   static propTpyes = {
-    floor: PropTypes.any,      // 鏄惁涓哄瓙琛�
     btnTab: PropTypes.any,     // 琛ㄥ崟鏍囩椤碉紙鎸夐挳锛夊弬鏁�
     config: PropTypes.any,     // 琛ㄥ崟鏍囩椤靛弬鏁�
     dict: PropTypes.object,    // 瀛楀吀椤�
@@ -439,8 +438,8 @@
   }
 
   UNSAFE_componentWillMount() {
-    const { columns, config, card } = this.props
-    let _verify = this.props.card.verify || {}
+    const { columns, config, card, btnTab } = this.props
+    let _verify = card.verify || {}
 
     let _invalid = _verify.invalid
 
@@ -468,55 +467,123 @@
       verify: _verify
     })
 
-    // 鎸夐挳-琛ㄥ崟鏍囩椤�
-    if (this.props.card.btnType) {
+    new Promise(resolve => {
       let _fields = []
-
-      config.groups.forEach(group => {
-        _fields.push(...group.sublist)
-      })
-
+      if (config.Template === 'FormTab') {
+        config.groups.forEach(group => {
+          _fields.push(...group.sublist)
+        })
+        resolve(_fields)
+      } else if (card.modal) {
+        if (card.modal.groups && card.modal.groups.length > 0) {
+          card.modal.groups.forEach(group => {
+            _fields.push(...group.sublist)
+          })
+        } else {
+          _fields = card.modal.fields || []
+        }
+        resolve(_fields)
+      } else if (card.OpenType === 'pop') {
+        Api.getSystemConfig({
+          func: 'sPC_Get_LongParam',
+          MenuID: card.uuid
+        }).then(res => {
+          if (res.status) {
+            let _LongParam = ''
+            if (res.LongParam) {
+              try {
+                _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam)))
+              } catch (e) {
+                console.warn('Parse Failure')
+                _LongParam = ''
+              }
+            }
+            
+            if (!_LongParam) {
+              notification.warning({
+                top: 92,
+                message: '鏈幏鍙栧埌琛ㄥ崟淇℃伅锛岄儴鍒嗛獙璇佸皢鏃犳硶璁剧疆锛�',
+                duration: 5
+              })
+            } else {
+              if (_LongParam.groups.length > 0) {
+                _LongParam.groups.forEach(group => {
+                  _fields.push(...group.sublist)
+                })
+              } else {
+                _fields = _LongParam.fields || []
+              }
+            }
+          } else {
+            notification.warning({
+              top: 92,
+              message: res.message,
+              duration: 5
+            })
+          }
+          resolve(_fields)
+        })
+      }
+    }).then(_fields => {
       let _usefulfields = ['BID', 'ID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey', 'UserName', 'FullName', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear', 'ModularDetailCode']
       let _declare = ['@UserName nvarchar(50)', '@FullName nvarchar(50)', '@ErrorCode nvarchar(50)', '@retmsg nvarchar(4000)', '@BillCode nvarchar(50)', '@BVoucher nvarchar(50)', '@FIBVoucherDate nvarchar(50)', '@FiYear nvarchar(50)', '@ModularDetailCode nvarchar(50)']
       let _select = ['@UserName=\'\'', '@FullName=\'\'', '@ErrorCode=\'\'', '@retmsg=\'\'', '@BillCode=\'\'', '@BVoucher=\'\'', '@FIBVoucherDate=\'\'', '@FiYear=\'\'', '@ModularDetailCode=\'\'']
       let fieldArr = _usefulfields.map(_f => _f.toLowerCase())
+      let hasBid = false
 
+      _fields = _fields.filter(_f => _f.field)
       _fields.forEach(_f => {
-        if (_f.field) {
-          if (fieldArr.includes(_f.field.toLowerCase())) return
-          fieldArr.push(_f.field.toLowerCase())
+        if (fieldArr.includes(_f.field.toLowerCase())) return
 
-          _usefulfields.push(_f.field)
+        fieldArr.push(_f.field.toLowerCase())
 
-          let _fieldlen = _f.fieldlength || 50
+        _usefulfields.push(_f.field)
 
-          if (['textarea', 'fileupload', 'multiselect'].includes(_f.type)) {
-            _fieldlen = _f.fieldlength || 512
-          } else if (_f.type === 'number') {
-            _fieldlen = _f.decimal ? _f.decimal : 0
-          }
+        let _fieldlen = _f.fieldlength || 50
 
-          if (_fieldlen > 2048) {
-            _fieldlen = 'max'
-          }
+        if (_f.type === 'number') {
+          _fieldlen = _f.decimal ? _f.decimal : 0
+        }
 
-          let _type = `nvarchar(${_fieldlen})`
+        if (_fieldlen > 2048) {
+          _fieldlen = 'max'
+        }
 
-          if (_f.type.match(/date/ig)) {
-            _type = 'datetime'
-            _select.push(`@${_f.field}='1900-01-01'`)
-          } else if (_f.type === 'number') {
-            _type = `decimal(18,${_fieldlen})`
-            _select.push(`@${_f.field}=0`)
-          } else {
-            _select.push(`@${_f.field}=''`)
-          }
+        let _type = `nvarchar(${_fieldlen})`
 
-          _declare.push(`@${_f.field} ${_type}`)
+        if (_f.type.match(/date/ig)) {
+          _type = 'datetime'
+          _select.push(`@${_f.field}='1900-01-01'`)
+        } else if (_f.type === 'number') {
+          _type = `decimal(18,${_fieldlen})`
+          _select.push(`@${_f.field}=0`)
+        } else {
+          _select.push(`@${_f.field}=''`)
+        }
+
+        _declare.push(`@${_f.field} ${_type}`)
+
+        if (_f.field.toLowerCase() === 'bid') {
+          hasBid = true
         }
       })
 
-      if (columns && columns.length > 0 && this.props.btnTab.Ot !== 'notRequired' && this.props.btnTab.Ot !== 'requiredOnce') {
+      if (!hasBid) { // 琛ㄥ崟涓鍔燘ID
+        _fields.unshift({ uuid: 'BID', field: 'BID', label: 'BID', type: 'text' })
+      }
+
+      let hasColumn = false
+      if (columns && columns.length > 0) {
+        if (btnTab) { // 琛ㄥ崟鏍囩
+          if (btnTab.Ot !== 'notRequired' && btnTab.Ot !== 'requiredOnce') {
+            hasColumn = true
+          }
+        } else if (card.Ot !== 'notRequired' && card.Ot !== 'requiredOnce') {
+          hasColumn = true
+        }
+      }
+
+      if (hasColumn) {
         columns.forEach(_f => {
           if (!_f.field || fieldArr.includes(_f.field.toLowerCase())) return
 
@@ -524,11 +591,18 @@
 
           _usefulfields.push(_f.field)
 
-          let _fieldlen = _f.fieldlength || 50
+          if (_f.datatype) { // 鑷畾涔夊瓧娈�
+            if (/decimal/ig.test(_f.datatype)) {
+              _select.push(`@${_f.field}=0`)
+            } else {
+              _select.push(`@${_f.field}=''`)
+            }
 
-          if (_f.type === 'picture' || _f.type === 'textarea') {
-            _fieldlen = _f.fieldlength || 512
+            _declare.push(`@${_f.field} ${_f.datatype}`)
+            return
           }
+
+          let _fieldlen = _f.fieldlength || 50
 
           if (_fieldlen > 2048) {
             _fieldlen = 'max'
@@ -552,16 +626,16 @@
         })
       }
 
-      _usefulfields = _usefulfields.join(', ')
       let _sql = `Declare ${_declare.join(', ')}
         Select ${_select.join(', ')}
       `
 
       // 榛樿sql
+      let _defaultsql = ''
       let _insertsql = ''
       let _updatesql = ''
 
-      if (this.props.card.sqlType === 'insert' || this.props.card.sqlType === 'insertOrUpdate') {
+      if (card.sqlType === 'insert' || card.sqlType === 'insertOrUpdate') {
         let keys = []
         let values = []
         _fields.forEach(item => {
@@ -594,10 +668,10 @@
   
         keys = keys.join(', ')
         values = values.join(', ')
-        _insertsql = `insert into ${this.props.card.sql} (${keys}) select ${values};`
+        _insertsql = `insert into ${card.sql} (${keys}) select ${values};`
       }
       
-      if (this.props.card.sqlType === 'update' || this.props.card.sqlType === 'insertOrUpdate') {
+      if (card.sqlType === 'update' || card.sqlType === 'audit' || card.sqlType === 'insertOrUpdate') {
         let _form = []
         let _arr = []
 
@@ -608,11 +682,20 @@
           _form.push(item.field + '=@' + item.field)
         })
 
-        if (!_arr.includes('modifydate')) {
-          _form.push('modifydate=getdate()')
-        }
-        if (!_arr.includes('modifyuserid')) {
-          _form.push('modifyuserid=@userid@')
+        if (this.props.card.sqlType === 'audit') {
+          if (!_arr.includes('submitdate')) {
+            _form.push('submitdate=getdate()')
+          }
+          if (!_arr.includes('submituserid')) {
+            _form.push('submituserid=@userid@')
+          }
+        } else {
+          if (!_arr.includes('modifydate')) {
+            _form.push('modifydate=getdate()')
+          }
+          if (!_arr.includes('modifyuserid')) {
+            _form.push('modifyuserid=@userid@')
+          }
         }
 
         if (_verify.voucher && _verify.voucher.enabled) {
@@ -628,18 +711,16 @@
         }
 
         _form = _form.join(', ')
-        _updatesql = `update ${this.props.card.sql} set ${_form} where ${config.setting.primaryKey}=@ID@;`
+        _updatesql = `update ${card.sql} set ${_form} where ${config.setting.primaryKey}${card.Ot !== 'requiredOnce' ? '=@ID@' : ' in (select ID  from dbo.SplitComma(@ID@))'};`
       }
 
-      let _defaultsql = ''
-
-      if (this.props.card.sqlType === 'insert') {
+      if (card.sqlType === 'insert') {
         _defaultsql = _insertsql
-      } else if (this.props.card.sqlType === 'update') {
+      } else if (card.sqlType === 'update' || card.sqlType === 'audit') {
         _defaultsql = _updatesql
-      } else if (this.props.card.sqlType === 'insertOrUpdate') {
+      } else if (card.sqlType === 'insertOrUpdate') {
         _defaultsql += `select @tbid=''
-          select @tbid='X' from ${this.props.card.sql} where ${config.setting.primaryKey}=@ID@
+          select @tbid='X' from ${card.sql} where ${config.setting.primaryKey}=@ID@
           if @tbid=''
             begin
             ${_insertsql}
@@ -649,341 +730,47 @@
             ${_updatesql}
             end
         `
-      }
-
-      this.setState({
-        fields: _fields,
-        initsql: _sql,
-        defaultsql: _defaultsql,
-        usefulfields: _usefulfields
-      }, () => {
-        this.getsysScript()
-      })
-
-      return
-    }
-
-    // 閫氱敤鎸夐挳
-    if (this.props.card.OpenType === 'pop') {
-      Api.getSystemConfig({
-        func: 'sPC_Get_LongParam',
-        MenuID: this.props.card.uuid
-      }).then(res => {
-        if (res.status) {
-          let _LongParam = ''
-          if (res.LongParam) {
-            try {
-              _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam)))
-            } catch (e) {
-              console.warn('Parse Failure')
-              _LongParam = ''
-            }
-          }
-  
-          if (!_LongParam) {
-            notification.warning({
-              top: 92,
-              message: '琛ㄥ崟鏈坊鍔犳垨瑙f瀽閿欒锛岃妫�鏌ヨ〃鍗曡缃紒',
-              duration: 5
-            })
-
-            this.getsysScript()
-
-            return
-          }
-          
-          let _fields = []
-          if (_LongParam.groups.length > 0) {
-            _LongParam.groups.forEach(group => {
-              _fields.push(...group.sublist)
-            })
-          } else {
-            _fields = _LongParam.fields
-          }
-
-          let _usefulfields = ['BID', 'ID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey', 'UserName', 'FullName', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear', 'ModularDetailCode']
-          let _declare = ['@UserName nvarchar(50)', '@FullName nvarchar(50)', '@ErrorCode nvarchar(50)', '@retmsg nvarchar(4000)', '@BillCode nvarchar(50)', '@BVoucher nvarchar(50)', '@FIBVoucherDate nvarchar(50)', '@FiYear nvarchar(50)', '@ModularDetailCode nvarchar(50)']
-          let _select = ['@UserName=\'\'', '@FullName=\'\'', '@ErrorCode=\'\'', '@retmsg=\'\'', '@BillCode=\'\'', '@BVoucher=\'\'', '@FIBVoucherDate=\'\'', '@FiYear=\'\'', '@ModularDetailCode=\'\'']
-          let hasBid = false
-          let fieldArr = _usefulfields.map(_f => _f.toLowerCase())
-          let _defaultfields = fromJS(_fields).toJS()
-
-          _fields.forEach(_f => {
-            if (_f.field) {
-              if (fieldArr.includes(_f.field.toLowerCase())) return
-              fieldArr.push(_f.field.toLowerCase())
-
-              _usefulfields.push(_f.field)
-
-              let _fieldlen = _f.fieldlength || 50
-
-              if (['textarea', 'fileupload', 'multiselect'].includes(_f.type)) {
-                _fieldlen = _f.fieldlength || 512
-              } else if (_f.type === 'number') {
-                _fieldlen = _f.decimal ? _f.decimal : 0
-              }
-
-              if (_fieldlen > 2048) {
-                _fieldlen = 'max'
-              }
-
-              let _type = `nvarchar(${_fieldlen})`
-
-              if (_f.type.match(/date/ig)) {
-                _type = 'datetime'
-                _select.push(`@${_f.field}='1900-01-01'`)
-              } else if (_f.type === 'number') {
-                _type = `decimal(18,${_fieldlen})`
-                _select.push(`@${_f.field}=0`)
-              } else {
-                _select.push(`@${_f.field}=''`)
-              }
-
-              _declare.push(`@${_f.field} ${_type}`)
-            }
-            if (_f.field && _f.field.toLowerCase() === 'bid') {
-              hasBid = true
-            }
-          })
-
-          if (this.props.floor === 'subtable' && !hasBid) { // 瀛愯〃琛ㄥ崟涓鍔燘ID
-            _fields.unshift({
-              uuid: 'BID',
-              field: 'BID',
-              label: 'BID',
-              type: 'text'
-            })
-          }
-
-          if (columns && columns.length > 0 && this.props.card.Ot !== 'notRequired' && this.props.card.Ot !== 'requiredOnce') {
-            columns.forEach(_f => {
-              if (!_f.field || fieldArr.includes(_f.field.toLowerCase())) return
-
-              fieldArr.push(_f.field.toLowerCase())
-
-              _usefulfields.push(_f.field)
-
-              let _fieldlen = _f.fieldlength || 50
-
-              if (_f.type === 'picture' || _f.type === 'textarea') {
-                _fieldlen = _f.fieldlength || 512
-              }
-
-              if (_fieldlen > 2048) {
-                _fieldlen = 'max'
-              }
-
-              let _type = `nvarchar(${_fieldlen})`
-
-              if (_f.type === 'number') {
-                _type = `decimal(18,${_f.decimal ? _f.decimal : 0})`
-              } else if (_f.type === 'picture' || _f.type === 'textarea') {
-                _type = `nvarchar(${_fieldlen})`
-              }
-
-              if (_f.type === 'number') {
-                _select.push(`@${_f.field}=0`)
-              } else {
-                _select.push(`@${_f.field}=''`)
-              }
-    
-              _declare.push(`@${_f.field} ${_type}`)
-            })
-          }
-
-          _usefulfields = _usefulfields.join(', ')
-          let _sql = `Declare ${_declare.join(', ')}
-            Select ${_select.join(', ')}
-          `
-
-          // 榛樿sql
-          let _defaultsql = ''
-
-          if (this.props.card.sqlType === 'insert') {
-            let keys = []
-            let values = []
-            _defaultfields.forEach(item => {
-              if (!item.field) return
-
-              keys.push(item.field.toLowerCase())
-              values.push('@' + item.field)
-            })
-
-            if (config.setting.primaryKey && !keys.includes(config.setting.primaryKey.toLowerCase())) {
-              keys.push(config.setting.primaryKey.toLowerCase())
-              values.push('@ID@')
-            }
-            if (!keys.includes('createuserid')) {
-              keys.push('createuserid')
-              values.push('@userid@')
-            }
-            if (!keys.includes('createuser')) {
-              keys.push('createuser')
-              values.push('@username')
-            }
-            if (!keys.includes('createstaff')) {
-              keys.push('createstaff')
-              values.push('@fullname')
-            }
-            if (!keys.includes('bid')) {
-              keys.push('bid')
-              values.push('@BID@')
-            }
-      
-            keys = keys.join(', ')
-            values = values.join(', ')
-            _defaultsql = `insert into ${this.props.card.sql} (${keys}) select ${values};`
-          } else if (this.props.card.sqlType === 'update' || this.props.card.sqlType === 'audit') {
-            let _form = []
-            let _arr = []
-
-            _defaultfields.forEach(item => {
-              if (!item.field) return
-
-              _arr.push(item.field.toLowerCase())
-              _form.push(item.field + '=@' + item.field)
-            })
-
-            if (this.props.card.sqlType === 'audit') {
-              if (!_arr.includes('submitdate')) {
-                _form.push('submitdate=getdate()')
-              }
-              if (!_arr.includes('submituserid')) {
-                _form.push('submituserid=@userid@')
-              }
-            } else {
-              if (!_arr.includes('modifydate')) {
-                _form.push('modifydate=getdate()')
-              }
-              if (!_arr.includes('modifyuserid')) {
-                _form.push('modifyuserid=@userid@')
-              }
-            }
-
-            if (_verify.voucher && _verify.voucher.enabled) {
-              if (!_arr.includes('bvoucher')) {
-                _form.push('BVoucher=@BVoucher')
-              }
-              if (!_arr.includes('fibvoucherdate')) {
-                _form.push('FIBVoucherDate=@FIBVoucherDate')
-              }
-              if (!_arr.includes('fiyear')) {
-                _form.push('FiYear=@FiYear')
-              }
-            }
-
-            _form = _form.join(', ')
-            _defaultsql = `update ${this.props.card.sql} set ${_form} where ${config.setting.primaryKey}${this.props.card.Ot !== 'requiredOnce' ? '=@ID@' : ' in (select ID  from dbo.SplitComma(@ID@))'};`
-          }
-          
-          this.setState({
-            fields: _fields,
-            initsql: _sql,
-            defaultsql: _defaultsql,
-            usefulfields: _usefulfields
-          }, () => {
-            this.getsysScript()
-          })
-        } else {
-          notification.warning({
-            top: 92,
-            message: res.message,
-            duration: 5
-          })
-          this.getsysScript()
-        }
-      })
-    } else {
-      let _usefulfields = ['BID', 'ID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey', 'UserName', 'FullName', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear', 'ModularDetailCode']
-      let _declare = ['@UserName nvarchar(50)', '@FullName nvarchar(50)', '@ErrorCode nvarchar(50)', '@retmsg nvarchar(4000)', '@BillCode nvarchar(50)', '@BVoucher nvarchar(50)', '@FIBVoucherDate nvarchar(50)', '@FiYear nvarchar(50)', '@ModularDetailCode nvarchar(50)']
-      let _select = ['@UserName=\'\'', '@FullName=\'\'', '@ErrorCode=\'\'', '@retmsg=\'\'', '@BillCode=\'\'', '@BVoucher=\'\'', '@FIBVoucherDate=\'\'', '@FiYear=\'\'', '@ModularDetailCode=\'\'']
-      let fieldArr = _usefulfields.map(_f => _f.toLowerCase())
-
-      if (columns && columns.length > 0 && this.props.card.Ot !== 'notRequired' && this.props.card.Ot !== 'requiredOnce') {
-        columns.forEach(_f => {
-          if (!_f.field || fieldArr.includes(_f.field.toLowerCase())) return
-
-          fieldArr.push(_f.field.toLowerCase())
-
-          _usefulfields.push(_f.field)
-
-          let _fieldlen = _f.fieldlength || 50
-
-          if (_f.type === 'picture' || _f.type === 'textarea') {
-            _fieldlen = _f.fieldlength || 512
-          }
-
-          if (_fieldlen > 2048) {
-            _fieldlen = 'max'
-          }
-
-          let _type = `nvarchar(${_fieldlen})`
-
-          if (_f.type === 'number') {
-            _type = `decimal(18,${_f.decimal ? _f.decimal : 0})`
-          } else if (_f.type === 'picture' || _f.type === 'textarea') {
-            _type = `nvarchar(${_fieldlen})`
-          }
-
-          if (_f.type === 'number') {
-            _select.push(`@${_f.field}=0`)
-          } else {
-            _select.push(`@${_f.field}=''`)
-          }
-
-          _declare.push(`@${_f.field} ${_type}`)
-        })
-      }
-
-      _usefulfields = _usefulfields.join(', ')
-      let _sql = `Declare ${_declare.join(', ')}
-        Select ${_select.join(', ')}
-      `
-
-      // 榛樿sql
-      let _defaultsql = ''
-
-      if (this.props.card.sqlType === 'LogicDelete') {
-        _defaultsql = `update ${this.props.card.sql} set deleted=1,modifydate=getdate(),modifyuserid=@userid@ where ${config.setting.primaryKey}${this.props.card.Ot !== 'requiredOnce' ? '=@ID@' : ' in (select ID  from dbo.SplitComma(@ID@))'};`
-      } else if (this.props.card.sqlType === 'delete') {
+      } else if (card.sqlType === 'LogicDelete') {
+        _defaultsql = `update ${card.sql} set deleted=1,modifydate=getdate(),modifyuserid=@userid@ where ${config.setting.primaryKey}${card.Ot !== 'requiredOnce' ? '=@ID@' : ' in (select ID  from dbo.SplitComma(@ID@))'};`
+      } else if (card.sqlType === 'delete') {
         let _msg = ''
-        if (columns && columns.length > 0 && this.props.card.Ot !== 'notRequired' && this.props.card.Ot !== 'requiredOnce') {
+        if (columns && columns.length > 0 && card.Ot !== 'notRequired' && card.Ot !== 'requiredOnce') {
           let _index = 0
           columns.forEach(col => {
-            if (col.field && col.Hide !== 'true' && _index < 4) {
-              _msg += col.label + '=\'\','
-              _index++
-            }
+            if (!col.field || col.Hide === 'true' || _index >= 4) return
+
+            _msg += col.label + '=\'\','
+            _index++
           })
         }
-        _defaultsql += `insert into snote (remark,createuserid,CreateUser,CreateStaff) select left('鍒犻櫎琛�:${this.props.card.sql} 鏁版嵁: ${_msg}${config.setting.primaryKey}='+@ID@,200),@userid@,@username,@fullname delete ${this.props.card.sql} where ${config.setting.primaryKey}${this.props.card.Ot !== 'requiredOnce' ? '=@ID@' : ' in (select ID  from dbo.SplitComma(@ID@))'};`
+        _defaultsql += `insert into snote (remark,createuserid,CreateUser,CreateStaff) select left('鍒犻櫎琛�:${card.sql} 鏁版嵁: ${_msg}${config.setting.primaryKey}='+@ID@,200),@userid@,@username,@fullname delete ${card.sql} where ${config.setting.primaryKey}${card.Ot !== 'requiredOnce' ? '=@ID@' : ' in (select ID  from dbo.SplitComma(@ID@))'};`
       }
 
+      let _columns = []
+      if (columns) {
+        _columns = fromJS(columns).toJS()
+        let hasbid = false
+        _columns = _columns.filter(col => {
+          if (col.field.toLowerCase() === 'bid') {
+            hasbid = true
+          }
+
+          return !!col.field
+        })
+
+        if (!hasbid) {
+          _columns.unshift({ uuid: 'BID', field: 'BID', label: 'BID', type: 'text' })
+        }
+      }
+      
       this.setState({
+        fields: _fields,
+        columnsFields: _columns,
         initsql: _sql,
         defaultsql: _defaultsql,
-        usefulfields: _usefulfields
-      }, () => {
-        this.getsysScript()
+        usefulfields: _usefulfields.join(', ')
       })
-    }
-
-    if (this.props.card.Ot === 'requiredOnce') {
-      let _columns = fromJS(config.columns).toJS()
-      _columns = _columns.filter(col => col.field)
-
-      if (this.props.floor === 'subtable' && _columns.filter(col => col.field.toLowerCase() === 'bid').length === 0) { // 瀛愯〃琛ㄥ崟涓鍔燘ID
-        _columns.unshift({
-          uuid: 'BID',
-          field: 'BID',
-          label: 'BID',
-          type: 'text'
-        })
-      }
-      this.setState({
-        columnsFields: _columns
-      })
-    }
+    })
   }
 
   componentDidMount() {
@@ -1012,6 +799,11 @@
         obj_name: 'noteCodes',
         arr_field: 'templatecode,describe',
         LText: window.btoa(window.encodeURIComponent(`select templatecode,'['+SignName+']'+describe as describe from (select * from bd_msn_sms_temp where  deleted=0 and TypeDesc='QX' and status=20 ) t inner join (select openid from susers where uid=@userid@) u on t.openid =t.openid`))
+      },
+      {
+        obj_name: 'scripts',
+        arr_field: 'funcname,longparam',
+        LText: window.btoa(window.encodeURIComponent(`Select distinct func+Remark as funcname,longparam, s.Sort from s_custom_script s inner join (select OpenID from sapp where ID=@Appkey@) p on s.openid = case when s.appkey='' then s.openid else p.OpenID end order by s.Sort`))
       }
     ]
 
@@ -1028,7 +820,6 @@
     mutilparam.LText = Utils.formatOptions(mutilparam.LText)
     mutilparam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
     mutilparam.secretkey = Utils.encrypt(mutilparam.LText, mutilparam.timestamp)
-
     mutilparam.open_key = Utils.encryptOpenKey(mutilparam.secretkey, mutilparam.timestamp)
 
     Api.getCloudCacheConfig(mutilparam).then(res => {
@@ -1043,58 +834,13 @@
               name: item.describe,
               value: item.templatecode
             }
+          }),
+          systemScripts: res.scripts.map(item => {
+            return {
+              name: item.funcname,
+              value: Utils.UnformatOptions(item.longparam)
+            }
           })
-        })
-      } else {
-        notification.warning({
-          top: 92,
-          message: res.message,
-          duration: 5
-        })
-      }
-    })
-  }
-
-  getsysScript = () => {
-    const { defaultsql } = this.state
-
-    let _scriptSql = `Select distinct func+Remark as funcname,longparam, s.Sort from聽 s_custom_script s inner join (select OpenID from sapp where ID=@Appkey@) p on s.openid = case when s.appkey='' then s.openid else p.OpenID end order by s.Sort`
-
-    _scriptSql = Utils.formatOptions(_scriptSql)
-
-    let _sParam = {
-      func: 'sPC_Get_SelectedList',
-      LText: _scriptSql,
-      obj_name: 'data',
-      arr_field: 'funcname,longparam'
-    }
-    
-    _sParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-    _sParam.secretkey = Utils.encrypt(_sParam.LText, _sParam.timestamp)
-    _sParam.open_key = Utils.encryptOpenKey(_sParam.secretkey, _sParam.timestamp) // 浜戠鏁版嵁楠岃瘉
-    
-    Api.getCloudCacheConfig(_sParam).then(res => {
-      if (res.status) {
-        let _scripts = []
-
-        if (defaultsql) {
-          _scripts.push({
-            name: '榛樿sql',
-            value: defaultsql
-          })
-        }
-
-        res.data.forEach(item => {
-          let _item = {
-            name: item.funcname,
-            value: Utils.UnformatOptions(item.longparam)
-          }
-
-          _scripts.push(_item)
-        })
-
-        this.setState({
-          systemScripts: _scripts
         })
       } else {
         notification.warning({
@@ -1122,9 +868,7 @@
       verify.uniques.push(values)
     }
 
-    this.setState({
-      verify: verify
-    })
+    this.setState({ verify })
   }
 
   contrastChange = (values) => {
@@ -1143,9 +887,7 @@
       verify.contrasts.push(values)
     }
 
-    this.setState({
-      verify: verify
-    })
+    this.setState({ verify })
   }
 
   customChange = (values) => {
@@ -1164,9 +906,7 @@
       verify.customverifys.push(values)
     }
 
-    this.setState({
-      verify: verify
-    })
+    this.setState({ verify })
   }
 
   scriptsChange = (values) => {
@@ -1185,9 +925,7 @@
       verify.scripts.push(values)
     }
 
-    this.setState({
-      verify: verify
-    })
+    this.setState({ verify })
   }
 
   orderChange = (values) => {
@@ -1206,9 +944,7 @@
       verify.billcodes.push(values)
     }
 
-    this.setState({
-      verify: verify
-    })
+    this.setState({ verify })
   }
 
   onNoteCodeChange = (val) => {
@@ -1243,7 +979,7 @@
       verify.contrasts = verify.contrasts.filter(item => item.uuid !== record.uuid)
     }
 
-    this.setState({ verify: verify })
+    this.setState({ verify })
   }
 
   handleEdit = (record, type) => {
@@ -1321,9 +1057,7 @@
       })
     }
 
-    this.setState({
-      verify: verify
-    })
+    this.setState({ verify })
   }
 
   handleUpDown = (record, type, direction) => {
@@ -1417,9 +1151,7 @@
       }
     }
 
-    this.setState({
-      verify: verify
-    })
+    this.setState({ verify })
   }
 
   voucherChange = (voucher) => {
@@ -1753,6 +1485,7 @@
               dict={this.props.dict}
               btn={this.props.card}
               customScripts={verify.scripts}
+              defaultsql={this.state.defaultsql}
               systemScripts={this.state.systemScripts}
               scriptsChange={this.scriptsChange}
               wrappedComponentRef={(inst) => this.scriptsForm = inst}

--
Gitblit v1.8.0