From b70376bd370f83e0087e629b664243f3a4bf191c Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 10 二月 2020 02:35:33 +0800
Subject: [PATCH] 2020-02-10

---
 src/tabviews/tableshare/mutilform/index.jsx  |    4 
 src/components/header/index.jsx              |   28 ++++++
 src/templates/ushare/editable/index.jsx      |   50 +++++++++++-
 src/utils/utils.js                           |   57 ++++++++------
 src/tabviews/tableshare/actionList/index.jsx |    8 +-
 src/templates/ushare/modalform/index.jsx     |   47 +++++++++--
 6 files changed, 149 insertions(+), 45 deletions(-)

diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx
index 769a009..079ead9 100644
--- a/src/components/header/index.jsx
+++ b/src/components/header/index.jsx
@@ -249,8 +249,23 @@
       })
     } else {
       sessionStorage.setItem('isEditState', state)
+      let _userName = sessionStorage.getItem('User_Name')
+      let _avatar = this.state.avatar
+
+      if (!state && sessionStorage.getItem('avatar')) {
+        _avatar = Utils.getrealurl(sessionStorage.getItem('avatar')) // 澶村儚
+      } else if (state && sessionStorage.getItem('CloudAvatar')) {
+        _avatar = Utils.getrealurl(sessionStorage.getItem('CloudAvatar')) // 澶村儚
+      }
+
+      if (state) {
+        _userName = sessionStorage.getItem('CloudUserName')
+      }
+
       this.setState({
-        menulist: null
+        menulist: null,
+        userName: _userName,
+        avatar: _avatar
       })
       this.loadmenu()
       this.props.modifyMainMenu('')
@@ -268,12 +283,21 @@
           sessionStorage.setItem('CloudUserID', res.UserID)
           sessionStorage.setItem('CloudSessionUid', Utils.getuuid())
           sessionStorage.setItem('CloudLoginUID', res.LoginUID)
+          sessionStorage.setItem('CloudUserName', res.UserName)
+          sessionStorage.setItem('CloudAvatar', res.icon)
           sessionStorage.setItem('isEditState', 'true')
+
+          let _avatar = this.state.avatar
+          if (res.icon) {
+            _avatar = Utils.getrealurl(res.icon) // 澶村儚
+          }
 
           this.setState({
             menulist: null,
             loginVisible: false,
-            loginLoading: false
+            loginLoading: false,
+            userName: res.UserName,
+            avatar: _avatar
           })
           this.loadmenu()
           this.props.modifyMainMenu('')
diff --git a/src/tabviews/tableshare/actionList/index.jsx b/src/tabviews/tableshare/actionList/index.jsx
index 5718b52..ef642e1 100644
--- a/src/tabviews/tableshare/actionList/index.jsx
+++ b/src/tabviews/tableshare/actionList/index.jsx
@@ -156,12 +156,12 @@
       }
 
       // 鎵ц鏂瑰紡涓哄琛屾嫾鎺ワ紝涓旀墦寮�鏂瑰紡涓鸿〃鍗曟椂锛屼細杞负寰幆鍙戦�佽姹�
-      // 鎵撳紑鏂瑰紡涓烘ā鎬佹锛屼娇鐢ㄥ唴閮ㄥ嚱鏁版坊鍔�
+      // 鎵撳紑鏂瑰紡涓烘ā鎬佹锛屼娇鐢ㄥ唴閮ㄥ嚱鏁版坊鍔�(鏈夋壒閲忔坊鍔犲満鏅紝宸插幓闄�)
       if (
         btn.Ot === 'notRequired' ||
         btn.Ot === 'requiredSgl' ||
-        (btn.Ot === 'requiredOnce' && btn.OpenType !== 'pop') ||
-        (btn.OpenType === 'pop' && !btn.innerFunc && btn.sql && btn.sqlType === 'insert')
+        (btn.Ot === 'requiredOnce' && btn.OpenType !== 'pop')
+        // (btn.OpenType === 'pop' && !btn.innerFunc && btn.sql && btn.sqlType === 'insert')
       ) {
 
         // 鍒涘缓鍑瘉鏃讹紝闇�瑕侀�夋嫨琛屾椂
@@ -318,7 +318,7 @@
       }
     } else if (btn.intertype === 'outer') {
       /** *********************璋冪敤澶栭儴鎺ュ彛************************* */
-
+      if (2 > 1) return
       if (!btn.interface) { // 鎺ュ彛鍦板潃涓嶅瓨鍦ㄦ椂鎶ラ敊
         this.actionSettingError()
         _resolve()
diff --git a/src/tabviews/tableshare/mutilform/index.jsx b/src/tabviews/tableshare/mutilform/index.jsx
index 4286fa1..e6d9d87 100644
--- a/src/tabviews/tableshare/mutilform/index.jsx
+++ b/src/tabviews/tableshare/mutilform/index.jsx
@@ -206,9 +206,9 @@
       let _data = option.props.data
       _field.linkSubField.forEach(subfield => {
         if (this.props.form.getFieldValue(subfield) !== undefined) {
-          fieldsvalue[subfield] = _data[subfield]
+          fieldsvalue[subfield] = _data[subfield] || ''
         } else {
-          _record[subfield] = _data[subfield]
+          _record[subfield] = _data[subfield] || ''
         }
       })
     }
diff --git a/src/templates/ushare/editable/index.jsx b/src/templates/ushare/editable/index.jsx
index 4f10603..a3064ca 100644
--- a/src/templates/ushare/editable/index.jsx
+++ b/src/templates/ushare/editable/index.jsx
@@ -1,4 +1,5 @@
 import React, {Component} from 'react'
+import { is, fromJS } from 'immutable'
 import { Table, Input, Button, Popconfirm, Form, Icon } from 'antd'
 import Utils from '@/utils/utils.js'
 import './index.scss'
@@ -91,19 +92,38 @@
 class EditTable extends Component {
   constructor(props) {
     super(props)
+
+    let _width = '40%'
+    let fields = []
+
+    if (props.type === 'link') {
+      _width = '27%'
+    } else {
+      _width = Math.floor(80 / (props.linkSubFields.length + 2)) + '%'
+      fields = props.linkSubFields.map(field => {
+        return {
+          title: field.label,
+          dataIndex: field.field,
+          width: _width,
+          editable: true
+        }
+      })
+    }
+
     let columns = [
       {
         title: 'Value',
         dataIndex: 'Value',
-        width: props.type === 'link' ? '27%' : '40%',
+        width: _width,
         editable: true
       },
       {
         title: 'Text',
         dataIndex: 'Text',
-        width: props.type === 'link' ? '27%' : '40%',
+        width: _width,
         editable: true
       },
+      ...fields,
       {
         title: '鎿嶄綔',
         align: 'center',
@@ -166,20 +186,38 @@
     this.setState({ dataSource: newData })
   }
 
-  resetColumn = (type) => {
+  resetColumn = (type, linkSubFields) => {
+    let _width = '40%'
+    let fields = []
+
+    if (type === 'link') {
+      _width = '27%'
+    } else {
+      _width = Math.floor(80 / (linkSubFields.length + 2)) + '%'
+      fields = linkSubFields.map(field => {
+        return {
+          title: field.label,
+          dataIndex: field.field,
+          width: _width,
+          editable: true
+        }
+      })
+    }
+
     let columns = [
       {
         title: 'Value',
         dataIndex: 'Value',
-        width: type === 'link' ? '27%' : '40%',
+        width: _width,
         editable: true
       },
       {
         title: 'Text',
         dataIndex: 'Text',
-        width: type === 'link' ? '27%' : '40%',
+        width: _width,
         editable: true
       },
+      ...fields,
       {
         title: '鎿嶄綔',
         align: 'center',
@@ -211,6 +249,8 @@
   UNSAFE_componentWillReceiveProps (nextProps) {
     if (this.props.type !== nextProps.type) {
       this.resetColumn(nextProps.type)
+    } else if (!is(fromJS(this.props.linkSubFields), fromJS(nextProps.linkSubFields))) {
+      this.resetColumn(this.props.type, nextProps.linkSubFields)
     }
   }
 
diff --git a/src/templates/ushare/modalform/index.jsx b/src/templates/ushare/modalform/index.jsx
index eeafd26..7eb8e38 100644
--- a/src/templates/ushare/modalform/index.jsx
+++ b/src/templates/ushare/modalform/index.jsx
@@ -18,14 +18,35 @@
   state = {
     openType: null,
     resourceType: null,
-    formlist: null
+    formlist: null,
+    linkSubFields: null
   }
 
   UNSAFE_componentWillMount () {
     let formlist = JSON.parse(JSON.stringify(this.props.formlist))
 
-    let type = formlist.filter(cell => cell.key === 'type')[0].initVal
-    let resourceType = formlist.filter(cell => cell.key === 'resourceType')[0].initVal
+    let type = ''
+    let resourceType = ''
+    let linkSubFields = []
+
+    formlist.forEach(cell => {
+      if (cell.key === 'type') {
+        type = cell.initVal
+      } else if (cell.key === 'resourceType') {
+        resourceType = cell.initVal
+      } else if (cell.key === 'linkSubField') {
+        let arr = []
+        linkSubFields = cell.options.filter(option => {
+          if (!['Value', 'Text'].includes(option.field) && cell.initVal.includes(option.field) && !arr.includes(option.field)) {
+            arr.push(option.field)
+            return true
+          } else {
+            return false
+          }
+        })
+      }
+    })
+    
     let _options = ['label', 'field', 'initval', 'type', 'readonly', 'required', 'hidden', 'readin'] // 榛樿鏄剧ず椤�
 
     if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '0') { // 閫夋嫨绫诲瀷銆佽嚜瀹氫箟璧勬簮
@@ -51,10 +72,11 @@
     } else if (type === 'linkMain') {
       _options = ['label', 'field', 'type', 'readonly', 'required', 'hidden', 'fieldlength']
     }
-    
+
     this.setState({
       openType: type,
       resourceType: resourceType,
+      linkSubFields: linkSubFields,
       formlist: formlist.map(form => {
         if (dateOptions.hasOwnProperty(type) && form.key === 'initval') {
           form.options = dateOptions[type]
@@ -137,6 +159,8 @@
             form.show = false
           } else if (form.key === 'resourceType') {
             form.initVal = this.state.resourceType
+          } else if (form.key === 'linkSubField') {
+            form.initVal = this.state.linkSubFields.map(_field => _field.field)
           }
           return form
         })
@@ -157,11 +181,18 @@
 
   multiselectChange = (key, value, options) => {
     if (key === 'linkSubField') {
+      let arr = []
+      let linkSubFields = options.filter(option => {
+        if (!['Value', 'Text'].includes(option.field) && value.includes(option.field) && !arr.includes(option.field)) {
+          arr.push(option.field)
+          return true
+        } else {
+          return false
+        }
+      })
 
+      this.setState({linkSubFields: linkSubFields})
     }
-    console.log(key)
-    console.log(value)
-    console.log(options)
   }
 
   onChange = (e, key) => {
@@ -384,7 +415,7 @@
       } else if (item.type === 'options') {
         fields.push(
           <Col span={20} offset={4} key={index}>
-            <EditTable data={item.initVal} type={this.state.openType} ref="editTable"/>
+            <EditTable data={item.initVal} type={this.state.openType} linkSubFields={this.state.linkSubFields} ref="editTable"/>
           </Col>
         )
       }
diff --git a/src/utils/utils.js b/src/utils/utils.js
index c7540b2..6b0a8e6 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -451,7 +451,8 @@
     let verify = btn.verify || {}
     let _formFieldValue = {}
     // 闇�瑕佸0鏄庣殑鍙橀噺闆�
-    let _vars = ['tbid', 'ErrorCode', 'retmsg', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear', 'UserName', 'FullName', 'ID', 'BID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey']
+    // let _vars = ['tbid', 'ErrorCode', 'retmsg', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear', 'UserName', 'FullName', 'ID', 'BID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey']
+    let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname', 'id', 'bid', 'loginuid', 'sessionuid', 'userid', 'appkey']
 
     // 涓婚敭瀛楁
     let primaryKey = setting.primaryKey || 'id'
@@ -460,7 +461,8 @@
     let _sql = `Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50)
       `
 
-    let _initvars = ['ID', 'BID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey'] // 宸茶祴鍊煎瓧娈甸泦
+    // let _initvars = ['ID', 'BID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey'] // 宸茶祴鍊煎瓧娈甸泦
+    let _initvars = ['id', 'bid', 'loginuid', 'sessionuid', 'userid', 'appkey'] // 宸茶祴鍊煎瓧娈甸泦
     let _initfields = []
     let _declarefields = []
 
@@ -468,14 +470,15 @@
     if (formdata) {
       formdata.forEach(form => {
         _formFieldValue[form.key] = form.value
+        let _key = form.key.toLowerCase()
 
-        if (!_initvars.includes(form.key)) {
-          _initvars.push(form.key)
-          _initfields.push(`@${form.key}='${form.value}'`)
+        if (!_initvars.includes(_key)) {
+          _initvars.push(_key)
+          _initfields.push(`@${_key}='${form.value}'`)
         }
         
-        if (!_vars.includes(form.key)) {
-          _vars.push(form.key)
+        if (!_vars.includes(_key)) {
+          _vars.push(_key)
 
           let _type = `nvarchar(${form.fieldlen})`
 
@@ -485,7 +488,7 @@
             _type = `decimal(18,${form.fieldlen})`
           }
 
-          _declarefields.push(`@${form.key} ${_type}`)
+          _declarefields.push(`@${_key} ${_type}`)
         }
       })
     }
@@ -496,15 +499,17 @@
 
       if (logcolumns && logcolumns.length > 0) {
         logcolumns.forEach(col => {
-          if (!_initvars.includes(col.field)) {
-            _initvars.push(col.field)
+          let _key = col.field.toLowerCase()
+
+          if (!_initvars.includes(_key)) {
+            _initvars.push(_key)
 
             let _val = data.hasOwnProperty(col.field) ? data[col.field] : ''
-            _initfields.push(`@${col.field}='${_val}'`)
+            _initfields.push(`@${_key}='${_val}'`)
           }
           
-          if (!_vars.includes(col.field)) {
-            _vars.push(col.field)
+          if (!_vars.includes(_key)) {
+            _vars.push(_key)
   
             let _type = `nvarchar(${col.fieldlength || 50})`
 
@@ -515,7 +520,7 @@
               _type = `nvarchar(${col.fieldlength || 512})`
             }
   
-            _declarefields.push(`@${col.field} ${_type}`)
+            _declarefields.push(`@${_key} ${_type}`)
           }
         })
       }
@@ -657,13 +662,15 @@
         }
 
         let _declare = ''
-        if (!_vars.includes(item.field)) {
-          _declare = `Declare @${item.field} nvarchar(50)`
+        let _key = item.field.toLowerCase()
+
+        if (!_vars.includes(_key)) {
+          _declare = `Declare @${_key} nvarchar(50)`
+          _vars.push(_key)
         }
-        _vars.push(item.field)
 
         _sql += `${_declare}
-          select @BillCode='', @${item.field}=''
+          select @BillCode='', @${_key}=''
           exec s_get_BillCode
             @ModularDetailCode='${_ModularDetailCode}',
             @Type=${item.Type},
@@ -674,7 +681,7 @@
             @retmsg=@retmsg output
           if @ErrorCode!=''
             goto aaa
-          set @${item.field}=@BillCode
+          set @${_key}=@BillCode
           `
       })
     }
@@ -704,8 +711,10 @@
     }
 
     // 鐢ㄤ簬鍙栫敤鎴蜂俊鎭�
-    let _user = `select @UserName=UserName,@FullName=FullName from SUsers where UID=@UserID
+    let _user = `select @UserName=UserName,@FullName=FullName from SUsers where UID=@UserID@
       `
+
+    let primaryKeyName = ['id', 'bid', 'loginuid', 'sessionuid', 'userid', 'appkey'].includes(primaryKey.toLowerCase()) ? primaryKey + '@' : primaryKey
 
     // 娣诲姞銆佷慨鏀广�侀�昏緫鍒犻櫎銆佺墿鐞嗗垹闄�
     if (btn.OpenType === 'pop' && btn.sqlType === 'insert' && verify.default !== 'false') {
@@ -727,7 +736,7 @@
       keys = keys.join(',')
       values = values.join(',')
       _sql += _user
-      _sql += `insert into ${btn.sql} (${keys},createuserid,CreateUser,CreateStaff,BID) select ${values},@userid,@username,@fullname,@BID;`
+      _sql += `insert into ${btn.sql} (${keys},createuserid,CreateUser,CreateStaff,BID) select ${values},@userid@,@username,@fullname,@BID@;`
     } else if (btn.OpenType === 'pop' && btn.sqlType === 'update' && verify.default !== 'false') {
       let _form = []
       formdata.forEach(item => {
@@ -740,9 +749,9 @@
         }
       })
       _form = _form.join(',')
-      _sql += `update ${btn.sql} set ${_form},modifydate=getdate(),modifyuserid=@userid${_updateconfig} where ${primaryKey}=@${primaryKey};`
+      _sql += `update ${btn.sql} set ${_form},modifydate=getdate(),modifyuserid=@userid@${_updateconfig} where ${primaryKey}=@${primaryKeyName};`
     } else if ((btn.OpenType === 'prompt' || btn.OpenType === 'exec') && btn.sqlType === 'LogicDelete' && verify.default !== 'false') { // 閫昏緫鍒犻櫎
-      _sql += `update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuserid=@userid where ${primaryKey}=@${primaryKey};`
+      _sql += `update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuserid=@userid@ where ${primaryKey}=@${primaryKeyName};`
     } else if ((btn.OpenType === 'prompt' || btn.OpenType === 'exec') && btn.sqlType === 'delete' && verify.default !== 'false') {      // 鐗╃悊鍒犻櫎
       let _msg = ''
       if (data && logcolumns && logcolumns.length > 0) {
@@ -755,7 +764,7 @@
         })
       }
       _sql += _user
-      _sql += `insert into snote (remark,createuserid,CreateUser,CreateStaff) select '鍒犻櫎琛�:${btn.sql} 鏁版嵁: ${_msg}${primaryKey}='+@${primaryKey},@userid,@username,@fullname delete ${btn.sql} where ${primaryKey}=@${primaryKey};`
+      _sql += `insert into snote (remark,createuserid,CreateUser,CreateStaff) select '鍒犻櫎琛�:${btn.sql} 鏁版嵁: ${_msg}${primaryKey}='+@${primaryKeyName},@userid@,@username,@fullname delete ${btn.sql} where ${primaryKey}=@${primaryKeyName};`
     }
 
     // 鎷兼帴鑷畾涔夎剼鏈�

--
Gitblit v1.8.0