From ea9cdac78107c68b94d24a0055bce461d0fd1ae2 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 11 五月 2023 10:41:36 +0800
Subject: [PATCH] 2023-05-11

---
 src/utils/utils-datamanage.js |  122 ++++++++++++++++++++++++++++++----------
 1 files changed, 92 insertions(+), 30 deletions(-)

diff --git a/src/utils/utils-datamanage.js b/src/utils/utils-datamanage.js
index 06fc8f6..c081694 100644
--- a/src/utils/utils-datamanage.js
+++ b/src/utils/utils-datamanage.js
@@ -64,10 +64,26 @@
           param.rduri = setting.interface
         }
       } else {
-        if (setting.sysInterface === 'true' && window.GLOB.mainSystemApi) {
-          param.rduri = window.GLOB.mainSystemApi
-        } else if (setting.sysInterface !== 'true') {
-          param.rduri = window.GLOB.systemType === 'production' ? (setting.proInterface || setting.interface) : setting.interface
+        if (setting.sysInterface === 'true') {
+          if (window.GLOB.mainSystemApi) {
+            param.rduri = window.GLOB.mainSystemApi
+          }
+        } else if (setting.sysInterface === 'external') {
+          if (window.GLOB.systemType === 'production') {
+            param.$token = setting.exProInterface || ''
+          } else {
+            param.$token = setting.exInterface || ''
+          }
+        } else {
+          if (window.GLOB.systemType === 'production' && setting.proInterface) {
+            param.rduri = setting.proInterface
+          } else {
+            param.rduri = setting.interface
+          }
+          let host = window.GLOB.baseurl.replace(/http(s):\/\//, '')
+          if (param.rduri.indexOf(host) === -1 && /\/dostars/.test(param.rduri)) {
+            param.$login = true
+          }
         }
       }
 
@@ -91,9 +107,9 @@
       default_sql: setting.execute ? 'true' : 'false'
     }
 
-    if (setting.transaction === 'true') {
-      param.func = 'sPC_Get_TableData_try'
-    }
+    // if (setting.transaction === 'true') {
+    //   param.func = 'sPC_Get_TableData_try'
+    // }
 
     let userName = sessionStorage.getItem('User_Name') || ''
     let fullName = sessionStorage.getItem('Full_Name') || ''
@@ -129,8 +145,8 @@
     _customScript = _customScript.replace(/\$sum@/ig, '/*')
     _customScript = _customScript.replace(/@sum\$/ig, '*/')
 
-    _dataresource = _dataresource.replace(/@ID@/ig, `''`)
-    _customScript = _customScript.replace(/@ID@/ig, `''`)
+    // _dataresource = _dataresource.replace(/@ID@/ig, `''`)
+    // _customScript = _customScript.replace(/@ID@/ig, `''`)
     _dataresource = _dataresource.replace(/@BID@/ig, `'${BID || ''}'`)
     _customScript = _customScript.replace(/@BID@/ig, `'${BID || ''}'`)
     _dataresource = _dataresource.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`)
@@ -141,6 +157,8 @@
     _customScript = _customScript.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`)
     _dataresource = _dataresource.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`)
     _customScript = _customScript.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`)
+    _dataresource = _dataresource.replace(/@typename@/ig, `'admin'`)
+    _customScript = _customScript.replace(/@typename@/ig, `'admin'`)
 
     let regoptions = null
     if (setting.queryType === 'statistics' || _customScript) {
@@ -188,18 +206,30 @@
       regoptions.forEach(item => {
         _customScript = _customScript.replace(item.reg, item.value)
       })
+      if (window.GLOB.breakpoint) {
+        _customScript = _customScript.replace(/\$breakpoint_proc@/ig, window.GLOB.breakpoint)
+        param.func = 'sPC_Get_TableData_debug'
+      }
     }
 
     let LText = ''
     let DateCount = ''
 
+    if (setting.sub_field) {
+      arrFields = arrFields + ',' + setting.sub_field
+    }
+
     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}`
+      LText = `/*system_query*/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 `
+      if (setting.sub_field) {
+        DateCount = `/*system_query*/select count(1) as total from (select distinct ${setting.primaryKey} from ${_dataresource} ${_search})a`
+      } else {
+        DateCount = `/*system_query*/select count(1) as total from ${_dataresource} ${_search}`
+      }
     } else if (_dataresource && orderBy) {
-      LText = ` select ${arrFields} from (select ${arrFields} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows `
+      LText = `/*system_query*/select ${arrFields} from (select ${arrFields} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows `
     } else if (_dataresource) {
-      LText = ` select ${arrFields} from ${_dataresource} ${_search}  `
+      LText = `/*system_query*/select ${arrFields} from ${_dataresource} ${_search}  `
     }
 
     if (_customScript) {
@@ -256,13 +286,31 @@
     // param.sub_name = 'sub_data'
     // param.sub_field = 'BID,friend_text,icon,Initials'
 
+    if (setting.sub_field) {
+      param.sub_name = setting.subdata
+      param.tabid = setting.primaryKey || ''
+      param.parid = setting.subBID || ''
+      param.sub_field = setting.sub_field
+    }
+
     // exec_type: 'y' 瑙g爜瀛楁锛歀Text銆丩Text1銆丩Text2銆乧ustom_script銆丏ateCount
 
     param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
     param.secretkey = Utils.encrypt('', param.timestamp)
 
+    if (window.GLOB.probation) {
+      param.s_debug_type = 'Y'
+    }
+
     if (window.GLOB.mkHS) { // 浜戠鏁版嵁楠岃瘉
       param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
+
+      // special HS鑷畾涔夊嚱鏁版煡璇�
+      if (setting.tableName === 's_custom_script' && options.cloudServiceApi) {
+        param.rduri = options.cloudServiceApi
+        param.userid = sessionStorage.getItem('CloudUserID') || ''
+        param.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
+      }
     }
 
     return param
@@ -280,9 +328,9 @@
       default_sql: setting.execute ? 'true' : 'false'
     }
 
-    if (setting.transaction === 'true') {
-      param.func = 'sPC_Get_TableData_try'
-    }
+    // if (setting.transaction === 'true') {
+    //   param.func = 'sPC_Get_TableData_try'
+    // }
     
     let _dataresource = setting.dataresource
     let _customScript = ''
@@ -317,8 +365,8 @@
     _customScript = _customScript.replace(/\$select@/ig, '/*')
     _customScript = _customScript.replace(/@select\$/ig, '*/')
 
-    _dataresource = _dataresource.replace(/@ID@/ig, `''`)
-    _customScript = _customScript.replace(/@ID@/ig, `''`)
+    // _dataresource = _dataresource.replace(/@ID@/ig, `''`)
+    // _customScript = _customScript.replace(/@ID@/ig, `''`)
     _dataresource = _dataresource.replace(/@BID@/ig, `'${BID || ''}'`)
     _customScript = _customScript.replace(/@BID@/ig, `'${BID || ''}'`)
     _dataresource = _dataresource.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`)
@@ -329,6 +377,8 @@
     _customScript = _customScript.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`)
     _dataresource = _dataresource.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`)
     _customScript = _customScript.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`)
+    _dataresource = _dataresource.replace(/@typename@/ig, `'admin'`)
+    _customScript = _customScript.replace(/@typename@/ig, `'admin'`)
 
     let regoptions = null
     if (setting.queryType === 'statistics' || _customScript) {
@@ -370,7 +420,7 @@
       })
     }
 
-    let LText = ` select ${statFields.map(col => `isnull(sum(${col.field}),0) as ${col.field}`).join(',')} from ${_dataresource} ${_search} `
+    let LText = ` /*system_query*/select ${statFields.map(col => `isnull(sum(${col.field}),0) as ${col.field}`).join(',')} from ${_dataresource} ${_search} `
 
     if (_customScript) {
       LText = `${LText}
@@ -431,7 +481,6 @@
    */
   static getPrevQueryParams (setting, search = [], BID) {
     let param = null
-
     if (setting.procMode !== 'inner') {
       param = this.getDefaultPrevQueryParam(setting, search, BID)
     } else {
@@ -511,6 +560,7 @@
       sql = sql.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`)
       sql = sql.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`)
       sql = sql.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`)
+      sql = sql.replace(/@typename@/ig, `'admin'`)
 
       // 娴嬭瘯绯荤粺鎵撳嵃鏌ヨ璇彞
       if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) {
@@ -526,7 +576,9 @@
       param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
     }
 
-    param.menuname = setting.MenuName || ''
+    if (setting.$name) {
+      param.menuname = setting.$name
+    }
 
     return param
   }
@@ -599,6 +651,7 @@
     sql = sql.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`)
     sql = sql.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`)
     sql = sql.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`)
+    sql = sql.replace(/@typename@/ig, `'admin'`)
 
     if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) {
       console.info(sql.replace(/\n\s{8}/ig, '\n'))
@@ -609,7 +662,10 @@
     param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
     param.secretkey = Utils.encrypt('', param.timestamp)
     param.LText = Utils.formatOptions(param.LText)
-    param.menuname = setting.MenuName || ''
+    
+    if (setting.$name) {
+      param.menuname = setting.$name
+    }
 
     if (BID) {
       param.BID = BID
@@ -698,7 +754,7 @@
  * @description 鐢熸垚鍗曚釜缁勪欢sPC_Get_structured_data璇锋眰鍙傛暟
  */
 export function getStructDefaultParam (component, searchlist, first) {
-  const { columns, setting, dataName, format } = component
+  const { columns, setting, dataName, format, uuid } = component
 
   let arr_field = columns.map(col => col.field)
   let _dataresource = setting.dataresource
@@ -764,6 +820,7 @@
   }
 
   return {
+    uuid: uuid,
     name: dataName,
     $name: setting.$name,
     columns: columns,
@@ -773,7 +830,7 @@
     foreign_key: '',
     sql: _dataresource,
     script: _customScript,
-    transaction: setting.transaction === 'true'
+    // transaction: setting.transaction === 'true'
   }
 }
 
@@ -784,7 +841,7 @@
 export function getStructuredParams (params, config, BID) {
   let LText_field = []
   let diffUser = false
-  let transaction = false
+  // let transaction = false
   let loginId = `'${sessionStorage.getItem('LoginUID') || ''}'`
   let sessionId = `'${localStorage.getItem('SessionUid') || ''}'`
   let userId = `'${sessionStorage.getItem('UserID') || ''}'`
@@ -796,9 +853,9 @@
     if (!diffUser && (/@userid@/ig.test(item.sql) || /@userid@/ig.test(_script))) {
       diffUser = true
     }
-    if (item.transaction) {
-      transaction = true
-    }
+    // if (item.transaction) {
+    //   transaction = true
+    // }
 
     _sql = _sql.replace(/@ID@/ig, `''`)
     _script = _script.replace(/@ID@/ig, `''`)
@@ -812,6 +869,8 @@
     _script = _script.replace(/@UserID@/ig, userId)
     _sql = _sql.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`)
     _script = _script.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`)
+    _sql = _sql.replace(/@typename@/ig, `'admin'`)
+    _script = _script.replace(/@typename@/ig, `'admin'`)
 
     // 娴嬭瘯绯荤粺鎵撳嵃鏌ヨ璇彞
     if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) {
@@ -832,9 +891,12 @@
     BID: BID
   }
 
-  if (transaction) {
-    param.func = 'sPC_Get_structured_data_try'
+  if (config.MenuName) {
+    param.menuname = config.MenuName
   }
+  // if (transaction) {
+  //   param.func = 'sPC_Get_structured_data_try'
+  // }
 
   let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText)
 

--
Gitblit v1.8.0