From 27eb6c35533be910488869c393e2c89e3c0a5b20 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 07 九月 2020 23:33:23 +0800 Subject: [PATCH] 2020-09-07 --- src/templates/sharecomponent/settingcomponent/settingform/customscript/index.jsx | 42 ++++++++++++++++-------------------------- 1 files changed, 16 insertions(+), 26 deletions(-) diff --git a/src/templates/sharecomponent/settingcomponent/settingform/customscript/index.jsx b/src/templates/sharecomponent/settingcomponent/settingform/customscript/index.jsx index b165a19..adb76d8 100644 --- a/src/templates/sharecomponent/settingcomponent/settingform/customscript/index.jsx +++ b/src/templates/sharecomponent/settingcomponent/settingform/customscript/index.jsx @@ -1,5 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' +import { fromJS } from 'immutable' import { Form, Row, Col, Button, notification, Modal, Select } from 'antd' import moment from 'moment' @@ -16,6 +17,7 @@ setting: PropTypes.object, // 璁剧疆 searches: PropTypes.array, // 鎼滅储鏉′欢 swhere: PropTypes.string, // where鏉′欢 + defaultSql: PropTypes.string, // 榛樿sql arr_field: PropTypes.string, // 鍒楀瓧娈� regoptions: PropTypes.array, // 姝e垯鏇挎崲 systemScripts: PropTypes.array, // 绯荤粺鑴氭湰 @@ -123,36 +125,23 @@ return } - 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 scripts = fromJS(this.props.scripts).toJS() - if (!this.state.editItem) { - _customScript += ` - ${values.sql} - ` + if (values.uuid) { + scripts = scripts.map(item => { + if (item.uuid === values.uuid) { + return values + } else { + return item + } + }) + } else { + scripts.push(values) } - - 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) + LText: SettingUtils.getDebugSql(setting, scripts, arr_field, regoptions, swhere) } param.LText = Utils.formatOptions(param.LText) @@ -203,7 +192,7 @@ } render() { - const { systemScripts, setting, type } = this.props + const { systemScripts, setting, type, defaultSql } = this.props const { getFieldDecorator } = this.props.form const { usefulFields } = this.state const formItemLayout = { @@ -242,6 +231,7 @@ filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} onChange={this.selectScript} > + <Select.Option key="default" value={defaultSql}>榛樿sql</Select.Option> {systemScripts.map((option, i) => <Select.Option style={{whiteSpace: 'normal'}} key={i} value={option.value}>{option.name}</Select.Option> )} -- Gitblit v1.8.0