From cb9ade2afd2a367ad767bc605ab7086c695dd010 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 09 十二月 2022 15:53:32 +0800
Subject: [PATCH] 2022-12-09

---
 src/tabviews/commontable/index.jsx |  248 ++++++++++++++++++++++++++++++-------------------
 1 files changed, 153 insertions(+), 95 deletions(-)

diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx
index 3b32650..f224e98 100644
--- a/src/tabviews/commontable/index.jsx
+++ b/src/tabviews/commontable/index.jsx
@@ -1,8 +1,7 @@
 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'
+import { notification, Spin, Tabs, Switch, Row, Col, Modal } from 'antd'
 
 import Api from '@/api'
 import zhCN from '@/locales/zh-CN/main.js'
@@ -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
 
@@ -36,7 +36,8 @@
     param: PropTypes.any,        // 鍏朵粬椤甸潰浼犻�掔殑鎼滅储鏉′欢绛夊弬鏁�
     MenuID: PropTypes.string,    // 鑿滃崟Id
     MenuNo: PropTypes.string,    // 鑿滃崟鍙傛暟
-    MenuName: PropTypes.string   // 鑿滃崟鍚嶇О
+    MenuName: PropTypes.string,  // 鑿滃崟鍚嶇О
+    changeTemp: PropTypes.func
   }
 
   state = {
@@ -51,7 +52,7 @@
     searchlist: null,     // 鎼滅储鏉′欢
     actions: null,        // 鎸夐挳闆�
     columns: null,        // 鏄剧ず鍒�
-    arr_field: '',        // 浣跨敤 sPC_Get_TableData 鏃剁殑鏌ヨ瀛楁闆�
+    arr_field: '',        // 鏌ヨ瀛楁闆�
     setting: null,        // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑
     data: [],             // 鍒楄〃鏁版嵁闆�
     selectedData: [],     // 宸查�夎〃鏍兼暟鎹�
@@ -69,14 +70,15 @@
     absFields: [],        // 缁濆鍊煎瓧娈�
     loadCustomApi: true,  // 鍔犺浇澶栭儴璧勬簮
     hasReqFields: false,
-    autoMatic: null
+    autoMatic: null,
+    visible: false
   }
 
   /**
    * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅
    */
   async loadconfig () {
-    const { permAction, permMenus, param, MenuName, MenuID } = this.props
+    const { param, MenuName, MenuID } = this.props
 
     let _param = {
       func: 'sPC_Get_LongParam',
@@ -90,17 +92,38 @@
 
       try { // 閰嶇疆淇℃伅瑙f瀽
         config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
-        config.MenuID = MenuID
-        config.MenuName = MenuName
-        config.setting.MenuName = MenuName
-        config.setting.$name = MenuName
       } catch (e) {
         console.warn('Parse Failure')
         config = ''
       }
+
+      // 椤甸潰閰嶇疆瑙f瀽閿欒鏃舵彁绀�
+      if (!config) {
+        this.setState({
+          loadingview: false,
+          viewlost: true
+        })
+        return
+      }
+
+      // 椤甸潰鏈惎鐢ㄦ椂锛屾樉绀烘湭鍚敤椤甸潰
+      if (!config.enabled) {
+        this.setState({
+          loadingview: false,
+          viewlost: true,
+          lostmsg: this.state.dict['main.view.unenabled']
+        })
+        return
+      }
+
+      // 妯℃澘閿欒
+      if (config.Template === 'BaseTable' || config.Template === 'CustomPage') {
+        this.props.changeTemp(MenuID, config.Template)
+        return
+      }
       
       // 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) {
@@ -135,45 +158,37 @@
         }
       }
 
-      // 椤甸潰閰嶇疆瑙f瀽閿欒鏃舵彁绀�
-      if (!config) {
-        this.setState({
-          loadingview: false,
-          viewlost: true
-        })
-        return
-      }
-
-      // 椤甸潰鏈惎鐢ㄦ椂锛屾樉绀烘湭鍚敤椤甸潰
-      if (!config.enabled) {
-        this.setState({
-          loadingview: false,
-          viewlost: true,
-          lostmsg: this.state.dict['main.view.unenabled']
-        })
-        return
-      }
+      // 淇℃伅鍒濆鍖栬祴鍊�
+      config.MenuID = MenuID
+      config.MenuName = MenuName
+      config.setting.MenuName = MenuName
+      config.setting.$name = MenuName
 
       // 鐗堟湰鍏煎
       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]
+            tab.ContainerId = this.state.ContainerId
+
+            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') {
               tab.supMenu = MenuID
             }
+            tab.ContainerId = this.state.ContainerId
+
             return tab
           })
         })
@@ -182,17 +197,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)
 
@@ -221,6 +241,7 @@
 
       // 鏍囪涓婚〉闈紝鐢ㄤ簬鎸夐挳鍥哄畾鍙婅〃鍗曟寕杞借缃�
       config.setting.tabType = 'main'
+      config.setting.ContainerId = this.state.ContainerId
 
       // 鏁版嵁婧愪俊鎭澶勭悊
       config.setting.laypage = config.setting.laypage !== 'false'     // 鏄惁鍒嗛〉锛岃浆涓篵oolean 缁熶竴鏍煎紡
@@ -258,7 +279,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 +287,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 => {
@@ -300,6 +319,7 @@
       config.action.forEach(item => {
         item.logLabel = MenuName + '-' + item.label // 鐢ㄤ簬sPC_TableData_InUpDe璁板綍鎿嶄綔鎸夐挳
         item.$menuId = this.props.MenuID
+        item.ContainerId = this.state.ContainerId
 
         if (item.OpenType === 'funcbutton' && item.funcType === 'print' && item.verify) { // 鎵撳嵃鏈鸿缃�
           let _item = window.GLOB.UserCacheMap.get(this.props.MenuID + item.uuid)
@@ -318,6 +338,7 @@
         }
         
         if (item.position === 'toolbar') {
+          item.$toolbtn = true
           _actions.push(item)
         } else if (item.position === 'grid') {
           _operations.push(item)
@@ -331,9 +352,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) // 閾炬帴鍚嶅瓧娈�
@@ -418,7 +448,7 @@
         chartId,
         config,
         statFields,
-        shortcuts,
+        shortcuts: shortcuts.length > 0 ? shortcuts : null,
         setting: config.setting,
         searchlist: config.search,
         actions: _actions,
@@ -449,11 +479,6 @@
   setShortcut = () => {
     const { shortcuts } = this.state
 
-    if (!shortcuts || shortcuts.length === 0) {
-      document.onkeydown = () => {}
-      return
-    }
-
     document.onkeydown = (event) => {
       let e = event || window.event
       let keyCode = e.keyCode || e.which || e.charCode
@@ -470,6 +495,16 @@
       if (!preKey || !keyCode) return
 
       let _shortcut = `${preKey}+${keyCode}`
+
+      if (window.GLOB.breakpoint && _shortcut === 'ctrl+67') {
+        window.debugger = false
+        window.GLOB.breakpoint = false
+        sessionStorage.removeItem('breakpoint')
+        
+        MKEmitter.emit('debugChange')
+      }
+
+      if (!shortcuts) return
 
       shortcuts.some(item => {
         if (item.$shortcut === _shortcut) {
@@ -533,7 +568,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 +660,7 @@
   }
 
   customCallbackRequest = (result) => {
-    const { setting } = this.state
+    const { setting, BID } = this.state
     let errSql = ''
     if (result.$ErrCode === 'E') {
       errSql = `
@@ -647,15 +682,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 +735,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)
 
@@ -773,11 +800,18 @@
       if (autoMatic) {
         MKEmitter.emit('autoMaticError', this.props.MenuID)
       }
-      notification.error({
-        top: 92,
-        message: result.message,
-        duration: 10
-      })
+
+      if (result.ErrCode === 'N') {
+        Modal.error({
+          title: result.message,
+        })
+      } else {
+        notification.error({
+          top: 92,
+          message: result.message,
+          duration: 10
+        })
+      }
     }
   }
 
@@ -792,7 +826,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 +894,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 +1017,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,
@@ -1084,6 +1118,10 @@
     }
   }
 
+  debugChange = () => {
+    this.setState({visible: !this.state.visible})
+  }
+
   UNSAFE_componentWillMount () {
     // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁
     this.loadconfig()
@@ -1095,6 +1133,7 @@
 
   componentDidMount () {
     MKEmitter.addListener('reloadData', this.reloadData)
+    MKEmitter.addListener('debugChange', this.debugChange)
     MKEmitter.addListener('reloadMenuView', this.reloadMenuView)
     MKEmitter.addListener('changeTableLine', this.changeTableLine)
     MKEmitter.addListener('resetActiveMenu', this.resetActiveMenu)
@@ -1111,6 +1150,7 @@
     }
     document.onkeydown = () => {}
     MKEmitter.removeListener('reloadData', this.reloadData)
+    MKEmitter.removeListener('debugChange', this.debugChange)
     MKEmitter.removeListener('reloadMenuView', this.reloadMenuView)
     MKEmitter.removeListener('changeTableLine', this.changeTableLine)
     MKEmitter.removeListener('resetActiveMenu', this.resetActiveMenu)
@@ -1119,16 +1159,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 => (
@@ -1151,7 +1191,6 @@
                       dict={this.state.dict}
                       MenuID={MenuID}
                       selectedData={selectedData}
-                      ContainerId={this.state.ContainerId}
                     />
                   </div>
                   <div className="main-table-box">
@@ -1170,7 +1209,6 @@
                       total={this.state.total}
                       loading={this.state.loading}
                       statFValue={this.state.statFValue}
-                      ContainerId={this.state.ContainerId}
                       refreshdata={this.refreshbytable}
                       chgSelectData={this.changeSelectedData}
                     />
@@ -1189,7 +1227,6 @@
                     columns={columns}
                     data={this.state.data}
                     loading={this.state.loading}
-                    ContainerId={this.state.ContainerId}
                   />
                 </Col>
               )
@@ -1208,6 +1245,39 @@
             }
           })}
         </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}
+            />
+          </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}
+              refreshdata={this.refreshbytable}
+              chgSelectData={this.changeSelectedData}
+            />
+          </div>
+        </div> : null }
         {setting && config.tabgroups.map(group => (
           <Tabs key={group.uuid}>
             {group.sublist.map(_tab => {
@@ -1223,7 +1293,6 @@
                     SupMenuID={MenuID}
                     MenuID={_tab.linkTab}
                     mainSearch={_tab.searchPass === 'true' ? search : null}
-                    ContainerId={this.state.ContainerId}
                     BID={this.state.BIDs[_tab.supMenu] || ''}
                     BData={this.state.BIDs[_tab.supMenu + 'data'] || ''}
                   />
@@ -1232,25 +1301,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 && setting ? <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