From af02b8f3c3ec9e5684be1084904d673429421d2b Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 03 九月 2020 16:40:47 +0800
Subject: [PATCH] 2020-09-03

---
 src/tabviews/subtabtable/index.jsx |  220 ++++++++----------------------------------------------
 1 files changed, 33 insertions(+), 187 deletions(-)

diff --git a/src/tabviews/subtabtable/index.jsx b/src/tabviews/subtabtable/index.jsx
index a1aa827..de49711 100644
--- a/src/tabviews/subtabtable/index.jsx
+++ b/src/tabviews/subtabtable/index.jsx
@@ -3,13 +3,12 @@
 import {connect} from 'react-redux'
 import { is, fromJS } from 'immutable'
 import { notification, Spin, Col, Row, Icon, Tabs} from 'antd'
-import moment from 'moment'
 
 import Api from '@/api'
 import zhCN from '@/locales/zh-CN/main.js'
 import enUS from '@/locales/en-US/main.js'
 import Utils from '@/utils/utils.js'
-import options from '@/store/options.js'
+import UtilsDM from '@/utils/utils-datamanage.js'
 
 import asyncComponent from '@/utils/asyncComponent'
 import asyncSpinComponent from '@/utils/asyncSpinComponent'
@@ -269,6 +268,29 @@
       })
 
       config.setting.tabType = 'subtab'
+      // 鏁版嵁婧愪俊鎭澶勭悊
+      config.setting.laypage = config.setting.laypage !== 'false'     // 鏄惁鍒嗛〉锛岃浆涓篵oolean 缁熶竴鏍煎紡
+      config.setting.execute = config.setting.default !== 'false'     // 榛樿sql鏄惁鎵ц锛岃浆涓篵oolean 缁熶竴鏍煎紡
+      config.setting.customScript = config.setting.customScript || '' // 鑷畾涔夎剼鏈�
+
+      if (!config.setting.execute) { // 榛樿sql 涓嶆墽琛屾椂 缃┖
+        config.setting.dataresource = ''
+      } else {
+        config.setting.dataresource = config.setting.dataresource || ''
+      }
+      if (/\s/.test(config.setting.dataresource)) {
+        config.setting.dataresource = '(' + config.setting.dataresource + ') tb'
+      }
+
+      if (this.props.dataManager) { // 鏁版嵁鏉冮檺
+        config.setting.dataresource = config.setting.dataresource.replace(/\$@/ig, '/*')
+        config.setting.dataresource = config.setting.dataresource.replace(/@\$/ig, '*/')
+        config.setting.customScript = config.setting.customScript.replace(/\$@/ig, '/*')
+        config.setting.customScript = config.setting.customScript.replace(/@\$/ig, '*/')
+      } else {
+        config.setting.dataresource = config.setting.dataresource.replace(/@\$|\$@/ig, '')
+        config.setting.customScript = config.setting.customScript.replace(/@\$|\$@/ig, '')
+      }
 
       this.setState({
         loadingview: false,
@@ -303,8 +325,13 @@
    * @description 瀛愯〃鏁版嵁鍔犺浇
    */
   async loadmaindata () {
-    const { setting, search } = this.state
-    let param = ''
+    const { mainSearch, BID } = this.props
+    const { setting, arr_field, search, orderBy, pageIndex, pageSize } = this.state
+
+    let searches = fromJS(search).toJS()
+    if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
+      searches = [...mainSearch, ...searches]
+    }
 
     let requireFields = search.filter(item => item.required && (!item.value || item.value.length === 0))
 
@@ -324,16 +351,8 @@
       loading: true
     })
 
-    if (setting.interType !== 'inner' || (setting.interType === 'inner' && setting.innerFunc)) {
-      param = this.getCustomParam()
-    } else {
-      param = this.getDefaultParam()
-    }
-
-    // 鏁版嵁绠$悊鏉冮檺
-    if (this.props.dataManager) {
-      param.dataM = 'Y'
-    }
+    let _orderBy = orderBy || setting.order
+    let param = UtilsDM.getQueryDataParams(setting, setting.customScript, arr_field, searches, _orderBy, pageIndex, pageSize, BID, this.props.menuType, this.props.dataManager)
 
     let result = await Api.genericInterface(param)
     if (result.status) {
@@ -355,179 +374,6 @@
         duration: 10
       })
     }
-  }
-
-  /**
-   * @description 鑾峰彇鐢ㄦ埛鑷畾涔夊瓨鍌ㄨ繃绋嬩紶鍙�
-   */
-  getCustomParam = () => {
-    const { mainSearch } = this.props
-    const { pageIndex, pageSize, orderBy, search, setting } = this.state
-
-    let searches = search
-    if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
-      searches = [...mainSearch, ...search]
-    }
-
-    let _search = Utils.formatCustomMainSearch(searches)
-
-    let param = {
-      OrderCol: orderBy || setting.order,
-      ..._search
-    }
-
-    if (setting.laypage !== 'false') {
-      param.PageIndex = pageIndex
-      param.PageSize = pageSize
-    }
-
-    if (setting.interType === 'inner') {
-      param.func = setting.innerFunc
-    } else {
-      if (this.props.menuType === 'HS') {
-        if (setting.sysInterface === 'true' && options.cloudServiceApi) {
-          param.rduri = options.cloudServiceApi
-        } else if (setting.sysInterface !== 'true') {
-          param.rduri = setting.interface
-        }
-      } else {
-        if (setting.sysInterface === 'true' && window.GLOB.mainSystemApi) {
-          param.rduri = window.GLOB.mainSystemApi
-        } else if (setting.sysInterface !== 'true') {
-          param.rduri = setting.interface
-        }
-      }
-
-      if (setting.outerFunc) {
-        param.func = setting.outerFunc
-      }
-    }
-
-    return param
-  }
-
-  /**
-   * @description 鑾峰彇绯荤粺瀛樺偍杩囩▼ sPC_Get_TableData 鐨勫弬鏁�
-   */
-  getDefaultParam = () => {
-    const { mainSearch } = this.props
-    const { arr_field, pageIndex, pageSize, orderBy, search, setting } = this.state
-
-    let searches = search
-    if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
-      searches = [...mainSearch, ...search]
-    }
-
-    let _search = Utils.joinMainSearchkey(searches)
-    _search = _search ? 'where ' + _search : ''
-
-    let param = {
-      func: 'sPC_Get_TableData',
-      obj_name: 'data',
-      arr_field: arr_field,
-      BID: this.props.BID,
-      custom_script: setting.customScript || '',
-      default_sql: setting.default || 'true'
-    }
-
-    let _orderBy = orderBy || setting.order
-    let _dataresource = setting.dataresource
-
-    if (/\s/.test(_dataresource)) {
-      _dataresource = '(' + _dataresource + ') tb'
-    }
-
-    if (this.props.dataManager) { // 鏁版嵁鏉冮檺
-      _dataresource = _dataresource.replace(/\$@/ig, '/*')
-      _dataresource = _dataresource.replace(/@\$/ig, '*/')
-      param.custom_script = param.custom_script.replace(/\$@/ig, '/*')
-      param.custom_script = param.custom_script.replace(/@\$/ig, '*/')
-    } else {
-      _dataresource = _dataresource.replace(/@\$|\$@/ig, '')
-      param.custom_script = param.custom_script.replace(/@\$|\$@/ig, '')
-    }
-
-    let regoptions = null
-    if (setting.queryType === 'statistics' || param.custom_script) {
-      let allSearch = Utils.getAllSearchOptions(searches)
-
-      regoptions = allSearch.map(item => {
-        return {
-          reg: new RegExp('@' + item.key + '@', 'ig'),
-          value: `'${item.value}'`
-        }
-      })
-    }
-
-    if (setting.queryType === 'statistics' && setting.default !== 'false') { // 缁熻鏁版嵁婧愶紝鍐呭鏇挎崲
-      regoptions.forEach(item => {
-        _dataresource = _dataresource.replace(item.reg, item.value)
-      })
-      _search = ''
-    }
-
-    let LText = ''
-    let DateCount = ''
-
-    if (setting.default !== 'false' && setting.laypage !== 'false') {
-      LText = ` select top ${pageSize} ${arr_field} from (select ${arr_field} ,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 (setting.default !== 'false') {
-      LText = ` select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows `
-      DateCount = ''
-    }
-
-    if (param.custom_script) {
-      regoptions.push({
-        reg: new RegExp('@orderBy@', 'ig'),
-        value: _orderBy
-      })
-      if (setting.laypage !== 'false') {
-        regoptions.push({
-          reg: new RegExp('@pageSize@', 'ig'),
-          value: pageSize
-        }, {
-          reg: new RegExp('@pageIndex@', 'ig'),
-          value: pageIndex
-        })
-      }
-
-      regoptions.forEach(item => {
-        param.custom_script = param.custom_script.replace(item.reg, item.value)
-      })
-
-      if (LText) {
-        LText += `
-          aaa:
-          if @ErrorCode!=''
-            insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ 
-        `
-      } else {
-        param.custom_script += `
-          aaa:
-          if @ErrorCode!=''
-            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) {
-      param.custom_script &&  console.log(`${LText ? '' : '/*涓嶆墽琛岄粯璁ql*/\n'}${param.custom_script}`)
-      LText &&  console.log(LText)
-    }
-    
-    param.custom_script = Utils.formatOptions(param.custom_script)
-    param.LText = Utils.formatOptions(LText)
-    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
-    param.secretkey = Utils.encrypt(param.LText, param.timestamp)
-    param.DateCount = Utils.formatOptions(DateCount)
-
-    if (this.props.menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉
-      param.open_key = Utils.encrypt(param.secretkey, param.timestamp, true)
-    }
-
-    return param
   }
 
   /**

--
Gitblit v1.8.0