| | |
| | | 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' |
| | | import VerifyCard from './verifycard' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import './index.scss' |
| | | |
| | | class DataSource extends Component { |
| | |
| | | this.setState({ |
| | | visible: true |
| | | }) |
| | | MKEmitter.emit('modalStatus', '数据源') |
| | | } |
| | | |
| | | verifySubmit = () => { |
| | |
| | | |
| | | 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*/`) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | res.show = config.setting.show || 'true' |
| | | res.advanceType = config.setting.advanceType || 'modal' |
| | | res.advanceWidth = config.setting.advanceWidth || 1000 |
| | | res.drawerPlacement = config.setting.drawerPlacement || 'right' |
| | | res.searchRatio = config.setting.searchRatio || 6 |
| | | res.searchLwidth = config.setting.searchLwidth !== undefined ? config.setting.searchLwidth : 33.3 |
| | | |
| | | this.setState({loading: false, visible: false}) |
| | | this.props.updateConfig({...config, ...res}) |
| | | |
| | | MKEmitter.emit('modalStatus', false) |
| | | }, () => { |
| | | this.setState({loading: false}) |
| | | }) |
| | |
| | | |
| | | return ( |
| | | <div className="model-datasource"> |
| | | <Icon type="setting" onClick={() => this.editDataSource()} /> |
| | | <SettingOutlined onClick={() => this.editDataSource()} /> |
| | | <Modal |
| | | wrapClassName="popview-modal" |
| | | title={'数据源配置'} |
| | | title="数据源配置" |
| | | visible={visible} |
| | | width={'75vw'} |
| | | maskClosable={false} |
| | | okText={dict['model.submit']} |
| | | onOk={this.verifySubmit} |
| | | confirmLoading={loading} |
| | | onCancel={() => { this.setState({ visible: false }) }} |
| | | onCancel={() => { MKEmitter.emit('modalStatus', false); this.setState({ visible: false }) }} |
| | | destroyOnClose |
| | | > |
| | | <VerifyCard |