From a7813a33fc5f60ea995dfe0f09f52243e2ccfbb2 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 22 二月 2024 16:28:11 +0800 Subject: [PATCH] 2024-02-22 --- src/menu/datasource/verifycard/customscript/index.jsx | 87 ++++--------------------------------------- 1 files changed, 9 insertions(+), 78 deletions(-) diff --git a/src/menu/datasource/verifycard/customscript/index.jsx b/src/menu/datasource/verifycard/customscript/index.jsx index adb3ad7..7c60348 100644 --- a/src/menu/datasource/verifycard/customscript/index.jsx +++ b/src/menu/datasource/verifycard/customscript/index.jsx @@ -6,7 +6,7 @@ import Toast from 'antd-mobile/es/components/toast' import Dialog from 'antd-mobile/es/components/dialog' -import Utils from '@/utils/utils.js' +import { checkSQL, getSearchFields } from '@/utils/utils-custom.js' import CodeMirror from '@/templates/zshare/codemirror' import MKEmitter from '@/utils/events.js' import './index.scss' @@ -33,41 +33,17 @@ UNSAFE_componentWillMount() { const { searches } = this.props - this.getSearchField(searches) + this.setState({ + usefulFields: getSearchFields(searches) + }) } UNSAFE_componentWillReceiveProps (nextProps) { if (!is(fromJS(this.props.searches), fromJS(nextProps.searches))) { - this.getSearchField(nextProps.searches) + this.setState({ + usefulFields: getSearchFields(nextProps.searches) + }) } - } - - getSearchField = (searches) => { - let _usefulFields = [] - searches.forEach(item => { - if (['dateweek', 'datemonth'].includes(item.type)) { - _usefulFields.push(item.key) - _usefulFields.push(item.key + '1') - } else if (item.type === 'daterange') { - let _skey = item.key - let _ekey = item.key + '1' - - if (/,/.test(item.key)) { - _skey = item.key.split(',')[0] - _ekey = item.key.split(',')[1] - } - _usefulFields.push(_skey) - _usefulFields.push(_ekey) - } else if (item.type === 'date' && _usefulFields.includes(item.key)) { - _usefulFields.push(item.key + '1') - } else { - _usefulFields.push(item.key) - } - }) - - this.setState({ - usefulFields: _usefulFields.join(', ') - }) } edit = (record) => { @@ -107,54 +83,9 @@ 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) + let pass = checkSQL(values.sql, 'customscript') - _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: 5 - }) - return - } else if (_lparen !== _rparen) { - notification.warning({ - top: 92, - message: 'sql涓�()蹇呴』鎴愬鍑虹幇', - duration: 5 - }) - return - } else if (/--/ig.test(values.sql)) { - notification.warning({ - top: 92, - message: '鑷畾涔塻ql璇彞涓紝涓嶅彲鍑虹幇瀛楃 -- 锛屾敞閲婅鐢� /*鍐呭*/', - duration: 5 - }) - return - } else if (/,,/ig.test(values.sql)) { - notification.warning({ - top: 92, - message: '鑷畾涔塻ql璇彞涓紝涓嶅彲鍑虹幇杩炵画鐨勮嫳鏂囬�楀彿锛�,,锛�', - duration: 5 - }) - return - } - - let error = Utils.verifySql(values.sql, 'customscript') - - if (error) { - notification.warning({ - top: 92, - message: 'sql涓笉鍙娇鐢�' + error, - duration: 5 - }) - return - } + if (!pass) return if (skip) { this.setState({ -- Gitblit v1.8.0