king
2020-09-03 3626595bb2bd245708590ada4b8929bd027d4222
2020-09-03
7个文件已修改
377 ■■■■ 已修改文件
src/api/index.js 174 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/components/chart/antv-bar-line/index.jsx 186 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/index.jsx 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/calendarconfig/index.jsx 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/comtableconfig/index.jsx 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/comtableconfig/source.jsx 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/sharecomponent/tablecomponent/index.jsx 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/index.js
@@ -119,20 +119,7 @@
    param.userid = param.userid || sessionStorage.getItem('UserID') || ''
    param.LoginUID = param.LoginUID || sessionStorage.getItem('LoginUID') || ''
    param.nonc = Utils.getuuid()
    let keys = Object.keys(param).sort()
    let values = ''
    keys.forEach(key => {
      if (key === 'rduri' || key === 't') return
      if (typeof(param[key]) === 'object') {
        values += key + JSON.stringify(param[key])
      } else {
        values += key + param[key]
      }
    })
    param.sign  = md5(values)
    param.t = new Date().getTime()
    param = this.encryptParam(param)
    return axios({
      url: '/webapi/dostar',
@@ -287,20 +274,7 @@
        param.rduri = window.GLOB.mainSystemApi
      }
  
      param.nonc = Utils.getuuid()
      let keys = Object.keys(param).sort()
      let values = ''
      keys.forEach(key => {
        if (key === 'rduri' || key === 't') return
        if (typeof(param[key]) === 'object') {
          values += key + JSON.stringify(param[key])
        } else {
          values += key + param[key]
        }
      })
      param.sign  = md5(values)
      param.t = new Date().getTime()
      param = this.encryptParam(param)
  
      return new Promise((resolve, reject) => {
        axios({
@@ -412,20 +386,7 @@
      param.LoginUID = sessionStorage.getItem('LoginUID') || ''
    }
    param.nonc = Utils.getuuid()
    let keys = Object.keys(param).sort()
    let values = ''
    keys.forEach(key => {
      if (key === 'rduri' || key === 't') return
      if (typeof(param[key]) === 'object') {
        values += key + JSON.stringify(param[key])
      } else {
        values += key + param[key]
      }
    })
    param.sign  = md5(values)
    param.t = new Date().getTime()
    param = this.encryptParam(param)
    return axios({
      url: `/webapi/dostars${param.func ? '/' + param.func : ''}`,
@@ -451,20 +412,7 @@
      param.rduri = window.GLOB.mainSystemApi
    }
    param.nonc = Utils.getuuid()
    let keys = Object.keys(param).sort()
    let values = ''
    keys.forEach(key => {
      if (key === 'rduri' || key === 't') return
      if (typeof(param[key]) === 'object') {
        values += key + JSON.stringify(param[key])
      } else {
        values += key + param[key]
      }
    })
    param.sign  = md5(values)
    param.t = new Date().getTime()
    param = this.encryptParam(param)
    return axios({
      url: `/webapi/dostars${param.func ? '/' + param.func : ''}`,
@@ -482,20 +430,7 @@
    param.LoginUID = sessionStorage.getItem('LoginUID') || ''
    param.appkey = window.GLOB.appkey || ''
    param.nonc = Utils.getuuid()
    let keys = Object.keys(param).sort()
    let values = ''
    keys.forEach(key => {
      if (key === 'rduri' || key === 't') return
      if (typeof(param[key]) === 'object') {
        values += key + JSON.stringify(param[key])
      } else {
        values += key + param[key]
      }
    })
    param.sign  = md5(values)
    param.t = new Date().getTime()
    param = this.encryptParam(param)
    return axios({
      url: `/webapi/dostars${param.func ? '/' + param.func : ''}`,
@@ -532,20 +467,7 @@
    _param  = md5(_param)
    
    if (mkDataBase && storUsable) {
      param.nonc = Utils.getuuid()
      let keys = Object.keys(param).sort()
      let values = ''
      keys.forEach(key => {
        if (key === 'rduri' || key === 't') return
        if (typeof(param[key]) === 'object') {
          values += key + JSON.stringify(param[key])
        } else {
          values += key + param[key]
        }
      })
      param.sign  = md5(values)
      param.t = new Date().getTime()
      param = this.encryptParam(param)
      return new Promise(resolve => {
        mkDataBase.transaction(tx => {
@@ -592,20 +514,7 @@
    } else if (window.GLOB.CacheMap.has(_param)) {
      return Promise.resolve(window.GLOB.CacheMap.get(_param))
    } else {
      param.nonc = Utils.getuuid()
      let keys = Object.keys(param).sort()
      let values = ''
      keys.forEach(key => {
        if (key === 'rduri' || key === 't') return
        if (typeof(param[key]) === 'object') {
          values += key + JSON.stringify(param[key])
        } else {
          values += key + param[key]
        }
      })
      param.sign  = md5(values)
      param.t = new Date().getTime()
      param = this.encryptParam(param)
      return new Promise(resolve => {
        axios({
@@ -632,6 +541,30 @@
  }
  /**
   * @description dostars 参数加密
   */
  encryptParam (param) {
    param.nonc = Utils.getuuid()
    let keys = Object.keys(param).sort()
    let values = ''
    keys.forEach(key => {
      if (key === 'rduri' || key === 't') return
      if (param[key] === undefined) {
        delete param[key]
      } else if (typeof(param[key]) === 'object') {
        values += key + JSON.stringify(param[key])
      } else {
        values += key + param[key]
      }
    })
    param.sign = md5(values)
    param.t = new Date().getTime()
    return param
  }
  /**
   * @description 获取系统配置,优先从缓存中取值,增加appkey
   * @param {Object}  param   请求参数
   * @param {Boolean} SSO     是否为单点登录地址
@@ -653,20 +586,7 @@
    if (window.GLOB.CacheMap.has(_param)) {
      return Promise.resolve(window.GLOB.CacheMap.get(_param))
    } else {
      param.nonc = Utils.getuuid()
      let keys = Object.keys(param).sort()
      let values = ''
      keys.forEach(key => {
        if (key === 'rduri' || key === 't') return
        if (typeof(param[key]) === 'object') {
          values += key + JSON.stringify(param[key])
        } else {
          values += key + param[key]
        }
      })
      param.sign = md5(values)
      param.t = new Date().getTime()
      param = this.encryptParam(param)
      return new Promise(resolve => {
        axios({
@@ -697,20 +617,7 @@
      param.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
    }
    param.nonc = Utils.getuuid()
    let keys = Object.keys(param).sort()
    let values = ''
    keys.forEach(key => {
      if (key === 'rduri' || key === 't') return
      if (typeof(param[key]) === 'object') {
        values += key + JSON.stringify(param[key])
      } else {
        values += key + param[key]
      }
    })
    param.sign  = md5(values)
    param.t = new Date().getTime()
    param = this.encryptParam(param)
    return axios({
      url: `/webapi/dostars${param.func ? '/' + param.func : ''}`,
@@ -796,20 +703,7 @@
      param.LoginUID = sessionStorage.getItem('LoginUID') || ''
    }
    param.nonc = Utils.getuuid()
    let keys = Object.keys(param).sort()
    let values = ''
    keys.forEach(key => {
      if (key === 'rduri' || key === 't') return
      if (typeof(param[key]) === 'object') {
        values += key + JSON.stringify(param[key])
      } else {
        values += key + param[key]
      }
    })
    param.sign  = md5(values)
    param.t = new Date().getTime()
    param = this.encryptParam(param)
    if (param.rduri) {
      param.rduri = param.rduri.replace(/webapi(.*)$/, 'webapi/SaveBase64Image')
src/tabviews/custom/components/chart/antv-bar-line/index.jsx
@@ -3,11 +3,13 @@
import { is, fromJS } from 'immutable'
import { Chart } from '@antv/g2'
import DataSet from '@antv/data-set'
import { Spin, Empty, Select } from 'antd'
import { Spin, Empty, Select, notification } from 'antd'
import asyncComponent from './asyncButtonComponent'
// import searchLine from '../../share/searchLine'
import Api from '@/api'
import Utils from '@/utils/utils.js'
import UtilsDM from '@/utils/utils-datamanage.js'
import zhCN from '@/locales/zh-CN/main.js'
import enUS from '@/locales/en-US/main.js'
import './index.scss'
@@ -27,10 +29,14 @@
  state = {
    dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, // 字典
    config: true,              // 图表配置信息
    empty: true,               // 图表数据为空
    chartId: Utils.getuuid(),  // 图表Id
    title: '',
    searchList: null,
    title: '',                 // 组件标题
    sync: false,               // 是否统一请求数据
    plot: null,                // 图表设置
    data: null,                // 数据
    search: null,              // 搜索条件
    chartData: [],             // 图表数据
    chartFields: [],           // 统计图表生成字段集
    selectFields: [],          // 统计图表选择字段
@@ -38,73 +44,110 @@
  }
  UNSAFE_componentWillMount () {
    // const { config, data, BID, mainSearch, menuType, dataManager } = this.props
    const { config, data } = this.props
    let _config = fromJS(config).toJS()
    // this.setState({
    //   title: config.setting.title,
    //   searchList: Utils.initMainSearch(config.search)
    // })
    let _data = null
    let _sync = config.setting.sync === 'true'
    if (config.setting.sync === 'true' && data) {
      _data = data[config.dataName] || []
      _sync = false
    }
    this.setState({
      config: _config,
      data: _data,
      arr_field: _config.columns.map(col => col.field).join(','),
      plot: _config.plot,
      sync: _sync,
      title: config.setting.title,
      search: Utils.initMainSearch(config.search)
    }, () => {
      if (config.setting.sync !== 'true') {
        this.loadData()
      } else if (config.setting.sync === 'true' && _data) {
        this.handleData()
      }
    })
  }
  /**
   * @description 校验图表的按钮组,如果为统计图表,计算图表字段
   */
  componentDidMount () {
    const { plot, data, config } = this.props
    let _state = {}
    let percentFields = []
    // const { plot, data, config } = this.props
    // let _state = {}
    // let percentFields = []
    if (plot.datatype === 'statistics' && (plot.chartType === 'line' || plot.chartType === 'bar')) {
      let result = this.getStaticMsg(data)
      _state.chartData = result.data
      _state.chartFields = result.chartFields
      _state.selectFields = result.selectFields
    // if (plot.datatype === 'statistics' && (plot.chartType === 'line' || plot.chartType === 'bar')) {
    //   let result = this.getStaticMsg(data)
    //   _state.chartData = result.data
    //   _state.chartFields = result.chartFields
    //   _state.selectFields = result.selectFields
      let _column = config.columns.filter(col => plot.InfoValue === col.field)[0]
    //   let _column = config.columns.filter(col => plot.InfoValue === col.field)[0]
      if (_column && _column.format === 'percent') {
        percentFields.push(plot.InfoValue)
        _state.percentFields = percentFields
      }
    //   if (_column && _column.format === 'percent') {
    //     percentFields.push(plot.InfoValue)
    //     _state.percentFields = percentFields
    //   }
      this.setState(_state, () => {
        this.viewrender()
      })
    } else {
      if (plot.chartType === 'line' || plot.chartType === 'bar') {
        try {
          plot.Yaxis.forEach(yaxis => {
            let _column = config.columns.filter(col => yaxis === col.field)[0]
            if (_column && _column.format === 'percent') {
              percentFields.push(_column.label)
            }
          })
        } catch {
          console.warn('Incorrect percentage setting')
        }
      }
      this.setState({ percentFields }, () => {
        this.viewrender()
      })
    }
    //   this.setState(_state, () => {
    //     this.viewrender()
    //   })
    // } else {
    //   if (plot.chartType === 'line' || plot.chartType === 'bar') {
    //     try {
    //       plot.Yaxis.forEach(yaxis => {
    //         let _column = config.columns.filter(col => yaxis === col.field)[0]
    //         if (_column && _column.format === 'percent') {
    //           percentFields.push(_column.label)
    //         }
    //       })
    //     } catch {
    //       console.warn('Incorrect percentage setting')
    //     }
    //   }
    //   this.setState({ percentFields }, () => {
    //     this.viewrender()
    //   })
    // }
  }
  /**
   * @description 图表数据更新,刷新内容
   */
  UNSAFE_componentWillReceiveProps (nextProps) {
    const { plot } = this.props
    if (!is(fromJS(this.props.data), fromJS(nextProps.data))) {
      let _state = {}
    const { sync, config } = this.state
      if (plot.datatype === 'statistics' && (plot.chartType === 'line' || plot.chartType === 'bar')) {
        let result = this.getStaticMsg(nextProps.data)
        _state.chartData = result.data
        _state.chartFields = result.chartFields
        _state.selectFields = result.selectFields
    if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) {
      let _data = []
      if (nextProps.data && nextProps.data[config.dataName]) {
        _data = nextProps.data[config.dataName] || []
      }
      this.setState(_state, () => {
      this.setState({sync: false, data: _data}, () => {
        this.handleData()
      })
    }
  }
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.state), fromJS(nextState))
  }
  handleData = () => {
    const { data, plot } = this.state
    if (plot.datatype === 'statistics') {
      let result = this.getStaticMsg(data)
      this.setState({
        chartData: result.data,
        chartFields: result.chartFields,
        selectFields: result.selectFields
      }, () => {
        let _element = document.getElementById(this.state.chartId)
        if (_element) {
          _element.innerHTML = ''
@@ -114,8 +157,41 @@
    }
  }
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
  async loadData () {
    const { mainSearch, BID, menuType, dataManager } = this.props
    const { config, arr_field, search } = this.state
    let searches = fromJS(search).toJS()
    if (mainSearch && mainSearch.length > 0) { // 主表搜索条件
      searches = [...mainSearch, ...searches]
    }
    this.setState({
      loading: true
    })
    let _orderBy = config.setting.order || ''
    let param = UtilsDM.getQueryDataParams(config.setting, config.customScript, arr_field, searches, _orderBy, '', '', BID, menuType, dataManager)
    let result = await Api.genericInterface(param)
    if (result.status) {
      this.setState({
        data: result.data.map((item, index) => {
          item.key = index
          return item
        }),
        loading: false
      })
    } else {
      this.setState({
        loading: false
      })
      notification.error({
        top: 92,
        message: result.message,
        duration: 10
      })
    }
  }
  /**
@@ -915,13 +991,13 @@
  }
  render() {
    const { plot, loading, config, BID, Tab } = this.props
    const { empty, chartFields, selectFields } = this.state
    const { loading, config, BID, Tab } = this.props
    const { title, plot, empty, chartFields, selectFields } = this.state
    return (
      <div className="custom-line-chart-plot-box">
        <searchLine />
        {plot.title ? <p className="chart-title">{plot.title}</p> : null}
        {title ? <p className="chart-title">{title}</p> : null}
        {loading ?
          <div className="loading-mask">
            <div className="ant-spin-blur"></div>
src/tabviews/custom/index.jsx
@@ -149,6 +149,7 @@
            `
          }
        })
        delete component.scripts
        if (component.setting && component.setting.interType === 'system') { // 使用系统函数
          component.setting.execute = component.setting.execute !== 'false'  // 默认sql是否执行,转为boolean 统一格式
src/templates/calendarconfig/index.jsx
@@ -103,6 +103,7 @@
    _config.MenuName = menu.MenuName || ''
    _config.MenuNo = menu.MenuNo || ''
    _config.OpenType = menu.PageParam ? menu.PageParam.OpenType : ''
    _config.easyCode = _config.easyCode || ''
    this.setState({
      openEdition: menu.open_edition || '',
src/templates/comtableconfig/index.jsx
@@ -105,12 +105,12 @@
    _config.MenuName = menu.MenuName || ''
    _config.MenuNo = menu.MenuNo || ''
    _config.OpenType = menu.PageParam ? menu.PageParam.OpenType : ''
    _config.easyCode = _config.easyCode || ''
    if (!_config.version || _config.version < '1.0') {
      // 配置默认值,兼容
      _config.version = '1.0'
      _config.Template = 'CommonTable'
      _config.easyCode = _config.easyCode || ''
  
      if (!_config.tabgroups) {
        _config.tabgroups = [{ uuid: 'tabs', sublist: [] }]
@@ -572,8 +572,9 @@
        ParentID: _config.ParentId,
        MenuID: menu.MenuID,
        MenuNo: _config.MenuNo,
        EasyCode: _config.easyCode,
        Template: _config.Template,
        // EasyCode: _config.easyCode || '',
        EasyCode: _config.easyCoded,
        Template: _config.Template || '',
        MenuName: _config.MenuName,
        PageParam: JSON.stringify({...menu.PageParam, Template: _config.Template, OpenType: _config.OpenType}),
        LongParam: _LongParam,
@@ -699,7 +700,6 @@
      }).then(resp => {
        if (resp === false) return
        let localParam = fromJS(param).toJS()
        Api.getSystemConfig(param).then(response => {
          if (response.status) {
            this.setState({
src/templates/comtableconfig/source.jsx
@@ -10,6 +10,7 @@
    type: 'system',
    Template: 'CommonTable',
    enabled: false,
    easyCode: '',
    setting: {
      actionfixed: false,
      columnfixed: false,
src/templates/sharecomponent/tablecomponent/index.jsx
@@ -99,7 +99,11 @@
              let _decimal = 0
              let _length = 50
              if (/^nvarchar/.test(_type)) {
                _length = +_type.match(/\d+/)[0] || 50
                try { // 存在max
                  _length = +_type.match(/\d+/)[0] || 50
                } catch {
                  _length = 2048
                }
                _type = 'text'
              } else if (/^int/.test(_type)) {
                _type = 'number'