From 9c6795fd3c44e46cf3955fbfd8f8eeca23acb7a9 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 08 十月 2022 00:31:51 +0800
Subject: [PATCH] 2022-10-08

---
 src/tabviews/commontable/index.jsx |  140 ++++++++++++++++++++++++++++------------------
 1 files changed, 85 insertions(+), 55 deletions(-)

diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx
index 3b32650..e9d8ba6 100644
--- a/src/tabviews/commontable/index.jsx
+++ b/src/tabviews/commontable/index.jsx
@@ -1,6 +1,5 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
-import {connect} from 'react-redux'
 import { is, fromJS } from 'immutable'
 import { notification, Spin, Tabs, Switch, Row, Col } from 'antd'
 
@@ -28,6 +27,7 @@
 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
 
@@ -51,7 +51,7 @@
     searchlist: null,     // 鎼滅储鏉′欢
     actions: null,        // 鎸夐挳闆�
     columns: null,        // 鏄剧ず鍒�
-    arr_field: '',        // 浣跨敤 sPC_Get_TableData 鏃剁殑鏌ヨ瀛楁闆�
+    arr_field: '',        // 鏌ヨ瀛楁闆�
     setting: null,        // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑
     data: [],             // 鍒楄〃鏁版嵁闆�
     selectedData: [],     // 宸查�夎〃鏍兼暟鎹�
@@ -76,7 +76,7 @@
    * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅
    */
   async loadconfig () {
-    const { permAction, permMenus, param, MenuName, MenuID } = this.props
+    const { param, MenuName, MenuID } = this.props
 
     let _param = {
       func: 'sPC_Get_LongParam',
@@ -100,7 +100,7 @@
       }
       
       // HS涓嶄娇鐢ㄨ嚜瀹氫箟璁剧疆
-      if (result.LongParamUser && this.props.menuType !== 'HS') {
+      if (result.LongParamUser && !window.GLOB.mkHS) {
         try { // 閰嶇疆淇℃伅瑙f瀽
           let userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser)))
           if (userConfig && !userConfig.version) {
@@ -158,17 +158,18 @@
       config = updateCommonTable(config)
 
       // 鏉冮檺杩囨护
-      if (this.props.menuType !== 'HS') {
-        config.action = config.action.filter(item => permAction[item.uuid])
+      if (!window.GLOB.mkHS) {
+        config.action = config.action.filter(item => item.hidden !== 'true' && window.GLOB.mkActions[item.uuid])
         config.tabgroups.forEach(group => {
           group.sublist = group.sublist.filter(tab => {
             if (tab.supMenu === 'mainTable') {
               tab.supMenu = MenuID
             }
-            return permAction[tab.linkTab]
+            return window.GLOB.mkActions[tab.linkTab]
           })
         })
       } else {
+        config.action = config.action.filter(item => item.hidden !== 'true')
         config.tabgroups.forEach(group => {
           group.sublist = group.sublist.map(tab => {
             if (tab.supMenu === 'mainTable') {
@@ -182,17 +183,22 @@
       config.tabgroups = config.tabgroups.filter(group => group.sublist.length > 0)
 
       let roleId = sessionStorage.getItem('role_id') || '' // 瑙掕壊ID
-      // 瑙嗗浘鏉冮檺
-      config.charts = config.charts.filter(item => {
-        if (item.Hide === 'true') return false
-        if (!item.blacklist || item.blacklist.length === 0) return true
-        return item.blacklist.filter(v => roleId.indexOf(v) > -1).length === 0
-      })
 
-      if (config.charts.length <= 1) {
-        config.expand = true
+      let chartId = ''
+
+      if (config.charts) {
+        // 瑙嗗浘鏉冮檺
+        config.charts = config.charts.filter(item => {
+          if (item.Hide === 'true') return false
+          if (!item.blacklist || item.blacklist.length === 0) return true
+          return item.blacklist.filter(v => roleId.indexOf(v) > -1).length === 0
+        })
+  
+        if (config.charts.length <= 1) {
+          config.expand = true
+        }
+        chartId = config.charts[0] ? config.charts[0].uuid : ''
       }
-      let chartId = config.charts[0] ? config.charts[0].uuid : ''
 
       config.search = Utils.initSearchVal(config.search)
 
@@ -258,7 +264,6 @@
 
         let userName = sessionStorage.getItem('User_Name') || ''
         let fullName = sessionStorage.getItem('Full_Name') || ''
-        let city = sessionStorage.getItem('city') || ''
 
         if (sessionStorage.getItem('isEditState') === 'true') {
           userName = sessionStorage.getItem('CloudUserName') || ''
@@ -267,8 +272,7 @@
 
         let regs = [
           { reg: /@userName@/ig, value: `'${userName}'` },
-          { reg: /@fullName@/ig, value: `'${fullName}'` },
-          { reg: /@login_city@/ig, value: `'${city}'` }
+          { reg: /@fullName@/ig, value: `'${fullName}'` }
         ]
 
         regs.forEach(cell => {
@@ -318,6 +322,7 @@
         }
         
         if (item.position === 'toolbar') {
+          item.$toolbtn = true
           _actions.push(item)
         } else if (item.position === 'grid') {
           _operations.push(item)
@@ -331,9 +336,18 @@
 
           if (col.linkmenu && col.linkmenu.length > 0) {
             let menu_id = col.linkmenu.slice(-1)[0]
-            col.linkThdMenu = permMenus.filter(m => m.MenuID === menu_id)[0] || ''
+            col.linkThdMenu = window.GLOB.mkThdMenus.filter(m => m.MenuID === menu_id)[0] || ''
           } else {
             col.linkThdMenu = ''
+          }
+
+          if (col.type === 'number') {
+            col.decimal = col.decimal || 0
+            col.round = Math.pow(10, col.decimal)
+
+            if (col.format === 'percent') {
+              col.decimal = col.decimal > 2 ? col.decimal - 2 : 0
+            }
           }
 
           col.nameField && _arrField.push(col.nameField) // 閾炬帴鍚嶅瓧娈�
@@ -533,7 +547,7 @@
   loadOutResource = () => {
     const { setting, search, BID } = this.state
 
-    let param = UtilsDM.getPrevQueryParams(setting, search, BID, this.props.menuType)
+    let param = UtilsDM.getPrevQueryParams(setting, search, BID)
 
     if (setting.execType === 'sync') {
       this.setState({
@@ -625,7 +639,7 @@
   }
 
   customCallbackRequest = (result) => {
-    const { setting } = this.state
+    const { setting, BID } = this.state
     let errSql = ''
     if (result.$ErrCode === 'E') {
       errSql = `
@@ -647,15 +661,7 @@
       `))
       sql = sql.join('')
       
-      param = UtilsDM.getCallBackQueryParams(setting, sql, errSql)
-
-      if (this.state.BID) {
-        param.BID = this.state.BID
-      }
-
-      if (this.props.menuType === 'HS') { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉
-        param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
-      }
+      param = UtilsDM.getCallBackQueryParams(setting, sql, errSql, BID)
     } else {
       param.func = 's_ex_result_back'
       param.s_ex_result = lines.map((item, index) => ({
@@ -708,7 +714,7 @@
     })
 
     let _orderBy = orderBy || setting.order
-    let param = UtilsDM.getQueryDataParams(setting, arr_field, search, _orderBy, pageIndex, pageSize, BID, this.props.menuType)
+    let param = UtilsDM.getQueryDataParams(setting, arr_field, search, _orderBy, pageIndex, pageSize, BID)
 
     let result = await Api.genericInterface(param)
 
@@ -792,7 +798,7 @@
     })
 
     let _orderBy = orderBy || setting.order
-    let param = UtilsDM.getQueryDataParams(setting, arr_field, search, _orderBy, pageIndex, pageSize, BID, this.props.menuType, id)
+    let param = UtilsDM.getQueryDataParams(setting, arr_field, search, _orderBy, pageIndex, pageSize, BID, id)
 
     let result = await Api.genericInterface(param)
     if (result.status) {
@@ -860,7 +866,7 @@
     if (statFields.length === 0 || !(setting.interType === 'system' || (setting.interType === 'custom' && setting.requestMode === 'system')) || !setting.dataresource) return
 
     let _orderBy = orderBy || setting.order
-    let param = UtilsDM.getStatQueryDataParams(setting, statFields, search, _orderBy, BID, this.props.menuType)
+    let param = UtilsDM.getStatQueryDataParams(setting, statFields, search, _orderBy, BID)
 
     Api.genericInterface(param).then(res => {
       if (res.status) {
@@ -983,13 +989,13 @@
   /**
    * @description 瀵煎嚭Excel鏃讹紝鑾峰彇椤甸潰鎼滅储鎺掑簭绛夊弬鏁�
    */
-  queryModuleParam = (menuId, btnId) => {
+  queryModuleParam = (menuId, callback) => {
     const { MenuName, MenuID } = this.props
     const { arr_field, orderBy, search, setting} = this.state
 
     if (MenuID !== menuId) return
 
-    MKEmitter.emit('returnModuleParam', MenuID, btnId, {
+    callback({
       arr_field: arr_field,
       orderBy: orderBy || setting.order,
       search: search,
@@ -1119,16 +1125,16 @@
   }
 
   render() {
-    const { menuType, MenuID } = this.props
+    const { MenuID } = this.props
     const { BID, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, config, chartId, search, selectedData, shortcuts, autoMatic } = 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} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null
+          <MainSearch BID={BID} searchlist={searchlist} setting={setting} refreshdata={this.refreshbysearch}/> : null
         }
-        {setting ? <Row className="chart-view" gutter={16}>
+        {setting && config.charts ? <Row className="chart-view" gutter={16}>
           {/* 瑙嗗浘缁� */}
           {!config.expand ? <Tabs activeKey={chartId} onChange={this.changeChart}>
             {config.charts.map(item => (
@@ -1208,6 +1214,41 @@
             }
           })}
         </Row> : null }
+        {setting && !config.charts ? <div className="chart-view">
+          <div className="commontable-main-action">
+            <MainAction
+              BID={BID}
+              setting={setting}
+              actions={actions}
+              columns={columns}
+              dict={this.state.dict}
+              MenuID={MenuID}
+              selectedData={selectedData}
+              ContainerId={this.state.ContainerId}
+            />
+          </div>
+          <div className="main-table-box">
+            {(setting.tableType === 'radio' || setting.tableType === 'checkbox') && this.state.data && this.state.data.length > 0 ?
+              <Switch title="鏀惰捣" className="main-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" checked={pickup} onChange={this.pickupChange} /> : null
+            }
+            <MainTable
+              MenuID={MenuID}
+              tableId={MenuID}
+              pickup={pickup}
+              setting={setting}
+              columns={columns}
+              pageSize={pageSize}
+              dict={this.state.dict}
+              data={this.state.data}
+              total={this.state.total}
+              loading={this.state.loading}
+              statFValue={this.state.statFValue}
+              ContainerId={this.state.ContainerId}
+              refreshdata={this.refreshbytable}
+              chgSelectData={this.changeSelectedData}
+            />
+          </div>
+        </div> : null }
         {setting && config.tabgroups.map(group => (
           <Tabs key={group.uuid}>
             {group.sublist.map(_tab => {
@@ -1232,25 +1273,14 @@
             })}
           </Tabs>))
         }
-        {menuType !== 'HS' && autoMatic ? <AutoMatic autoMatic={autoMatic} config={config} /> : null}
-        {menuType !== 'HS' && window.GLOB.systemType !== 'production' ? <PagemsgComponent menu={{MenuName: this.props.MenuName, MenuNo: this.props.MenuNo}} config={config} dict={this.state.dict} /> : null}
-        {menuType !== 'HS' && shortcuts ? <SettingComponent config={config} dict={this.state.dict} shortcuts={shortcuts} permAction={this.props.permAction}/> : null}
+        {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 && shortcuts ? <SettingComponent config={config} dict={this.state.dict} shortcuts={shortcuts}/> : null}
         {viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
       </div>
     )
   }
 }
 
-const mapStateToProps = (state) => {
-  return {
-    menuType: state.editLevel,
-    permAction: state.permAction,
-    permMenus: state.permMenus
-  }
-}
-
-const mapDispatchToProps = () => {
-  return {}
-}
-
-export default connect(mapStateToProps, mapDispatchToProps)(NormalTable)
\ No newline at end of file
+export default NormalTable
\ No newline at end of file

--
Gitblit v1.8.0