king
2020-12-03 e739b47d88c14c2d83ad400d74241f9396e5d7cc
src/tabviews/custom/components/share/tabtransfer/index.jsx
@@ -4,6 +4,7 @@
import { is, fromJS } from 'immutable'
import { Row, Col, Empty, notification } from 'antd'
import moment from 'moment'
import md5 from 'md5'
import Api from '@/api'
import options from '@/store/options.js'
@@ -17,6 +18,7 @@
const AntvPie = asyncComponent(() => import('@/tabviews/custom/components/chart/antv-pie'))
const AntvTabs = asyncComponent(() => import('@/tabviews/custom/components/tabs/antv-tabs'))
const DataCard = asyncComponent(() => import('@/tabviews/custom/components/card/data-card'))
const TableCard = asyncComponent(() => import('@/tabviews/custom/components/card/table-card'))
const PropCard = asyncComponent(() => import('@/tabviews/custom/components/card/prop-card'))
class TabTransfer extends Component {
@@ -83,7 +85,10 @@
    })
    this.setState({mainSearch: _mainSearch, self})
    this.loadmaindata(params)
    if (params.length > 0) {
      this.loadmaindata(params)
    }
  }
  UNSAFE_componentWillReceiveProps(nextProps) {
@@ -151,8 +156,8 @@
    // 测试系统打印查询语句
    if ((options.sysType === 'local' && !window.GLOB.systemType) || window.debugger === true) {
      _customScript &&  console.log(`${_dataresource ? '' : '/*不执行默认sql*/\n'}${_customScript}`)
      _dataresource &&  console.log(_dataresource)
      _customScript &&  console.info(`${_dataresource ? '' : '/*不执行默认sql*/\n'}${_customScript}`)
      _dataresource &&  console.info(_dataresource)
    }
    return {
@@ -171,10 +176,10 @@
   * @description 主表数据加载
   */ 
  loadmaindata = (params) => {
    if (!params || params.length === 0) return
    const { config } = this.props
    let LText_field = []
    let LText = params.map((item, index) => {
      let _sql = item.sql
    let diffUser = false
    let _LText = params.map((item, index) => {
      let _script = item.script
      if (index === 0) {
@@ -182,21 +187,38 @@
          ${_script}
        `
      }
      if (!diffUser && (/@userid@/ig.test(item.sql) || /@userid@/ig.test(_script))) {
        diffUser = true
      }
      item.columns.forEach(cell => {
        LText_field.push(`Select '${item.name}' as tablename,'${cell.field}' as fieldname,'${cell.datatype}' as field_type`)
      })
      return `Select '${item.name}' as tablename,'${window.btoa(window.encodeURIComponent(_sql))}' as LText,'${window.btoa(window.encodeURIComponent(_script))}' as Lcustomize,'${item.type}' as table_type,'${item.primaryKey}' as primary_key,'${item.par_tablename}' as par_tablename,'${item.foreign_key}' as foreign_key,'${index}' as Sort`
      return `Select '${item.name}' as tablename,'${window.btoa(window.encodeURIComponent(item.sql))}' as LText,'${window.btoa(window.encodeURIComponent(_script))}' as Lcustomize,'${item.type}' as table_type,'${item.primaryKey}' as primary_key,'${item.par_tablename}' as par_tablename,'${item.foreign_key}' as foreign_key,'${index}' as Sort`
    })
    let param = {
      func: 'sPC_Get_structured_data',
      LText: LText.join(' union all '),
      LText: _LText.join(' union all '),
      LText_field: LText_field.join(' union all ')
    }
    param.LText = Utils.formatOptions(param.LText)
    let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText)
    param.LText1 = LText1
    param.LText = LText
    param.LText2 = LText2
    param.LText_field = Utils.formatOptions(param.LText_field)
    if (config.cacheUseful === 'true') {
      param.time_type = config.timeUnit
      param.time_limit = config.cacheTime
      if (diffUser) {
        param.userid = sessionStorage.getItem('UserID')
      }
      param.data_md5 = md5(JSON.stringify(param))
    }
    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
    param.secretkey = Utils.encrypt(param.LText, param.timestamp)
@@ -270,6 +292,12 @@
            <PropCard config={item} data={data} BID={BID} mainSearch={mainSearch} menuType={menuType} dataManager={dataManager} />
          </Col>
        )
      } else if (item.type === 'table' && item.subtype === 'tablecard') {
        return (
          <Col span={item.width} key={item.uuid}>
            <TableCard config={item} data={data} BID={BID} mainSearch={mainSearch} menuType={menuType} dataManager={dataManager} />
          </Col>
        )
      } else {
        return null
      }