| | |
| | | import PropTypes from 'prop-types' |
| | | import { fromJS } from 'immutable' |
| | | import { Form, Tabs, Row, Col, Input, Button, Popconfirm, notification, Modal, message, InputNumber, Radio, Typography } from 'antd' |
| | | import { StopTwoTone, CheckCircleTwoTone, EditOutlined, SwapOutlined, DeleteOutlined } from '@ant-design/icons' |
| | | import { StopTwoTone, CheckCircleTwoTone, EditOutlined, SwapOutlined, DeleteOutlined, BorderOutlined, CheckCircleOutlined, StopOutlined } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | |
| | | import MKEmitter from '@/utils/events.js' |
| | | import UniqueForm from './uniqueform' |
| | | import CustomScript from './customscript' |
| | | import MinView from '@/assets/img/minview.png' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import './index.scss' |
| | | |
| | |
| | | } |
| | | |
| | | state = { |
| | | visible: false, |
| | | scriptId: '', |
| | | verify: {}, |
| | | fields: [], |
| | | fieldLabel: {}, |
| | |
| | | dataIndex: 'position', |
| | | width: '10%', |
| | | render: (text, record) => { |
| | | let _text = '' |
| | | if (record.position === 'front') { |
| | | _text = 'sql前' |
| | | } else if (record.position === 'init') { |
| | | _text = '初始化' |
| | | if (record.position === 'init') { |
| | | return <span style={{color: 'orange'}}>初始化</span> |
| | | } else if (record.position === 'front') { |
| | | return <span style={{color: '#26C281'}}>sql前</span> |
| | | } else { |
| | | _text = 'sql后' |
| | | return <span style={{color: '#1890ff'}}>sql后</span> |
| | | } |
| | | return _text |
| | | } |
| | | }, |
| | | { |
| | |
| | | verify.scripts.push(values) |
| | | } |
| | | |
| | | MKEmitter.emit('editLineId', values.uuid) |
| | | |
| | | this.setState({ |
| | | verify: verify |
| | | }) |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { verify, scriptsColumns, uniqueColumns, activeKey, fields } = this.state |
| | | const { verify, scriptsColumns, uniqueColumns, activeKey, fields, visible } = this.state |
| | | const formItemLayout = { |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | |
| | | {verify.scripts.length ? <span className="count-tip">{verify.scripts.length}</span> : null} |
| | | </span> |
| | | } key="scripts"> |
| | | <BorderOutlined className="full-scripts" onClick={() => { |
| | | if (this.scriptsForm && (this.scriptsForm.state.editItem || (this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))))) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请保存自定义脚本!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | this.setState({visible: true, scriptId: ''}) |
| | | }}/> |
| | | <CustomScript |
| | | btn={verify} |
| | | usefulfields={fields} |
| | |
| | | </Form> |
| | | </TabPane> |
| | | </Tabs> |
| | | <Modal |
| | | wrapClassName="model-custom-scripts-modal" |
| | | title="自定义脚本" |
| | | visible={visible} |
| | | width={'95vw'} |
| | | maskClosable={false} |
| | | destroyOnClose |
| | | > |
| | | <img className="unfull-scripts" src={MinView} onClick={() => this.setState({visible: false, scriptId: ''})} alt=""/> |
| | | <div className="script-table-wrap"> |
| | | {verify.scripts.map(item => { |
| | | let title = item.sql.match(/^\s*\/\*.+\*\//) |
| | | title = title && title[0] ? title[0] : '' |
| | | let _text = title ? item.sql.replace(title, '') : item.sql |
| | | |
| | | let position = null |
| | | if (item.position === 'init') { |
| | | position = <span style={{color: 'orange'}}>初始化</span> |
| | | } else if (item.position === 'front') { |
| | | position = <span style={{color: '#26C281'}}>sql前</span> |
| | | } else { |
| | | position = <span style={{color: '#1890ff'}}>sql后</span> |
| | | } |
| | | |
| | | if (item.status === 'false') { |
| | | return ( |
| | | <div className="script-item" key={item.uuid}> |
| | | <div style={{cursor: 'not-allowed'}}> |
| | | {title ? <div style={{color: '#a50', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis'}}>{title}</div> : null} |
| | | <Paragraph copyable={{ text: item.sql }} ellipsis={{ rows: 4 }}>{_text}</Paragraph> |
| | | <div>{position} |
| | | <span style={{color: '#ff4d4f', marginLeft: '20px'}}> |
| | | 禁用 |
| | | <StopOutlined style={{marginLeft: '5px'}} /> |
| | | </span> |
| | | </div> |
| | | </div> |
| | | <div style={{height: '24px'}}></div> |
| | | </div> |
| | | ) |
| | | } else { |
| | | return ( |
| | | <div className={'script-item ' + (this.state.scriptId === item.uuid ? 'active' : '') } key={item.uuid}> |
| | | <div style={{cursor: 'pointer'}} onClick={() => { |
| | | this.scriptsFullForm.edit(item) |
| | | this.setState({scriptId: item.uuid}) |
| | | }}> |
| | | {title ? <div style={{color: '#a50', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis'}}>{title}</div> : null} |
| | | <Paragraph copyable={{ text: item.sql }} ellipsis={{ rows: 4 }}>{_text}</Paragraph> |
| | | <div>{position} |
| | | <span style={{color: '#26C281', marginLeft: '20px'}}> |
| | | 启用 |
| | | <CheckCircleOutlined style={{marginLeft: '5px'}}/> |
| | | </span> |
| | | </div> |
| | | </div> |
| | | <div style={{textAlign: 'right'}}> |
| | | <span className="operation-btn" onClick={() => this.handleStatus(item, 'scripts')} style={{color: '#8E44AD'}}><SwapOutlined /></span> |
| | | <Popconfirm |
| | | overlayClassName="popover-confirm" |
| | | title="确定删除吗?" |
| | | onConfirm={() => this.handleDelete(item, 'scripts') |
| | | }> |
| | | <span className="operation-btn" style={{color: '#ff4d4f'}}><DeleteOutlined /></span> |
| | | </Popconfirm> |
| | | </div> |
| | | </div> |
| | | ) |
| | | } |
| | | })} |
| | | </div> |
| | | <CustomScript |
| | | type="fullscreen" |
| | | btn={verify} |
| | | usefulfields={fields} |
| | | scripts={verify.scripts} |
| | | systemScripts={this.state.systemScripts} |
| | | scriptsChange={this.scriptsChange} |
| | | wrappedComponentRef={(inst) => this.scriptsFullForm = inst} |
| | | /> |
| | | </Modal> |
| | | </div> |
| | | ) |
| | | } |