From c4143d291e70b3ccff023a5a3e09f49889f5daa0 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 03 十一月 2023 21:48:34 +0800 Subject: [PATCH] 2023-11-03 --- src/templates/zshare/modalform/index.jsx | 12 src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx | 69 --- src/components/header/index.jsx | 3 src/templates/zshare/verifycard/callbackcustomscript/index.jsx | 72 --- src/menu/datasource/verifycard/customscript/index.jsx | 70 --- src/utils/utils-custom.js | 147 +++++++ src/templates/zshare/verifycard/customscript/index.jsx | 70 --- src/views/menudesign/menuform/index.jsx | 14 src/tabviews/custom/popview/index.jsx | 18 src/views/tabledesign/index.jsx | 2 src/views/tabledesign/menuform/index.jsx | 14 src/tabviews/basetable/index.jsx | 2 src/templates/zshare/verifycard/customform/index.jsx | 70 --- src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx | 70 --- src/menu/components/table/edit-table/columns/editColumn/index.jsx | 14 src/views/menudesign/index.jsx | 2 src/views/tabledesign/menuform/index.scss | 16 src/utils/utils.js | 40 - src/views/menudesign/menuform/index.scss | 17 src/tabviews/custom/components/card/cardcellList/index.jsx | 2 src/templates/sharecomponent/actioncomponent/verifyprint/index.jsx | 2 src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx | 53 -- src/menu/datasource/verifycard/settingform/index.jsx | 60 -- src/templates/sharecomponent/treesettingcomponent/settingform/datasource/index.jsx | 53 -- src/menu/components/share/actioncomponent/index.jsx | 2 src/tabviews/zshare/actionList/printbutton/index.jsx | 98 ++- src/tabviews/custom/index.jsx | 2 src/menu/components/table/edit-table/columns/tableIn/customscript/index.jsx | 70 --- src/templates/sharecomponent/actioncomponent/verifyexcelout/datasource/index.jsx | 53 -- src/templates/zshare/customscript/index.jsx | 73 --- src/templates/sharecomponent/searchcomponent/searchform/index.jsx | 12 31 files changed, 331 insertions(+), 871 deletions(-) diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx index 9269928..fc4d28c 100644 --- a/src/components/header/index.jsx +++ b/src/components/header/index.jsx @@ -328,6 +328,7 @@ trdItem.type = PageParam.Template || 'CommonTable' trdItem.OpenType = PageParam.OpenType || 'newtab' trdItem.hidden = PageParam.hidden || 'false' + trdItem.menuColor = PageParam.menuColor || '' if (trdItem.type === 'NewPage') { trdItem.OpenType = 'newpage' @@ -706,7 +707,7 @@ <div className="title" onClick={e => e.stopPropagation()}>{cell.MenuName}</div> <div className="menu-detail"> {cell.children && cell.children.map(m => ( - <div key={m.MenuID} title={m.MenuName} onClick={() => {this.changeVerMenu(m)}}> + <div key={m.MenuID} title={m.MenuName} style={m.menuColor ? {color: m.menuColor} : null} onClick={() => {this.changeVerMenu(m)}}> {m.MenuName} </div> ))} diff --git a/src/menu/components/share/actioncomponent/index.jsx b/src/menu/components/share/actioncomponent/index.jsx index a66f2fa..e33d65e 100644 --- a/src/menu/components/share/actioncomponent/index.jsx +++ b/src/menu/components/share/actioncomponent/index.jsx @@ -136,7 +136,7 @@ changeBtnStyle = (element) => { let _style = element.style ? fromJS(element.style).toJS() : {} - let options = ['font', 'border', 'background', 'margin', 'padding'] + let options = ['font', 'border', 'background', 'margin', 'padding', 'minHeight'] this.setState({ card: element diff --git a/src/menu/components/table/edit-table/columns/editColumn/index.jsx b/src/menu/components/table/edit-table/columns/editColumn/index.jsx index ccd72fa..1077a06 100644 --- a/src/menu/components/table/edit-table/columns/editColumn/index.jsx +++ b/src/menu/components/table/edit-table/columns/editColumn/index.jsx @@ -6,6 +6,7 @@ import Api from '@/api' import Utils from '@/utils/utils.js' +import { checkSQL } from '@/utils/utils-custom.js' import { getColumnForm } from './formconfig' import asyncComponent from '@/utils/asyncComponent' import { formRule } from '@/utils/option.js' @@ -521,16 +522,9 @@ } if (values.dataSource) { - let error = Utils.verifySql(values.dataSource) - - if (error) { - notification.warning({ - top: 92, - message: '鏁版嵁婧愪腑涓嶅彲浣跨敤' + error, - duration: 5 - }) - return - } + let pass = checkSQL(values.dataSource) + + if (!pass) return } if (values.editType === 'select' && values.resourceType === '1' && values.dataSource) { diff --git a/src/menu/components/table/edit-table/columns/tableIn/customscript/index.jsx b/src/menu/components/table/edit-table/columns/tableIn/customscript/index.jsx index 78760b7..ed62fd1 100644 --- a/src/menu/components/table/edit-table/columns/tableIn/customscript/index.jsx +++ b/src/menu/components/table/edit-table/columns/tableIn/customscript/index.jsx @@ -3,8 +3,8 @@ import { Form, Row, Col, Button, notification, Modal, Tooltip, Radio, Select, Switch } from 'antd' import { QuestionCircleOutlined } from '@ant-design/icons' -import Utils from '@/utils/utils.js' import Api from '@/api' +import { checkSQL } from '@/utils/utils-custom.js' import CodeMirror from '@/templates/zshare/codemirror' import './index.scss' @@ -95,73 +95,9 @@ values.status = editItem.status || 'true' } - 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 - } else if (/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig.test(values.sql)) { - let list = values.sql.match(/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig) - let errors = [] - list.forEach(str => { - str = str.replace(/^\s/, '') - let strs = str.match(/(\s|=)[a-z0-9_]+\./ig) - if (strs.length === 2 && (strs[0].replace(/\s|\./g, '') === strs[1].replace(/\s|\./g, ''))) { - errors.push(str) - } - }) - - if (errors.length > 0) { - notification.warning({ - top: 92, - message: '涓嶅彲浣跨敤鍚屼竴涓〃瀛楁杩涜鍏宠仈锛�' + errors.join('銆�'), - 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 let sheet = btn.sheet.replace(/(.*)\.(.*)\.|@db@/ig, '') let tail = ` diff --git a/src/menu/datasource/verifycard/customscript/index.jsx b/src/menu/datasource/verifycard/customscript/index.jsx index 8f28de4..e1f4766 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 } from '@/utils/utils-custom.js' import CodeMirror from '@/templates/zshare/codemirror' import MKEmitter from '@/utils/events.js' import './index.scss' @@ -107,73 +107,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 - } else if (/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig.test(values.sql)) { - let list = values.sql.match(/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig) - let errors = [] - list.forEach(str => { - str = str.replace(/^\s/, '') - let strs = str.match(/(\s|=)[a-z0-9_]+\./ig) - if (strs.length === 2 && (strs[0].replace(/\s|\./g, '') === strs[1].replace(/\s|\./g, ''))) { - errors.push(str) - } - }) - - if (errors.length > 0) { - notification.warning({ - top: 92, - message: '涓嶅彲浣跨敤鍚屼竴涓〃瀛楁杩涜鍏宠仈锛�' + errors.join('銆�'), - 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({ diff --git a/src/menu/datasource/verifycard/settingform/index.jsx b/src/menu/datasource/verifycard/settingform/index.jsx index a97fa31..5f5d523 100644 --- a/src/menu/datasource/verifycard/settingform/index.jsx +++ b/src/menu/datasource/verifycard/settingform/index.jsx @@ -5,8 +5,8 @@ import { QuestionCircleOutlined, PlusOutlined } from '@ant-design/icons' import { formRule } from '@/utils/option.js' -import Utils from '@/utils/utils.js' import MenuUtils from '@/utils/utils-custom.js' +import { checkSQL } from '@/utils/utils-custom.js' import CodeMirror from '@/templates/zshare/codemirror' import KeyInterface from '@/components/keyInterface' import './index.scss' @@ -108,56 +108,9 @@ // 鏁版嵁婧愬墠绔獙璇� if (values.interType === 'system' && values.execute !== '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 - }) - reject() - return - } else if (/,,/ig.test(values.dataresource)) { - notification.warning({ - top: 92, - message: '鏁版嵁婧愪腑锛屼笉鍙嚭鐜拌繛缁殑鑻辨枃閫楀彿锛�,,锛�', - duration: 5 - }) - reject() - return - } - - let error = Utils.verifySql(values.dataresource) - - if (error) { - notification.warning({ - top: 92, - message: '鏁版嵁婧愪腑涓嶅彲浣跨敤' + error, - duration: 5 - }) + if (!pass) { reject() return } @@ -521,12 +474,7 @@ </Form.Item> </Col> : null} {config.pageable && setting.laypage !== 'false' ? <Col span={8}> - <Form.Item label={ - <Tooltip placement="topLeft" title="閫夋嫨鍒嗛〉鏃舵湁鏁堛��"> - <QuestionCircleOutlined className="mk-form-tip" /> - 姣忛〉鏁伴噺 - </Tooltip> - }> + <Form.Item label="姣忛〉鏁伴噺"> {getFieldDecorator('pageSize', { initialValue: setting.pageSize || 10, rules: [ diff --git a/src/tabviews/basetable/index.jsx b/src/tabviews/basetable/index.jsx index 6e2c374..565fea4 100644 --- a/src/tabviews/basetable/index.jsx +++ b/src/tabviews/basetable/index.jsx @@ -516,6 +516,8 @@ getPrinter = (item, parentId) => { let _item = window.GLOB.UserCacheMap.get(parentId + item.uuid) + item.verify.logLabel = item.logLabel + if (_item) { item.printer = _item.printer || '' item.verify.defaultPrinter = _item.printer || '' diff --git a/src/tabviews/custom/components/card/cardcellList/index.jsx b/src/tabviews/custom/components/card/cardcellList/index.jsx index 5ca4716..c9f4fe3 100644 --- a/src/tabviews/custom/components/card/cardcellList/index.jsx +++ b/src/tabviews/custom/components/card/cardcellList/index.jsx @@ -813,7 +813,7 @@ val += _val }) - } else if (data && data.$$empty) { + } else if (data && data.$$empty && /@.*@/.test(card.formula)) { val = '' } else if (data) { let _val = card.formula diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index 7fea2ad..373d6df 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -990,6 +990,8 @@ getPrinter = (item, parentId) => { let _item = window.GLOB.UserCacheMap.get(parentId + item.uuid) + item.verify.logLabel = item.logLabel + if (_item) { item.printer = _item.printer || '' item.verify.defaultPrinter = _item.printer || '' diff --git a/src/tabviews/custom/popview/index.jsx b/src/tabviews/custom/popview/index.jsx index b2a01d8..f7e15a4 100644 --- a/src/tabviews/custom/popview/index.jsx +++ b/src/tabviews/custom/popview/index.jsx @@ -699,24 +699,6 @@ return cell } - getPrinter = (item, parentId) => { - let _item = window.GLOB.UserCacheMap.get(parentId + item.uuid) - - if (_item) { - item.printer = _item.printer || '' - item.verify.defaultPrinter = _item.printer || '' - if (item.verify.printerTypeList && _item.printerList) { - item.verify.printerTypeList = item.verify.printerTypeList.map(cell => { - cell.printer = _item.printerList[cell.Value] || '' - - return cell - }) - } - } - - return item - } - // 鏍煎紡鍖栭粯璁よ缃� formatSetting = (components, params, regs, balMap) => { let delay = 20 diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx index b55792d..a6a037c 100644 --- a/src/tabviews/zshare/actionList/printbutton/index.jsx +++ b/src/tabviews/zshare/actionList/printbutton/index.jsx @@ -270,6 +270,9 @@ Object.keys(cell).forEach(key => { let _key = key.toLowerCase() + + if (/^\$/.test(_key)) return + _cell[_key] = cell[key] }) @@ -564,16 +567,28 @@ execCustomPrint = (printlist, formdata) => { const { btn } = this.props - this.execSuccess({ - ErrCode: '-1', - message: '', - status: true - }) + let callback = null + + if (/callback\(\)/.test(btn.verify.printFunc)) { + callback = () => { + this.execSuccess({ + ErrCode: '-1', + message: '', + status: true + }) + } + } else { + this.execSuccess({ + ErrCode: '-1', + message: '', + status: true + }) + } try { // eslint-disable-next-line - let func = new Function('data', 'form', 'printer', 'notification', 'Api', 'systemType', btn.verify.printFunc) - func(printlist, formdata, btn.verify, notification, Api, window.GLOB.systemType) + let func = new Function('data', 'form', 'printer', 'notification', 'Api', 'systemType', 'callback', btn.verify.printFunc) + func(printlist, formdata, btn.verify, notification, Api, window.GLOB.systemType, callback) // 鑷畾涔夋墦鍗扮ず渚� // let defaultPrinter = printer.defaultPrinter || 'lackprinter' @@ -769,18 +784,11 @@ } catch (e) { console.warn(e) - try { - // eslint-disable-next-line - let evalfunc = eval('(true && function (data, form, printer, notification, Api, systemType) {' + btn.verify.printFunc + '})') - evalfunc(printlist, formdata, btn.verify, notification, Api, window.GLOB.systemType) - } catch (error) { - console.warn(error) - notification.warning({ - top: 92, - message: '鑷畾涔夊嚱鏁版墽琛岄敊璇紒', - duration: 5 - }) - } + notification.warning({ + top: 92, + message: '鑷畾涔夊嚱鏁版墽琛岄敊璇紒', + duration: 5 + }) } } @@ -1761,26 +1769,35 @@ return } + if (printerList.length === 0) { + this.execSuccess({ + ErrCode: '-1', + message: '鏈幏鍙栧埌鎵撳嵃淇℃伅锛�', + status: true + }) + return + } + if (!socket || socket.readyState !== 1 || socket.url !== 'ws://' + btn.verify.linkUrl) { socket = new WebSocket('ws://' + btn.verify.linkUrl) } else { - this.syncMessageSend(printerList) - - this.execSuccess({ - ErrCode: 'S', - message: '鎵撳嵃璇锋眰宸插彂鍑恒��', - status: true + this.syncMessageSend(printerList, () => { + this.execSuccess({ + ErrCode: 'S', + message: '鎵撳嵃璇锋眰宸插彂鍑恒��', + status: true + }) }) } // 鎵撳紑Socket socket.onopen = () =>{ - this.syncMessageSend(printerList) - - this.execSuccess({ - ErrCode: 'S', - message: '鎵撳嵃璇锋眰宸插彂鍑恒��', - status: true + this.syncMessageSend(printerList, () => { + this.execSuccess({ + ErrCode: 'S', + message: '鎵撳嵃璇锋眰宸插彂鍑恒��', + status: true + }) }) } // 鐩戝惉娑堟伅 @@ -1835,17 +1852,26 @@ } } - syncMessageSend = (list) => { + syncMessageSend = (list, callback) => { let param = list.shift() - if (socket && param) { - socket.send(JSON.stringify(param)) + if (socket) { + try { + socket.send(JSON.stringify(param)) + } catch(e) { + console.warn('鎵撳嵃璇锋眰鍙戦�佸け璐ワ紒') + } } - if (list && list.length > 0) { - setTimeout(() => {this.syncMessageSend(list)}, 3000) + if (list.length > 0) { + setTimeout(() => { + this.syncMessageSend(list, callback) + }, 3000) + } else { + callback() } } + /** * @description 鎿嶄綔鎴愬姛鍚庡鐞� * 1銆乪xcel瀵煎嚭锛屾垚鍔熷悗鍙栨秷瀵煎嚭鎸夐挳鍔犺浇涓姸鎬� diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx index 73b091b..ab0f6ad 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx @@ -4,8 +4,8 @@ import { Form, Row, Col, Button, notification, Modal, Tooltip, Radio, Select, Switch } from 'antd' import { QuestionCircleOutlined } from '@ant-design/icons' -import Utils from '@/utils/utils.js' import Api from '@/api' +import { checkSQL } from '@/utils/utils-custom.js' import CodeMirror from '@/templates/zshare/codemirror' import './index.scss' @@ -112,73 +112,9 @@ values.status = editItem.status || 'true' } - 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 - } else if (/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig.test(values.sql)) { - let list = values.sql.match(/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig) - let errors = [] - list.forEach(str => { - str = str.replace(/^\s/, '') - let strs = str.match(/(\s|=)[a-z0-9_]+\./ig) - if (strs.length === 2 && (strs[0].replace(/\s|\./g, '') === strs[1].replace(/\s|\./g, ''))) { - errors.push(str) - } - }) - - if (errors.length > 0) { - notification.warning({ - top: 92, - message: '涓嶅彲浣跨敤鍚屼竴涓〃瀛楁杩涜鍏宠仈锛�' + errors.join('銆�'), - 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 let sheet = btn.sheet.replace(/(.*)\.(.*)\.|@db@/ig, '') let tail = ` diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx index 365fd36..2ac2c12 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx @@ -7,6 +7,7 @@ import Api from '@/api' import Utils from '@/utils/utils.js' +import { checkSQL } from '@/utils/utils-custom.js' import CodeMirror from '@/templates/zshare/codemirror' import './index.scss' @@ -147,73 +148,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 - } else if (/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig.test(values.sql)) { - let list = values.sql.match(/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig) - let errors = [] - list.forEach(str => { - str = str.replace(/^\s/, '') - let strs = str.match(/(\s|=)[a-z0-9_]+\./ig) - if (strs.length === 2 && (strs[0].replace(/\s|\./g, '') === strs[1].replace(/\s|\./g, ''))) { - errors.push(str) - } - }) - - if (errors.length > 0) { - notification.warning({ - top: 92, - message: '涓嶅彲浣跨敤鍚屼竴涓〃瀛楁杩涜鍏宠仈锛�' + errors.join('銆�'), - 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 this.setState({ loading: true diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelout/datasource/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelout/datasource/index.jsx index 6d1b718..1bbd830 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelout/datasource/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelout/datasource/index.jsx @@ -3,7 +3,7 @@ import { Form, Row, Col, Input, Radio, Tooltip, notification, InputNumber } from 'antd' import { QuestionCircleOutlined } from '@ant-design/icons' -import Utils from '@/utils/utils.js' +import { checkSQL } from '@/utils/utils-custom.js' import asyncComponent from '@/utils/asyncComponent' import './index.scss' @@ -44,56 +44,9 @@ reject() return } else if (values.defaultSql === 'true' && 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 - }) - reject() - return - } else if (/,,/ig.test(values.dataresource)) { - notification.warning({ - top: 92, - message: '鏁版嵁婧愪腑锛屼笉鍙嚭鐜拌繛缁殑鑻辨枃閫楀彿锛�,,锛�', - duration: 5 - }) - reject() - return - } - - let error = Utils.verifySql(values.dataresource) - - if (error) { - notification.warning({ - top: 92, - message: '鏁版嵁婧愪腑涓嶅彲浣跨敤' + error, - duration: 5 - }) + if (!pass) { reject() return } diff --git a/src/templates/sharecomponent/actioncomponent/verifyprint/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyprint/index.jsx index 494b38b..2d94432 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyprint/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyprint/index.jsx @@ -270,7 +270,7 @@ dataType: _verify.dataType || 'line', linkType: _verify.linkType, printMode: _verify.printMode, - printFunc: _verify.printFunc || '// Function(data, form, printer, notification) data-鎵撳嵃鏁版嵁鍒楄〃锛宖orm-琛ㄥ崟淇℃伅锛堜笉瀛樺湪鏃朵负{}锛夛紝printer-鎵撳嵃璁剧疆锛宯otification-淇℃伅鎻愮ず鎺т欢' + printFunc: _verify.printFunc || '// Function(data, form, printer, notification) data-鎵撳嵃鏁版嵁鍒楄〃锛宖orm-琛ㄥ崟淇℃伅锛堜笉瀛樺湪鏃朵负{}锛夛紝printer-鎵撳嵃璁剧疆锛宯otification-淇℃伅鎻愮ず鎺т欢锛宑allback-閲婃斁鎸夐挳鐨勫洖璋�' }) } diff --git a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx index efd4a13..5dbb18b 100644 --- a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx +++ b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx @@ -6,6 +6,7 @@ import { dateOptions, matchReg, 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 asyncComponent from '@/utils/asyncComponent' import './index.scss' @@ -828,16 +829,9 @@ } }) - let error = Utils.verifySql(values.dataSource) + let pass = checkSQL(values.dataSource) - if (error) { - notification.warning({ - top: 92, - message: '鏁版嵁婧愪腑涓嶅彲浣跨敤' + error, - duration: 5 - }) - return - } + if (!pass) return resolve(values) } else { diff --git a/src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx b/src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx index 30cbbed..404d13d 100644 --- a/src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx +++ b/src/templates/sharecomponent/settingcomponent/settingform/datasource/index.jsx @@ -4,7 +4,7 @@ import { QuestionCircleOutlined } from '@ant-design/icons' import { formRule } from '@/utils/option.js' -import Utils from '@/utils/utils.js' +import { checkSQL } from '@/utils/utils-custom.js' import asyncComponent from '@/utils/asyncComponent' // import './index.scss' @@ -84,56 +84,9 @@ 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 - }) - reject() - return - } else if (/,,/ig.test(values.dataresource)) { - notification.warning({ - top: 92, - message: '鏁版嵁婧愪腑锛屼笉鍙嚭鐜拌繛缁殑鑻辨枃閫楀彿锛�,,锛�', - duration: 5 - }) - reject() - return - } - - let error = Utils.verifySql(values.dataresource) - - if (error) { - notification.warning({ - top: 92, - message: '鏁版嵁婧愪腑涓嶅彲浣跨敤' + error, - duration: 5 - }) + if (!pass) { reject() return } diff --git a/src/templates/sharecomponent/treesettingcomponent/settingform/datasource/index.jsx b/src/templates/sharecomponent/treesettingcomponent/settingform/datasource/index.jsx index 6ac9645..064c117 100644 --- a/src/templates/sharecomponent/treesettingcomponent/settingform/datasource/index.jsx +++ b/src/templates/sharecomponent/treesettingcomponent/settingform/datasource/index.jsx @@ -4,7 +4,7 @@ import { QuestionCircleOutlined } from '@ant-design/icons' 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' @@ -73,56 +73,9 @@ 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 - }) - reject() - return - } else if (/,,/ig.test(values.dataresource)) { - notification.warning({ - top: 92, - message: '鏁版嵁婧愪腑锛屼笉鍙嚭鐜拌繛缁殑鑻辨枃閫楀彿锛�,,锛�', - duration: 5 - }) - reject() - return - } - - let error = Utils.verifySql(values.dataresource) - - if (error) { - notification.warning({ - top: 92, - message: '鏁版嵁婧愪腑涓嶅彲浣跨敤' + error, - duration: 5 - }) + if (!pass) { reject() return } diff --git a/src/templates/zshare/customscript/index.jsx b/src/templates/zshare/customscript/index.jsx index 80db92a..b3a0de2 100644 --- a/src/templates/zshare/customscript/index.jsx +++ b/src/templates/zshare/customscript/index.jsx @@ -7,6 +7,7 @@ import Utils from '@/utils/utils.js' import Api from '@/api' +import { checkSQL } from '@/utils/utils-custom.js' import CodeMirror from '@/templates/zshare/codemirror' import asyncComponent from '@/utils/asyncComponent' import MKEmitter from '@/utils/events.js' @@ -202,77 +203,13 @@ return } + let pass = checkSQL(_sql, 'customscript') + + if (!pass) return + let values = { uuid: editItem && editItem.uuid ? editItem.uuid : Utils.getuuid(), sql: _sql - } - - 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: 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 - } else if (/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig.test(values.sql)) { - let list = values.sql.match(/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig) - let errors = [] - list.forEach(str => { - str = str.replace(/^\s/, '') - let strs = str.match(/(\s|=)[a-z0-9_]+\./ig) - if (strs.length === 2 && (strs[0].replace(/\s|\./g, '') === strs[1].replace(/\s|\./g, ''))) { - errors.push(str) - } - }) - - if (errors.length > 0) { - notification.warning({ - top: 92, - message: '涓嶅彲浣跨敤鍚屼竴涓〃瀛楁杩涜鍏宠仈锛�' + errors.join('銆�'), - duration: 5 - }) - return - } - } - - let error = Utils.verifySql(values.sql, 'customscript') - - if (error) { - notification.warning({ - top: 92, - message: 'sql涓笉鍙娇鐢�' + error, - duration: 5 - }) - return } let _scripts = fromJS(scripts).toJS() diff --git a/src/templates/zshare/modalform/index.jsx b/src/templates/zshare/modalform/index.jsx index 310bdb6..7ae6d40 100644 --- a/src/templates/zshare/modalform/index.jsx +++ b/src/templates/zshare/modalform/index.jsx @@ -9,6 +9,7 @@ import { dateOptions } from '@/utils/option.js' import Utils from '@/utils/utils.js' import EditTable from './modaleditable' +import { checkSQL } from '@/utils/utils-custom.js' import asyncComponent from '@/utils/asyncComponent' import CodeMirror from '@/templates/zshare/codemirror' import './index.scss' @@ -1075,16 +1076,9 @@ } }) - let error = Utils.verifySql(values.dataSource) + let pass = checkSQL(values.dataSource) - if (error) { - notification.warning({ - top: 92, - message: '鏁版嵁婧愪腑涓嶅彲浣跨敤' + error, - duration: 5 - }) - return - } + if (!pass) return window.GLOB.formId = card.uuid diff --git a/src/templates/zshare/verifycard/callbackcustomscript/index.jsx b/src/templates/zshare/verifycard/callbackcustomscript/index.jsx index 002b1da..347e92c 100644 --- a/src/templates/zshare/verifycard/callbackcustomscript/index.jsx +++ b/src/templates/zshare/verifycard/callbackcustomscript/index.jsx @@ -1,10 +1,10 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Row, Col, Button, notification, Modal, Tooltip, Radio, Select, Switch } from 'antd' +import { Form, Row, Col, Button, Modal, Tooltip, Radio, Select, Switch } from 'antd' import { QuestionCircleOutlined } from '@ant-design/icons' -import Utils from '@/utils/utils.js' import Api from '@/api' +import { checkSQL } from '@/utils/utils-custom.js' import CodeMirror from '@/templates/zshare/codemirror' import './index.scss' @@ -42,73 +42,9 @@ if (!err) { values.uuid = editItem ? 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 - } else if (/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig.test(values.sql)) { - let list = values.sql.match(/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig) - let errors = [] - list.forEach(str => { - str = str.replace(/^\s/, '') - let strs = str.match(/(\s|=)[a-z0-9_]+\./ig) - if (strs.length === 2 && (strs[0].replace(/\s|\./g, '') === strs[1].replace(/\s|\./g, ''))) { - errors.push(str) - } - }) - - if (errors.length > 0) { - notification.warning({ - top: 92, - message: '涓嶅彲浣跨敤鍚屼竴涓〃瀛楁杩涜鍏宠仈锛�' + errors.join('銆�'), - 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 let tail = ` aaa: diff --git a/src/templates/zshare/verifycard/customform/index.jsx b/src/templates/zshare/verifycard/customform/index.jsx index 5b9ec40..c149f84 100644 --- a/src/templates/zshare/verifycard/customform/index.jsx +++ b/src/templates/zshare/verifycard/customform/index.jsx @@ -2,8 +2,8 @@ import PropTypes from 'prop-types' import { Form, Row, Col, Input, Select, Button, notification, Modal, Tooltip } from 'antd' -import Utils from '@/utils/utils.js' import Api from '@/api' +import { checkSQL } from '@/utils/utils-custom.js' import CodeMirror from '@/templates/zshare/codemirror' // import './index.scss' @@ -60,73 +60,9 @@ values.uuid = this.state.editItem ? this.state.editItem.uuid : '' values.resultName = values.result === 'false' ? '涓嶅瓨鍦�' : '瀛樺湪' - 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 - } else if (/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig.test(values.sql)) { - let list = values.sql.match(/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig) - let errors = [] - list.forEach(str => { - str = str.replace(/^\s/, '') - let strs = str.match(/(\s|=)[a-z0-9_]+\./ig) - if (strs.length === 2 && (strs[0].replace(/\s|\./g, '') === strs[1].replace(/\s|\./g, ''))) { - errors.push(str) - } - }) - - if (errors.length > 0) { - notification.warning({ - top: 92, - message: '涓嶅彲浣跨敤鍚屼竴涓〃瀛楁杩涜鍏宠仈锛�' + errors.join('銆�'), - duration: 5 - }) - return - } - } - - let error = Utils.verifySql(values.sql) - - if (error) { - notification.warning({ - top: 92, - message: 'sql涓笉鍙娇鐢�' + error, - duration: 5 - }) - return - } + if (!pass) return let sql = `${this.props.initsql} /* 鑷畾涔夐獙璇� */ diff --git a/src/templates/zshare/verifycard/customscript/index.jsx b/src/templates/zshare/verifycard/customscript/index.jsx index 42c568b..5e204ba 100644 --- a/src/templates/zshare/verifycard/customscript/index.jsx +++ b/src/templates/zshare/verifycard/customscript/index.jsx @@ -3,8 +3,8 @@ import { Form, Row, Col, Button, notification, Modal, Tooltip, Radio, Select, Switch } from 'antd' import { QuestionCircleOutlined } from '@ant-design/icons' -import Utils from '@/utils/utils.js' import Api from '@/api' +import { checkSQL } from '@/utils/utils-custom.js' import CodeMirror from '@/templates/zshare/codemirror' import './index.scss' @@ -72,73 +72,9 @@ values.status = editItem.status || 'true' } - 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 - } else if (/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig.test(values.sql)) { - let list = values.sql.match(/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig) - let errors = [] - list.forEach(str => { - str = str.replace(/^\s/, '') - let strs = str.match(/(\s|=)[a-z0-9_]+\./ig) - if (strs.length === 2 && (strs[0].replace(/\s|\./g, '') === strs[1].replace(/\s|\./g, ''))) { - errors.push(str) - } - }) - - if (errors.length > 0) { - notification.warning({ - top: 92, - message: '涓嶅彲浣跨敤鍚屼竴涓〃瀛楁杩涜鍏宠仈锛�' + errors.join('銆�'), - 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 let tail = ` aaa: diff --git a/src/utils/utils-custom.js b/src/utils/utils-custom.js index 6e80931..350ccc7 100644 --- a/src/utils/utils-custom.js +++ b/src/utils/utils-custom.js @@ -1,4 +1,5 @@ import md5 from 'md5' +import { notification } from 'antd' export default class MenuUtils { /** @@ -1702,4 +1703,150 @@ } return errors +} + +/** + * @description 妫�娴媠ql + */ +export function checkSQL(sql, type) { + if (!sql) return true + + let label = '鏁版嵁婧愪腑' + if (type === 'customscript') { + label = '鑷畾涔塻ql璇彞涓�' + } + + let _quot = sql.match(/'{1}/g) + let _lparen = sql.match(/\({1}/g) + let _rparen = 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: 5 + }) + return false + } else if (_lparen !== _rparen) { + notification.warning({ + top: 92, + message: 'sql涓�()蹇呴』鎴愬鍑虹幇', + duration: 5 + }) + return false + } else if (/--/ig.test(sql)) { + let lines = [] + sql.split(/\n/).forEach((s, i) => { + if (/--/ig.test(s)) { + lines.push(i + 1) + } + }) + + lines = lines.join('銆�') + lines = lines ? '(绗�' + lines + '琛�)' : '' + + notification.warning({ + top: 92, + message: label + `${lines}锛屼笉鍙嚭鐜板瓧绗� -- 锛屾敞閲婅鐢� /*鍐呭*/`, + duration: 5 + }) + return false + } else if (/,,/ig.test(sql)) { + let lines = [] + sql.split(/\n/).forEach((s, i) => { + if (/,,/ig.test(s)) { + lines.push(i + 1) + } + }) + + lines = lines.join('銆�') + lines = lines ? '(绗�' + lines + '琛�)' : '' + + notification.warning({ + top: 92, + message: label + `${lines}锛屼笉鍙嚭鐜拌繛缁殑鑻辨枃閫楀彿,,`, + duration: 5 + }) + return false + } else if (/鈥榺鈥�/ig.test(sql)) { + let lines = [] + sql.split(/\n/).forEach((s, i) => { + if (/鈥榺鈥�/ig.test(s)) { + lines.push(i + 1) + } + }) + + lines = lines.join('銆�') + lines = lines ? '(绗�' + lines + '琛�)' : '' + + notification.warning({ + top: 92, + message: label + `${lines}锛屼笉鍙嚭鐜颁腑鏂囧崟寮曞彿`, + duration: 5 + }) + return false + } else if (type === 'customscript' && /\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig.test(sql)) { + let list = sql.match(/\son\s+[a-z0-9_]+\.[a-z0-9_]+\s*=\s*[a-z0-9_]+\.[a-z0-9_]+/ig) + let errors = [] + list.forEach(str => { + str = str.replace(/^\s/, '') + let strs = str.match(/(\s|=)[a-z0-9_]+\./ig) + if (strs.length === 2 && (strs[0].replace(/\s|\./g, '') === strs[1].replace(/\s|\./g, ''))) { + errors.push(str) + } + }) + + if (errors.length > 0) { + notification.warning({ + top: 92, + message: '涓嶅彲浣跨敤鍚屼竴涓〃瀛楁杩涜鍏宠仈锛�' + errors.join('銆�'), + duration: 5 + }) + return false + } + } + + let error = '' + let chars = [ + {key: 'create', reg: /(^|\s|\(|\))create\s/ig}, + {key: 'insert', reg: /(^|\s|\(|\))insert\s/ig}, + {key: 'delete', reg: /(^|\s|\(|\))delete\s/ig}, + {key: 'update', reg: /(^|\s|\(|\))update\s/ig}, + {key: 'set', reg: /(^|\s|\(|\))set\s/ig}, + {key: 'drop', reg: /(^|\s|\(|\))drop\s/ig}, + {key: 'alter', reg: /(^|\s|\(|\))alter\s/ig}, + {key: 'truncate', reg: /(^|\s|\(|\))truncate\s/ig}, + {key: 'if', reg: /(^|\s|\(|\))if\s/ig}, + {key: 'exec', reg: /(^|\s|\(|\))exec(\s|\()/ig}, + {key: 'OBJECT', reg: /(^|\s|\(|\))object(\s|\()/ig}, + {key: 'sys.', reg: /(^|\s|\(|\))sys\./ig}, + {key: 'kill', reg: /(^|\s|\(|\))kill\s/ig} + ] + + if (type === 'customscript') { + chars = chars.filter(char => !['create', 'insert', 'delete', 'update', 'set', 'drop', 'if', 'exec'].includes(char.key)) + } + + sql = sql.replace(/sys\.fn_/ig, '') // 璺宠繃sys.fn_楠岃瘉 + + chars.forEach(char => { + if (!error && char.reg.test(sql)) { + error = char.key + } + }) + + if (error) { + notification.warning({ + top: 92, + message: 'sql涓笉鍙娇鐢�' + error, + duration: 5 + }) + return false + } + + return true } \ No newline at end of file diff --git a/src/utils/utils.js b/src/utils/utils.js index 3c4adea..74db930 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -116,46 +116,6 @@ } /** - * @description sql璇硶楠岃瘉 - * @return {String} sql sql璇彞 - * @return {String} type 楠岃瘉绫诲瀷 - */ - static verifySql (sql, type) { - if (!sql) return '' - let chars = [ - {key: 'create', reg: /(^|\s|\(|\))create\s/ig}, - {key: 'insert', reg: /(^|\s|\(|\))insert\s/ig}, - {key: 'delete', reg: /(^|\s|\(|\))delete\s/ig}, - {key: 'update', reg: /(^|\s|\(|\))update\s/ig}, - {key: 'set', reg: /(^|\s|\(|\))set\s/ig}, - {key: 'drop', reg: /(^|\s|\(|\))drop\s/ig}, - {key: 'alter', reg: /(^|\s|\(|\))alter\s/ig}, - {key: 'truncate', reg: /(^|\s|\(|\))truncate\s/ig}, - {key: 'if', reg: /(^|\s|\(|\))if\s/ig}, - {key: 'exec', reg: /(^|\s|\(|\))exec(\s|\()/ig}, - {key: 'OBJECT', reg: /(^|\s|\(|\))object(\s|\()/ig}, - {key: 'sys.', reg: /(^|\s|\(|\))sys\./ig}, - {key: 'kill', reg: /(^|\s|\(|\))kill\s/ig} - ] - - if (type === 'customscript') { - chars = chars.filter(char => !['create', 'insert', 'delete', 'update', 'set', 'drop', 'if', 'exec'].includes(char.key)) - } - - let error = '' - - sql = sql.replace(/sys\.fn_/ig, '') // 璺宠繃sys.fn_楠岃瘉 - - chars.forEach(char => { - if (!error && char.reg.test(sql)) { - error = char.key - } - }) - - return error - } - - /** * @description sql鍔犲瘑 * @return {String} value */ diff --git a/src/views/menudesign/index.jsx b/src/views/menudesign/index.jsx index 455baa1..506ac21 100644 --- a/src/views/menudesign/index.jsx +++ b/src/views/menudesign/index.jsx @@ -791,7 +791,7 @@ EasyCode: config.easyCode || '', Template: 'CustomPage', MenuName: config.MenuName || '', - PageParam: JSON.stringify({Template: 'CustomPage', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false', interfaces}), + PageParam: JSON.stringify({Template: 'CustomPage', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false', menuColor: config.menuColor || '', interfaces}), open_edition: config.open_edition, LText: '', LTexttb: '', diff --git a/src/views/menudesign/menuform/index.jsx b/src/views/menudesign/menuform/index.jsx index 235f6b1..737270b 100644 --- a/src/views/menudesign/menuform/index.jsx +++ b/src/views/menudesign/menuform/index.jsx @@ -4,9 +4,13 @@ import { QuestionCircleOutlined } from '@ant-design/icons' import Api from '@/api' +import asyncComponent from '@/utils/asyncComponent' import './index.scss' const { TextArea } = Input + +const ColorSketch = asyncComponent(() => import('@/mob/colorsketch')) +const SysColorSketch = asyncComponent(() => import('@/menu/stylecontroller/syscolorsketch')) class CustomMenuForm extends Component { static propTpyes = { @@ -475,6 +479,16 @@ })(<TextArea rows={2} placeholder={''} onChange={(e) => {this.selectChange('Remark', e.target.value)}}/>)} </Form.Item> </Col> + <Col span={24}> + <Form.Item style={{marginBottom: '0px'}} label="鑿滃崟棰滆壊"> + <ColorSketch allowClear={true} value={config.menuColor || ''} onChange={(val) => {this.selectChange('menuColor', val)}} /> + </Form.Item> + </Col> + <Col span={24}> + <Form.Item style={{marginBottom: '0px'}} label="绯荤粺鑹�"> + <SysColorSketch onChange={(val) => {this.selectChange('menuColor', val)}} /> + </Form.Item> + </Col> </Row> </Form> ) diff --git a/src/views/menudesign/menuform/index.scss b/src/views/menudesign/menuform/index.scss index 39343af..7023782 100644 --- a/src/views/menudesign/menuform/index.scss +++ b/src/views/menudesign/menuform/index.scss @@ -13,4 +13,21 @@ color: red; } } + .color-sketch-block { + position: relative; + top: 7px; + .color-sketch-block-box { + width: 40px; + } + .color-sketch-value { + width: 130px; + + .anticon-close-circle { + right: 10px; + } + } + } + .sys-color-sketch-block { + white-space: nowrap; + } } \ No newline at end of file diff --git a/src/views/tabledesign/index.jsx b/src/views/tabledesign/index.jsx index cb48eb5..a3a5952 100644 --- a/src/views/tabledesign/index.jsx +++ b/src/views/tabledesign/index.jsx @@ -592,7 +592,7 @@ EasyCode: config.easyCode || '', Template: 'BaseTable', MenuName: config.MenuName || '', - PageParam: JSON.stringify({Template: 'BaseTable', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false', interfaces}), + PageParam: JSON.stringify({Template: 'BaseTable', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false', menuColor: config.menuColor || '', interfaces}), open_edition: config.open_edition, LText: '', LTexttb: '', diff --git a/src/views/tabledesign/menuform/index.jsx b/src/views/tabledesign/menuform/index.jsx index 84553b2..e1a70b1 100644 --- a/src/views/tabledesign/menuform/index.jsx +++ b/src/views/tabledesign/menuform/index.jsx @@ -3,9 +3,13 @@ import { Form, Row, Col, Input, Select, notification, Switch, Radio } from 'antd' import Api from '@/api' +import asyncComponent from '@/utils/asyncComponent' import './index.scss' const { TextArea } = Input + +const ColorSketch = asyncComponent(() => import('@/mob/colorsketch')) +const SysColorSketch = asyncComponent(() => import('@/menu/stylecontroller/syscolorsketch')) class CustomMenuForm extends Component { static propTpyes = { @@ -374,6 +378,16 @@ })(<TextArea rows={2} placeholder={''} onChange={this.changeRemark} />)} </Form.Item> </Col> + <Col span={24}> + <Form.Item style={{marginBottom: '0px'}} label="鑿滃崟棰滆壊"> + <ColorSketch allowClear={true} value={config.menuColor || ''} onChange={(val) => {this.selectChange('menuColor', val)}} /> + </Form.Item> + </Col> + <Col span={24}> + <Form.Item style={{marginBottom: '0px'}} label="绯荤粺鑹�"> + <SysColorSketch onChange={(val) => {this.selectChange('menuColor', val)}} /> + </Form.Item> + </Col> </Row> </Form> ) diff --git a/src/views/tabledesign/menuform/index.scss b/src/views/tabledesign/menuform/index.scss index 39343af..c4c5f98 100644 --- a/src/views/tabledesign/menuform/index.scss +++ b/src/views/tabledesign/menuform/index.scss @@ -13,4 +13,20 @@ color: red; } } + .color-sketch-block { + position: relative; + top: 7px; + .color-sketch-block-box { + width: 40px; + } + .color-sketch-value { + width: 130px; + .anticon-close-circle { + right: 10px; + } + } + } + .sys-color-sketch-block { + white-space: nowrap; + } } \ No newline at end of file -- Gitblit v1.8.0