king
2020-09-18 51a60b5cb00fdeaf9e42c29341242460bf2154e8
src/tabviews/custom/index.jsx
@@ -130,65 +130,8 @@
        }
      })
      // 权限过滤
      if (this.props.menuType !== 'HS') {
        config.components.forEach(component => {
          if (component.action) {
            component.action = component.action.filter(item => permAction[item.uuid])
          }
        })
      }
      let params = []
      config.components.forEach(component => {
        if (!component.format) return // 没有动态数据
        let _customScript = ''
        component.scripts && component.scripts.forEach(script => {
          if (script.status !== 'false') {
            _customScript += `
            ${script.sql}
            `
          }
        })
        delete component.scripts
        if (component.setting && component.setting.interType === 'system') { // 使用系统函数
          component.setting.execute = component.setting.execute !== 'false'  // 默认sql是否执行,转为boolean 统一格式
          component.setting.laypage = component.setting.laypage === 'true'   // 是否分页,转为boolean 统一格式
          if (!component.setting.execute) {
            component.setting.dataresource = ''
          }
          if (/\s/.test(component.setting.dataresource)) {
            component.setting.dataresource = '(' + component.setting.dataresource + ') tb'
          }
          if (this.props.dataManager) { // 数据权限
            component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*')
            component.setting.dataresource = component.setting.dataresource.replace(/@\$/ig, '*/')
            _customScript = _customScript.replace(/\$@/ig, '/*')
            _customScript = _customScript.replace(/@\$/ig, '*/')
          } else {
            component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '')
            _customScript = _customScript.replace(/@\$|\$@/ig, '')
          }
        }
        if (component.setting) {
          component.setting.customScript = _customScript // 整理后自定义脚本
        }
        // format   数据格式 array 或 object
        // dataName 系统生成的数据源名称
        // pageable 是否分页,组件属性,不分页的组件才可以统一查询
        if (component.format && component.dataName && !component.pageable && component.setting.interType === 'system' && component.setting.onload === 'true' && component.setting.sync === 'true') {
          let param = this.getDefaultParam(component, mainSearch)
          params.push(param)
        } else {
          component.setting.sync = 'false'
        }
      })
      config.components = this.formatSetting(config.components, params, mainSearch, permAction)
      this.setState({
        BID: param && param.BID ? param.BID : '',
@@ -211,6 +154,75 @@
        duration: 5
      })
    }
  }
  // 格式化默认设置
  formatSetting = (components, params, mainSearch, permAction) => {
    return components.map(component => {
      if (component.type === 'tabs') {
        component.subtabs = component.subtabs.map(tab => {
          tab.components = this.formatSetting(tab.components, [], [], permAction)
          return tab
        })
      }
      // 权限过滤
      if (this.props.menuType !== 'HS') {
        if (component.action) {
          component.action = component.action.filter(item => permAction[item.uuid])
        }
      }
      if (!component.format) return component // 没有动态数据  数据格式 array 或 object
      let _customScript = ''
      component.scripts && component.scripts.forEach(script => {
        if (script.status !== 'false') {
          _customScript += `
          ${script.sql}
          `
        }
      })
      delete component.scripts
      if (component.setting && component.setting.interType === 'system') { // 使用系统函数
        component.setting.execute = component.setting.execute !== 'false'  // 默认sql是否执行,转为boolean 统一格式
        component.setting.laypage = component.setting.laypage === 'true'   // 是否分页,转为boolean 统一格式
        if (!component.setting.execute) {
          component.setting.dataresource = ''
        }
        if (/\s/.test(component.setting.dataresource)) {
          component.setting.dataresource = '(' + component.setting.dataresource + ') tb'
        }
        if (this.props.dataManager) { // 数据权限
          component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*')
          component.setting.dataresource = component.setting.dataresource.replace(/@\$/ig, '*/')
          _customScript = _customScript.replace(/\$@/ig, '/*')
          _customScript = _customScript.replace(/@\$/ig, '*/')
        } else {
          component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '')
          _customScript = _customScript.replace(/@\$|\$@/ig, '')
        }
      }
      if (component.setting) {
        component.setting.customScript = _customScript // 整理后自定义脚本
      }
      // floor    组件的层级
      // dataName 系统生成的数据源名称
      // pageable 是否分页,组件属性,不分页的组件才可以统一查询
      if (component.floor === 1 && component.dataName && !component.pageable && component.setting.interType === 'system' && component.setting.onload === 'true' && component.setting.sync === 'true') {
        let param = this.getDefaultParam(component, mainSearch)
        params.push(param)
      } else {
        component.setting.sync = 'false'
      }
      return component
    })
  }
  /**
@@ -310,7 +322,6 @@
        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,'${_sql}' as LText,'${_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 = {
@@ -427,7 +438,7 @@
    return config.components.map(item => {
      if (item.type === 'bar' || item.type === 'line') {
        return (
          <Col key={item.uuid}>
          <Col span={item.setting.span} key={item.uuid}>
            <AntvBarAndLine config={item} data={data} BID={BID} mainSearch={mainSearch} menuType={menuType} dataManager={dataManager} />
          </Col>
        )
@@ -442,9 +453,9 @@
    const { loadingview, viewlost } = this.state
    return (
      <div className="calendar-page" id={this.state.ContainerId}>
      <div className="custom-page-wrap" id={this.state.ContainerId}>
        {loadingview && <Spin size="large" />}
        <Row>{this.getComponents()}</Row>
        <Row gutter={8}>{this.getComponents()}</Row>
        {options.sysType !== 'cloud' ? <Button
          icon="copy"
          shape="circle"