From a94b0a4d15b26ecf8fe99f0a1c3e60d60b97766d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 15 八月 2023 14:22:03 +0800
Subject: [PATCH] 2023-08-15

---
 src/tabviews/commontable/index.jsx |  263 ++++++++--------------------------------------------
 1 files changed, 42 insertions(+), 221 deletions(-)

diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx
index 1133667..43da736 100644
--- a/src/tabviews/commontable/index.jsx
+++ b/src/tabviews/commontable/index.jsx
@@ -4,10 +4,7 @@
 import { notification, Spin, Tabs, Switch, Row, Col, Modal } from 'antd'
 
 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 { updateCommonTable } from '@/utils/utils-update.js'
 import asyncComponent from '@/utils/asyncComponent'
@@ -25,8 +22,6 @@
 const SubTable = asyncSpinComponent(() => import('@/tabviews/subtable'))
 const CardComponent = asyncSpinComponent(() => import('@/tabviews/zshare/cardcomponent'))
 const ChartComponent = asyncSpinComponent(() => import('@/tabviews/zshare/chartcomponent'))
-const PagemsgComponent = asyncComponent(() => import('@/tabviews/zshare/pageMessage'))
-const AutoMatic = asyncComponent(() => import('@/tabviews/zshare/automatic'))
 const DebugTable = asyncComponent(() => import('@/tabviews/debugtable'))
 
 const { TabPane } = Tabs
@@ -41,7 +36,6 @@
   }
 
   state = {
-    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
     ContainerId: Utils.getuuid(), // 鑿滃崟澶栧眰html Id
     BID: null,            // 椤甸潰璺宠浆鏃舵惡甯D
     loadingview: true,    // 椤甸潰鍔犺浇涓�
@@ -49,7 +43,6 @@
     lostmsg: '',          // 椤甸潰涓㈠け鏃剁殑鎻愮ず淇℃伅
     config: {},           // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷寜閽�佹悳绱€�佹樉绀哄垪銆佹爣绛剧瓑
     shortcuts: null,      // 蹇嵎閿�
-    searchlist: null,     // 鎼滅储鏉′欢
     actions: null,        // 鎸夐挳闆�
     columns: null,        // 鏄剧ず鍒�
     arr_field: '',        // 鏌ヨ瀛楁闆�
@@ -68,8 +61,6 @@
     statFields: [],       // 鍚堣瀛楁
     statFValue: [],       // 鍚堣鍊�
     absFields: [],        // 缁濆鍊煎瓧娈�
-    loadCustomApi: true,  // 鍔犺浇澶栭儴璧勬簮
-    hasReqFields: false,
     autoMatic: null,
     visible: false
   }
@@ -111,7 +102,7 @@
         this.setState({
           loadingview: false,
           viewlost: true,
-          lostmsg: this.state.dict['main.view.unenabled']
+          lostmsg: '鎶辨瓑锛屾偍璁块棶鐨勯〉闈㈡湭鍚敤锛岃鑱旂郴绠$悊鍛樸��'
         })
         return
       }
@@ -123,7 +114,7 @@
       }
       
       // HS涓嶄娇鐢ㄨ嚜瀹氫箟璁剧疆
-      if (result.LongParamUser && !window.GLOB.mkHS) {
+      if (result.LongParamUser) {
         try { // 閰嶇疆淇℃伅瑙f瀽
           let userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser)))
           if (userConfig && !userConfig.version) {
@@ -177,7 +168,8 @@
             }
             tab.ContainerId = this.state.ContainerId
 
-            return window.GLOB.mkActions[tab.linkTab]
+            // return window.GLOB.mkActions[tab.linkTab]
+            return tab
           })
         })
       } else {
@@ -214,19 +206,13 @@
         chartId = config.charts[0] ? config.charts[0].uuid : ''
       }
 
-      config.search = Utils.initSearchVal(config.search)
+      Utils.initSearchVal(config)
 
       // 瀛楁閫忚鍙婂繀濉爣蹇�
-      let hasReqFields = false
       config.search = config.search.map(item => {
         if (['text', 'select', 'link'].includes(item.type) && param && param.$searchkey === item.field) {
           item.initval = param.$searchval
         }
-
-        if (item.required) {
-          hasReqFields = true
-        }
-
         return item
       })
 
@@ -249,7 +235,7 @@
       config.setting.customScript = ''                                // 鑷畾涔夎剼鏈�
       config.setting.dataresource = config.setting.dataresource || ''
 
-      if (config.setting.interType === 'system' || (config.setting.interType === 'custom' && config.setting.requestMode === 'system')) {
+      if (config.setting.interType === 'system') {
         if (config.setting.scripts && config.setting.scripts.length > 0) {
           let _customScript = ''
           config.setting.scripts.forEach(item => {
@@ -268,10 +254,8 @@
         }
   
         if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
-          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, '*/')
+          config.setting.dataresource = config.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/')
+          config.setting.customScript = config.setting.customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/')
         } else {
           config.setting.dataresource = config.setting.dataresource.replace(/@\$|\$@/ig, '')
           config.setting.customScript = config.setting.customScript.replace(/@\$|\$@/ig, '')
@@ -279,11 +263,6 @@
 
         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') || ''
-        }
 
         let regs = [
           { reg: /@userName@/ig, value: `'${userName}'` },
@@ -335,6 +314,14 @@
                 return cell
               })
             }
+          }
+        }
+
+        if (item.controlField) {
+          if (/,/ig.test(item.controlVal)) {
+            item.controlVals = item.controlVal.split(',')
+          } else {
+            item.controlVals = [(item.controlVal || '')]
           }
         }
         
@@ -441,6 +428,19 @@
         }
       }
 
+      config.type = 'table'
+      config.wrap = {
+        show: config.setting.show || '',
+        float: config.setting.float || '',
+        advanceType: config.setting.advanceType || '',
+        advanceWidth: config.setting.advanceWidth || '',
+        drawerPlacement: config.setting.drawerPlacement || '',
+        searchRatio: config.setting.searchRatio || '',
+        searchLwidth: config.setting.searchLwidth,
+        borderRadius: config.setting.borderRadius,
+        resetContrl: config.setting.resetContrl,
+      }
+
       this.setState({
         pageSize: config.setting.pageSize || 10,
         loadingview: false,
@@ -451,13 +451,11 @@
         statFields,
         shortcuts: shortcuts.length > 0 ? shortcuts : null,
         setting: config.setting,
-        searchlist: config.search,
         actions: _actions,
         columns: _columns,
         arr_field: _arrField.join(','),
         BID: param && param.$BID ? param.$BID : '',
-        search: Utils.initMainSearch(config.search),
-        hasReqFields
+        search: Utils.initMainSearch(config.search)
       }, () => {
         if (config.setting.onload !== 'false') { // 鍒濆鍖栧彲鍔犺浇
           this.loadData()
@@ -498,7 +496,6 @@
       let _shortcut = `${preKey}+${keyCode}`
 
       if (window.GLOB.breakpoint && _shortcut === 'ctrl+67') {
-        window.debugger = false
         window.GLOB.breakpoint = false
         sessionStorage.removeItem('breakpoint')
         
@@ -525,14 +522,14 @@
 
   loadData = (id) => {
     const { MenuID } = this.props
-    const { setting, search, loadCustomApi, hasReqFields, ContainerId } = this.state
+    const { setting, search, config, ContainerId } = this.state
 
     this.setState({
       selectedData: []
     })
     MKEmitter.emit('changeTableLine', ContainerId, MenuID, '', '')
 
-    if (hasReqFields) {
+    if (config.$s_req) {
       let requireFields = search.filter(item => item.required && item.value === '')
 
       if (requireFields.length > 0) {
@@ -543,186 +540,16 @@
       }
     }
 
-    if (window.GLOB.systemType === 'production' && setting.interType === 'custom' && !setting.proInterface) {
+    if (setting.interType === 'custom') {
       notification.warning({
         top: 92,
-        message: '鏈缃寮忕郴缁熷湴鍧�!',
+        message: '绯荤粺涓嶅湪鏀寔鑷畾涔夋帴鍙�!',
         duration: 3
       })
       return
     }
 
-    if (setting.interType === 'custom' && loadCustomApi) {
-      if (setting.execTime === 'once') {
-        this.setState({loadCustomApi: false})
-      }
-
-      this.loadOutResource()
-      if (setting.execType === 'async') {
-        this.loadmaindata(id)
-      }
-    } else {
-      this.loadmaindata(id)
-    }
-  }
-
-  loadOutResource = () => {
-    const { setting, search, BID } = this.state
-
-    let param = UtilsDM.getPrevQueryParams(setting, search, BID)
-
-    if (setting.execType === 'sync') {
-      this.setState({
-        loading: true
-      })
-    }
-
-    Api.genericInterface(param).then(res => {
-      if (res.status) {
-        if (res.mk_ex_invoke === 'false' || res.mk_ex_invoke === false) {
-          this.loadmaindata()
-        } else {
-          this.customOuterRequest(res)
-        }
-      } else {
-        this.setState({
-          loading: false
-        })
-        notification.error({
-          top: 92,
-          message: res.message,
-          duration: 10
-        })
-      }
-    }, () => {
-      this.setState({
-        loading: false
-      })
-    })
-  }
-
-  customOuterRequest = (result) => {
-    const { setting } = this.state
-    let url = ''
-
-    if (window.GLOB.systemType === 'production') {
-      url = setting.proInterface
-    } else {
-      url = setting.interface
-    }
-
-    let mkey = result.mk_api_key || ''
-
-    delete result.mk_ex_invoke // 鏄惁缁х画鎵ц
-    delete result.status
-    delete result.message
-    delete result.ErrCode
-    delete result.ErrMesg
-    delete result.mk_api_key   // 褰撳墠璇锋眰鐨刱ey鍊硷紝鐢ㄤ簬鍥炶皟
-
-    let param = {}
-
-    Object.keys(result).forEach(key => {
-      key = key.replace(/^mk_/ig, '')
-      param[key] = result[key]
-    })
-
-    Api.directRequest(url, setting.method, param, setting.cross).then(res => {
-      if (typeof(res) !== 'object') {
-        let error = '鏈煡鐨勮繑鍥炵粨鏋滐紒'
-
-        if (typeof(res) === 'string') {
-          error = res.replace(/'/ig, '"')
-        }
-
-        let _result = {
-          mk_api_key: mkey,
-          $ErrCode: 'E',
-          $ErrMesg: error
-        }
-
-        this.customCallbackRequest(_result)
-      } else {
-        if (Array.isArray(res)) {
-          res = { data: res }
-        }
-        res.mk_api_key = mkey
-        this.customCallbackRequest(res)
-      }
-    }, (e) => {
-      let _result = {
-        mk_api_key: mkey,
-        $ErrCode: 'E',
-        $ErrMesg: e && e.statusText ? e.statusText : ''
-      }
-
-      this.customCallbackRequest(_result)
-    })
-  }
-
-  customCallbackRequest = (result) => {
-    const { setting, BID } = this.state
-    let errSql = ''
-    if (result.$ErrCode === 'E') {
-      errSql = `
-        set @ErrorCode='E'
-        set @retmsg='${result.$ErrMesg}'
-      `
-      delete result.$ErrCode
-      delete result.$ErrMesg
-    }
-
-    let lines = UtilsDM.getCallBackSql(setting, result)
-    let param = {}
-
-    if (setting.callbackType === 'script') { // 浣跨敤鑷畾涔夎剼鏈�
-      let sql = lines.map(item => (`
-        ${item.insert}
-        ${item.selects.join(` union all
-        `)}
-      `))
-      sql = sql.join('')
-      
-      param = UtilsDM.getCallBackQueryParams(setting, sql, errSql, BID)
-    } else {
-      param.func = 's_ex_result_back'
-      param.s_ex_result = lines.map((item, index) => ({
-        MenuID: this.state.config.MenuID,
-        MenuName: this.state.config.MenuName,
-        TableName: item.table,
-        LongText: window.btoa(window.encodeURIComponent(`${item.insert}  ${item.selects.join(` union all `)}`)),
-        Sort: index + 1
-      }))
-
-      if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) {
-        let sql = lines.map(item => (`
-          ${item.insert}
-          ${item.selects.join(` union all
-          `)}
-        `))
-        sql = sql.join('')
-        console.info(sql.replace(/\n\s{10}/ig, '\n'))
-      }
-    }
-
-    Api.genericInterface(param).then(res => {
-      if (res.status) {
-        this.loadmaindata()
-      } else {
-        this.setState({
-          loading: false
-        })
-        notification.error({
-          top: 92,
-          message: res.message,
-          duration: 10
-        })
-      }
-    }, () => {
-      this.setState({
-        loading: false
-      })
-    })
+    this.loadmaindata(id)
   }
 
   /**
@@ -775,7 +602,7 @@
           item.$Index = start + index + ''
 
           if (setting.controlField) {
-            if (setting.controlVal.includes(item[setting.controlField])) {
+            if (setting.controlVal.includes(item[setting.controlField] + '')) {
               item.$disabled = true
             }
           }
@@ -892,7 +719,7 @@
   getStatFieldsValue = () => {
     const { setting, search, BID, orderBy, statFields } = this.state
 
-    if (statFields.length === 0 || !(setting.interType === 'system' || (setting.interType === 'custom' && setting.requestMode === 'system')) || !setting.dataresource) return
+    if (statFields.length === 0 || setting.interType !== 'system' || !setting.dataresource) return
 
     let _orderBy = orderBy || setting.order
     let param = UtilsDM.getStatQueryDataParams(setting, statFields, search, _orderBy, BID)
@@ -1009,7 +836,7 @@
   reloadview = () => {
     this.setState({ loadingview: true, viewlost: false, config: {}, setting: null,
       data: null, total: 0, loading: false, pageIndex: 1, shortcuts: null,
-      pageSize: 10, orderBy: '', search: '', BIDs: {}, pickup: false, searchlist: null
+      pageSize: 10, orderBy: '', search: '', BIDs: {}, pickup: false
     }, () => {
       this.loadconfig()
     })
@@ -1161,13 +988,13 @@
 
   render() {
     const { MenuID } = this.props
-    const { BID, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, config, chartId, search, selectedData, shortcuts, autoMatic } = this.state
+    const { BID, setting, pageSize, actions, columns, loadingview, viewlost, pickup, config, chartId, search, selectedData, shortcuts } = this.state
 
     return (
       <div className="commontable" id={this.state.ContainerId}>
         {loadingview ? <Spin size="large" /> : null}
-        {searchlist && searchlist.length ?
-          <MainSearch BID={BID} searchlist={searchlist} setting={setting} refreshdata={this.refreshbysearch}/> : null
+        {config && config.search && config.search.length ?
+          <MainSearch BID={BID} config={config} refreshdata={this.refreshbysearch}/> : null
         }
         {setting && config.charts ? <Row className="chart-view" gutter={16}>
           {/* 瑙嗗浘缁� */}
@@ -1189,7 +1016,6 @@
                       setting={setting}
                       actions={actions}
                       columns={columns}
-                      dict={this.state.dict}
                       MenuID={MenuID}
                       selectedData={selectedData}
                     />
@@ -1205,7 +1031,6 @@
                       setting={setting}
                       columns={columns}
                       pageSize={pageSize}
-                      dict={this.state.dict}
                       data={this.state.data}
                       total={this.state.total}
                       loading={this.state.loading}
@@ -1253,7 +1078,6 @@
               setting={setting}
               actions={actions}
               columns={columns}
-              dict={this.state.dict}
               MenuID={MenuID}
               selectedData={selectedData}
             />
@@ -1269,7 +1093,6 @@
               setting={setting}
               columns={columns}
               pageSize={pageSize}
-              dict={this.state.dict}
               data={this.state.data}
               total={this.state.total}
               loading={this.state.loading}
@@ -1303,9 +1126,7 @@
           </Tabs>))
         }
         {setting && window.GLOB.breakpoint ? <DebugTable /> : null}
-        {!window.GLOB.mkHS && autoMatic ? <AutoMatic autoMatic={autoMatic} config={config} /> : null}
-        {!window.GLOB.mkHS && window.GLOB.systemType !== 'production' ? <PagemsgComponent menu={{MenuName: this.props.MenuName, MenuNo: this.props.MenuNo}} config={config} dict={this.state.dict} /> : null}
-        {!window.GLOB.mkHS && setting ? <SettingComponent config={config} dict={this.state.dict} shortcuts={shortcuts || []}/> : null}
+        {!window.GLOB.mkHS && setting ? <SettingComponent config={config} shortcuts={shortcuts || []}/> : null}
         {viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
       </div>
     )

--
Gitblit v1.8.0