From dbc911dbb044895f98a49ef69ef5a5800a4aba3e Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 15 九月 2024 20:26:39 +0800 Subject: [PATCH] 2024-09-15 --- src/templates/sharecomponent/treesettingcomponent/settingform/datasource/index.jsx | 108 +++++++++++++----------------------------------------- 1 files changed, 26 insertions(+), 82 deletions(-) diff --git a/src/templates/sharecomponent/treesettingcomponent/settingform/datasource/index.jsx b/src/templates/sharecomponent/treesettingcomponent/settingform/datasource/index.jsx index 48382e0..064c117 100644 --- a/src/templates/sharecomponent/treesettingcomponent/settingform/datasource/index.jsx +++ b/src/templates/sharecomponent/treesettingcomponent/settingform/datasource/index.jsx @@ -2,11 +2,9 @@ import PropTypes from 'prop-types' import { Form, Row, Col, Input, Radio, Tooltip, notification, InputNumber } from 'antd' import { QuestionCircleOutlined } from '@ant-design/icons' -import moment from 'moment' -import Api from '@/api' import { formRule } from '@/utils/option.js' -import Utils from '@/utils/utils.js' +import { checkSQL } from '@/utils/utils-custom.js' import CodeMirror from '@/templates/zshare/codemirror' // import './index.scss' @@ -14,7 +12,6 @@ class SettingForm extends Component { static propTpyes = { - dict: PropTypes.object, // 瀛楀吀椤� menu: PropTypes.object, // 鑿滃崟淇℃伅 setting: PropTypes.object, // 鏁版嵁婧愰厤缃� inputSubmit: PropTypes.func // 瑙﹀彂鎻愪氦 @@ -62,7 +59,6 @@ } handleConfirm = () => { - const { setting } = this.props // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� return new Promise((resolve, reject) => { this.props.form.validateFieldsAndScroll((err, values) => { @@ -77,69 +73,12 @@ reject() return } else if (values.interType === 'system' && values.default !== 'false' && values.dataresource) { - let _quot = values.dataresource.match(/'{1}/g) - let _lparen = values.dataresource.match(/\({1}/g) - let _rparen = values.dataresource.match(/\){1}/g) + let pass = checkSQL(values.dataresource) - _quot = _quot ? _quot.length : 0 - _lparen = _lparen ? _lparen.length : 0 - _rparen = _rparen ? _rparen.length : 0 - - if (_quot % 2 !== 0) { - notification.warning({ - top: 92, - message: '鏁版嵁婧愪腑\'蹇呴』鎴愬鍑虹幇', - duration: 5 - }) - reject() - return - } else if (_lparen !== _rparen) { - notification.warning({ - top: 92, - message: '鏁版嵁婧愪腑()蹇呴』鎴愬鍑虹幇', - duration: 5 - }) - reject() - return - } else if (/--/ig.test(values.dataresource)) { - notification.warning({ - top: 92, - message: '鏁版嵁婧愪腑锛屼笉鍙嚭鐜板瓧绗� -- 锛屾敞閲婅鐢� /*鍐呭*/', - duration: 5 - }) + if (!pass) { reject() return } - - let error = Utils.verifySql(values.dataresource) - - if (error) { - notification.warning({ - top: 92, - message: '鏁版嵁婧愪腑涓嶅彲浣跨敤' + error, - duration: 5 - }) - reject() - return - } - } - - // 鏁版嵁婧愪繚瀛� - if ( - values.interType === 'system' && values.default !== 'false' && - /[^\s]+\s+[^\s]+/ig.test(values.dataresource) && setting.dataresource !== values.dataresource - ) { - let param = { - func: 's_DataSrc_Save', - LText: values.dataresource, - MenuID: this.props.menu.MenuID - } - - param.LText = Utils.formatOptions(param.LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - Api.genericInterface(param) } resolve(values) @@ -175,7 +114,7 @@ } render() { - const { setting, dict, menu } = this.props + const { setting, menu } = this.props const { getFieldDecorator } = this.props.form const { interType, funcRules, funcTooltip } = this.state @@ -200,7 +139,7 @@ rules: [ { required: true, - message: dict['form.required.input'] + '琛ㄥ悕!' + message: '璇疯緭鍏ヨ〃鍚�!' }, { max: 50, @@ -217,7 +156,7 @@ rules: [ { required: true, - message: dict['form.required.input'] + '鏍囬!' + message: '璇疯緭鍏ユ爣棰�!' }, { max: formRule.input.max, @@ -228,13 +167,13 @@ </Form.Item> </Col> <Col span={8}> - <Form.Item label={dict['header.form.intertype']}> + <Form.Item label="鎺ュ彛绫诲瀷"> {getFieldDecorator('interType', { initialValue: interType, rules: [ { required: true, - message: dict['form.required.select'] + dict['header.form.intertype'] + '!' + message: '璇烽�夋嫨鎺ュ彛绫诲瀷!' } ] })( @@ -246,19 +185,24 @@ </Form.Item> </Col> {interType === 'outer' ? <Col span={8}> - <Form.Item label={dict['header.form.sysInterface']}> + <Form.Item label={ + <Tooltip placement="topLeft" title="鍗曠偣鐧诲綍绯荤粺"> + <QuestionCircleOutlined className="mk-form-tip" /> + 绯荤粺鎺ュ彛 + </Tooltip> + }> {getFieldDecorator('sysInterface', { initialValue: setting.sysInterface || 'false', rules: [ { required: true, - message: dict['form.required.select'] + dict['header.form.sysInterface'] + '!' + message: '璇烽�夋嫨绯荤粺鎺ュ彛!' }, ] })( <Radio.Group onChange={(e) => {this.onRadioChange(e, 'sysInterface')}}> - <Radio value="true">{dict['model.true']}</Radio> - <Radio value="false">{dict['model.false']}</Radio> + <Radio value="true">鏄�</Radio> + <Radio value="false">鍚�</Radio> </Radio.Group>)} </Form.Item> </Col> : null} @@ -274,7 +218,7 @@ rules: [ { required: true, - message: dict['form.required.input'] + '鍐呴儴鍑芥暟!' + message: '璇疯緭鍏ュ唴閮ㄥ嚱鏁�!' }, { max: formRule.func.max, @@ -292,7 +236,7 @@ rules: [ { required: true, - message: dict['form.required.input'] + '鎺ュ彛鍦板潃!' + message: '璇疯緭鍏ユ帴鍙e湴鍧�!' } ] })(<TextArea rows={2}/>)} @@ -328,7 +272,7 @@ </Col> : null} <Col span={8}> <Form.Item label={ - <Tooltip placement="topLeft" title={'鏁版嵁鍊煎瓧娈点��'}> + <Tooltip placement="topLeft" title="鏁版嵁鍊煎瓧娈点��"> <QuestionCircleOutlined className="mk-form-tip" /> Value </Tooltip> @@ -338,7 +282,7 @@ rules: [ { required: true, - message: dict['form.required.input'] + 'Value!' + message: '璇疯緭鍏alue!' }, { pattern: formRule.field.pattern, @@ -363,7 +307,7 @@ rules: [ { required: true, - message: dict['form.required.input'] + 'Label!' + message: '璇疯緭鍏abel!' }, { pattern: formRule.field.pattern, @@ -378,7 +322,7 @@ </Col> <Col span={8}> <Form.Item label={ - <Tooltip placement="topLeft" title={'鐖剁骇瀛楁銆�'}> + <Tooltip placement="topLeft" title="鐖剁骇瀛楁銆�"> <QuestionCircleOutlined className="mk-form-tip" /> Parent </Tooltip> @@ -388,7 +332,7 @@ rules: [ { required: true, - message: dict['form.required.input'] + 'Label!' + message: '璇疯緭鍏abel!' }, { pattern: formRule.field.pattern, @@ -408,7 +352,7 @@ rules: [ { required: true, - message: dict['form.required.input'] + '鎺掑簭!' + message: '璇疯緭鍏ユ帓搴�!' }, { max: formRule.input.max, @@ -448,7 +392,7 @@ rules: [ { required: true, - message: dict['form.required.input'] + '瀹藉害!' + message: '璇疯緭鍏ュ搴�!' } ] })(<InputNumber min={2} max={12} precision={0} />)} -- Gitblit v1.8.0