From 06404e701a89955958cbf56213e2eec618d8644d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 16 十二月 2020 18:36:16 +0800
Subject: [PATCH] 2020-12-16

---
 src/utils/utils-datamanage.js |   80 ++++++++++++++++++++++++++++-----------
 1 files changed, 57 insertions(+), 23 deletions(-)

diff --git a/src/utils/utils-datamanage.js b/src/utils/utils-datamanage.js
index 15e098a..38b6f12 100644
--- a/src/utils/utils-datamanage.js
+++ b/src/utils/utils-datamanage.js
@@ -13,23 +13,22 @@
    * @param {Number}   pageSize     姣忛〉鏁伴噺
    * @param {String}   BID          涓婄骇ID
    * @param {String}   menuType     鑿滃崟绫诲瀷锛屾櫘閫氳彍鍗曚笌HS
-   * @param {Boolean}  dataManager  鏁版嵁鏉冮檺
    * @return {Object}  param
    */
-  static getQueryDataParams (setting, arrFields, search = [], orderBy = '', pageIndex = 1, pageSize = 10, BID, menuType, dataManager) {
+  static getQueryDataParams (setting, arrFields, search = [], orderBy = '', pageIndex = 1, pageSize = 10, BID, menuType, id) {
     let param = null
 
     if (setting.interType === 'system' || (setting.interType === 'inner' && !setting.innerFunc)) {
-      param = this.getDefaultQueryParam(setting, arrFields, search, orderBy, pageIndex, pageSize, menuType)
+      param = this.getDefaultQueryParam(setting, arrFields, search, orderBy, pageIndex, pageSize, menuType, id)
     } else {
-      param = this.getCustomQueryParam(setting, search, orderBy, pageIndex, pageSize, menuType)
+      param = this.getCustomQueryParam(setting, search, orderBy, pageIndex, pageSize, menuType, id)
     }
 
     if (BID) {
       param.BID = BID
     }
     // 鏁版嵁绠$悊鏉冮檺
-    if (dataManager) {
+    if (sessionStorage.getItem('dataM') === 'true') {
       param.dataM = 'Y'
     }
 
@@ -39,14 +38,16 @@
   /**
    * @description 鑾峰彇鐢ㄦ埛鑷畾涔夊瓨鍌ㄨ繃绋嬩紶鍙�
    */
-  static getCustomQueryParam (setting, search, orderBy, pageIndex, pageSize, menuType) {
+  static getCustomQueryParam (setting, search, orderBy, pageIndex, pageSize, menuType, id) {
     let param = Utils.formatCustomMainSearch(search)
 
     if (orderBy) {
       param.OrderCol = orderBy
     }
 
-    if (setting.laypage) {
+    if (id) {
+      param.ID = id
+    } else if (setting.laypage) {
       param.PageIndex = pageIndex
       param.PageSize = pageSize
     }
@@ -79,14 +80,15 @@
   /**
    * @description 鑾峰彇绯荤粺瀛樺偍杩囩▼ sPC_Get_TableData 鐨勫弬鏁�
    */
-  static getDefaultQueryParam (setting, arrFields, search, orderBy, pageIndex, pageSize, menuType) {
+  static getDefaultQueryParam (setting, arrFields, search, orderBy, pageIndex, pageSize, menuType, id) {
     let param = {
       func: 'sPC_Get_TableData',
       obj_name: 'data',
+      exec_type: 'y',
       arr_field: arrFields,
       default_sql: setting.execute ? 'true' : 'false'
     }
-    
+
     let _dataresource = setting.dataresource
     let _customScript = ''
     
@@ -99,6 +101,13 @@
     let regoptions = null
     if (setting.queryType === 'statistics' || _customScript) {
       let allSearch = Utils.getAllSearchOptions(search)
+      let userName = sessionStorage.getItem('User_Name') || ''
+      let fullName = sessionStorage.getItem('Full_Name') || ''
+
+      if (sessionStorage.getItem('isEditState') === 'true') {
+        userName = sessionStorage.getItem('CloudUserName') || ''
+        fullName = sessionStorage.getItem('CloudFullName') || ''
+      }
 
       regoptions = allSearch.map(item => {
         return {
@@ -107,6 +116,12 @@
         }
       })
       regoptions.push({
+        reg: new RegExp('@userName@', 'ig'),
+        value: userName
+      }, {
+        reg: new RegExp('@fullName@', 'ig'),
+        value: fullName
+      }, {
         reg: new RegExp('@orderBy@', 'ig'),
         value: orderBy
       }, {
@@ -124,11 +139,14 @@
       regoptions.forEach(item => {
         _dataresource = _dataresource.replace(item.reg, item.value)
       })
-    } else if (_dataresource) {
+    } else if (_dataresource && !id) {
       _search = Utils.joinMainSearchkey(search)
       if (_search) {
         _search = 'where ' + _search
       }
+    } else if (_dataresource && id) {
+      _search = Utils.joinMainSearchkey(search)
+      _search = `where ${_search ? _search + ' AND ' : ''} ${setting.primaryKey || 'ID'}='${id}'`
     }
 
     if (_customScript) {
@@ -140,7 +158,7 @@
     let LText = ''
     let DateCount = ''
 
-    if (_dataresource && setting.laypage && orderBy) {
+    if (_dataresource && setting.laypage && orderBy && !id) {
       LText = ` select top ${pageSize} ${arrFields} from (select ${arrFields} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${_dataresource} ${_search}) tmptable where rows > ${pageSize * (pageIndex - 1)} order by tmptable.rows `
       DateCount = `select count(1) as total from ${_dataresource} ${_search}`
     } else if (_dataresource && orderBy) {
@@ -160,22 +178,23 @@
         _customScript = `${_customScript}
           aaa:
           if @ErrorCode!=''
-            insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@
+            insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ 
         `
       }
     }
 
     // 娴嬭瘯绯荤粺鎵撳嵃鏌ヨ璇彞
     if ((options.sysType === 'local' && !window.GLOB.systemType) || window.debugger === true) {
-      _customScript &&  console.log(`${LText ? '' : '/*涓嶆墽琛岄粯璁ql*/\n'}${_customScript}`)
-      LText &&  console.log(LText)
+      _customScript &&  console.info(`${LText ? '' : '/*涓嶆墽琛岄粯璁ql*/\n'}${_customScript}`)
+      LText &&  console.info(LText)
     }
-    
+
     param.custom_script = Utils.formatOptions(_customScript)
     param.LText = Utils.formatOptions(LText)
-    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-    param.secretkey = Utils.encrypt(param.LText, param.timestamp)
     param.DateCount = Utils.formatOptions(DateCount)
+
+    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+    param.secretkey = Utils.encrypt('', param.timestamp)
 
     if (menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉
       param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
@@ -187,10 +206,11 @@
   /**
    * @description 鑾峰彇绯荤粺瀛樺偍杩囩▼ sPC_Get_TableData 鍚堣鍊肩殑鍙傛暟
    */
-  static getStatQueryDataParams (setting, statFields, search, orderBy, BID, menuType, dataManager) {
+  static getStatQueryDataParams (setting, statFields, search, orderBy, BID, menuType) {
     let param = {
       func: 'sPC_Get_TableData',
       obj_name: 'data',
+      exec_type: 'y',
       arr_field: statFields.map(col => col.field).join(','),
       default_sql: setting.execute ? 'true' : 'false'
     }
@@ -207,6 +227,13 @@
     let regoptions = null
     if (setting.queryType === 'statistics' || _customScript) {
       let allSearch = Utils.getAllSearchOptions(search)
+      let userName = sessionStorage.getItem('User_Name') || ''
+      let fullName = sessionStorage.getItem('Full_Name') || ''
+
+      if (sessionStorage.getItem('isEditState') === 'true') {
+        userName = sessionStorage.getItem('CloudUserName') || ''
+        fullName = sessionStorage.getItem('CloudFullName') || ''
+      }
 
       regoptions = allSearch.map(item => {
         return {
@@ -215,6 +242,12 @@
         }
       })
       regoptions.push({
+        reg: new RegExp('@userName@', 'ig'),
+        value: userName
+      }, {
+        reg: new RegExp('@fullName@', 'ig'),
+        value: fullName
+      }, {
         reg: new RegExp('@orderBy@', 'ig'),
         value: orderBy
       }, {
@@ -255,15 +288,16 @@
 
     // 娴嬭瘯绯荤粺鎵撳嵃鏌ヨ璇彞
     if ((options.sysType === 'local' && !window.GLOB.systemType) || window.debugger === true) {
-      _customScript &&  console.log(`${LText ? '' : '/*涓嶆墽琛岄粯璁ql*/\n'}${_customScript}`)
-      LText &&  console.log(LText)
+      _customScript &&  console.info(`${LText ? '' : '/*涓嶆墽琛岄粯璁ql*/\n'}${_customScript}`)
+      LText &&  console.info(LText)
     }
     
     param.custom_script = Utils.formatOptions(_customScript)
     param.LText = Utils.formatOptions(LText)
-    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-    param.secretkey = Utils.encrypt(param.LText, param.timestamp)
     param.DateCount = ''
+
+    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+    param.secretkey = Utils.encrypt('', param.timestamp)
 
     if (menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉
       param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
@@ -274,7 +308,7 @@
     }
     
     // 鏁版嵁绠$悊鏉冮檺
-    if (dataManager) {
+    if (sessionStorage.getItem('dataM') === 'true') {
       param.dataM = 'Y'
     }
 

--
Gitblit v1.8.0