king
2020-11-12 f830c733cbc071f023c9a9a4e1571b7c81d672bf
src/tabviews/custom/index.jsx
@@ -43,8 +43,6 @@
    config: null,         // 页面配置信息,包括组件等
    mainSearch: null,
    userConfig: null,     // 用户自定义设置
    arr_field: '',        // 使用 sPC_Get_TableData 时的查询字段集
    setting: null,        // 页面全局设置:数据源、按钮及显示列固定、主键等
    data: null,           // 列表数据集
    loading: false,       // 列表数据加载中
    visible: false,       // 标签页控制
@@ -67,12 +65,6 @@
      let config = ''
      let userConfig = null
      setTimeout(() => { // 延时加载状态
        this.setState({
          loadingview: false
        })
      }, 1500)
      try { // 配置信息解析
        config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
      } catch (e) {
@@ -89,11 +81,12 @@
          userConfig = null
        }
      }
      // 页面配置解析错误时提示
      if (!config) {
        this.setState({
          viewlost: true
          viewlost: true,
          loadingview: false
        })
        return
      }
@@ -102,6 +95,7 @@
      if (!config.enabled) {
        this.setState({
          viewlost: true,
          loadingview: false,
          lostmsg: this.state.dict['main.view.unenabled']
        })
        return
@@ -146,16 +140,24 @@
      })
      let params = []
      config.components = this.formatSetting(config.components, params, mainSearch, permAction)
      let BID = param && param.BID ? param.BID : ''
      config.components = this.formatSetting(config.components, params, mainSearch, permAction, BID)
      this.setState({
        BID: param && param.BID ? param.BID : '',
        BID: BID,
        userConfig: userConfig,
        setting: config.setting,
        config,
        mainSearch
      }, () => {
        this.loadmaindata(params)
        if (!params || params.length === 0) {
          setTimeout(() => { // 延时加载状态
            this.setState({
              loadingview: false
            })
          }, 1000)
        } else {
          this.loadmaindata(params)
        }
      })
    } else {
      this.setState({
@@ -207,7 +209,7 @@
  }
  // 格式化默认设置
  formatSetting = (components, params, mainSearch, permAction) => {
  formatSetting = (components, params, mainSearch, permAction, BID) => {
    return components.map(component => {
      if (component.type === 'tabs') {
        component.subtabs = component.subtabs.map(tab => {
@@ -266,7 +268,7 @@
      // dataName 系统生成的数据源名称
      // pageable 是否分页,组件属性,不分页的组件才可以统一查询
      if (component.floor === 1 && component.dataName && (!component.pageable || (component.pageable && !component.setting.laypage)) && component.setting.onload === 'true' && component.setting.sync === 'true') {
        let param = this.getDefaultParam(component, mainSearch)
        let param = this.getDefaultParam(component, mainSearch, BID)
        params.push(param)
      } else if (component.floor === 1) {
        component.setting.sync = 'false'
@@ -279,7 +281,7 @@
  /**
   * @description 获取系统存储过程 sPC_Get_TableData 的参数
   */
  getDefaultParam = (component, mainSearch) => {
  getDefaultParam = (component, mainSearch, BID) => {
    const { columns, search, setting, dataName, format } = component
    
    let searchlist = []
@@ -300,6 +302,7 @@
    let _dataresource = setting.dataresource
    let _customScript = setting.customScript
    if (setting.queryType === 'statistics' || _customScript) {
      let allSearch = Utils.getAllSearchOptions(searchlist)
      let regoptions = allSearch.map(item => {
@@ -313,10 +316,11 @@
        if (_dataresource && setting.queryType === 'statistics') {
          _dataresource = _dataresource.replace(item.reg, item.value)
        }
        if (_customScript) {
          _customScript = _customScript.replace(item.reg, item.value)
        }
        _customScript = _customScript.replace(item.reg, item.value)
      })
      _dataresource = _dataresource.replace(/@BID@/ig, BID)
      _customScript = _customScript.replace(/@BID@/ig, BID)
    }
    let _search = ''
@@ -353,7 +357,6 @@
   * @description 主表数据加载
   */ 
  loadmaindata = (params) => {
    if (!params || params.length === 0) return
    let LText_field = []
    let LText = params.map((item, index) => {
      let _sql = item.sql
@@ -381,6 +384,8 @@
    param.LText_field = Utils.formatOptions(param.LText_field)
    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
    param.secretkey = Utils.encrypt(param.LText, param.timestamp)
    this.setState({loading: true, loadingview: false})
    Api.getLocalConfig(param).then(result => {
      if (result.status) {
@@ -511,11 +516,11 @@
  render() {
    const { menuType, MenuNo } = this.props
    const { loadingview, viewlost, config } = this.state
    const { loadingview, viewlost, config, loading } = this.state
    return (
      <div className="custom-page-wrap" id={this.state.ContainerId} style={config ? config.style : null}>
        {loadingview && <Spin size="large" />}
        {(loadingview || loading) ? <Spin size="large" /> : null}
        <Row>{this.getComponents()}</Row>
        {MenuNo && options.sysType !== 'cloud' && menuType !== 'HS' ? <Button
          icon="copy"