king
2023-08-11 4adb8b8868aeed1f5f3b89ae269a7724c6b451ad
src/templates/sharecomponent/tablecomponent/index.jsx
@@ -6,8 +6,8 @@
import moment from 'moment'
import Api from '@/api'
import options from '@/store/options.js'
import Utils from '@/utils/utils.js'
import MKEmitter from '@/utils/events.js'
import { queryTableSql } from '@/utils/option.js'
import './index.scss'
@@ -33,15 +33,28 @@
  UNSAFE_componentWillMount () {
    const { config } = this.props
    let tables = config.tables ? fromJS(config.tables).toJS() : []
    window.GLOB.publicTables = tables
    this.setState({
      selectedTables: config.tables ? fromJS(config.tables).toJS() : []
      selectedTables: tables
    }, () => {
      this.gettableFields()
    })
  }
  componentDidMount () {
    MKEmitter.addListener('publicTableChange', this.publicTableChange)
    this.gettables()
  }
  publicTableChange = (table, type) => {
    if (type === 'plus') {
      this.onTableChange(table)
    } else if (type === 'del') {
      this.deleteTable(table)
    }
  }
  /**
@@ -60,8 +73,8 @@
    param.secretkey = Utils.encrypt(param.LText, param.timestamp)
    param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) // 云端数据验证
    if (options.cloudServiceApi) { // 且存在云端地址
      param.rduri = options.cloudServiceApi
    if (window.GLOB.cloudServiceApi) { // 且存在云端地址
      param.rduri = window.GLOB.cloudServiceApi
      param.userid = sessionStorage.getItem('CloudUserID') || ''
      param.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
    }
@@ -87,8 +100,8 @@
    let deffers = this.state.selectedTables.map((item, i) => {
      return new Promise(resolve => {
        let param = {func: 'sPC_Get_FieldName', TBName: item.TbName}
        if (options.cloudServiceApi) { // 且存在云端地址
          param.rduri = options.cloudServiceApi
        if (window.GLOB.cloudServiceApi) { // 且存在云端地址
          param.rduri = window.GLOB.cloudServiceApi
          param.userid = sessionStorage.getItem('CloudUserID') || ''
          param.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
        }
@@ -170,13 +183,17 @@
    let _table = tables.filter(item => item.TbName === value)[0]
    let isSelected = !!selectedTables.filter(cell => cell.TbName === value)[0]
    if (!isSelected) {
      let _tables = [...selectedTables, _table]
      window.GLOB.publicTables = _tables
      this.setState({
        selectedTables: [...selectedTables, _table]
        selectedTables: _tables
      })
      let _config = {...config, tables: [...selectedTables, _table]}
      let _config = {...config, tables: _tables}
      
      Api.getSystemConfig({func: 'sPC_Get_FieldName', TBName: value}).then(res => {
      Api.getCloudConfig({func: 'sPC_Get_FieldName', TBName: value}).then(res => {
        if (res.status) {
          let tabmsg = {
            tableName: _table.TbName,
@@ -248,6 +265,8 @@
    let _tables = selectedTables.filter(item => item.TbName !== table.TbName)
    let _fields = tableFields.filter(item => item.tableName !== table.TbName)
    window.GLOB.publicTables = _tables
    this.setState({
      selectedTables: _tables,
      tableFields: _fields
@@ -265,6 +284,7 @@
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('publicTableChange', this.publicTableChange)
  }
  render() {
@@ -276,7 +296,7 @@
        {/* 表名添加 */}
        <div className="ant-col ant-form-item-label">
          <label>
            <Tooltip placement="topLeft" title="此处可以添加页面配置相关的常用表,可通过工具栏中的添加按钮,可批量添加表格相关字段。">
            <Tooltip placement="topLeft" title="此处可以添加页面配置相关的常用表。">
              <QuestionCircleOutlined className="mk-form-tip" />
              表名
            </Tooltip>