king
2022-02-09 d59f518f466274b2caeb2e01c10c92deafe7c93b
src/templates/sharecomponent/settingcalcomponent/index.jsx
@@ -1,7 +1,8 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Icon, Modal } from 'antd'
import { Modal } from 'antd'
import { SettingOutlined } from '@ant-design/icons'
import zhCN from '@/locales/zh-CN/model.js'
import enUS from '@/locales/en-US/model.js'
@@ -12,12 +13,11 @@
  static propTpyes = {
    config: PropTypes.any,
    MenuID: PropTypes.string,
    tableFields: PropTypes.any,
    updateConfig: PropTypes.func
  }
  state = {
    dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    sourcelist: [],
    visible: false,
    loading: false,
@@ -45,6 +45,17 @@
    this.setState({loading: true})
    this.verifyRef.submitDataSource().then(res => {
      if (window.GLOB.funcs && window.GLOB.funcs.length > 0) {
        window.GLOB.funcs.forEach(m => {
          let reg = new RegExp('\\$ex@' + m.func_code + '@ex\\$', 'ig')
          res.scripts.forEach(item => {
            item.sql = item.sql.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`)
          })
          if (res.setting.dataresource) {
            res.setting.dataresource = res.setting.dataresource.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`)
          }
        })
      }
      this.setState({loading: false, visible: false})
      this.props.updateConfig({...config, ...res})
@@ -59,14 +70,13 @@
    return (
      <div className="model-datasource">
        <Icon type="setting" onClick={() => this.editDataSource()} />
        <SettingOutlined onClick={() => this.editDataSource()} />
        <Modal
          wrapClassName="popview-modal"
          title={'数据源配置'}
          visible={visible}
          width={'75vw'}
          maskClosable={false}
          style={{minWidth: '900px', maxWidth: '1200px'}}
          okText={dict['model.submit']}
          onOk={this.verifySubmit}
          confirmLoading={loading}
@@ -76,7 +86,6 @@
          <VerifyCard
            dict={dict}
            config={config}
            tableFields={this.props.tableFields}
            menuId={this.props.config.uuid}
            searches={config.search}
            wrappedComponentRef={(inst) => this.verifyRef = inst}