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/commontable/index.jsx |  267 +++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 206 insertions(+), 61 deletions(-)

diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx
index b80a1da..d4fac9e 100644
--- a/src/tabviews/commontable/index.jsx
+++ b/src/tabviews/commontable/index.jsx
@@ -2,7 +2,7 @@
 import PropTypes from 'prop-types'
 import {connect} from 'react-redux'
 import { is, fromJS } from 'immutable'
-import { notification, Spin, Tabs, Icon, Switch, Modal, Button, message, Tree, Typography } from 'antd'
+import { notification, Spin, Tabs, Icon, Switch, Modal, Button, message, Tree, Typography, Col } from 'antd'
 import moment from 'moment'
 
 import Api from '@/api'
@@ -12,6 +12,7 @@
 import asyncLoadComponent from '@/utils/asyncLoadComponent'
 import {refreshTabView, modifyTabview} from '@/store/action'
 
+import ChartComponent from '@/tabviews/zshare/chartcomponent'
 import MainTable from '@/tabviews/zshare/normalTable'
 import MainSearch from '@/tabviews/zshare/topSearch'
 import NotFount from '@/components/404'
@@ -127,13 +128,63 @@
         return
       }
 
+      // 鍏煎鏍囩
+      if (!config.tabgroups) {
+        config.tabgroups = [{ uuid: 'tabs', sublist: [] }]
+      } else if (typeof(config.tabgroups[0]) === 'string') {
+        let _tabgroups = []
+        config.tabgroups.forEach(groupId => {
+          let _group = {
+            uuid: groupId,
+            sublist: fromJS(config[groupId]).toJS()
+          }
+  
+          delete config[groupId]
+  
+          _tabgroups.push(_group)
+        })
+  
+        config.tabgroups = _tabgroups
+      }
+  
+      // 鍏煎鍥捐〃
+      if (!config.charts) {
+        config.expand = false
+        config.charts = [{
+          uuid: Utils.getuuid(),
+          label: '',
+          title: '',
+          chartType: 'table',
+          icon: 'table',
+          Hide: 'false',
+          blacklist: []
+        }]
+      }
+
       // 鏉冮檺杩囨护
       config.action = config.action.filter(item => permAction[item.uuid])
       config.tabgroups.forEach(group => {
-        if (!config[group]) return
-
-        config[group] = config[group].filter(tab => permAction[tab.linkTab])
+        group.sublist = group.sublist.filter(tab => permAction[tab.linkTab])
       })
+
+      // 瑙嗗浘鏉冮檺
+      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
+      }
 
       // 瀛楁鏉冮檺榛戝悕鍗�
       config.search = config.search.filter(item => {
@@ -195,9 +246,9 @@
 
       let _tabActive = {} // 绛涢�夊睍寮�鐨則ab椤�
 
-      config.tabgroups.forEach(groupId => {
-        if (!config[groupId] || config[groupId].length === 0) return
-        _tabActive[groupId] = config[groupId][0].uuid
+      config.tabgroups.forEach(group => {
+        if (group.sublist.length === 0) return
+        _tabActive[group.uuid] = group.sublist[0].uuid
       })
 
       let _arrField = []     // 瀛楁闆�
@@ -385,12 +436,12 @@
 
             let _groupId = ''
             let _ActiveTabId = ''
-            config.tabgroups.forEach(groupId => {
-              if (!config[groupId] || config[groupId].length === 0) return
+            config.tabgroups.forEach(group => {
+              if (group.sublist.length === 0) return
 
-              let _tab = config[groupId].filter(tab => tab.uuid === key)[0]
+              let _tab = group.sublist.filter(tab => tab.uuid === key)[0]
               if (_tab) {
-                _groupId = groupId
+                _groupId = group.uuid
                 _ActiveTabId = _tab.uuid
               }
             })
@@ -580,10 +631,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') {
@@ -625,7 +679,9 @@
     let param = {
       func: 'sPC_Get_TableData',
       obj_name: 'data',
-      arr_field: arr_field
+      arr_field: arr_field,
+      custom_script: setting.customScript || '',
+      default_sql: setting.default || 'true'
     }
     
     let _orderBy = orderBy || setting.order
@@ -655,6 +711,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)
@@ -1197,58 +1259,141 @@
               refreshdata={this.refreshbysearch}
             /> : null
           }
-          {actions && setting.onload !== 'false' ?
-            <div style={{minHeight: '25px'}}>
-              <MainAction
-                BID=""
-                type="main"
-                menuType="main"
-                setting={setting}
-                actions={actions}
-                triggerBtn={triggerBtn}
-                dict={this.state.dict}
-                MenuID={this.props.MenuID}
-                permRoles={this.props.permRoles}
-                logcolumns={this.state.logcolumns}
-                ContainerId={this.state.ContainerId}
-                refreshdata={this.refreshbyaction}
-                triggerPopview={this.triggerPopview}
-                getexceloutparam={this.getexceloutparam}
-                gettableselected={this.gettableselected}
-              />
-            </div> : null
-          }
-          {columns && setting.onload !== 'false' ?
-            <div className="main-table-box">
-              <Icon className="custom-control" type="setting" onClick={this.controlCustomSetting} />
-              {this.state.data && this.state.data.length > 0 ?
-                <Switch title="鏀惰捣" className="main-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={pickup} onChange={this.pickupChange} /> : null
+          {setting && setting.onload !== 'false' ? <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'}}>
+                        <MainAction
+                          BID=""
+                          type="main"
+                          menuType="main"
+                          setting={setting}
+                          actions={actions}
+                          triggerBtn={triggerBtn}
+                          dict={this.state.dict}
+                          MenuID={this.props.MenuID}
+                          permRoles={this.props.permRoles}
+                          logcolumns={this.state.logcolumns}
+                          ContainerId={this.state.ContainerId}
+                          refreshdata={this.refreshbyaction}
+                          triggerPopview={this.triggerPopview}
+                          getexceloutparam={this.getexceloutparam}
+                          gettableselected={this.gettableselected}
+                        />
+                      </div>
+                      <div className="main-table-box">
+                        <Icon className="custom-control" type="setting" onClick={this.controlCustomSetting} />
+                        {this.state.data && this.state.data.length > 0 ?
+                          <Switch title="鏀惰捣" className="main-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={pickup} onChange={this.pickupChange} /> : null
+                        }
+                        <MainTable
+                          ref="mainTable"
+                          tableId="mainTable"
+                          pickup={pickup}
+                          setting={setting}
+                          columns={columns}
+                          dict={this.state.dict}
+                          data={this.state.data}
+                          total={this.state.total}
+                          MenuID={this.props.MenuID}
+                          loading={this.state.loading}
+                          pagination={setting.laypage !== 'false'}
+                          refreshdata={this.refreshbytable}
+                          buttonTrigger={this.buttonTrigger}
+                          linkTrigger={this.linkTrigger}
+                          handleTableId={this.handleTableId}
+                        />
+                      </div>
+                    </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'}}>
+                      <MainAction
+                        BID=""
+                        type="main"
+                        menuType="main"
+                        setting={setting}
+                        actions={actions}
+                        triggerBtn={triggerBtn}
+                        dict={this.state.dict}
+                        MenuID={this.props.MenuID}
+                        permRoles={this.props.permRoles}
+                        logcolumns={this.state.logcolumns}
+                        ContainerId={this.state.ContainerId}
+                        refreshdata={this.refreshbyaction}
+                        triggerPopview={this.triggerPopview}
+                        getexceloutparam={this.getexceloutparam}
+                        gettableselected={this.gettableselected}
+                      />
+                    </div>
+                    <div className="main-table-box">
+                      <Icon className="custom-control" type="setting" onClick={this.controlCustomSetting} />
+                      {this.state.data && this.state.data.length > 0 ?
+                        <Switch title="鏀惰捣" className="main-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={pickup} onChange={this.pickupChange} /> : null
+                      }
+                      <MainTable
+                        ref="mainTable"
+                        tableId="mainTable"
+                        pickup={pickup}
+                        setting={setting}
+                        columns={columns}
+                        dict={this.state.dict}
+                        data={this.state.data}
+                        total={this.state.total}
+                        MenuID={this.props.MenuID}
+                        loading={this.state.loading}
+                        pagination={setting.laypage !== 'false'}
+                        refreshdata={this.refreshbytable}
+                        buttonTrigger={this.buttonTrigger}
+                        linkTrigger={this.linkTrigger}
+                        handleTableId={this.handleTableId}
+                      />
+                    </div>
+                  </Col>
+                )
+              } else {
+                return (
+                  <Col span={item.width} key={item.uuid}>
+                    <ChartComponent
+                      plot={item}
+                      data={this.state.data}
+                      config={config}
+                    />
+                  </Col>
+                )
               }
-              <MainTable
-                ref="mainTable"
-                tableId="mainTable"
-                pickup={pickup}
-                setting={setting}
-                columns={columns}
-                dict={this.state.dict}
-                data={this.state.data}
-                total={this.state.total}
-                MenuID={this.props.MenuID}
-                loading={this.state.loading}
-                refreshdata={this.refreshbytable}
-                buttonTrigger={this.buttonTrigger}
-                linkTrigger={this.linkTrigger}
-                handleTableId={this.handleTableId}
-              />
-            </div> : null
-          }
+            })}
+          </div> : null }
           {setting && setting.onload !== 'false' &&
             config.tabgroups.map(group => {
-              if (config[group].length === 0) return null
+              if (group.sublist.length === 0) return null
 
               return (
-                <Tabs activeKey={tabActive[group]} key={group} onChange={(key) => this.setState({tabActive: {...tabActive, [group]: key}})}>
-                  {config[group].map(_tab => {
+                <Tabs activeKey={tabActive[group.uuid]} key={group.uuid} onChange={(key) => this.setState({tabActive: {...tabActive, [group.uuid]: key}})}>
+                  {group.sublist.map(_tab => {
                     return (
                       <TabPane tab={
                         <span>

--
Gitblit v1.8.0