From be8f81fe2eb52e841efead8586e514842471e0ba Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 14 九月 2023 16:50:35 +0800 Subject: [PATCH] 2023-09-14 --- src/templates/zshare/verifycard/callbackcustomscript/index.jsx | 151 +++++++++++++++++++++++++++++++++++-------------- 1 files changed, 107 insertions(+), 44 deletions(-) diff --git a/src/templates/zshare/verifycard/callbackcustomscript/index.jsx b/src/templates/zshare/verifycard/callbackcustomscript/index.jsx index b53a5fd..a0e7a52 100644 --- a/src/templates/zshare/verifycard/callbackcustomscript/index.jsx +++ b/src/templates/zshare/verifycard/callbackcustomscript/index.jsx @@ -1,6 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Row, Col, Button, notification, Modal, Tooltip, Icon, Radio, Select } from 'antd' +import { Form, Row, Col, Button, notification, Modal, Tooltip, Radio, Select, Switch } from 'antd' +import { QuestionCircleOutlined } from '@ant-design/icons' import moment from 'moment' import Utils from '@/utils/utils.js' @@ -10,8 +11,9 @@ class CustomForm extends Component { static propTpyes = { - dict: PropTypes.object, // 瀛楀吀椤� btn: PropTypes.object, // 鎸夐挳淇℃伅 + initsql: PropTypes.string, // 鍒濆鍖栬剼鏈� + usefulfields: PropTypes.string, // 鍙敤瀛楁 systemScripts: PropTypes.array, // 绯荤粺鑴氭湰 customScripts: PropTypes.array, // 鑷畾涔夎剼鏈� scriptsChange: PropTypes.func // 琛ㄥ崟 @@ -19,7 +21,8 @@ state = { editItem: null, - loading: false + loading: false, + skip: false } edit = (record) => { @@ -34,7 +37,7 @@ } handleConfirm = () => { - const { editItem } = this.state + const { editItem, skip } = this.state // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { @@ -66,6 +69,13 @@ notification.warning({ top: 92, message: '鑷畾涔塻ql璇彞涓紝涓嶅彲鍑虹幇瀛楃 -- 锛屾敞閲婅鐢� /*鍐呭*/', + duration: 5 + }) + return + } else if (/,,/ig.test(values.sql)) { + notification.warning({ + top: 92, + message: '鑷畾涔塻ql璇彞涓紝涓嶅彲鍑虹幇杩炵画鐨勮嫳鏂囬�楀彿锛�,,锛�', duration: 5 }) return @@ -105,14 +115,36 @@ } }) + if (!values.uuid) { + if (values.position === 'front') { + _prevCustomScript += ` + /* 榛樿sql鍓嶈剼鏈� */ + ${values.sql} + ` + } else { + _backCustomScript += ` + /* 榛樿sql鍚庤剼鏈� */ + ${values.sql} + ` + } + } + let param = { func: 's_debug_sql', exec_type: 'y', - LText: _prevCustomScript + _backCustomScript + tail + LText: 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') + param.LText = param.LText.replace(reg, `/*$ex@${item.func_code}-begin*/\n${item.key_sql}\n/*@ex$-end*/`) + }) } // 鏁版嵁鏉冮檺 param.LText = param.LText.replace(/@\$|\$@/ig, '') + // check param.LText = param.LText.replace(/\$check@|@check\$/ig, '') @@ -121,32 +153,47 @@ 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|typename)@/ig, `'${param.timestamp}'`) + console.info(`/* sql 楠岃瘉 */\n${param.LText.replace(/\n\s{6,20}/ig, '\n')}`) + param.LText = param.LText.replace(/\n/g, ' ') param.LText = Utils.formatOptions(param.LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt('', param.timestamp) - this.setState({loading: true}) - Api.getLocalConfig(param).then(res => { - if (res.status) { - 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 - }) - } - }) + if (skip) { + this.setState({ + skip: false, + editItem: null + }, () => { + this.props.scriptsChange(values) + }) + this.props.form.setFieldsValue({ + sql: ' ' + }) + } else { + this.setState({loading: true}) + Api.genericInterface(param).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 + }) + } + }) + } } }) } @@ -162,7 +209,11 @@ } selectScript = (value, option) => { + if (!value || !option) return let _sql = this.props.form.getFieldValue('sql') + if (/^\s+$/.test(_sql)) { + _sql = '' + } if (_sql) { _sql = _sql + ` @@ -181,8 +232,9 @@ } render() { - const { systemScripts, btn } = this.props + const { usefulfields, systemScripts, btn } = this.props const { getFieldDecorator } = this.props.form + const { skip } = this.state const formItemLayout = { labelCol: { xs: { span: 24 }, @@ -194,23 +246,33 @@ } } + // 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="verify-custom-scripts"> + <Form {...formItemLayout} className="verify-form verify-custom-callback-scripts" id="verify-custom-callback-scripts"> <Row gutter={24}> - {btn.cbTable ? <Col span={8}> + <Col span={8}> <Form.Item label={'琛ㄥ悕'} style={{whiteSpace: 'nowrap', margin: 0}}> {btn.cbTable} </Form.Item> - </Col> : null} - <Col span={16}> - <Form.Item label={'鎶ラ敊瀛楁'} style={{margin: 0}}> - ErrorCode, retmsg + </Col> + <Col span={10}> + <Form.Item label={'鎶ラ敊瀛楁'} style={{margin: 0, whiteSpace: 'nowrap'}}> + ErrorCode锛堝鍔犲悗缂�NT琛ㄧず鏁版嵁涓嶅洖婊氾紝濡侲NT銆丯NT銆丗NT銆丯MNT銆丆NT銆�-2NT锛�, retmsg + </Form.Item> + </Col> + <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, time_id, typename</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: '#13c2c2'}}>BillCode, BVoucher, FIBVoucherDate, FiYear, ModularDetailCode</span></Tooltip> + {usefulfields ? <span>, {usefulfields}</span> : ''} </Form.Item> </Col> <Col span={8} style={{whiteSpace: 'nowrap'}}> <Form.Item style={{marginBottom: 0}} label={ <Tooltip placement="bottomLeft" title={'鑷畾涔夎剼鏈笌榛樿sql浣嶇疆鍏崇郴銆�'}> - <Icon type="question-circle" style={{color: '#c49f47', marginRight: '5px'}} /> + <QuestionCircleOutlined className="mk-form-tip" /> 鎵ц浣嶇疆 </Tooltip> }> @@ -224,21 +286,23 @@ )} </Form.Item> </Col> - <Col span={10}> + <Col span={8}> <Form.Item label={'蹇嵎娣诲姞'} style={{marginBottom: 0}}> <Select + allowClear showSearch filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} onChange={this.selectScript} - getPopupContainer={() => document.getElementById('verify-custom-scripts')} + getPopupContainer={() => document.getElementById('verify-custom-callback-scripts')} > + <Select.Option key="default" value={`declare @${btn.cbTable} table (mk_api_key nvarchar(100),mk_level nvarchar(10),mk_id nvarchar(50),mk_bid nvarchar(50))\n/*@${btn.cbTable}_data table (mk_level nvarchar(10),mk_id nvarchar(50),mk_bid nvarchar(50))*/`}>榛樿sql</Select.Option> {systemScripts.map((option, i) => <Select.Option key={i} value={option.value}>{option.name}</Select.Option> )} </Select> </Form.Item> </Col> - <Col span={6} className="add"> + <Col span={5} className="add" style={{whiteSpace: 'nowrap'}}> <Button onClick={this.handleConfirm} loading={this.state.loading} className="mk-green" style={{marginBottom: 15, marginLeft: 40}}> 淇濆瓨 </Button> @@ -246,19 +310,18 @@ 鍙栨秷 </Button> </Col> + <Col span={3} style={{paddingTop: '15px', fontSize: '12px', whiteSpace: 'nowrap'}}> + 寮哄埗淇濆瓨锛� + <Switch checked={skip} size="small" onChange={() => this.setState({skip: !skip})}/> + </Col> <Col span={24} className="sql"> - <Form.Item label={ - <Tooltip placement="topLeft" title={'鏁版嵁妫�鏌ユ浛鎹㈢ $check@ -> /* 鎴� \'\'銆� @check$ -> */ 鎴� \'\''}> - <Icon type="question-circle" /> - sql - </Tooltip> - }> + <Form.Item label="sql"> {getFieldDecorator('sql', { initialValue: '', rules: [ { required: true, - message: this.props.dict['form.required.input'] + 'sql!' + message: '璇疯緭鍏ql!' } ] })(<CodeMirror />)} -- Gitblit v1.8.0