king
2020-05-06 4e1938344ca46c0cbe699756ecaffa630e698aec
src/tabviews/subtable/index.jsx
@@ -2,7 +2,7 @@
import PropTypes from 'prop-types'
import {connect} from 'react-redux'
import { is, fromJS } from 'immutable'
import { notification, Spin, Modal, Button, Switch} from 'antd'
import { notification, Spin, Modal, Button, Switch, Col, Icon, Tabs} from 'antd'
import moment from 'moment'
import Api from '@/api'
@@ -12,6 +12,7 @@
import options from '@/store/options.js'
import { modifyTabview } from '@/store/action'
import ChartComponent from '@/tabviews/zshare/chartcomponent'
import SubTable from '@/tabviews/zshare/normalTable'
import SubSearch from '@/tabviews/zshare/topSearch'
import asyncComponent from '@/utils/asyncComponent'
@@ -20,6 +21,7 @@
import './index.scss'
const { TabPane } = Tabs
const SubAction = asyncComponent(() => import('@/tabviews/zshare/actionList'))
const SubTabTable = asyncLoadComponent(() => import('@/tabviews/subtabtable'))
@@ -136,6 +138,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: []
        }]
      }
      // 权限过滤
      if (this.props.menuType !== 'HS') {
        config.action = config.action.filter(item => permAction[item.uuid])
@@ -168,6 +184,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
      }
      if (userConfig) {
@@ -492,11 +527,14 @@
    let _search = Utils.formatCustomMainSearch(searches)
    let param = {
      PageIndex: pageIndex,
      PageSize: pageSize,
      OrderCol: orderBy || setting.order,
      BID: BID,
      ..._search
    }
    if (setting.laypage !== 'false') {
      param.PageIndex = pageIndex
      param.PageSize = pageSize
    }
    if (setting.interType === 'inner') {
@@ -543,7 +581,9 @@
      func: 'sPC_Get_TableData',
      obj_name: 'data',
      arr_field: arr_field,
      BID: BID
      BID: BID,
      custom_script: setting.customScript || '',
      default_sql: setting.default || 'true'
    }
    let _orderBy = orderBy || setting.order
@@ -573,6 +613,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)
@@ -813,7 +859,7 @@
  }
  render() {
    const { setting, searchlist, actions, columns, loadingview, viewlost, pickup, triggerBtn } = this.state
    const { config, setting, searchlist, actions, columns, loadingview, viewlost, pickup, triggerBtn } = this.state
    return (
      <div className="subtable" id={'subtable' + this.props.MenuID}>
@@ -825,53 +871,138 @@
            dict={this.state.dict}
          /> : null
        }
        {actions ?
          <div className="sub-action">
            <SubAction
              type="sub"
              menuType={this.props.menuType}
              triggerBtn={triggerBtn}
              setting={setting}
              actions={actions}
              Tab={this.props.Tab}
              BID={this.props.BID}
              BData={this.props.BData}
              dict={this.state.dict}
              MenuID={this.props.MenuID}
              permRoles={this.props.permRoles}
              logcolumns={this.state.logcolumns}
              refreshdata={this.refreshbyaction}
              ContainerId={this.props.ContainerId}
              triggerPopview={this.triggerPopview}
              getexceloutparam={this.getexceloutparam}
              gettableselected={this.gettableselected}
            />
          </div> : null
        }
        {columns ?
          <div className="subtable-box">
            {this.state.data && this.state.data.length > 0 ?
              <Switch title="收起" className="subtable-pickup" checkedChildren="开" unCheckedChildren="关" defaultChecked={pickup} onChange={this.pickupChange} /> : null
        {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 className="sub-action">
                      <SubAction
                        type="sub"
                        menuType={this.props.menuType}
                        triggerBtn={triggerBtn}
                        setting={setting}
                        actions={actions}
                        Tab={this.props.Tab}
                        BID={this.props.BID}
                        BData={this.props.BData}
                        dict={this.state.dict}
                        MenuID={this.props.MenuID}
                        permRoles={this.props.permRoles}
                        logcolumns={this.state.logcolumns}
                        refreshdata={this.refreshbyaction}
                        ContainerId={this.props.ContainerId}
                        triggerPopview={this.triggerPopview}
                        getexceloutparam={this.getexceloutparam}
                        gettableselected={this.gettableselected}
                      />
                    </div>
                    <div className="subtable-box">
                      {this.state.data && this.state.data.length > 0 ?
                        <Switch title="收起" className="subtable-pickup" checkedChildren="开" unCheckedChildren="关" defaultChecked={pickup} onChange={this.pickupChange} /> : null
                      }
                      <SubTable
                        ref="subTable"
                        menuType={this.props.menuType}
                        tableId={this.props.Tab.uuid}
                        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 className="sub-action">
                    <SubAction
                      type="sub"
                      menuType={this.props.menuType}
                      triggerBtn={triggerBtn}
                      setting={setting}
                      actions={actions}
                      Tab={this.props.Tab}
                      BID={this.props.BID}
                      BData={this.props.BData}
                      dict={this.state.dict}
                      MenuID={this.props.MenuID}
                      permRoles={this.props.permRoles}
                      logcolumns={this.state.logcolumns}
                      refreshdata={this.refreshbyaction}
                      ContainerId={this.props.ContainerId}
                      triggerPopview={this.triggerPopview}
                      getexceloutparam={this.getexceloutparam}
                      gettableselected={this.gettableselected}
                    />
                  </div>
                  <div className="subtable-box">
                    {this.state.data && this.state.data.length > 0 ?
                      <Switch title="收起" className="subtable-pickup" checkedChildren="开" unCheckedChildren="关" defaultChecked={pickup} onChange={this.pickupChange} /> : null
                    }
                    <SubTable
                      ref="subTable"
                      menuType={this.props.menuType}
                      tableId={this.props.Tab.uuid}
                      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>
              )
            }
            <SubTable
              ref="subTable"
              menuType={this.props.menuType}
              tableId={this.props.Tab.uuid}
              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 }
        <Modal
          className="popview-modal"
          title={this.state.popAction.label}