From 24f0ce147c8daef39ec437d5def9d089ea5b1839 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 05 六月 2020 17:23:53 +0800 Subject: [PATCH] 2020-06-05 --- src/templates/sharecomponent/settingcomponent/settingform/customscript/index.jsx | 116 +++++++++++++++++++++++++-------------------------------- 1 files changed, 51 insertions(+), 65 deletions(-) diff --git a/src/templates/sharecomponent/settingcomponent/settingform/customscript/index.jsx b/src/templates/sharecomponent/settingcomponent/settingform/customscript/index.jsx index 2924724..6c9d489 100644 --- a/src/templates/sharecomponent/settingcomponent/settingform/customscript/index.jsx +++ b/src/templates/sharecomponent/settingcomponent/settingform/customscript/index.jsx @@ -1,9 +1,10 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Row, Col, Input, Button, notification, Modal, Select, Radio } from 'antd' +import { Form, Row, Col, Input, Button, notification, Modal, Select } from 'antd' import moment from 'moment' import Utils from '@/utils/utils.js' +import SettingUtils from '../utils.jsx' import Api from '@/api' import './index.scss' @@ -11,11 +12,14 @@ class CustomForm extends Component { static propTpyes = { + type: PropTypes.string, // 鑿滃崟绫诲瀷 dict: PropTypes.object, // 瀛楀吀椤� setting: PropTypes.object, // 璁剧疆 searches: PropTypes.array, // 鎼滅储鏉′欢 + swhere: PropTypes.string, // where鏉′欢 + arr_field: PropTypes.string, // 鍒楀瓧娈� + regoptions: PropTypes.array, // 姝e垯鏇挎崲 systemScripts: PropTypes.array, // 绯荤粺鑴氭湰 - customScripts: PropTypes.array, // 鑷畾涔夎剼鏈� scriptsChange: PropTypes.func // 琛ㄥ崟 } @@ -57,14 +61,22 @@ }) this.props.form.setFieldsValue({ - sql: record.sql, - initsql: record.initsql || 'false' + sql: record.sql + }) + } + + handleCancel = () => { + this.setState({ + editItem: null + }) + this.props.form.setFieldsValue({ + sql: '' }) } handleConfirm = () => { - const { searches, setting } = this.props - + const { setting, arr_field, regoptions, swhere } = this.props + // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { @@ -112,54 +124,37 @@ return } - let tail = ` - aaa: - ` - - let _initsql = '' - this.props.customScripts.forEach(script => { - if (this.state.editItem && this.state.editItem.uuid === script.uuid) return - if (script.status === 'false' || script.initsql !== 'true') return - - _initsql += ` + let _customScript = '' + setting.scripts && setting.scripts.forEach(script => { + if (this.state.editItem && this.state.editItem.uuid === script.uuid) { + _customScript += ` + ${values.sql} + ` + } else if (script.status !== 'false') { + _customScript += ` ${script.sql} ` - }) - - let param = { - func: 's_debug_sql', - LText: _initsql + values.sql + tail - } - - param.LText = param.LText.replace(/@\$|\$@/ig, '') - - let allSearch = Utils.initMainSearch(searches) - allSearch = Utils.getAllSearchOptions(allSearch) - - let regoptions = allSearch.map(item => { - return { - reg: new RegExp('@' + item.key + '@', 'ig'), - value: `'${item.value}'` } }) - regoptions.push({ - reg: new RegExp('@orderBy@', 'ig'), - value: setting.order - }) - if (setting.laypage !== 'false') { - regoptions.push({ - reg: new RegExp('@pageSize@', 'ig'), - value: 10 - }, { - reg: new RegExp('@pageIndex@', 'ig'), - value: 1 - }) + if (!this.state.editItem) { + _customScript += ` + ${values.sql} + ` } - - regoptions.forEach(item => { - param.LText = param.LText.replace(item.reg, item.value) - }) + + if (_customScript) { + _customScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000) select @ErrorCode='',@retmsg ='' + ${_customScript} + ` + } + + let _setting = {...setting, customScript: _customScript} + + let param = { + func: 's_debug_sql', + LText: SettingUtils.getDebugSql(_setting, arr_field, regoptions, swhere) + } param.LText = Utils.formatOptions(param.LText) param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' @@ -209,7 +204,7 @@ } render() { - const { systemScripts, setting } = this.props + const { systemScripts, setting, type } = this.props const { getFieldDecorator } = this.props.form const { usefulFields } = this.state const formItemLayout = { @@ -233,24 +228,12 @@ </Col> : null} <Col span={16}> <Form.Item label={'鎶ラ敊瀛楁'} style={{margin: 0}}> - errorCode, errmsg + ErrorCode, retmsg </Form.Item> </Col> <Col span={24} className="sqlfield"> <Form.Item label={'鍙敤瀛楁'}> - id, bid, loginuid, sessionuid, userid, appkey, orderBy{setting.laypage !== 'false' ? ', pageSize, pageIndex': ''}{usefulFields ? ', ' + usefulFields : ''} - </Form.Item> - </Col> - <Col span={8} style={{whiteSpace: 'nowrap'}}> - <Form.Item style={{marginBottom: 0}} label="鍒濆鍖杝ql"> - {getFieldDecorator('initsql', { - initialValue: 'false' - })( - <Radio.Group> - <Radio value="true">鏄�</Radio> - <Radio value="false">鍚�</Radio> - </Radio.Group> - )} + id, bid, loginuid, sessionuid, userid, appkey, {type === 'main' ? 'out_id, ' : '' }time_id, orderBy{setting.laypage !== 'false' ? ', pageSize, pageIndex': ''}{usefulFields ? ', ' + usefulFields : ''} </Form.Item> </Col> <Col span={10}> @@ -266,10 +249,13 @@ </Select> </Form.Item> </Col> - <Col span={4} className="add"> - <Button onClick={this.handleConfirm} loading={this.state.loading} className="mk-green" style={{marginBottom: 15, marginLeft: 40}}> + <Col span={6} className="add"> + <Button onClick={this.handleConfirm} loading={this.state.loading} className="mk-green" style={{marginTop: 5, marginBottom: 15, marginLeft: 30}}> 淇濆瓨 </Button> + <Button onClick={this.handleCancel} style={{marginTop: 5, marginBottom: 15, marginLeft: 10}}> + 鍙栨秷 + </Button> </Col> <Col span={24} className="sql"> <Form.Item label={'sql'}> -- Gitblit v1.8.0