From ce2b708f61de1855771d78f35309bd77df9d3b15 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 09 八月 2020 23:28:08 +0800 Subject: [PATCH] 2020-08-09 --- src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx | 61 +++++++++++++++++++++++++----- 1 files changed, 51 insertions(+), 10 deletions(-) diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx index abf8146..9b8ecee 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx @@ -1,13 +1,13 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Row, Col, Input, Button, notification, Modal, Icon, Tooltip, Radio, Select } from 'antd' +import { is, fromJS } from 'immutable' +import { Form, Row, Col, Button, notification, Modal, Icon, Tooltip, Radio, Select } 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 = { @@ -38,7 +38,7 @@ } let _sql = `Declare @${btn.sheet} table (${usefulfields.map(item => item.Column + ' ' + item.type).join(',')},jskey nvarchar(50) ) - Declare @UserName nvarchar(50),@FullName nvarchar(50),@ErrorCode nvarchar(50), @retmsg nvarchar(4000) + Declare @UserName nvarchar(50),@FullName nvarchar(50),@ErrorCode nvarchar(50), @retmsg nvarchar(4000),@tbid Nvarchar(512) Select @ErrorCode='', @retmsg='' ` @@ -46,6 +46,31 @@ verifySql: _sql, usefulfields: fields.join(', ') }) + } + + UNSAFE_componentWillReceiveProps (nextProps) { + const { btn } = this.props + + if (nextProps.usefulfields && !is(fromJS(this.props.usefulfields), fromJS(nextProps.usefulfields))) { + + let fields = nextProps.usefulfields.map(item => item.Column) + if (!fields.includes('ID')) { + fields.unshift('ID') + } + if (!fields.includes('BID')) { + fields.unshift('BID') + } + + let _sql = `Declare @${btn.sheet} table (${nextProps.usefulfields.map(item => item.Column + ' ' + item.type).join(',')},jskey nvarchar(50) ) + Declare @UserName nvarchar(50),@FullName nvarchar(50),@ErrorCode nvarchar(50), @retmsg nvarchar(4000),@tbid Nvarchar(512) + Select @ErrorCode='', @retmsg='' + ` + + this.setState({ + verifySql: _sql, + usefulfields: fields.join(', ') + }) + } } edit = (record) => { @@ -125,6 +150,9 @@ func: 's_debug_sql', LText: this.state.verifySql + _initsql + values.sql + tail } + + param.LText = param.LText.replace(/@\$|\$@/ig, '') + 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) @@ -153,6 +181,16 @@ }) } + handleCancel = () => { + this.setState({ + editItem: null + }) + + this.props.form.setFieldsValue({ + sql: '' + }) + } + selectScript = (value, option) => { const { usefulfields, btn } = this.props @@ -164,7 +202,7 @@ fields = fields + ',' } - _value = `Insert into ${btn.sheet} (${fields}createuserid,createuser,createstaff,bid)\nSelect ${fields}@userid,@username,@fullname,@BID From @${btn.sheet}` + _value = `Insert into ${btn.sheet} (${fields}createuserid,createuser,createstaff,bid)\nSelect ${fields}@userid@,@username,@fullname,@BID@ From @${btn.sheet}` } else { _value = value } @@ -212,12 +250,12 @@ </Col> : null} <Col span={16}> <Form.Item label={'鎶ラ敊瀛楁'} style={{margin: 0}}> - errorCode, errmsg + ErrorCode, retmsg </Form.Item> </Col> {usefulfields ? <Col span={24} className="sqlfield"> <Form.Item label={'鍙敤瀛楁'}> - {usefulfields} + {usefulfields}, jskey </Form.Item> </Col> : null} <Col span={8} style={{whiteSpace: 'nowrap'}}> @@ -228,7 +266,7 @@ </Tooltip> }> {getFieldDecorator('position', { - initialValue: 'back' + initialValue: 'front' })( <Radio.Group> <Radio value="init">鍒濆鍖�</Radio> @@ -257,9 +295,12 @@ </Select> </Form.Item> </Col> - <Col span={4} className="add"> + <Col span={6} className="add"> <Button onClick={this.handleConfirm} loading={this.state.loading} className="mk-green" style={{marginBottom: 15, marginLeft: 40}}> 淇濆瓨 + </Button> + <Button onClick={this.handleCancel} style={{marginBottom: 15, marginLeft: 10}}> + 鍙栨秷 </Button> </Col> <Col span={24} className="sql"> @@ -272,7 +313,7 @@ message: this.props.dict['form.required.input'] + 'sql!' } ] - })(<TextArea rows={15} />)} + })(<CodeMirror />)} </Form.Item> </Col> </Row> -- Gitblit v1.8.0