| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { fromJS } from 'immutable' |
| | | import { Form, Tabs, Popconfirm, notification, Modal, Typography, Spin, message, Button, Input } from 'antd' |
| | | import { Form, Tabs, Popconfirm, notification, Modal, Typography, Spin, message, Button, Input, Switch } from 'antd' |
| | | import { StopOutlined, CheckCircleOutlined, TableOutlined, EditOutlined, SwapOutlined, DeleteOutlined, CopyOutlined, BorderOutlined, SnippetsOutlined } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | |
| | |
| | | subColumns: [], |
| | | activeKey: 'setting', |
| | | loading: false, |
| | | skip: false, |
| | | colLoading: false, |
| | | searchKey: '', |
| | | usefulfields: '', |
| | |
| | | } |
| | | |
| | | triggerConfirm = () => { |
| | | const { script, scriptValue, scripts } = this.state |
| | | const { script, scriptValue, scripts, skip } = this.state |
| | | let _scripts = fromJS(scripts).toJS() |
| | | |
| | | if (!scriptValue) { |
| | |
| | | _scripts.push(_script) |
| | | } |
| | | |
| | | this.setState({loading: true, editLineId}) |
| | | if (skip) { |
| | | this.setState({scripts: _scripts, script: null, scriptValue: '', editLineId}) |
| | | } else { |
| | | this.setState({loading: true, editLineId}) |
| | | |
| | | this.sqlverify(() => {this.setState({scripts: _scripts, script: null, scriptValue: '', loading: false})}, () => {this.setState({loading: false})}, 'script', _scripts) |
| | | this.sqlverify(() => {this.setState({scripts: _scripts, script: null, scriptValue: '', loading: false})}, () => {this.setState({loading: false})}, 'script', _scripts) |
| | | } |
| | | } |
| | | |
| | | updatefields = (columns) => { |
| | |
| | | |
| | | render() { |
| | | const { config } = this.props |
| | | const { columns, subColumns, median, setting, scripts, colColumns, scriptsColumns, activeKey, loading, searches, defaultsql, visible, pvisible, reload, script, scriptValue, searchKey, editLineId } = this.state |
| | | const { columns, subColumns, median, skip, setting, scripts, colColumns, scriptsColumns, activeKey, loading, searches, defaultsql, visible, pvisible, reload, script, scriptValue, searchKey, editLineId } = this.state |
| | | |
| | | return ( |
| | | <div className="model-data-source-wrap"> |
| | |
| | | }) |
| | | return |
| | | } |
| | | this.setState({visible: true, script: null, scriptValue: '', editLineId: ''}) |
| | | this.setState({visible: true, skip: false, script: null, scriptValue: '', editLineId: ''}) |
| | | }}/> : null} |
| | | <CustomScriptsForm |
| | | type={config.type} |
| | |
| | | setting={setting} |
| | | searches={searches} |
| | | defaultsql={defaultsql} |
| | | customScripts={scripts} |
| | | systemScripts={this.state.systemScripts} |
| | | scriptsChange={this.scriptsChange} |
| | | scriptSubmit={this.scriptSubmit} |
| | |
| | | <Button onClick={() => {this.setState({script: null, scriptValue: ''})}} style={{marginBottom: 15, marginLeft: 10}}> |
| | | 取消 |
| | | </Button> |
| | | <span style={{paddingLeft: '20px', fontSize: '12px'}}> |
| | | 强制保存: |
| | | <Switch checked={skip} size="small" onChange={() => this.setState({skip: !skip})}/> |
| | | </span> |
| | | </div> |
| | | <CodeMirror value={scriptValue} onChange={(val) => {this.setState({scriptValue: val})}}></CodeMirror> |
| | | </Modal> |