From 113ff1aa0d62549730f1413fe5ffcadcf3a14f11 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 23 八月 2022 11:37:24 +0800 Subject: [PATCH] 2022-08-23 --- src/templates/zshare/verifycard/customform/index.jsx | 97 +++++++++++++++++++++++++++++++++++++----------- 1 files changed, 75 insertions(+), 22 deletions(-) diff --git a/src/templates/zshare/verifycard/customform/index.jsx b/src/templates/zshare/verifycard/customform/index.jsx index 2217988..1b96426 100644 --- a/src/templates/zshare/verifycard/customform/index.jsx +++ b/src/templates/zshare/verifycard/customform/index.jsx @@ -1,17 +1,17 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Row, Col, Input, Select, Button, notification } from 'antd' +import { Form, Row, Col, Input, Select, Button, notification, Modal, Tooltip } from 'antd' import moment from 'moment' import Utils from '@/utils/utils.js' import Api from '@/api' +import CodeMirror from '@/templates/zshare/codemirror' import './index.scss' - -const { TextArea } = Input class CustomForm extends Component { static propTpyes = { dict: PropTypes.object, // 瀛楀吀椤� + btn: PropTypes.object, // 鎸夐挳 usefulfields: PropTypes.string, // 鍙敤瀛楁 initsql: PropTypes.string, // 鍙敤瀛楁 customChange: PropTypes.func // 琛ㄥ崟 @@ -35,6 +35,16 @@ }) } + handleCancel = () => { + this.setState({ + editItem: null + }) + + this.props.form.setFieldsValue({ + sql: ' ', + errmsg: '' + }) + } handleConfirm = () => { // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� @@ -55,51 +65,81 @@ notification.warning({ top: 92, message: 'sql涓璡'蹇呴』鎴愬鍑虹幇', - duration: 10 + duration: 5 }) return } else if (_lparen !== _rparen) { notification.warning({ top: 92, message: 'sql涓�()蹇呴』鎴愬鍑虹幇', - duration: 10 + duration: 5 }) return } else if (/--/ig.test(values.sql)) { notification.warning({ top: 92, message: '鑷畾涔塻ql璇彞涓紝涓嶅彲鍑虹幇瀛楃 -- 锛屾敞閲婅鐢� /*鍐呭*/', - duration: 10 + duration: 5 + }) + return + } + + let error = Utils.verifySql(values.sql) + + if (error) { + notification.warning({ + top: 92, + message: 'sql涓笉鍙娇鐢�' + error, + duration: 5 }) return } let param = { func: 's_debug_sql', + exec_type: 'y', LText: this.props.initsql + values.sql } + + if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { + window.GLOB.funcs.forEach(item => { + let reg = new RegExp('\\$ex@' + item.func_code + '@ex\\$', 'ig') + param.LText = param.LText.replace(reg, `/*$ex@${item.func_code}-begin*/\n${item.key_sql}\n/*@ex$-end*/`) + }) + } + + // 鏁版嵁鏉冮檺 + param.LText = param.LText.replace(/@\$|\$@/ig, '') + + // 澶栬仈鏁版嵁搴撴浛鎹� + if (window.GLOB.externalDatabase !== null) { + param.LText = param.LText.replace(/@db@/ig, window.GLOB.externalDatabase) + } + + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.LText = param.LText.replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'${param.timestamp}'`) + param.LText = Utils.formatOptions(param.LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - param.secretkey = Utils.encrypt(param.LText, param.timestamp) + param.secretkey = Utils.encrypt('', param.timestamp) this.setState({loading: true}) - Api.getLocalConfig(param).then(res => { + Api.genericInterface(param).then(res => { if (res.status) { - this.props.customChange(values) this.setState({ loading: false, editItem: null + }, () => { + this.props.customChange(values) }) this.props.form.setFieldsValue({ - sql: '', + sql: ' ', errmsg: '' }) } else { this.setState({loading: false}) - notification.warning({ - top: 92, - message: res.message, - duration: 10 + + Modal.error({ + title: res.message }) } }) @@ -108,7 +148,7 @@ } render() { - const { usefulfields } = this.props + const { usefulfields, btn } = this.props const { getFieldDecorator } = this.props.form const formItemLayout = { labelCol: { @@ -120,14 +160,20 @@ sm: { span: 16 } } } + + // let _usefulfields = usefulfields ? usefulfields.replace(/(BID|ID|LoginUID|SessionUid|UserID|Appkey|UserName|FullName|RoleID|mk_departmentcode|mk_organization|mk_nation|mk_province|mk_city|mk_district|mk_address|mk_user_type|BillCode|BVoucher|FIBVoucherDate|FiYear|ModularDetailCode),\s/ig, '') : null + return ( <Form {...formItemLayout} className="verify-form" id="verifycard2"> <Row gutter={24}> - {usefulfields ? <Col span={21} className="sqlfield"> + <Col span={21} className="sqlfield"> <Form.Item label={'鍙敤瀛楁'}> - {usefulfields} + <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'鍏叡鍊硷紝璇锋寜鐓xxx@鏍煎紡浣跨敤銆�'}><span style={{color: '#1890ff'}}>BID, ID, LoginUID, SessionUid, UserID, Appkey, time_id</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</span></Tooltip>, + <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'绯荤粺鍙橀噺锛岀郴缁熶細瀹氫箟鍙橀噺骞跺湪鍗曞彿鐢熸垚鎴栧垱寤哄嚟璇佹椂浣跨敤銆�'}><span style={{color: '#13c2c2'}}>BillCode, BVoucher, FIBVoucherDate, FiYear, ModularDetailCode</span></Tooltip> + {usefulfields ? <span>, {usefulfields}</span> : ''} </Form.Item> - </Col> : null} + </Col> <Col span={21} className="sql"> <Form.Item label={'sql'}> {getFieldDecorator('sql', { @@ -138,13 +184,20 @@ message: this.props.dict['form.required.input'] + 'sql!' } ] - })(<TextArea rows={15} />)} + })(<CodeMirror />)} </Form.Item> </Col> <Col span={3} className="add"> - <Button onClick={this.handleConfirm} loading={this.state.loading} type="primary" className="add-row"> - 纭畾 + <Button onClick={this.handleConfirm} loading={this.state.loading} className="mk-green"> + 淇濆瓨 </Button> + <div></div> + <Button onClick={this.handleCancel}> + 鍙栨秷 + </Button> + {btn.sql ? <div style={{marginTop: '31px'}}> + 琛ㄥ悕: <div style={{wordBreak: 'break-all'}}>{btn.sql}</div> + </div> : null} </Col> <Col span={7}> <Form.Item label={'缁撴灉澶勭悊'}> -- Gitblit v1.8.0