From 2998f413a5e196e99df887787aa4b250cd9f3b78 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 24 十二月 2024 14:56:23 +0800 Subject: [PATCH] Merge branch 'positec' into dms --- src/templates/zshare/verifycard/callbackcustomscript/index.jsx | 145 +++++++++++------------------------------------- 1 files changed, 34 insertions(+), 111 deletions(-) diff --git a/src/templates/zshare/verifycard/callbackcustomscript/index.jsx b/src/templates/zshare/verifycard/callbackcustomscript/index.jsx index 1cd3231..1024b90 100644 --- a/src/templates/zshare/verifycard/callbackcustomscript/index.jsx +++ b/src/templates/zshare/verifycard/callbackcustomscript/index.jsx @@ -1,22 +1,19 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Row, Col, Button, Modal, Tooltip, Radio, Select, Switch, notification } from 'antd' +import { Form, Row, Col, Button, Tooltip, Radio, Select, Switch, notification } from 'antd' import { QuestionCircleOutlined } from '@ant-design/icons' -import Api from '@/api' import { checkSQL } from '@/utils/utils-custom.js' import CodeMirror from '@/templates/zshare/codemirror' import './index.scss' class CustomForm extends Component { static propTpyes = { - btn: PropTypes.object, // 鎸夐挳淇℃伅 - initsql: PropTypes.string, // 鍒濆鍖栬剼鏈� + btn: PropTypes.object, formfields: PropTypes.string, colfields: PropTypes.string, - systemScripts: PropTypes.array, // 绯荤粺鑴氭湰 - customScripts: PropTypes.array, // 鑷畾涔夎剼鏈� - scriptsChange: PropTypes.func // 琛ㄥ崟 + systemScripts: PropTypes.array, + cbScriptsChange: PropTypes.func } state = { @@ -47,7 +44,9 @@ const { editItem, skip } = this.state // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� this.props.form.validateFieldsAndScroll((err, values) => { - if (type === 'fullscreen' && err) { + if (err) return + + if (!values.sql || /^[\s\n]+$/.test(values.sql)) { notification.warning({ top: 92, message: '璇疯緭鍏ql!', @@ -56,110 +55,40 @@ return } - if (!err) { - if (/^[\s\n]+$/.test(values.sql)) { - notification.warning({ - top: 92, - message: '璇疯緭鍏ql!', - duration: 5 - }) - return - } + values.uuid = editItem ? editItem.uuid : '' + values.position = values.position || (editItem ? editItem.position : 'front') - values.uuid = editItem ? editItem.uuid : '' - values.position = values.position || (editItem ? editItem.position : 'front') + if (type === 'fullscreen' && editItem) { + values.status = editItem.status || 'true' + } - if (type === 'fullscreen' && editItem) { - values.status = editItem.status || 'true' - } + let pass = checkSQL(values.sql, 'customscript') - let pass = checkSQL(values.sql, 'customscript') + if (!pass && !skip) return - if (!pass && !skip) return - - let tail = ` - aaa: - ` - - let _prevCustomScript = '' // 榛樿sql鍓嶆墽琛岃剼鏈� - let _backCustomScript = '' // 榛樿sql鍚庢墽琛岃剼鏈� - - this.props.customScripts.forEach(item => { - if (item.status === 'false') return - - if (item.position === 'front') { - _prevCustomScript += ` - /* 榛樿sql鍓嶈剼鏈� */ - ${values.uuid === item.uuid ? values.sql : item.sql} - ` - } else { - _backCustomScript += ` - /* 榛樿sql鍚庤剼鏈� */ - ${values.uuid === item.uuid ? values.sql : item.sql} - ` - } + if (skip) { + this.setState({ + skip: false, + editItem: null }) + this.props.form.setFieldsValue({ + sql: '' + }) + this.props.cbScriptsChange(values) + } else { + this.setState({loading: true}) - if (!values.uuid) { - if (values.position === 'front') { - _prevCustomScript += ` - /* 榛樿sql鍓嶈剼鏈� */ - ${values.sql} - ` - } else { - _backCustomScript += ` - /* 榛樿sql鍚庤剼鏈� */ - ${values.sql} - ` - } - } - - let sql = this.props.initsql + _prevCustomScript + _backCustomScript + tail - - // if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { - // window.GLOB.funcs.forEach(item => { - // let reg = new RegExp('\\$ex@' + item.func_code + '@ex\\$', 'ig') - // sql = sql.replace(reg, `/*$ex@${item.func_code}-begin*/\n${item.key_sql}\n/*@ex$-end*/`) - // }) - // } - - // 鏁版嵁鏉冮檺 - sql = sql.replace(/@\$|\$@/ig, '').replace(/\$check@|@check\$/ig, '') - sql = sql.replace(/@datam@/ig, `''`) - sql = sql.replace(/@typename@/ig, `'debug'`) - - if (skip) { + this.props.cbScriptsChange(values, () => { this.setState({ - skip: false, + loading: false, editItem: null - }, () => { - this.props.scriptsChange(values) }) this.props.form.setFieldsValue({ - sql: ' ' + sql: '' }) - } else { - this.setState({loading: true}) - Api.sDebug(sql).then(res => { - if (res.status || res.ErrCode === '-2') { - this.setState({ - loading: false, - editItem: null - }, () => { - this.props.scriptsChange(values) - }) - this.props.form.setFieldsValue({ - sql: ' ' - }) - } else { - this.setState({loading: false}) - - Modal.error({ - title: res.message - }) - } - }) - } + }, () => { + this.setState({loading: false}) + }) } }) } @@ -170,7 +99,7 @@ }) this.props.form.setFieldsValue({ - sql: ' ' + sql: '' }) } @@ -228,7 +157,7 @@ {!type ? <Col span={24} className="sqlfield"> <Form.Item label="鍙敤瀛楁"> <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'鍏叡鍊硷紝璇锋寜鐓xxx@鏍煎紡浣跨敤銆�'}><span style={{color: '#1890ff'}}>BID, ID, LoginUID, SessionUid, UserID, Appkey, lang, time_id, typename, datam</span></Tooltip>, - <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'绯荤粺鍙橀噺锛岀郴缁熶細瀹氫箟鍙橀噺骞惰祴鍊笺��'}><span style={{color: '#fa8c16'}}>UserName, FullName, RoleID, mk_departmentcode, mk_organization, mk_user_type, mk_nation, mk_province, mk_city, mk_district, mk_address, mk_deleted</span></Tooltip>, + <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'绯荤粺鍙橀噺锛岀郴缁熶細瀹氫箟鍙橀噺骞惰祴鍊笺��'}><span style={{color: '#fa8c16'}}>UserName, FullName, RoleID, mk_departmentcode, mk_organization, mk_user_type, mk_nation, mk_province, mk_city, mk_district, mk_address, mk_deleted, mk_submit_type</span></Tooltip>, <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'绯荤粺鍙橀噺锛岀郴缁熶細瀹氫箟鍙橀噺骞跺湪鍗曞彿鐢熸垚鎴栧垱寤哄嚟璇佹椂浣跨敤銆�'}><span style={{color: '#13c2c2'}}>BillCode, BVoucher, FIBVoucherDate, FiYear, ModularDetailCode</span></Tooltip> {formfields ? <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title="琛ㄥ崟鍙橀噺锛岀郴缁熶細瀹氫箟鍙橀噺骞惰祴鍊笺��">, <span style={{color: '#8E44AD'}}>{formfields}</span></Tooltip> : ''} {colfields ? <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title="瀛楁闆嗗彉閲忥紝绯荤粺浼氬畾涔夊彉閲忓苟璧嬪�笺��">, {colfields}</Tooltip> : ''} @@ -280,15 +209,9 @@ <Switch checked={skip} size="small" onChange={() => this.setState({skip: !skip})}/> </Col> <Col span={24} className="sql"> - <Form.Item label="sql"> + <Form.Item label="sql" required> {getFieldDecorator('sql', { - initialValue: '', - rules: [ - { - required: true, - message: '璇疯緭鍏ql!' - } - ] + initialValue: '' })(<CodeMirror />)} </Form.Item> </Col> -- Gitblit v1.8.0