From 063b983daaf51a7f1e8677bde1e9c0e618866c91 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 21 二月 2020 10:30:19 +0800 Subject: [PATCH] 2020-02-21 --- src/templates/tableshare/verifycard/customscript/index.jsx | 48 +++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 39 insertions(+), 9 deletions(-) diff --git a/src/templates/tableshare/verifycard/customscript/index.jsx b/src/templates/tableshare/verifycard/customscript/index.jsx index 9928e47..549ba8c 100644 --- a/src/templates/tableshare/verifycard/customscript/index.jsx +++ b/src/templates/tableshare/verifycard/customscript/index.jsx @@ -1,15 +1,15 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Row, Col, Input, Button } from 'antd' +import { Form, Row, Col, Input, Button, notification } from 'antd' import './index.scss' const { TextArea } = Input class CustomForm extends Component { static propTpyes = { - dict: PropTypes.object, // 瀛楀吀椤� - fields: PropTypes.array, // 琛ㄥ崟 - scriptsChange: PropTypes.func // 琛ㄥ崟 + dict: PropTypes.object, // 瀛楀吀椤� + usefulfields: PropTypes.string, // 鍙敤瀛楁 + scriptsChange: PropTypes.func // 琛ㄥ崟 } state = { @@ -33,6 +33,37 @@ if (!err) { values.uuid = this.state.editItem ? this.state.editItem.uuid : '' + let _quot = values.sql.match(/'{1}/g) + let _lparen = values.sql.match(/\({1}/g) + let _rparen = values.sql.match(/\){1}/g) + + _quot = _quot ? _quot.length : 0 + _lparen = _lparen ? _lparen.length : 0 + _rparen = _rparen ? _rparen.length : 0 + + if (_quot % 2 !== 0) { + notification.warning({ + top: 92, + message: 'sql涓璡'蹇呴』鎴愬鍑虹幇', + duration: 10 + }) + return + } else if (_lparen !== _rparen) { + notification.warning({ + top: 92, + message: 'sql涓�()蹇呴』鎴愬鍑虹幇', + duration: 10 + }) + return + } else if (/--/ig.test(values.sql)) { + notification.warning({ + top: 92, + message: '鑷畾涔塻ql璇彞涓紝涓嶅彲鍑虹幇瀛楃 -- 锛屾敞閲婅鐢� /*鍐呭*/', + duration: 10 + }) + return + } + this.props.scriptsChange(values) this.setState({ editItem: null @@ -45,7 +76,7 @@ } render() { - const { fields } = this.props + const { usefulfields } = this.props const { getFieldDecorator } = this.props.form const formItemLayout = { labelCol: { @@ -57,14 +88,13 @@ sm: { span: 16 } } } - let _fields = fields.map(item => item.field) return ( <Form {...formItemLayout} className="verify-form" id="verifycard2"> <Row gutter={24}> - {fields && fields.length > 0 ? <Col span={21} className="sqlfield"> - <Form.Item label={'琛ㄥ崟瀛楁'}> - {_fields.join(', ')} + {usefulfields ? <Col span={21} className="sqlfield"> + <Form.Item label={'鍙敤瀛楁'}> + {usefulfields} </Form.Item> </Col> : null} <Col span={21} className="sql"> -- Gitblit v1.8.0