From 4e1938344ca46c0cbe699756ecaffa630e698aec Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 06 五月 2020 13:59:54 +0800
Subject: [PATCH] 2020-05-06

---
 src/tabviews/subtabtable/index.jsx |  209 +++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 165 insertions(+), 44 deletions(-)

diff --git a/src/tabviews/subtabtable/index.jsx b/src/tabviews/subtabtable/index.jsx
index 912166b..d426bec 100644
--- a/src/tabviews/subtabtable/index.jsx
+++ b/src/tabviews/subtabtable/index.jsx
@@ -2,7 +2,7 @@
 import PropTypes from 'prop-types'
 import {connect} from 'react-redux'
 import { is, fromJS } from 'immutable'
-import { notification, Spin} from 'antd'
+import { notification, Spin, Col, Icon, Tabs} from 'antd'
 import moment from 'moment'
 
 import Api from '@/api'
@@ -11,6 +11,7 @@
 import Utils from '@/utils/utils.js'
 import options from '@/store/options.js'
 
+import ChartComponent from '@/tabviews/zshare/chartcomponent'
 import asyncComponent from '@/utils/asyncComponent'
 import SubTable from '@/tabviews/zshare/normalTable'
 import SubSearch from '@/tabviews/zshare/topSearch'
@@ -18,6 +19,7 @@
 
 import './index.scss'
 
+const { TabPane } = Tabs
 const SubAction = asyncComponent(() => import('@/tabviews/zshare/actionList'))
 
 class SubTabModalTable extends Component {
@@ -37,7 +39,7 @@
     loadingview: true,    // 椤甸潰鍔犺浇涓�
     viewlost: false,      // 椤甸潰涓㈠け锛�1銆佹湭鑾峰彇鍒伴厤缃�-椤甸潰涓㈠け锛�2銆侀〉闈㈡湭鍚敤
     lostmsg: '',          // 椤甸潰涓㈠け鏃剁殑鎻愮ず淇℃伅
-    config: {},           // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷寜閽�佹悳绱€�佹樉绀哄垪銆佹爣绛剧瓑
+    config: null,         // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷寜閽�佹悳绱€�佹樉绀哄垪銆佹爣绛剧瓑
     searchlist: null,     // 鎼滅储鏉′欢
     actions: null,        // 鎸夐挳闆�
     columns: null,        // 鏄剧ず鍒�
@@ -100,6 +102,20 @@
       let _hideCol = []      // 闅愯棌鍙婂悎骞跺垪涓瓧娈电殑uuid闆�
       let colMap = new Map()
 
+      // 鍏煎鍥捐〃
+      if (!config.charts) {
+        config.expand = false
+        config.charts = [{
+          uuid: Utils.getuuid(),
+          label: '',
+          title: '',
+          chartType: 'table',
+          icon: 'table',
+          Hide: 'false',
+          blacklist: []
+        }]
+      }
+
       // 浠呮敮鎸乪xec銆乸rompt銆乸op 涓夌绫诲瀷鎸夐挳
       config.action = config.action.filter(item => ['exec', 'prompt', 'pop'].includes(item.OpenType))
 
@@ -135,6 +151,25 @@
             return true
           }
         })
+
+        // 瑙嗗浘鏉冮檺
+        config.charts = config.charts.filter(item => {
+          if (!item.blacklist || item.blacklist.length === 0) return true
+
+          let _black = item.blacklist.filter(v => {
+            return this.props.permRoles.indexOf(v) !== -1
+          })
+
+          if (_black.length > 0 || item.Hide === 'true') {
+            return false
+          } else {
+            return true
+          }
+        })
+      }
+
+      if (config.charts.length <= 1) {
+        config.expand = true
       }
 
       // 1銆佺瓫閫夊瓧娈甸泦锛�2銆佽繃婊ら殣钘忓垪鍙婂悎骞跺垪涓殑瀛楁uuid
@@ -375,10 +410,13 @@
     let _search = Utils.formatCustomMainSearch(search)
 
     let param = {
-      PageIndex: pageIndex,
-      PageSize: pageSize,
       OrderCol: orderBy || setting.order,
       ..._search
+    }
+
+    if (setting.laypage !== 'false') {
+      param.PageIndex = pageIndex
+      param.PageSize = pageSize
     }
 
     if (setting.interType === 'inner') {
@@ -419,7 +457,9 @@
       func: 'sPC_Get_TableData',
       obj_name: 'data',
       arr_field: arr_field,
-      BID: this.props.BID
+      BID: this.props.BID,
+      custom_script: setting.customScript || '',
+      default_sql: setting.default || 'true'
     }
 
     let _orderBy = orderBy || setting.order
@@ -449,6 +489,12 @@
     let 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`
     let DateCount = `select count(1) as total from ${_dataresource} ${_search}`
 
+    if (setting.laypage === '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 = ''
+    }
+
+    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)
@@ -513,7 +559,7 @@
       loadingview: true,
       viewlost: false,
       lostmsg: '',
-      config: {},
+      config: null,
       searchlist: null,
       actions: null,
       columns: null,
@@ -594,7 +640,7 @@
   }
 
   render() {
-    const { setting, searchlist, actions, columns, loadingview, viewlost, triggerBtn } = this.state
+    const { config, setting, searchlist, actions, columns, loadingview, viewlost, triggerBtn } = this.state
 
     return (
       <div className="subtabtable" id={'subtabtable' + this.props.MenuID}>
@@ -606,43 +652,118 @@
             dict={this.state.dict}
           /> : null
         }
-        {actions ?
-          <div style={{minHeight: '25px'}}>
-            <SubAction
-              type="subtab"
-              triggerBtn={triggerBtn}
-              menuType={this.props.menuType}
-              setting={setting}
-              actions={actions}
-              BID={this.props.BID}
-              dict={this.state.dict}
-              BData={this.props.BData}
-              MenuID={this.props.SupMenuID}
-              permRoles={this.props.permRoles}
-              logcolumns={this.state.logcolumns}
-              refreshdata={this.refreshbyaction}
-              ContainerId={this.props.ContainerId}
-              gettableselected={this.gettableselected}
-            />
-          </div> : null
-        }
-        {columns &&
-          <SubTable
-            ref="subTable"
-            menuType={this.props.menuType}
-            tableId=""
-            dict={this.state.dict}
-            MenuID={this.props.MenuID}
-            setting={setting}
-            columns={columns}
-            data={this.state.data}
-            total={this.state.total}
-            loading={this.state.loading}
-            refreshdata={this.refreshbytable}
-            buttonTrigger={this.buttonTrigger}
-            handleTableId={() => {}}
-          />
-        }
+        {config ? <div className="chart-view">
+          {/* 瑙嗗浘缁� */}
+          {!config.expand ? <Tabs>
+            {config.charts.map(item => (
+              <TabPane tab={
+                <Icon type={item.icon} />
+              } key={item.uuid}>
+                {item.chartType === 'table' ? 
+                  <Col span={item.width || 24} key={item.uuid}>
+                    {config.charts.length > 1 ? <p className="chart-table chart-title">{item.title}</p> : null}
+                    <div style={{minHeight: '25px'}}>
+                      <SubAction
+                        type="subtab"
+                        triggerBtn={triggerBtn}
+                        menuType={this.props.menuType}
+                        setting={setting}
+                        actions={actions}
+                        BID={this.props.BID}
+                        dict={this.state.dict}
+                        BData={this.props.BData}
+                        MenuID={this.props.SupMenuID}
+                        permRoles={this.props.permRoles}
+                        logcolumns={this.state.logcolumns}
+                        refreshdata={this.refreshbyaction}
+                        ContainerId={this.props.ContainerId}
+                        gettableselected={this.gettableselected}
+                      />
+                    </div>
+                    <SubTable
+                      ref="subTable"
+                      menuType={this.props.menuType}
+                      tableId=""
+                      dict={this.state.dict}
+                      MenuID={this.props.MenuID}
+                      setting={setting}
+                      columns={columns}
+                      data={this.state.data}
+                      total={this.state.total}
+                      loading={this.state.loading}
+                      pagination={setting.laypage !== 'false'}
+                      refreshdata={this.refreshbytable}
+                      buttonTrigger={this.buttonTrigger}
+                      handleTableId={() => {}}
+                    />
+                  </Col> : null
+                }
+                {item.chartType !== 'table' ? 
+                  <Col span={item.width} key={item.uuid}>
+                    <ChartComponent
+                      plot={item}
+                      data={this.state.data}
+                      config={config}
+                    />
+                  </Col> : null
+                }
+              </TabPane>
+            ))}
+          </Tabs> : null}
+          {config.expand && config.charts.map(item => {
+            if (item.chartType === 'table') {
+              return (
+                <Col span={item.width || 24} key={item.uuid}>
+                  {config.charts.length > 1 ? <p className="chart-table chart-title">{item.title}</p> : null}
+                  <div style={{minHeight: '25px'}}>
+                    <SubAction
+                      type="subtab"
+                      triggerBtn={triggerBtn}
+                      menuType={this.props.menuType}
+                      setting={setting}
+                      actions={actions}
+                      BID={this.props.BID}
+                      dict={this.state.dict}
+                      BData={this.props.BData}
+                      MenuID={this.props.SupMenuID}
+                      permRoles={this.props.permRoles}
+                      logcolumns={this.state.logcolumns}
+                      refreshdata={this.refreshbyaction}
+                      ContainerId={this.props.ContainerId}
+                      gettableselected={this.gettableselected}
+                    />
+                  </div>
+                  <SubTable
+                    ref="subTable"
+                    menuType={this.props.menuType}
+                    tableId=""
+                    dict={this.state.dict}
+                    MenuID={this.props.MenuID}
+                    setting={setting}
+                    columns={columns}
+                    data={this.state.data}
+                    total={this.state.total}
+                    loading={this.state.loading}
+                    pagination={setting.laypage !== 'false'}
+                    refreshdata={this.refreshbytable}
+                    buttonTrigger={this.buttonTrigger}
+                    handleTableId={() => {}}
+                  />
+                </Col>
+              )
+            } else {
+              return (
+                <Col span={item.width} key={item.uuid}>
+                  <ChartComponent
+                    plot={item}
+                    data={this.state.data}
+                    config={config}
+                  />
+                </Col>
+              )
+            }
+          })}
+        </div> : null }
         {viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
       </div>
     )

--
Gitblit v1.8.0