From 2a347c8d91d6962f4302f0553c55a3b9f743baa5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 09 九月 2020 21:15:58 +0800 Subject: [PATCH] 2020-09-09 --- src/tabviews/treepage/index.jsx | 59 src/templates/sharecomponent/settingcomponent/index.jsx | 27 src/templates/zshare/customscript/index.scss | 8 src/templates/comtableconfig/index.jsx | 31 src/tabviews/calendar/index.jsx | 64 src/templates/treepageconfig/index.jsx | 5 src/templates/zshare/editcomponent/index.jsx | 120 ++ src/templates/modalconfig/index.jsx | 67 - src/templates/sharecomponent/settingcalcomponent/verifycard/index.jsx | 285 ---- src/components/sidemenu/config.jsx | 8 src/templates/sharecomponent/settingcomponent/settingform/index.jsx | 505 +++------ src/templates/sharecomponent/treesettingcomponent/settingform/datasource/index.scss | 22 src/templates/zshare/replaceform/index.jsx | 119 ++ src/templates/sharecomponent/settingcomponent/settingform/utils.jsx | 10 src/templates/zshare/replaceform/index.scss | 3 src/templates/sharecomponent/settingcalcomponent/verifycard/index.scss | 2 src/templates/sharecomponent/treesettingcomponent/settingform/datasource/index.jsx | 496 +++++++++ src/templates/sharecomponent/settingcalcomponent/verifycard/utils.jsx | 2 src/templates/sharecomponent/treesettingcomponent/settingform/index.jsx | 800 ++----------- /dev/null | 34 src/templates/sharecomponent/treesettingcomponent/index.scss | 1 src/templates/sharecomponent/treesettingcomponent/settingform/utils.jsx | 48 src/templates/zshare/customscript/index.jsx | 436 +++++++ src/templates/sharecomponent/treesettingcomponent/index.jsx | 92 - src/templates/sharecomponent/treesettingcomponent/settingform/index.scss | 9 25 files changed, 1,749 insertions(+), 1,504 deletions(-) diff --git a/src/components/sidemenu/config.jsx b/src/components/sidemenu/config.jsx index 02602f3..d6fc819 100644 --- a/src/components/sidemenu/config.jsx +++ b/src/components/sidemenu/config.jsx @@ -177,6 +177,14 @@ MenuNo: 'bd_msn_sms_tempM', MenuName: '澶т簬鐭俊妯℃澘', text: '澶т簬鐭俊妯℃澘' + }, { + src: '', + PageParam: {OpenType: 'newtab', Template: 'ManageTable'}, + type: 'ManageTable', + MenuID: '1599613340050c8nu6rbst9d4emnnbsq', + MenuNo: 's_sms_qxM', + MenuName: '濂囦簯鐭俊妯℃澘', + text: '濂囦簯鐭俊妯℃澘' }] }, { MenuID: 'systemPayManage', diff --git a/src/tabviews/calendar/index.jsx b/src/tabviews/calendar/index.jsx index 6d43995..899056d 100644 --- a/src/tabviews/calendar/index.jsx +++ b/src/tabviews/calendar/index.jsx @@ -150,21 +150,37 @@ return item }) - // 鏁寸悊鏁版嵁婧愯嚜瀹氫箟鑴氭湰 - let _customScript = '' - config.scripts && config.scripts.forEach(script => { - if (script.status !== 'false') { - _customScript += ` - ${script.sql} - ` - } - }) - - config.setting.customScript = _customScript - // 鏁版嵁婧� if (config.setting.interType === 'inner' && !config.setting.innerFunc) { config.setting.interType = 'system' + } + + if (config.setting.interType === 'system') { + // 鏁寸悊鏁版嵁婧愯嚜瀹氫箟鑴氭湰 + let _customScript = '' + config.scripts && config.scripts.forEach(script => { + if (script.status !== 'false') { + _customScript += ` + ${script.sql} + ` + } + }) + + if (/\s/.test(config.setting.dataresource)) { + config.setting.dataresource = '(' + config.setting.dataresource + ') tb' + } + + if (this.props.dataManager) { // 鏁版嵁鏉冮檺 + config.setting.dataresource = config.setting.dataresource.replace(/\$@/ig, '/*') + config.setting.dataresource = config.setting.dataresource.replace(/@\$/ig, '*/') + _customScript = _customScript.replace(/\$@/ig, '/*') + _customScript = _customScript.replace(/@\$/ig, '*/') + } else { + config.setting.dataresource = config.setting.dataresource.replace(/@\$|\$@/ig, '') + _customScript = _customScript.replace(/@\$|\$@/ig, '') + } + + config.setting.customScript = _customScript } this.setState({ @@ -301,33 +317,17 @@ const { arr_field, search, setting, config, calendarYear } = this.state let _search = Utils.joinMainSearchkey(search) - _search = _search ? 'where ' + _search : '' let param = { func: 'sPC_Get_TableData', obj_name: 'data', arr_field: arr_field, - custom_script: setting.customScript || '', - default_sql: setting.default || 'true' + custom_script: setting.customScript, + default_sql: setting.execute || 'true' } let _dataresource = setting.dataresource - - if (/\s/.test(_dataresource)) { - _dataresource = '(' + _dataresource + ') tb' - } - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - _dataresource = _dataresource.replace(/\$@/ig, '/*') - _dataresource = _dataresource.replace(/@\$/ig, '*/') - param.custom_script = param.custom_script.replace(/\$@/ig, '/*') - param.custom_script = param.custom_script.replace(/@\$/ig, '*/') - } else { - _dataresource = _dataresource.replace(/@\$|\$@/ig, '') - param.custom_script = param.custom_script.replace(/@\$|\$@/ig, '') - } - let regoptions = null if (setting.queryType === 'statistics' || param.custom_script) { let allSearch = Utils.getAllSearchOptions(search) @@ -351,7 +351,7 @@ }) } - if (setting.queryType === 'statistics' && setting.default !== 'false') { // 缁熻鏁版嵁婧愶紝鍐呭鏇挎崲 + if (setting.queryType === 'statistics' && setting.execute !== 'false') { // 缁熻鏁版嵁婧愶紝鍐呭鏇挎崲 regoptions.forEach(item => { _dataresource = _dataresource.replace(item.reg, item.value) }) @@ -360,7 +360,7 @@ let LText = '' - if (setting.default !== 'false') { + if (setting.execute !== 'false') { LText = `select ${arr_field} from ${_dataresource} ${_search}` } diff --git a/src/tabviews/treepage/index.jsx b/src/tabviews/treepage/index.jsx index c7e9302..b95c688 100644 --- a/src/tabviews/treepage/index.jsx +++ b/src/tabviews/treepage/index.jsx @@ -146,34 +146,41 @@ config.setting.execute = config.setting.default !== 'false' // 榛樿sql鏄惁鎵ц锛岃浆涓篵oolean 缁熶竴鏍煎紡 config.setting.customScript = '' // 鑷畾涔夎剼鏈� - if (config.setting.scripts && config.setting.scripts.length > 0) { - let _customScript = '' - config.setting.scripts.forEach(item => { - if (item.status === 'false') return - _customScript += ` - ${item.sql} - ` - }) - config.setting.customScript = _customScript + // 鏁版嵁婧� + if (config.setting.interType === 'inner' && !config.setting.innerFunc) { + config.setting.interType = 'system' } - if (!config.setting.execute) { // 榛樿sql 涓嶆墽琛屾椂 缃┖ - config.setting.dataresource = '' - } else { - config.setting.dataresource = config.setting.dataresource || '' - } - if (/\s/.test(config.setting.dataresource)) { - config.setting.dataresource = '(' + config.setting.dataresource + ') tb' - } - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - config.setting.dataresource = config.setting.dataresource.replace(/\$@/ig, '/*') - config.setting.dataresource = config.setting.dataresource.replace(/@\$/ig, '*/') - config.setting.customScript = config.setting.customScript.replace(/\$@/ig, '/*') - config.setting.customScript = config.setting.customScript.replace(/@\$/ig, '*/') - } else { - config.setting.dataresource = config.setting.dataresource.replace(/@\$|\$@/ig, '') - config.setting.customScript = config.setting.customScript.replace(/@\$|\$@/ig, '') + if (config.setting.interType === 'system') { + if (config.setting.scripts && config.setting.scripts.length > 0) { + let _customScript = '' + config.setting.scripts.forEach(item => { + if (item.status === 'false') return + _customScript += ` + ${item.sql} + ` + }) + config.setting.customScript = _customScript + } + + if (!config.setting.execute) { // 榛樿sql 涓嶆墽琛屾椂 缃┖ + config.setting.dataresource = '' + } else { + config.setting.dataresource = config.setting.dataresource || '' + } + if (/\s/.test(config.setting.dataresource)) { + config.setting.dataresource = '(' + config.setting.dataresource + ') tb' + } + + if (this.props.dataManager) { // 鏁版嵁鏉冮檺 + config.setting.dataresource = config.setting.dataresource.replace(/\$@/ig, '/*') + config.setting.dataresource = config.setting.dataresource.replace(/@\$/ig, '*/') + config.setting.customScript = config.setting.customScript.replace(/\$@/ig, '/*') + config.setting.customScript = config.setting.customScript.replace(/@\$/ig, '*/') + } else { + config.setting.dataresource = config.setting.dataresource.replace(/@\$|\$@/ig, '') + config.setting.customScript = config.setting.customScript.replace(/@\$|\$@/ig, '') + } } this.setState({ diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index c3f085b..e173344 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -1139,6 +1139,37 @@ pasteContent: null }) }) + } else if (res.type === 'replace') { + let config = fromJS(this.state.config).toJS() + + if (res.repType === 'field') { + let origin = res.origin.toLowerCase() + let value = res.value + + config.search = config.search.map(item => { + if (item.field && item.field.toLowerCase() === origin) { + item.field = value + } else if (item.datefield && item.datefield.toLowerCase() === origin) { + item.datefield = value + } + return item + }) + config.columns = config.columns.map(item => { + if (item.field && item.field.toLowerCase() === origin) { + item.field = value + } else if (item.nameField && item.nameField.toLowerCase() === origin) { + item.nameField = value + } + return item + }) + } + + notification.success({ + top: 92, + message: '鏇挎崲鎴愬姛銆�', + duration: 2 + }) + this.setState({ config }) } } diff --git a/src/templates/modalconfig/index.jsx b/src/templates/modalconfig/index.jsx index 6659705..954a46a 100644 --- a/src/templates/modalconfig/index.jsx +++ b/src/templates/modalconfig/index.jsx @@ -15,13 +15,13 @@ import { queryTableSql } from '@/utils/option.js' import ModalForm from '@/templates/zshare/modalform' -import PasteForm from '@/templates/zshare/pasteform' import DragElement from './dragelement' import SourceElement from './dragelement/source' import SettingForm from './settingform' import GroupForm from './groupform' import EditCard from './editcard' import MenuForm from './menuform' +import EditComponent from '@/templates/zshare/editcomponent' import { BaseConfig, SearchItems } from './source' import './index.scss' @@ -68,7 +68,6 @@ curgroup: null, // 褰撳墠缁勶紝鏂板缓鎴栫紪杈� optionLibs: null, // 鑷畾涔変笅鎷夐�夐」搴� sources: null, // 琛ㄥ崟绫诲瀷 - pasteVisible: null, // 琛ㄥ崟绮樿创 sqlVerifing: false, // sql楠岃瘉 openEdition: '' // 缂栬緫鐗堟湰鏍囪锛岄槻姝㈠浜烘搷浣� } @@ -1217,44 +1216,15 @@ } } - pasteSubmit = () => { - let _config = JSON.parse(JSON.stringify(this.state.config)) - - this.pasteFormRef.handleConfirm().then(res => { - if (res.copyType === 'form') { - if (_config.groups.length > 0) { - _config.groups.forEach(group => { - if (group.default) { - group.sublist.push(res) - } - }) - } else { - _config.fields.push(res) - } - - if (!this.props.editTab && res.type === 'linkMain') { - notification.warning({ - top: 92, - message: '涓嶆敮鎸佹琛ㄥ崟绫诲瀷锛�', - duration: 10 - }) - return - } - - this.setState({ - config: _config, - pasteVisible: null - }, () => { - this.handleForm(res, 'edit') - }) - } else { - notification.warning({ - top: 92, - message: '閰嶇疆淇℃伅鏍煎紡閿欒锛�', - duration: 10 - }) - } - }) + /** + * @description 缂栬緫鍔熻兘瀹屾垚鏇存柊锛屽寘鎷В鍐绘寜閽�佺矘璐淬�佹浛鎹㈢瓑 + */ + updateConfig = (res) => { + if (res.type === 'paste') { + this.setState({ + config: res.content + }) + } } render () { @@ -1317,6 +1287,7 @@ <div className="setting"> <Card title={this.state.dict['header.menu.form.configurable']} bordered={false} extra={ <div> + <EditComponent dict={this.state.dict} type="form" config={this.state.config} refresh={this.updateConfig}/> <Button type="primary" onClick={this.submitConfig} loading={this.state.menuloading}>{this.state.dict['model.save']}</Button> <Button onClick={this.cancelConfig}>{this.state.dict['model.back']}</Button> </div> @@ -1330,7 +1301,6 @@ <div className="ant-modal-title">{config.setting.title}</div> </div> <div className="ant-modal-body"> - <Icon className="paste-Icon" type="snippets" title={this.state.dict['header.form.paste']} onClick={() => {this.setState({pasteVisible: true})}} /> <div className="modal-form"> {config.groups.length > 0 && config.groups.map(group => { @@ -1471,21 +1441,6 @@ group={this.state.curgroup} inputSubmit={this.handleGroupSave} wrappedComponentRef={(inst) => this.groupRef = inst} - /> - </Modal> - {/* 鎸夐挳閰嶇疆淇℃伅绮樿创澶嶅埗 */} - <Modal - title={this.state.dict['header.form.paste']} - visible={this.state.pasteVisible} - width={600} - maskClosable={false} - onOk={this.pasteSubmit} - onCancel={() => {this.setState({pasteVisible: null})}} - destroyOnClose - > - <PasteForm - dict={this.state.dict} - wrappedComponentRef={(inst) => this.pasteFormRef = inst} /> </Modal> </div> diff --git a/src/templates/sharecomponent/settingcalcomponent/verifycard/customscript/index.jsx b/src/templates/sharecomponent/settingcalcomponent/verifycard/customscript/index.jsx deleted file mode 100644 index 5376305..0000000 --- a/src/templates/sharecomponent/settingcalcomponent/verifycard/customscript/index.jsx +++ /dev/null @@ -1,235 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { Form, Row, Col, Button, notification, Select } from 'antd' - -import Utils from '@/utils/utils.js' -import CodeMirror from '@/templates/zshare/codemirror' -import './index.scss' - -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, // 绯荤粺鑴氭湰 - scriptSubmit: PropTypes.func, // 鑴氭湰楠岃瘉鍚庢彁浜� - scriptsChange: PropTypes.func // 鑴氭湰楠岃瘉 - } - - state = { - editItem: null, - loading: false, - usefulFields: '' - } - - UNSAFE_componentWillMount() { - const { searches } = this.props - - let _usefulFields = [] - searches.forEach(item => { - if (!item.field) return - - if (item.type === 'group') { - if (item.transfer === 'true') { - _usefulFields.push(item.field) - } - _usefulFields.push(item.datefield) - _usefulFields.push(item.datefield + '1') - } else if (['dateweek', 'datemonth', 'daterange'].includes(item.type)) { - _usefulFields.push(item.field) - _usefulFields.push(item.field + '1') - } else if (_usefulFields.includes(item.field)) { - _usefulFields.push(item.field + '1') - } else { - _usefulFields.push(item.field) - } - }) - - this.setState({ - usefulFields: _usefulFields.join(', ') - }) - } - - edit = (record) => { - this.setState({ - editItem: record - }) - - this.props.form.setFieldsValue({ - sql: record.sql - }) - } - - handleCancel = () => { - this.setState({ - editItem: null - }) - this.props.form.setFieldsValue({ - sql: '' - }) - } - - handleConfirm = () => { - // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - values.uuid = this.state.editItem ? this.state.editItem.uuid : '' - - let _quot = values.sql.match(/'{1}/g) - let _lparen = values.sql.match(/\({1}/g) - let _rparen = values.sql.match(/\){1}/g) - - _quot = _quot ? _quot.length : 0 - _lparen = _lparen ? _lparen.length : 0 - _rparen = _rparen ? _rparen.length : 0 - - if (_quot % 2 !== 0) { - notification.warning({ - top: 92, - message: 'sql涓璡'蹇呴』鎴愬鍑虹幇', - duration: 5 - }) - return - } else if (_lparen !== _rparen) { - notification.warning({ - top: 92, - message: 'sql涓�()蹇呴』鎴愬鍑虹幇', - duration: 5 - }) - return - } else if (/--/ig.test(values.sql)) { - notification.warning({ - top: 92, - message: '鑷畾涔塻ql璇彞涓紝涓嶅彲鍑虹幇瀛楃 -- 锛屾敞閲婅鐢� /*鍐呭*/', - duration: 5 - }) - return - } - - let error = Utils.verifySql(values.sql, 'customscript') - - if (error) { - notification.warning({ - top: 92, - message: 'sql涓笉鍙娇鐢�' + error, - duration: 5 - }) - return - } - - this.setState({loading: true}) - this.props.scriptsChange(values).then(() => { - this.setState({ - editItem: null, - loading: false - }) - this.props.form.setFieldsValue({ - sql: '' - }) - this.props.scriptSubmit(values) - }, () => { - this.setState({ - loading: false - }) - }) - } - }) - } - - selectScript = (value, option) => { - let _sql = this.props.form.getFieldValue('sql') - if (_sql) { - _sql = _sql + ` - - ` - } - - _sql = _sql.replace(/\s{6}$/, '') - _sql = _sql + `/*${option.props.children}*/ - ` - _sql = _sql.replace(/\s{4}$/, '') - _sql = _sql + value - - this.props.form.setFieldsValue({ - sql: _sql - }) - } - - render() { - const { systemScripts, setting } = this.props - const { getFieldDecorator } = this.props.form - const { usefulFields } = this.state - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 8 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 16 } - } - } - - return ( - <Form {...formItemLayout} className="modal-menu-setting-script"> - <Row gutter={24}> - {setting.tableName ? <Col span={8}> - <Form.Item label={'琛ㄥ悕'} style={{whiteSpace: 'nowrap', margin: 0}}> - {setting.tableName} - </Form.Item> - </Col> : null} - <Col span={16}> - <Form.Item label={'鎶ラ敊瀛楁'} style={{margin: 0}}> - ErrorCode, retmsg - </Form.Item> - </Col> - <Col span={24} className="sqlfield"> - <Form.Item label={'鍙敤瀛楁'}> - id, bid, loginuid, sessionuid, userid, appkey, time_id, calendarDate, calendarDate1{usefulFields ? ', ' + usefulFields : ''} - </Form.Item> - </Col> - <Col span={10}> - <Form.Item label={'蹇嵎娣诲姞'} style={{marginBottom: 0}}> - <Select - showSearch - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - onChange={this.selectScript} - > - {systemScripts.map((option, i) => - <Select.Option style={{whiteSpace: 'normal'}} key={i} value={option.value}>{option.name}</Select.Option> - )} - </Select> - </Form.Item> - </Col> - <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'}> - {getFieldDecorator('sql', { - initialValue: '', - rules: [ - { - required: true, - message: this.props.dict['form.required.input'] + 'sql!' - } - ] - })(<CodeMirror />)} - </Form.Item> - </Col> - </Row> - </Form> - ) - } -} - -export default Form.create()(CustomForm) \ No newline at end of file diff --git a/src/templates/sharecomponent/settingcalcomponent/verifycard/index.jsx b/src/templates/sharecomponent/settingcalcomponent/verifycard/index.jsx index ee48c94..8cf05d2 100644 --- a/src/templates/sharecomponent/settingcalcomponent/verifycard/index.jsx +++ b/src/templates/sharecomponent/settingcalcomponent/verifycard/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { fromJS } from 'immutable' -import { Form, Tabs, Table, Popconfirm, Icon, notification, Modal, Typography, Spin } from 'antd' +import { Form, Tabs, Table, Popconfirm, Icon, notification, Modal, Spin } from 'antd' import moment from 'moment' import Api from '@/api' @@ -9,13 +9,12 @@ import asyncComponent from '@/utils/asyncComponent' import ColForm from './columnform' -import CustomScriptsForm from './customscript' +import CustomScript from '@/templates/zshare/customscript' import SettingForm from './settingform' import SettingUtils from './utils' import './index.scss' const { TabPane } = Tabs -const { Paragraph } = Typography const FieldsComponent = asyncComponent(() => import('@/templates/sharecomponent/fieldscomponent')) @@ -33,13 +32,8 @@ columns: [], activeKey: 'setting', loading: false, - initsql: '', // sql楠岃瘉鏃跺彉閲忓0鏄庡強璧嬪�� usefulfields: '', defaultsql: '', // 榛樿Sql - systemScripts: [{ - name: '榛樿sql', - value: '' - }], colColumns: [ { title: '鍚嶇О', @@ -63,59 +57,11 @@ dataIndex: 'operation', render: (text, record) => (<div> - <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record, 'columns')} style={{color: '#1890ff'}}><Icon type="edit" /></span> + <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record)} style={{color: '#1890ff'}}><Icon type="edit" /></span> <Popconfirm overlayClassName="popover-confirm" title={this.props.dict['model.query.delete']} onConfirm={() => this.deleteColumn(record) - }> - <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> - </Popconfirm> - </div>) - } - ], - scriptsColumns: [ - { - title: 'SQL', - dataIndex: 'sql', - width: '60%', - render: (text) => ( - <Paragraph copyable ellipsis={{ rows: 5, expandable: true }}>{text}</Paragraph> - ) - }, - { - title: '鐘舵��', - dataIndex: 'status', - width: '20%', - render: (text, record) => record.status === 'false' ? - ( - <div> - {this.props.dict['model.status.forbidden']} - <Icon style={{marginLeft: '5px'}} type="stop" theme="twoTone" twoToneColor="#ff4d4f" /> - </div> - ) : - ( - <div> - {this.props.dict['model.status.open']} - <Icon style={{marginLeft: '5px'}} type="check-circle" theme="twoTone" twoToneColor="#52c41a" /> - </div> - ) - }, - { - title: '鎿嶄綔', - align: 'center', - width: '20%', - dataIndex: 'operation', - render: (text, record) => - (<div> - <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record, 'scripts')} style={{color: '#1890ff'}}><Icon type="edit" /></span> - <span className="operation-btn" onClick={() => this.handleUpDown(record, 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> - <span className="operation-btn" onClick={() => this.handleUpDown(record, 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> - <span className="operation-btn" title={this.props.dict['model.status.change']} onClick={() => this.handleStatus(record)} style={{color: '#8E44AD'}}><Icon type="swap" /></span> - <Popconfirm - overlayClassName="popover-confirm" - title={this.props.dict['model.query.delete']} - onConfirm={() => this.deleteScript(record) }> <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> </Popconfirm> @@ -127,59 +73,10 @@ UNSAFE_componentWillMount() { const { config } = this.props - let _setting = fromJS(config.setting).toJS() - if (_setting.interType === 'inner' && !_setting.innerFunc) { - _setting.interType = 'system' - } - this.setState({ - setting: _setting, + setting: fromJS(config.setting).toJS(), columns: fromJS(config.columns).toJS(), scripts: fromJS(config.scripts).toJS() - }) - - this.getsysScript() - } - - getsysScript = () => { - let _scriptSql = `Select distinct func+Remark as funcname,longparam, s.Sort from聽 s_custom_script s inner join (select OpenID from sapp where ID=@Appkey@) p on s.openid = case when s.appkey='' then s.openid else p.OpenID end order by s.Sort` - - _scriptSql = Utils.formatOptions(_scriptSql) - - let _sParam = { - func: 'sPC_Get_SelectedList', - LText: _scriptSql, - obj_name: 'data', - arr_field: 'funcname,longparam' - } - - _sParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _sParam.secretkey = Utils.encrypt(_sParam.LText, _sParam.timestamp) - _sParam.open_key = Utils.encryptOpenKey(_sParam.secretkey, _sParam.timestamp) // 浜戠鏁版嵁楠岃瘉 - - Api.getSystemConfig(_sParam).then(res => { - if (res.status) { - let _scripts = [] - - res.data.forEach(item => { - let _item = { - name: item.funcname, - value: Utils.UnformatOptions(item.longparam) - } - - _scripts.push(_item) - }) - - this.setState({ - systemScripts: [...this.state.systemScripts, ..._scripts] - }) - } else { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } }) } @@ -206,18 +103,10 @@ this.setState({ columns: this.state.columns.filter(item => item.uuid !== record.uuid) }) } - deleteScript = (record) => { - this.setState({ scripts: this.state.scripts.filter(item => item.uuid !== record.uuid) }) - } + handleEdit = (record) => { + this.contrastForm.edit(record) - handleEdit = (record, type) => { - if (type === 'scripts') { - this.scriptsForm.edit(record) - } else if (type === 'columns') { - this.contrastForm.edit(record) - } - - let node = document.getElementById('model-verify-card-box-tab').parentNode + let node = document.getElementById('model-setting-form-body').parentNode if (node && node.scrollTop) { let inter = Math.ceil(node.scrollTop / 10) @@ -233,88 +122,9 @@ } } - handleStatus = (record) => { - let scripts = fromJS(this.state.scripts).toJS() - record.status = record.status === 'false' ? 'true' : 'false' - - scripts = scripts.map(item => { - if (item.uuid === record.uuid) { - return record - } else { - return item - } - }) - - this.setState({ scripts }) - } - - handleUpDown = (record, direction) => { - let scripts = fromJS(this.state.scripts).toJS() - let index = 0 - - scripts = scripts.filter((item, i) => { - if (item.uuid === record.uuid) { - index = i - } - - return item.uuid !== record.uuid - }) - if ((index === 0 && direction === 'up') || (index === scripts.length && direction === 'down')) { - return - } - - if (direction === 'up') { - scripts.splice(index - 1, 0, record) - } else { - scripts.splice(index + 1, 0, record) - } - - this.setState({ scripts }) - } - - scriptsChange = (values) => { - let scripts = fromJS(this.state.scripts).toJS() - - if (values.uuid) { - scripts = scripts.map(item => { - if (item.uuid === values.uuid) { - return values - } else { - return item - } - }) - } else { - scripts.push(values) - } - - return new Promise((resolve, reject) => { - this.sqlverify(resolve, reject, false, scripts) - }) - } - - scriptSubmit = (values) => { - let scripts = fromJS(this.state.scripts).toJS() - - if (values.uuid) { - scripts = scripts.map(item => { - if (item.uuid === values.uuid) { - return values - } else { - return item - } - }) - } else { - values.uuid = Utils.getuuid() - scripts.push(values) - } - - this.setState({ scripts }) - } - changeTab = (val) => { const { activeKey, setting } = this.state - this.setState({loading: true}) if (activeKey === 'setting') { this.settingForm.handleConfirm().then(res => { if (res.interType !== 'system' && val === 'scripts') { @@ -323,7 +133,6 @@ message: '浣跨敤绯荤粺鎺ュ彛鏃讹紝鎵嶅彲浠ヨ缃嚜瀹氫箟鑴氭湰锛�', duration: 5 }) - this.setState({loading: false}) return } @@ -331,6 +140,8 @@ setting: res }, () => { if (res.interType === 'system') { // 绯荤粺鎺ュ彛锛宻ql楠岃瘉 + this.setState({loading: true}) + this.sqlverify(() => { // 楠岃瘉鎴愬姛 this.setState({ activeKey: val, @@ -343,13 +154,10 @@ }, activeKey) } else { this.setState({ - activeKey: val, - loading: false + activeKey: val }) } }) - }, () => { - this.setState({loading: false}) }) } else if (activeKey === 'columns') { if (setting.interType !== 'system' && val === 'scripts') { @@ -358,26 +166,12 @@ message: '浣跨敤绯荤粺鎺ュ彛鏃讹紝鎵嶅彲浠ヨ缃嚜瀹氫箟鑴氭湰锛�', duration: 5 }) - this.setState({loading: false}) - return - } else if (setting.interType !== 'system') { - this.setState({ - activeKey: val, - loading: false - }) return } - this.sqlverify(() => { // 楠岃瘉鎴愬姛 - this.setState({ - activeKey: val, - loading: false - }) - }, () => { // 楠岃瘉澶辫触 - this.setState({ - loading: false - }) - }, activeKey) + this.setState({ + activeKey: val + }) } else if (activeKey === 'scripts') { let _loading = false if (this.scriptsForm && this.scriptsForm.state.editItem) { @@ -392,12 +186,10 @@ message: '瀛樺湪鏈繚瀛樿剼鏈紝璇风偣鍑荤‘瀹氫繚瀛橈紝鎴栫偣鍑诲彇娑堟斁寮冧慨鏀癸紒', duration: 5 }) - this.setState({ - loading: false - }) return } + this.setState({loading: true}) this.sqlverify(() => { // 楠岃瘉鎴愬姛 this.setState({ activeKey: val, @@ -453,6 +245,12 @@ sqlverify = (resolve, reject, type, testScripts) => { const { searches } = this.props const { columns, setting, scripts } = this.state + + if (setting.interType !== 'system') { // 涓嶄娇鐢ㄧ郴缁熸帴鍙f椂锛屼笉闇�瑕乻ql楠岃瘉 + resolve() + return + } + let _scripts = [] if (testScripts) { @@ -461,7 +259,7 @@ _scripts = scripts.filter(item => item.status !== 'false') } - if (type === 'submit' && setting.interType === 'system' && setting.execute === 'false' && _scripts.length === 0) { + if (type === 'submit' && setting.execute === 'false' && _scripts.length === 0) { notification.warning({ top: 92, message: '涓嶆墽琛岄粯璁ql鏃讹紝璇锋坊鍔犺嚜瀹氫箟鑴氭湰锛�', @@ -472,11 +270,11 @@ } // 涓嶄娇鐢ㄩ粯璁ql鍒囨崲 - if (type === 'setting' && setting.interType === 'system' && setting.execute === 'false') { + if (type === 'setting' && setting.execute === 'false') { resolve() } else if (type === 'scripts' && _scripts.length === 0) { resolve() - } else if (setting.interType === 'system' && (setting.execute !== 'false' || _scripts.length > 0)) { + } else if (setting.execute !== 'false' || _scripts.length > 0) { let param = { func: 's_debug_sql', LText: SettingUtils.getDebugSql(setting, _scripts, columns, searches) @@ -506,6 +304,18 @@ }) } + // 鑷畾涔夎剼鏈慨鏀� + scriptsChange = (scripts) => { + return new Promise((resolve, reject) => { + this.sqlverify(resolve, reject, 'verify', scripts) + }) + } + + // 鑷畾涔夎剼鏈洿鏂� + scriptsUpdate = (scripts) => { + this.setState({scripts}) + } + /** * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 */ @@ -516,10 +326,10 @@ } render() { - const { columns, setting, scripts, colColumns, scriptsColumns, activeKey, loading } = this.state + const { columns, setting, scripts, colColumns, activeKey, loading } = this.state return ( - <div id="model-verify-card-box-tab"> + <div className="model-verify-card-box-tab" id="model-setting-form-body"> {loading && <Spin size="large" />} <Tabs activeKey={activeKey} className="verify-card-box" onChange={this.changeTab}> <TabPane tab="鏁版嵁婧�" key="setting"> @@ -555,24 +365,15 @@ /> </TabPane> <TabPane tab="鑷畾涔夎剼鏈�" key="scripts"> - <CustomScriptsForm - setting={setting} - searches={this.props.searches} - initsql={this.state.initsql} + <CustomScript dict={this.props.dict} - customScripts={scripts} - systemScripts={this.state.systemScripts} + setting={setting} + scripts={scripts} + defaultSql={this.state.defaultsql} + searches={this.props.searches} scriptsChange={this.scriptsChange} - scriptSubmit={this.scriptSubmit} + scriptsUpdate={this.scriptsUpdate} wrappedComponentRef={(inst) => this.scriptsForm = inst} - /> - <Table - bordered - rowKey="uuid" - className="custom-table" - dataSource={scripts} - columns={scriptsColumns} - pagination={false} /> </TabPane> </Tabs> diff --git a/src/templates/sharecomponent/settingcalcomponent/verifycard/index.scss b/src/templates/sharecomponent/settingcalcomponent/verifycard/index.scss index 31e4d0a..3847eb4 100644 --- a/src/templates/sharecomponent/settingcalcomponent/verifycard/index.scss +++ b/src/templates/sharecomponent/settingcalcomponent/verifycard/index.scss @@ -1,4 +1,4 @@ -#model-verify-card-box-tab { +.model-verify-card-box-tab { .ant-spin { position: absolute; left: calc(50% - 16px); diff --git a/src/templates/sharecomponent/settingcalcomponent/verifycard/utils.jsx b/src/templates/sharecomponent/settingcalcomponent/verifycard/utils.jsx index 8d04983..dd9ef88 100644 --- a/src/templates/sharecomponent/settingcalcomponent/verifycard/utils.jsx +++ b/src/templates/sharecomponent/settingcalcomponent/verifycard/utils.jsx @@ -27,7 +27,7 @@ ` } - if (setting.interType === 'inner' && !setting.innerFunc && setting.execute !== 'false') { + if (setting.execute !== 'false') { _dataresource = setting.dataresource } diff --git a/src/templates/sharecomponent/settingcomponent/index.jsx b/src/templates/sharecomponent/settingcomponent/index.jsx index 2550016..ff5fe44 100644 --- a/src/templates/sharecomponent/settingcomponent/index.jsx +++ b/src/templates/sharecomponent/settingcomponent/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Icon, Modal, Button, notification } from 'antd' +import { Icon, Modal, Button } from 'antd' import Utils from '@/utils/utils.js' import DevUtils from '@/utils/devutils.js' @@ -84,18 +84,8 @@ const { config } = this.props const { menu } = this.state - this.settingRef.handleConfirm(true).then(setting => { - if (setting.interType !== 'inner' || !setting.innerFunc) { - notification.warning({ - top: 92, - message: '浣跨敤鍐呴儴鎺ュ彛锛屼笖瀛樺湪鍐呴儴鍑芥暟鏃讹紝鎵嶅彲浠ュ垱寤哄瓨鍌ㄨ繃绋嬶紒', - duration: 5 - }) - return - } - + this.settingRef.handleConfirm('func').then(setting => { let _config = {...config, setting: setting} - let newLText = Utils.formatOptions(DevUtils.getTableFunc(setting, menu, _config)) // 鍒涘缓瀛樺偍杩囩▼sql let DelText = Utils.formatOptions(DevUtils.dropfunc(setting.innerFunc)) // 鍒犻櫎瀛樺偍杩囩▼sql @@ -114,16 +104,7 @@ const { config } = this.props const { menu } = this.state - this.settingRef.handleConfirm(true).then(setting => { - if (setting.interType !== 'system') { - notification.warning({ - top: 92, - message: '浣跨敤绯荤粺鎺ュ彛鏃讹紝鎵嶅彲浠ュ垱寤烘帴鍙o紒', - duration: 5 - }) - return - } - + this.settingRef.handleConfirm('interface').then(setting => { let _config = {...config, setting: setting} let _menu = { type: config.Template === 'CommonTable' ? 'main' : 'subtable', @@ -173,13 +154,11 @@ destroyOnClose > <SettingForm - type={config.Template === 'CommonTable' ? 'main' : 'subtable'} dict={dict} menu={menu} config={config} search={search} permFuncField={permFuncField} - inputSubmit={this.settingSave} wrappedComponentRef={(inst) => this.settingRef = inst} /> </Modal> diff --git a/src/templates/sharecomponent/settingcomponent/settingform/customscript/index.jsx b/src/templates/sharecomponent/settingcomponent/settingform/customscript/index.jsx deleted file mode 100644 index adb76d8..0000000 --- a/src/templates/sharecomponent/settingcomponent/settingform/customscript/index.jsx +++ /dev/null @@ -1,268 +0,0 @@ -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' - -import Utils from '@/utils/utils.js' -import SettingUtils from '../utils.jsx' -import Api from '@/api' -import CodeMirror from '@/templates/zshare/codemirror' -import './index.scss' - -class CustomForm extends Component { - static propTpyes = { - type: PropTypes.string, // 鑿滃崟绫诲瀷 - dict: PropTypes.object, // 瀛楀吀椤� - 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, // 绯荤粺鑴氭湰 - scriptsChange: PropTypes.func // 琛ㄥ崟 - } - - state = { - editItem: null, - loading: false, - usefulFields: '' - } - - UNSAFE_componentWillMount() { - const { searches } = this.props - - let _usefulFields = [] - searches.forEach(item => { - if (item.type === 'group') { - if (item.transfer === 'true') { - _usefulFields.push(item.field) - } - _usefulFields.push(item.datefield) - _usefulFields.push(item.datefield + '1') - } else if (['dateweek', 'datemonth', 'daterange'].includes(item.type)) { - _usefulFields.push(item.field) - _usefulFields.push(item.field + '1') - } else if (_usefulFields.includes(item.field)) { - _usefulFields.push(item.field + '1') - } else { - _usefulFields.push(item.field) - } - }) - - this.setState({ - usefulFields: _usefulFields.join(', ') - }) - } - - edit = (record) => { - this.setState({ - editItem: record - }) - - this.props.form.setFieldsValue({ - sql: record.sql - }) - } - - handleCancel = () => { - this.setState({ - editItem: null - }) - this.props.form.setFieldsValue({ - sql: '' - }) - } - - handleConfirm = () => { - const { setting, arr_field, regoptions, swhere } = this.props - - // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - values.uuid = this.state.editItem ? this.state.editItem.uuid : '' - - let _quot = values.sql.match(/'{1}/g) - let _lparen = values.sql.match(/\({1}/g) - let _rparen = values.sql.match(/\){1}/g) - - _quot = _quot ? _quot.length : 0 - _lparen = _lparen ? _lparen.length : 0 - _rparen = _rparen ? _rparen.length : 0 - - if (_quot % 2 !== 0) { - notification.warning({ - top: 92, - message: 'sql涓璡'蹇呴』鎴愬鍑虹幇', - duration: 5 - }) - return - } else if (_lparen !== _rparen) { - notification.warning({ - top: 92, - message: 'sql涓�()蹇呴』鎴愬鍑虹幇', - duration: 5 - }) - return - } else if (/--/ig.test(values.sql)) { - notification.warning({ - top: 92, - message: '鑷畾涔塻ql璇彞涓紝涓嶅彲鍑虹幇瀛楃 -- 锛屾敞閲婅鐢� /*鍐呭*/', - duration: 5 - }) - return - } - - let error = Utils.verifySql(values.sql, 'customscript') - - if (error) { - notification.warning({ - top: 92, - message: 'sql涓笉鍙娇鐢�' + error, - duration: 5 - }) - return - } - - let scripts = fromJS(this.props.scripts).toJS() - - if (values.uuid) { - scripts = scripts.map(item => { - if (item.uuid === values.uuid) { - return values - } else { - return item - } - }) - } else { - scripts.push(values) - } - - let param = { - func: 's_debug_sql', - LText: SettingUtils.getDebugSql(setting, scripts, arr_field, regoptions, swhere) - } - - 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) - - 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 - }) - } - }) - } - }) - } - - selectScript = (value, option) => { - let _sql = this.props.form.getFieldValue('sql') - if (_sql) { - _sql = _sql + ` - - ` - } - - _sql = _sql.replace(/\s{6}$/, '') - _sql = _sql + `/*${option.props.children}*/ - ` - _sql = _sql.replace(/\s{4}$/, '') - _sql = _sql + value - - this.props.form.setFieldsValue({ - sql: _sql - }) - } - - render() { - const { systemScripts, setting, type, defaultSql } = this.props - const { getFieldDecorator } = this.props.form - const { usefulFields } = this.state - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 8 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 16 } - } - } - - return ( - <Form {...formItemLayout} className="modal-menu-setting-script"> - <Row gutter={24}> - {setting.tableName ? <Col span={8}> - <Form.Item label={'琛ㄥ悕'} style={{whiteSpace: 'nowrap', margin: 0}}> - {setting.tableName} - </Form.Item> - </Col> : null} - <Col span={16}> - <Form.Item label={'鎶ラ敊瀛楁'} style={{margin: 0}}> - ErrorCode, retmsg - </Form.Item> - </Col> - <Col span={24} className="sqlfield"> - <Form.Item label={'鍙敤瀛楁'}> - 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}> - <Form.Item label={'蹇嵎娣诲姞'} style={{marginBottom: 0}}> - <Select - showSearch - 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> - )} - </Select> - </Form.Item> - </Col> - <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'}> - {getFieldDecorator('sql', { - initialValue: '', - rules: [ - { - required: true, - message: this.props.dict['form.required.input'] + 'sql!' - } - ] - })(<CodeMirror />)} - </Form.Item> - </Col> - </Row> - </Form> - ) - } -} - -export default Form.create()(CustomForm) \ No newline at end of file diff --git a/src/templates/sharecomponent/settingcomponent/settingform/customscript/index.scss b/src/templates/sharecomponent/settingcomponent/settingform/customscript/index.scss deleted file mode 100644 index 2a1d2d8..0000000 --- a/src/templates/sharecomponent/settingcomponent/settingform/customscript/index.scss +++ /dev/null @@ -1,34 +0,0 @@ -.modal-menu-setting-script { - .sqlfield { - .ant-form-item { - margin-bottom: 5px; - } - .ant-form-item-control { - line-height: 24px; - } - .ant-form-item-label { - line-height: 25px; - } - .ant-form-item-children { - line-height: 22px; - } - .ant-col-sm-8 { - width: 10.5%; - } - .ant-col-sm-16 { - width: 89.5%; - } - } - .sql { - .ant-col-sm-8 { - width: 10.5%; - } - .ant-col-sm-16 { - width: 89.5%; - padding-top: 4px; - } - .CodeMirror { - height: 350px; - } - } -} \ No newline at end of file diff --git a/src/templates/sharecomponent/settingcomponent/settingform/index.jsx b/src/templates/sharecomponent/settingcomponent/settingform/index.jsx index 50ca2a2..84361f9 100644 --- a/src/templates/sharecomponent/settingcomponent/settingform/index.jsx +++ b/src/templates/sharecomponent/settingcomponent/settingform/index.jsx @@ -1,28 +1,25 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { fromJS } from 'immutable' -import { Form, Icon, notification, Modal, Spin, Tabs, Table, Popconfirm, Typography } from 'antd' +import { Form, notification, Modal, Spin, Tabs } from 'antd' import moment from 'moment' import Api from '@/api' import Utils from '@/utils/utils.js' import SettingUtils from './utils.jsx' -import CustomScript from './customscript' +import CustomScript from '@/templates/zshare/customscript' import DataSource from './datasource' import './index.scss' const { TabPane } = Tabs -const { Paragraph } = Typography class SettingForm extends Component { static propTpyes = { - type: PropTypes.string, // 鑿滃崟绫诲瀷 dict: PropTypes.object, // 瀛楀吀椤� menu: PropTypes.object, // 鑿滃崟淇℃伅 config: PropTypes.object, // 椤甸潰閰嶇疆淇℃伅 permFuncField: PropTypes.array, // 鑷畾涔夊嚱鏁板彲鐢ㄥ瓧娈� - search: PropTypes.array, // 鎼滅储鏉′欢 - inputSubmit: PropTypes.any // 鍥炶溅鎻愪氦浜嬩欢 + search: PropTypes.array // 鎼滅储鏉′欢 } state = { @@ -33,57 +30,7 @@ arr_field: '', regoptions: [], setting: null, - view: 'normal', - defaultSql: '', - systemScripts: [], - scriptsColumns: [ - { - title: 'SQL', - dataIndex: 'sql', - width: '70%', - render: (text) => ( - <Paragraph copyable ellipsis={{ rows: 5, expandable: true }}>{text}</Paragraph> - ) - }, - { - title: '鐘舵��', - dataIndex: 'status', - width: '10%', - render: (text, record) => record.status === 'false' ? - ( - <div> - {this.props.dict['model.status.forbidden']} - <Icon style={{marginLeft: '5px'}} type="stop" theme="twoTone" twoToneColor="#ff4d4f" /> - </div> - ) : - ( - <div> - {this.props.dict['model.status.open']} - <Icon style={{marginLeft: '5px'}} type="check-circle" theme="twoTone" twoToneColor="#52c41a" /> - </div> - ) - }, - { - title: '鎿嶄綔', - align: 'center', - width: '20%', - dataIndex: 'operation', - render: (text, record) => - (<div> - <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record)} style={{color: '#1890ff'}}><Icon type="edit" /></span> - <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> - <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> - <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record)} style={{color: '#8E44AD'}}><Icon type="swap" /></span> - <Popconfirm - overlayClassName="popover-confirm" - title={this.props.dict['model.query.delete']} - onConfirm={() => this.handleDelete(record) - }> - <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> - </Popconfirm> - </div>) - } - ] + defaultSql: '' } UNSAFE_componentWillMount() { @@ -144,173 +91,6 @@ }) } - componentDidMount () { - this.getsysScript() - } - - getsysScript = () => { - let _scriptSql = `Select distinct func+Remark as funcname,longparam, s.Sort from聽 s_custom_script s inner join (select OpenID from sapp where ID=@Appkey@) p on s.openid = case when s.appkey='' then s.openid else p.OpenID end order by s.Sort` - - _scriptSql = Utils.formatOptions(_scriptSql) - - let _sParam = { - func: 'sPC_Get_SelectedList', - LText: _scriptSql, - obj_name: 'data', - arr_field: 'funcname,longparam' - } - - _sParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _sParam.secretkey = Utils.encrypt(_sParam.LText, _sParam.timestamp) - _sParam.open_key = Utils.encryptOpenKey(_sParam.secretkey, _sParam.timestamp) // 浜戠鏁版嵁楠岃瘉 - - Api.getSystemConfig(_sParam).then(res => { - if (res.status) { - let _scripts = res.data.map(item => { - let _item = { - name: item.funcname, - value: Utils.UnformatOptions(item.longparam) - } - return _item - }) - - this.setState({ - systemScripts: _scripts - }) - } else { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } - }) - } - - handleConfirm = (trigger) => { - const { activeKey, setting, scripts } = this.state - - if (trigger) { - this.setState({loading: true}) - } - - // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� - if (activeKey === 'setting') { - return new Promise((resolve, reject) => { - this.settingForm.handleConfirm().then(res => { - if (res.interType === 'system' && res.default === 'false' && scripts.length === 0) { - notification.warning({ - top: 92, - message: '涓嶆墽琛岄粯璁ql鏃讹紝璇锋坊鍔犺嚜瀹氫箟鑴氭湰锛�', - duration: 5 - }) - reject() - return - } - - this.setState({ - setting: res - }, () => { - this.sqlverify(() => { - this.setState({loading: false}) - resolve({...res, scripts}) - }, () => { - this.setState({loading: false}) - reject() - }, true) - }) - }, () => { - this.setState({loading: false}) - }) - }) - } else { - return new Promise((resolve, reject) => { - let _loading = false - if (this.scriptsForm && this.scriptsForm.state.editItem) { - _loading = true - } else if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { - _loading = true - } - - if (_loading) { - notification.warning({ - top: 92, - message: '瀛樺湪鏈繚瀛樿剼鏈紝璇风偣鍑荤‘瀹氫繚瀛橈紝鎴栫偣鍑诲彇娑堟斁寮冧慨鏀癸紒', - duration: 5 - }) - this.setState({loading: false}) - reject() - } else if (setting.interType === 'system' && setting.default === 'false' && scripts.length === 0) { - notification.warning({ - top: 92, - message: '涓嶆墽琛岄粯璁ql鏃讹紝璇锋坊鍔犺嚜瀹氫箟鑴氭湰锛�', - duration: 5 - }) - this.setState({loading: false}) - reject() - } else { - this.sqlverify(() => { - this.setState({loading: false}) - resolve({...setting, scripts}) - }, () => { - this.setState({loading: false}) - reject() - }, true) - } - }) - } - } - - getCustomScript = (setting) => { - let _customScript = '' - if (setting.scripts && setting.scripts.length > 0) { - setting.scripts.forEach(item => { - if (item.status === 'false') return - _customScript += ` - ${item.sql} - ` - }) - } - - if (_customScript) { - _customScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000) select @ErrorCode='',@retmsg ='' - ${_customScript} - ` - } - - return _customScript - } - - sqlverify = (_resolve, _reject, force) => { - const { setting, scripts, arr_field, regoptions, search } = this.state - - if (setting.interType !== 'system') { // 涓嶄娇鐢ㄧ郴缁熸帴鍙f椂锛屼笉闇�瑕乻ql楠岃瘉 - _resolve() - } - if (force || (setting.interType === 'system' && setting.default !== 'false')) { - let param = { - func: 's_debug_sql', - LText: SettingUtils.getDebugSql(setting, scripts, arr_field, regoptions, search) - } - 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) - - Api.getLocalConfig(param).then(result => { - if (result.status) { - _resolve() - } else { - _reject() - Modal.error({ - title: result.message - }) - } - }) - } else { - _resolve() - } - } - /** * @description 鑾峰彇鍏ㄩ儴鎼滅储鏉′欢 * @param {Array} searches 鎼滅储鏉′欢鏁扮粍 @@ -363,108 +143,155 @@ return newsearches } - handleSubmit = (e) => { - e.preventDefault() + handleConfirm = (trigger) => { + const { activeKey, setting, scripts } = this.state - if (this.props.inputSubmit) { - this.props.inputSubmit() + if (trigger) { + this.setState({loading: true}) } - } - handleEdit = (record) => { - this.scriptsForm.edit(record) + let _scripts = scripts.filter(script => script.status !== 'false') - this.scrolltop() - } + // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� + if (activeKey === 'setting') { + return new Promise((resolve, reject) => { + this.settingForm.handleConfirm().then(res => { + if (trigger === 'func' && res.interType !== 'inner') { + notification.warning({ + top: 92, + message: '浣跨敤鍐呴儴鎺ュ彛锛屾墠鍙互鍒涘缓瀛樺偍杩囩▼锛�', + duration: 5 + }) + this.setState({loading: false}) + reject() + return + } else if (trigger === 'interface' && res.interType !== 'system') { + notification.warning({ + top: 92, + message: '浣跨敤绯荤粺鎺ュ彛鏃讹紝鎵嶅彲浠ュ垱寤烘帴鍙o紒', + duration: 5 + }) + this.setState({loading: false}) + reject() + return + } else if (res.interType === 'system' && res.default === 'false' && _scripts.length === 0) { + notification.warning({ + top: 92, + message: '涓嶆墽琛岄粯璁ql鏃讹紝璇锋坊鍔犺嚜瀹氫箟鑴氭湰锛�', + duration: 5 + }) + reject() + return + } - scrolltop = () => { - let node = document.getElementById('model-table-setting-form-box').parentNode - - if (node && node.scrollTop) { - let inter = Math.ceil(node.scrollTop / 10) - - let timer = setInterval(() => { - if (node.scrollTop - inter > 0) { - node.scrollTop = node.scrollTop - inter - } else { - node.scrollTop = 0 - clearInterval(timer) + this.setState({ + setting: res + }, () => { + this.sqlverify(() => { + this.setState({loading: false}) + resolve({...res, scripts}) + }, () => { + this.setState({loading: false}) + reject() + }, 'submit') + }) + }, () => { + this.setState({loading: false}) + reject() + }) + }) + } else { + return new Promise((resolve, reject) => { + let _loading = false + if (this.scriptsForm && this.scriptsForm.state.editItem) { + _loading = true + } else if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { + _loading = true } - }, 10) + + if (trigger === 'func' && setting.interType !== 'inner') { + notification.warning({ + top: 92, + message: '浣跨敤鍐呴儴鎺ュ彛锛屾墠鍙互鍒涘缓瀛樺偍杩囩▼锛�', + duration: 5 + }) + this.setState({loading: false}) + reject() + } else if (_loading) { + notification.warning({ + top: 92, + message: '瀛樺湪鏈繚瀛樿剼鏈紝璇风偣鍑荤‘瀹氫繚瀛橈紝鎴栫偣鍑诲彇娑堟斁寮冧慨鏀癸紒', + duration: 5 + }) + this.setState({loading: false}) + reject() + } else if (setting.interType === 'system' && setting.default === 'false' && _scripts.length === 0) { + notification.warning({ + top: 92, + message: '涓嶆墽琛岄粯璁ql鏃讹紝璇锋坊鍔犺嚜瀹氫箟鑴氭湰锛�', + duration: 5 + }) + this.setState({loading: false}) + reject() + } else { + this.sqlverify(() => { + this.setState({loading: false}) + resolve({...setting, scripts}) + }, () => { + this.setState({loading: false}) + reject() + }, 'submit') + } + }) } } - handleUpDown = (record, direction) => { - let scripts = fromJS(this.state.scripts).toJS() - let index = 0 + sqlverify = (_resolve, _reject, type, uscripts) => { + const { setting, scripts, arr_field, regoptions, search } = this.state - scripts = scripts.filter((item, i) => { - if (item.uuid === record.uuid) { - index = i - } - - return item.uuid !== record.uuid - }) - if ((index === 0 && direction === 'up') || (index === scripts.length && direction === 'down')) { + if (setting.interType !== 'system') { // 涓嶄娇鐢ㄧ郴缁熸帴鍙f椂锛屼笉闇�瑕乻ql楠岃瘉 + _resolve() return } - if (direction === 'up') { - scripts.splice(index - 1, 0, record) + let _scripts = [] + if (uscripts) { // 杩囨护绂佺敤鐨勮剼鏈� + _scripts = uscripts.filter(script => script.status !== 'false') } else { - scripts.splice(index + 1, 0, record) + _scripts = scripts.filter(script => script.status !== 'false') } - this.setState({scripts}) - } - - handleStatus = (record) => { - let scripts = fromJS(this.state.scripts).toJS() - record.status = record.status === 'false' ? 'true' : 'false' - - scripts = scripts.map(item => { - if (item.uuid === record.uuid) { - return record - } else { - return item + if (type === 'setting' && setting.default === 'false') { + _resolve() + } else if (type === 'scripts' && _scripts.length === 0) { + _resolve() + } else { // type 涓� submit 銆� verify 锛屼互鍙婂叾浠栭渶瑕侀獙璇佺殑鍦烘櫙 + let param = { + func: 's_debug_sql', + LText: SettingUtils.getDebugSql(setting, _scripts, arr_field, regoptions, search) } - }) - - this.setState({scripts}) - } - - handleDelete = (record) => { - let scripts = fromJS(this.state.scripts).toJS() - scripts = scripts.filter(item => item.uuid !== record.uuid) - - this.setState({ scripts }) - } - - scriptsChange = (values) => { - let scripts = fromJS(this.state.scripts).toJS() - - if (values.uuid) { - scripts = scripts.map(item => { - if (item.uuid === values.uuid) { - return values + 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) + + Api.getLocalConfig(param).then(result => { + if (result.status) { + _resolve() } else { - return item + _reject() + Modal.error({ + title: result.message + }) } }) - } else { - values.uuid = Utils.getuuid() - scripts.push(values) } - - this.setState({scripts}) } + // 鏍囩鍒囨崲 changeTab = (val) => { const { activeKey, search, arr_field } = this.state if (activeKey === 'setting') { - this.setState({loading: true}) - let _defaultSql = '' this.settingForm.handleConfirm().then(res => { if (res.interType !== 'system') { @@ -473,37 +300,35 @@ message: '浣跨敤绯荤粺鎺ュ彛鏃讹紝鎵嶅彲浠ヨ缃嚜瀹氫箟鑴氭湰锛�', duration: 5 }) - this.setState({loading: false}) return + } + + if (res.dataresource) { + let _dataresource = res.dataresource + + if (/\s/.test(_dataresource)) { + _dataresource = '(' + _dataresource + ') tb' + } + + _defaultSql = `select top @pageSize@ ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by @orderBy@) as rows from ${_dataresource} ${search}) tmptable where rows > (@pageSize@ * (@pageIndex@ - 1)) order by tmptable.rows` } this.setState({ - setting: res + setting: res, + defaultSql: _defaultSql }, () => { - if (res.dataresource) { - let _dataresource = res.dataresource - - if (/\s/.test(_dataresource)) { - _dataresource = '(' + _dataresource + ') tb' - } - - _defaultSql = `select top @pageSize@ ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by @orderBy@) as rows from ${_dataresource} ${search}) tmptable where rows > (@pageSize@ * (@pageIndex@ - 1)) order by tmptable.rows` - } - + this.setState({loading: true}) this.sqlverify(() => { // 楠岃瘉鎴愬姛 this.setState({ activeKey: val, - defaultSql: _defaultSql, loading: false }) }, () => { // 楠岃瘉澶辫触 this.setState({ loading: false }) - }) + }, activeKey) }) - }, () => { - this.setState({loading: false}) }) } else if (activeKey === 'scripts') { let _loading = false @@ -521,24 +346,44 @@ }) return } - - this.setState({ - activeKey: val - }) + + this.setState({loading: true}) + this.sqlverify(() => { // 楠岃瘉鎴愬姛 + this.setState({ + activeKey: val, + loading: false + }) + }, () => { // 楠岃瘉澶辫触 + this.setState({ + loading: false + }) + }, activeKey) } } + // 鑷畾涔夎剼鏈慨鏀� + scriptsChange = (scripts) => { + return new Promise((resolve, reject) => { + this.sqlverify(resolve, reject, 'verify', scripts) + }) + } + + // 鑷畾涔夎剼鏈洿鏂� + scriptsUpdate = (scripts) => { + this.setState({scripts}) + } + render() { - const { type, menu, dict, permFuncField } = this.props - const { loading, activeKey, setting, scriptsColumns, systemScripts, arr_field, defaultSql, regoptions, search, columns, scripts } = this.state + const { config, menu, dict, permFuncField } = this.props + const { loading, activeKey, setting, defaultSql, columns, scripts } = this.state return ( - <div className="model-table-setting-form-box" id="model-table-setting-form-box"> + <div className="model-table-setting-form-box" id="model-setting-form-body"> {loading && <Spin size="large" />} <Tabs activeKey={activeKey} className="verify-card-box" onChange={this.changeTab}> <TabPane tab="鏁版嵁婧�" key="setting"> <DataSource - type={type} + type={config.Template === 'CommonTable' ? 'main' : ''} menu={menu} dict={dict} columns={columns} @@ -550,26 +395,14 @@ </TabPane> <TabPane tab="鑷畾涔夎剼鏈�" key="scripts"> <CustomScript - type={type} dict={dict} - swhere={search} setting={setting} scripts={scripts} - arr_field={arr_field} defaultSql={defaultSql} - regoptions={regoptions} searches={this.props.search} - systemScripts={systemScripts} scriptsChange={this.scriptsChange} + scriptsUpdate={this.scriptsUpdate} wrappedComponentRef={(inst) => this.scriptsForm = inst} - /> - <Table - bordered - rowKey="uuid" - className="custom-table" - dataSource={scripts} - columns={scriptsColumns} - pagination={false} /> </TabPane> </Tabs> diff --git a/src/templates/sharecomponent/settingcomponent/settingform/utils.jsx b/src/templates/sharecomponent/settingcomponent/settingform/utils.jsx index c5bb301..19cea66 100644 --- a/src/templates/sharecomponent/settingcomponent/settingform/utils.jsx +++ b/src/templates/sharecomponent/settingcomponent/settingform/utils.jsx @@ -12,11 +12,9 @@ let _dataresource = setting.dataresource let _customScript = '' scripts && scripts.forEach(script => { - if (script.status !== 'false') { - _customScript += ` - ${script.sql} - ` - } + _customScript += ` + ${script.sql} + ` }) if (_customScript) { @@ -25,7 +23,7 @@ ` } - if (setting.interType === 'system' && setting.default === 'false') { + if (setting.default === 'false') { _dataresource = '' } diff --git a/src/templates/sharecomponent/treesettingcomponent/index.jsx b/src/templates/sharecomponent/treesettingcomponent/index.jsx index d1d4f11..70a2779 100644 --- a/src/templates/sharecomponent/treesettingcomponent/index.jsx +++ b/src/templates/sharecomponent/treesettingcomponent/index.jsx @@ -1,17 +1,10 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { fromJS } from 'immutable' -import { Icon, Modal, Button, notification } from 'antd' +import { Icon, Modal } from 'antd' -import Utils from '@/utils/utils.js' -import DevUtils from '@/utils/devutils.js' import zhCN from '@/locales/zh-CN/model.js' import enUS from '@/locales/en-US/model.js' -import { getTreeSettingForm } from '@/templates/zshare/formconfig' - import SettingForm from './settingform' -import CreateFunc from '@/templates/zshare/createfunc' -import CreateInterface from '@/templates/zshare/createinterface' import './index.scss' @@ -26,7 +19,6 @@ state = { dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, menu: null, // 鑿滃崟淇℃伅 - formlist: null, // 琛ㄥ崟淇℃伅 visible: false, // 妯℃�佹鎺у埗 loading: false // 璁剧疆淇℃伅楠岃瘉淇濆瓨涓� } @@ -35,16 +27,12 @@ * @description 鍏ㄥ眬璁剧疆瑙﹀彂 */ changeSetting = () => { - const { MenuID, config, permFuncField } = this.props + const { MenuID, config } = this.props let menu = {MenuID: MenuID, MenuName: config.MenuName, MenuNo: config.MenuNo} - - let _config = fromJS(config).toJS() this.setState({ visible: true, - formlist: getTreeSettingForm(config.setting, permFuncField, MenuID), - menu: menu, - config: _config + menu: menu }) } @@ -63,72 +51,11 @@ loading: false }) - delete res.customScript // 娓呴櫎鏁寸悊鍚庣殑鑷畾涔夎剼鏈� - this.props.updatesetting({...config, setting: res}) }, () => { this.setState({ loading: false }) - }) - } - - /** - * @description 鍒涘缓琛ㄦ牸瀛樺偍杩囩▼ - */ - tableCreatFunc = () => { - const { config } = this.props - const { menu } = this.state - - this.settingRef.handleConfirm().then(setting => { - - if (!(setting.interType === 'inner') || !setting.innerFunc) { - notification.warning({ - top: 92, - message: '鎺ュ彛绫诲瀷涓�-鍐呴儴锛屼笖瀛樺湪鍐呴儴鍑芥暟鏃讹紝鎵嶅彲浠ュ垱寤哄瓨鍌ㄨ繃绋嬶紒', - duration: 5 - }) - return - } - - let _config = {...config, setting: setting} - let newLText = Utils.formatOptions(DevUtils.getTableFunc(setting, menu, _config)) // 鍒涘缓瀛樺偍杩囩▼sql - let DelText = Utils.formatOptions(DevUtils.dropfunc(setting.innerFunc)) // 鍒犻櫎瀛樺偍杩囩▼sql - - this.refs.funcCreatComponent.exec(setting.innerFunc, newLText, DelText).then(result => { - if (result === 'success') { - this.props.updatesetting(_config) - } - }) - }) - } - - /** - * @description 鍒涘缓琛ㄦ牸鎺ュ彛锛堣鍑猴級 - */ - tableCreatInterface = () => { - const { config } = this.props - const { menu } = this.state - - this.settingRef.handleConfirm().then(setting => { - if (setting.interType !== 'inner' || setting.innerFunc) { - notification.warning({ - top: 92, - message: '鎺ュ彛绫诲瀷涓�-鍐呴儴锛屼笖涓嶅瓨鍦ㄥ唴閮ㄥ嚱鏁版椂锛屾墠鍙互鍒涘缓鎺ュ彛锛�', - duration: 5 - }) - return - } - - let _config = {...config, setting: setting} - let _menu = { - type: 'main', - MenuID: menu.MenuID, - menuName: menu.MenuName, - menuNo: menu.MenuNo - } - - this.refs.tableCreatInterface.triggerOutInterface(_menu, _config) }) } @@ -142,7 +69,8 @@ } render() { - const { dict, visible, config } = this.state + const { config } = this.props + const { dict, visible, loading } = this.state return ( <div className="model-tree-menu-setting"> @@ -155,12 +83,8 @@ width={900} maskClosable={false} onCancel={() => { this.setState({ visible: false })}} - footer={[ - <CreateInterface key="interface" dict={dict} ref="tableCreatInterface" trigger={this.tableCreatInterface}/>, - <CreateFunc key="create" dict={dict} ref="funcCreatComponent" trigger={this.tableCreatFunc}/>, - <Button key="cancel" onClick={() => { this.setState({ visible: false }) }}>{this.state.dict['model.cancel']}</Button>, - <Button key="confirm" type="primary" loading={this.state.loading} onClick={this.settingSave}>{this.state.dict['model.confirm']}</Button> - ]} + confirmLoading={loading} + onOk={this.settingSave} destroyOnClose > <SettingForm @@ -168,7 +92,7 @@ config={config} menu={this.state.menu} inputSubmit={this.settingSave} - formlist={this.state.formlist} + permFuncField={this.props.permFuncField} wrappedComponentRef={(inst) => this.settingRef = inst} /> </Modal> diff --git a/src/templates/sharecomponent/treesettingcomponent/index.scss b/src/templates/sharecomponent/treesettingcomponent/index.scss index 89b8f64..2875bc1 100644 --- a/src/templates/sharecomponent/treesettingcomponent/index.scss +++ b/src/templates/sharecomponent/treesettingcomponent/index.scss @@ -17,6 +17,7 @@ .ant-modal-body { max-height: calc(100vh - 190px); overflow-y: auto; + padding-top: 10px; } .ant-modal-body::-webkit-scrollbar { width: 7px; diff --git a/src/templates/sharecomponent/treesettingcomponent/settingform/customscript/index.jsx b/src/templates/sharecomponent/treesettingcomponent/settingform/customscript/index.jsx deleted file mode 100644 index 3c4492e..0000000 --- a/src/templates/sharecomponent/treesettingcomponent/settingform/customscript/index.jsx +++ /dev/null @@ -1,249 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { Form, Row, Col, Button, notification, Modal, Select } from 'antd' -import moment from 'moment' - -import Utils from '@/utils/utils.js' -import SettingUtils from '../utils.jsx' -import CodeMirror from '@/templates/zshare/codemirror' -import Api from '@/api' -import './index.scss' - -class CustomForm extends Component { - static propTpyes = { - dict: PropTypes.object, // 瀛楀吀椤� - setting: PropTypes.object, // 璁剧疆 - systemScripts: PropTypes.array, // 绯荤粺鑴氭湰 - scriptsChange: PropTypes.func // 琛ㄥ崟 - } - - state = { - editItem: null, - loading: false, - } - - UNSAFE_componentWillMount() { - - } - - edit = (record) => { - this.setState({ - editItem: record - }) - - this.props.form.setFieldsValue({ - sql: record.sql - }) - } - - handleCancel = () => { - this.setState({ - editItem: null - }) - this.props.form.setFieldsValue({ - sql: '' - }) - } - - handleConfirm = () => { - const { setting } = this.props - - // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - values.uuid = this.state.editItem ? this.state.editItem.uuid : '' - - let _quot = values.sql.match(/'{1}/g) - let _lparen = values.sql.match(/\({1}/g) - let _rparen = values.sql.match(/\){1}/g) - - _quot = _quot ? _quot.length : 0 - _lparen = _lparen ? _lparen.length : 0 - _rparen = _rparen ? _rparen.length : 0 - - if (_quot % 2 !== 0) { - notification.warning({ - top: 92, - message: 'sql涓璡'蹇呴』鎴愬鍑虹幇', - duration: 5 - }) - return - } else if (_lparen !== _rparen) { - notification.warning({ - top: 92, - message: 'sql涓�()蹇呴』鎴愬鍑虹幇', - duration: 5 - }) - return - } else if (/--/ig.test(values.sql)) { - notification.warning({ - top: 92, - message: '鑷畾涔塻ql璇彞涓紝涓嶅彲鍑虹幇瀛楃 -- 锛屾敞閲婅鐢� /*鍐呭*/', - duration: 5 - }) - return - } - - let error = Utils.verifySql(values.sql, 'customscript') - - if (error) { - notification.warning({ - top: 92, - message: 'sql涓笉鍙娇鐢�' + error, - duration: 5 - }) - 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} - ` - } - }) - - if (!this.state.editItem) { - _customScript += ` - ${values.sql} - ` - } - - 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) - } - - 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) - - 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 - }) - } - }) - } - }) - } - - selectScript = (value, option) => { - let _sql = this.props.form.getFieldValue('sql') - if (_sql) { - _sql = _sql + ` - - ` - } - - _sql = _sql.replace(/\s{6}$/, '') - _sql = _sql + `/*${option.props.children}*/ - ` - _sql = _sql.replace(/\s{4}$/, '') - _sql = _sql + value - - this.props.form.setFieldsValue({ - sql: _sql - }) - } - - render() { - const { systemScripts, setting } = this.props - const { getFieldDecorator } = this.props.form - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 8 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 16 } - } - } - - return ( - <Form {...formItemLayout} className="modal-tree-menu-setting-script"> - <Row gutter={24}> - {setting.tableName ? <Col span={8}> - <Form.Item label={'琛ㄥ悕'} style={{whiteSpace: 'nowrap', margin: 0}}> - {setting.tableName} - </Form.Item> - </Col> : null} - <Col span={16}> - <Form.Item label={'鎶ラ敊瀛楁'} style={{margin: 0}}> - ErrorCode, retmsg - </Form.Item> - </Col> - <Col span={24} className="sqlfield"> - <Form.Item label={'鍙敤瀛楁'}> - id, bid, loginuid, sessionuid, userid, appkey, time_id, orderBy, {setting.valueField}, {setting.labelField}, {setting.parentField} - </Form.Item> - </Col> - <Col span={10}> - <Form.Item label={'蹇嵎娣诲姞'} style={{marginBottom: 0}}> - <Select - showSearch - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - onChange={this.selectScript} - > - {systemScripts.map((option, i) => - <Select.Option style={{whiteSpace: 'normal'}} key={i} value={option.value}>{option.name}</Select.Option> - )} - </Select> - </Form.Item> - </Col> - <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'}> - {getFieldDecorator('sql', { - initialValue: '', - rules: [ - { - required: true, - message: this.props.dict['form.required.input'] + 'sql!' - } - ] - })(<CodeMirror />)} - </Form.Item> - </Col> - </Row> - </Form> - ) - } -} - -export default Form.create()(CustomForm) \ No newline at end of file diff --git a/src/templates/sharecomponent/treesettingcomponent/settingform/customscript/index.scss b/src/templates/sharecomponent/treesettingcomponent/settingform/customscript/index.scss deleted file mode 100644 index d853da1..0000000 --- a/src/templates/sharecomponent/treesettingcomponent/settingform/customscript/index.scss +++ /dev/null @@ -1,34 +0,0 @@ -.modal-tree-menu-setting-script { - .sqlfield { - .ant-form-item { - margin-bottom: 5px; - } - .ant-form-item-control { - line-height: 24px; - } - .ant-form-item-label { - line-height: 25px; - } - .ant-form-item-children { - line-height: 22px; - } - .ant-col-sm-8 { - width: 10.5%; - } - .ant-col-sm-16 { - width: 89.5%; - } - } - .sql { - .ant-col-sm-8 { - width: 10.5%; - } - .ant-col-sm-16 { - width: 89.5%; - padding-top: 4px; - } - .CodeMirror { - height: 350px; - } - } -} \ No newline at end of file diff --git a/src/templates/sharecomponent/treesettingcomponent/settingform/datasource/index.jsx b/src/templates/sharecomponent/treesettingcomponent/settingform/datasource/index.jsx new file mode 100644 index 0000000..2029b4d --- /dev/null +++ b/src/templates/sharecomponent/treesettingcomponent/settingform/datasource/index.jsx @@ -0,0 +1,496 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { Form, Row, Col, Input, Radio, Tooltip, Icon, notification, InputNumber } from 'antd' +import moment from 'moment' + +import Api from '@/api' +import { formRule } from '@/utils/option.js' +import Utils from '@/utils/utils.js' +import CodeMirror from '@/templates/zshare/codemirror' +import './index.scss' + +class SettingForm extends Component { + static propTpyes = { + dict: PropTypes.object, // 瀛楀吀椤� + menu: PropTypes.object, // 鑿滃崟淇℃伅 + permFuncField: PropTypes.any, // 瀛樺偍杩囩▼鍙敤寮�濮嬪瓧绗� + setting: PropTypes.object, // 鏁版嵁婧愰厤缃� + inputSubmit: PropTypes.func // 瑙﹀彂鎻愪氦 + } + + state = { + interType: 'system', + funcTooltip: '', + funcRules: [] + } + + UNSAFE_componentWillMount () { + const { setting, permFuncField } = this.props + + let tooltip = null + let rules = [] + + if (permFuncField && permFuncField.length > 0) { + tooltip = '寮�澶村彲鐢ㄥ瓧绗︼細' + permFuncField.join(', ') + let str = '^(' + permFuncField.join('|') + ')' + let _patten = new RegExp(str + formRule.func.innerPattern + '$', 'g') + + rules.push({ + pattern: _patten, + message: formRule.func.innerMessage + }) + } + + this.setState({ + interType: setting.interType || 'system', + funcTooltip: tooltip, + funcRules: rules + }) + } + + handleConfirm = () => { + const { setting } = this.props + // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� + return new Promise((resolve, reject) => { + this.props.form.validateFieldsAndScroll((err, values) => { + if (!err) { + // 鏁版嵁婧愬墠绔獙璇� + if (values.interType === 'system' && values.default !== 'false' && !values.dataresource) { + notification.warning({ + top: 92, + message: '璇峰~鍐欐暟鎹簮锛�', + duration: 5 + }) + reject() + return + } else if (values.interType === 'system' && values.default !== 'false' && values.dataresource) { + let _quot = values.dataresource.match(/'{1}/g) + let _lparen = values.dataresource.match(/\({1}/g) + let _rparen = values.dataresource.match(/\){1}/g) + + _quot = _quot ? _quot.length : 0 + _lparen = _lparen ? _lparen.length : 0 + _rparen = _rparen ? _rparen.length : 0 + + if (_quot % 2 !== 0) { + notification.warning({ + top: 92, + message: '鏁版嵁婧愪腑\'蹇呴』鎴愬鍑虹幇', + duration: 5 + }) + reject() + return + } else if (_lparen !== _rparen) { + notification.warning({ + top: 92, + message: '鏁版嵁婧愪腑()蹇呴』鎴愬鍑虹幇', + duration: 5 + }) + reject() + return + } else if (/--/ig.test(values.dataresource)) { + notification.warning({ + top: 92, + message: '鏁版嵁婧愪腑锛屼笉鍙嚭鐜板瓧绗� -- 锛屾敞閲婅鐢� /*鍐呭*/', + duration: 5 + }) + reject() + return + } + + let error = Utils.verifySql(values.dataresource) + + if (error) { + notification.warning({ + top: 92, + message: '鏁版嵁婧愪腑涓嶅彲浣跨敤' + error, + duration: 5 + }) + reject() + return + } + } + + // 鏁版嵁婧愪繚瀛� + if ( + values.interType === 'system' && values.default !== 'false' && + /[^\s]+\s+[^\s]+/ig.test(values.dataresource) && setting.dataresource !== values.dataresource + ) { + let param = { + func: 's_DataSrc_Save', + LText: values.dataresource, + MenuID: this.props.menu.MenuID + } + + 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) + + Api.getLocalConfig(param) + } + + resolve(values) + } else { + reject(err) + } + }) + }) + } + + onRadioChange = (e, key) => { + let value = e.target.value + + if (key === 'interType') { + this.setState({ + interType: value + }) + } else if (key === 'sysInterface') { + if (value === 'true') { + this.props.form.setFieldsValue({ + interface: window.GLOB.mainSystemApi || '' + }) + } + } + } + + handleSubmit = (e) => { + e.preventDefault() + + if (this.props.inputSubmit) { + this.props.inputSubmit() + } + } + + render() { + const { setting, dict, menu } = this.props + const { getFieldDecorator } = this.props.form + const { interType, funcRules, funcTooltip } = this.state + + const formItemLayout = { + labelCol: { + xs: { span: 24 }, + sm: { span: 8 } + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 16 } + } + } + + return ( + <div className="model-table-datasource-setting-form-box"> + <Form {...formItemLayout} className="model-setting-form"> + <Row gutter={24}> + <Col span={12}> + <Form.Item label="琛ㄥ悕"> + {getFieldDecorator('tableName', { + initialValue: setting.tableName || '', + rules: [ + { + required: true, + message: dict['form.required.input'] + '琛ㄥ悕!' + }, + { + max: formRule.input.max, + message: formRule.input.message + } + ] + })(<Input placeholder={''} autoComplete="off" onPressEnter={this.handleSubmit}/>)} + </Form.Item> + </Col> + <Col span={12}> + <Form.Item label="鏍囬"> + {getFieldDecorator('title', { + initialValue: setting.title || '', + rules: [ + { + required: true, + message: dict['form.required.input'] + '鏍囬!' + }, + { + max: formRule.input.max, + message: formRule.input.message + } + ] + })(<Input placeholder={''} autoComplete="off" onPressEnter={this.handleSubmit} />)} + </Form.Item> + </Col> + <Col span={12}> + <Form.Item label={dict['header.form.intertype']}> + {getFieldDecorator('interType', { + initialValue: interType, + rules: [ + { + required: true, + message: dict['form.required.select'] + dict['header.form.intertype'] + '!' + } + ] + })( + <Radio.Group onChange={(e) => {this.onRadioChange(e, 'interType')}}> + <Radio value="system">绯荤粺</Radio> + <Radio value="inner">鍐呴儴</Radio> + <Radio value="outer">澶栭儴</Radio> + </Radio.Group>)} + </Form.Item> + </Col> + {interType === 'outer' ? <Col span={12}> + <Form.Item label={dict['header.form.sysInterface']}> + {getFieldDecorator('sysInterface', { + initialValue: setting.sysInterface || 'false', + rules: [ + { + required: true, + message: dict['form.required.select'] + dict['header.form.sysInterface'] + '!' + }, + ] + })( + <Radio.Group onChange={(e) => {this.onRadioChange(e, 'sysInterface')}}> + <Radio value="true">{dict['model.true']}</Radio> + <Radio value="false">{dict['model.false']}</Radio> + </Radio.Group>)} + </Form.Item> + </Col> : null} + {interType === 'inner' ? <Col span={12}> + <Form.Item label={ + <Tooltip placement="topLeft" title={funcTooltip}> + <Icon type="question-circle" /> + 鍐呴儴鍑芥暟 + </Tooltip> + }> + {getFieldDecorator('innerFunc', { + initialValue: setting.innerFunc || '', + rules: [ + { + required: true, + message: dict['form.required.input'] + '鍐呴儴鍑芥暟!' + }, + { + max: formRule.func.max, + message: formRule.func.maxMessage + }, + ...funcRules + ] + })(<Input placeholder={''} autoComplete="off" onPressEnter={this.handleSubmit} />)} + </Form.Item> + </Col> : null} + {interType === 'outer' ? <Col span={12}> + <Form.Item label="鎺ュ彛鍦板潃"> + {getFieldDecorator('interface', { + initialValue: setting.interface || '', + rules: [ + { + required: true, + message: dict['form.required.input'] + '鎺ュ彛鍦板潃!' + } + ] + })(<Input placeholder={''} autoComplete="off" onPressEnter={this.handleSubmit} />)} + </Form.Item> + </Col> : null} + {interType === 'outer' ? <Col span={12}> + <Form.Item label="澶栭儴鍑芥暟"> + {getFieldDecorator('outerFunc', { + initialValue: setting.outerFunc || '', + rules: [ + { + pattern: formRule.func.pattern, + message: formRule.func.message + }, { + max: formRule.func.max, + message: formRule.func.maxMessage + } + ] + })(<Input placeholder={''} autoComplete="off" onPressEnter={this.handleSubmit} />)} + </Form.Item> + </Col> : null} + {interType === 'system' ? <Col span={24} className="data-source" style={{paddingLeft: '7px'}}> + <Form.Item help={'鏁版嵁ID锛�' + menu.MenuID} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } label={ + <Tooltip placement="topLeft" title={'浣跨敤绯荤粺鍑芥暟鏃讹紝闇�濉啓鏁版嵁婧愩�傛敞锛氭暟鎹潈闄愭浛鎹㈢ $@ -> /* 鎴� \'\'銆� @$ -> */ 鎴� \'\''}> + <Icon type="question-circle" /> + 鏁版嵁婧� + </Tooltip> + }> + {getFieldDecorator('dataresource', { + initialValue: setting.dataresource || '' + })(<CodeMirror />)} + </Form.Item> + </Col> : null} + <Col span={12}> + <Form.Item label={ + <Tooltip placement="topLeft" title={'鏁版嵁鍊煎瓧娈点��'}> + <Icon type="question-circle" /> + Value + </Tooltip> + }> + {getFieldDecorator('valueField', { + initialValue: setting.valueField || '', + rules: [ + { + required: true, + message: dict['form.required.input'] + 'Value!' + }, + { + pattern: formRule.field.pattern, + message: formRule.field.message + }, { + max: formRule.field.max, + message: formRule.field.maxMessage + } + ] + })(<Input placeholder={''} autoComplete="off" />)} + </Form.Item> + </Col> + <Col span={12}> + <Form.Item label={ + <Tooltip placement="topLeft" title={'鏄剧ず鏂囧瓧瀛楁銆�'}> + <Icon type="question-circle" /> + Label + </Tooltip> + }> + {getFieldDecorator('labelField', { + initialValue: setting.labelField || '', + rules: [ + { + required: true, + message: dict['form.required.input'] + 'Label!' + }, + { + pattern: formRule.field.pattern, + message: formRule.field.message + }, { + max: formRule.field.max, + message: formRule.field.maxMessage + } + ] + })(<Input placeholder={''} autoComplete="off" onPressEnter={this.handleSubmit} />)} + </Form.Item> + </Col> + <Col span={12}> + <Form.Item label={ + <Tooltip placement="topLeft" title={'鐖剁骇瀛楁銆�'}> + <Icon type="question-circle" /> + Parent + </Tooltip> + }> + {getFieldDecorator('parentField', { + initialValue: setting.parentField || '', + rules: [ + { + required: true, + message: dict['form.required.input'] + 'Label!' + }, + { + pattern: formRule.field.pattern, + message: formRule.field.message + }, { + max: formRule.field.max, + message: formRule.field.maxMessage + } + ] + })(<Input placeholder={''} autoComplete="off" onPressEnter={this.handleSubmit} />)} + </Form.Item> + </Col> + <Col span={12}> + <Form.Item label="鎺掑簭"> + {getFieldDecorator('order', { + initialValue: setting.order || '', + rules: [ + { + required: true, + message: dict['form.required.input'] + '鎺掑簭!' + }, + { + max: formRule.input.max, + message: formRule.input.message + } + ] + })(<Input placeholder={'ID asc, UID desc'} autoComplete="off" onPressEnter={this.handleSubmit} />)} + </Form.Item> + </Col> + <Col span={12}> + <Form.Item label={ + <Tooltip placement="topLeft" title={'鐖剁骇瀛楁鍊间笌椤剁骇鏍囪瘑锛堥粯璁ゅ�间负绌猴級鐩稿悓鏃讹紝瑙嗕负椤剁骇鑺傜偣銆�'}> + <Icon type="question-circle" /> + 椤剁骇鏍囪瘑 + </Tooltip> + }> + {getFieldDecorator('mark', { + initialValue: setting.mark || '', + rules: [ + { + max: formRule.input.max, + message: formRule.input.message + } + ] + })(<Input placeholder={''} autoComplete="off" onPressEnter={this.handleSubmit} />)} + </Form.Item> + </Col> + <Col span={12}> + <Form.Item label={ + <Tooltip placement="topLeft" title={'姣忚鍒嗕负24浠斤紝鏍戝舰姣斾緥鍙缃负2-12锛堟渶澶�50%锛�'}> + <Icon type="question-circle" /> + 瀹藉害 + </Tooltip> + }> + {getFieldDecorator('width', { + initialValue: setting.width || 5, + rules: [ + { + required: true, + message: dict['form.required.input'] + '瀹藉害!' + } + ] + })(<InputNumber min={2} max={12} precision={0} />)} + </Form.Item> + </Col> + <Col span={12}> + <Form.Item label="鎼滅储"> + {getFieldDecorator('searchable', { + initialValue: setting.searchable || 'true' + })( + <Radio.Group> + <Radio value="true">鏄剧ず</Radio> + <Radio value="false">闅愯棌</Radio> + </Radio.Group>)} + </Form.Item> + </Col> + {interType === 'system' ? <Col span={12}> + <Form.Item label="榛樿sql"> + {getFieldDecorator('default', { + initialValue: setting.default || 'true' + })( + <Radio.Group> + <Radio value="true">鎵ц</Radio> + <Radio value="false">涓嶆墽琛�</Radio> + </Radio.Group>)} + </Form.Item> + </Col> : null} + <Col span={12}> + <Form.Item label="鏄剧ず鍥炬爣"> + {getFieldDecorator('showIcon', { + initialValue: setting.showIcon || 'false' + })( + <Radio.Group> + <Radio value="true">鏄�</Radio> + <Radio value="false">鍚�</Radio> + </Radio.Group>)} + </Form.Item> + </Col> + <Col span={12}> + <Form.Item label="鏄剧ず鍒嗗壊绾�"> + {getFieldDecorator('showLine', { + initialValue: setting.showLine || 'false' + })( + <Radio.Group> + <Radio value="true">鏄�</Radio> + <Radio value="false">鍚�</Radio> + </Radio.Group>)} + </Form.Item> + </Col> + </Row> + </Form> + </div> + ) + } +} + +export default Form.create()(SettingForm) \ No newline at end of file diff --git a/src/templates/sharecomponent/treesettingcomponent/settingform/datasource/index.scss b/src/templates/sharecomponent/treesettingcomponent/settingform/datasource/index.scss new file mode 100644 index 0000000..a6d2df7 --- /dev/null +++ b/src/templates/sharecomponent/treesettingcomponent/settingform/datasource/index.scss @@ -0,0 +1,22 @@ +.model-table-datasource-setting-form-box { + position: relative; + + .model-setting-form { + .data-source { + .ant-form-item-label { + width: 16.5%; + } + .ant-form-item-control-wrapper { + width: 83.5%; + } + .CodeMirror { + height: 150px; + } + } + .anticon-question-circle { + color: #c49f47; + margin-right: 3px; + } + } + +} \ No newline at end of file diff --git a/src/templates/sharecomponent/treesettingcomponent/settingform/index.jsx b/src/templates/sharecomponent/treesettingcomponent/settingform/index.jsx index a0da051..e71602e 100644 --- a/src/templates/sharecomponent/treesettingcomponent/settingform/index.jsx +++ b/src/templates/sharecomponent/treesettingcomponent/settingform/index.jsx @@ -1,289 +1,131 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { fromJS } from 'immutable' -import { Form, Row, Col, Input, Radio, Select, Tooltip, Icon, notification, InputNumber, Modal, Table, Popconfirm, Typography, Button } from 'antd' +import { Form, notification, Modal, Spin, Tabs } from 'antd' import moment from 'moment' import Api from '@/api' import Utils from '@/utils/utils.js' import SettingUtils from './utils.jsx' -import CustomScript from './customscript' -import CodeMirror from '@/templates/zshare/codemirror' +import DataSource from './datasource' +import CustomScript from '@/templates/zshare/customscript' import './index.scss' -const { confirm } = Modal -const { Paragraph } = Typography +const { TabPane } = Tabs class SettingForm extends Component { static propTpyes = { - type: PropTypes.string, // 鑿滃崟绫诲瀷 - dict: PropTypes.object, // 瀛楀吀椤� - menu: PropTypes.object, // 鑿滃崟淇℃伅 - config: PropTypes.object, // 椤甸潰閰嶇疆淇℃伅 - formlist: PropTypes.array, // 琛ㄥ崟淇℃伅 - inputSubmit: PropTypes.any // 鍥炶溅鎻愪氦浜嬩欢 + dict: PropTypes.object, // 瀛楀吀椤� + menu: PropTypes.object, // 鑿滃崟淇℃伅 + config: PropTypes.object, // 椤甸潰閰嶇疆淇℃伅 + permFuncField: PropTypes.array, // 瀛樺偍杩囩▼鍙敤瀛楁 + inputSubmit: PropTypes.any // 鍥炶溅鎻愪氦浜嬩欢 } state = { - formlist: [], - btnloading: false, + loading: false, setting: null, - view: 'normal', - systemScripts: [{ - name: '榛樿sql', - value: '' - }], - scriptsColumns: [ - { - title: 'SQL', - dataIndex: 'sql', - width: '70%', - render: (text) => ( - <Paragraph copyable ellipsis={{ rows: 5, expandable: true }}>{text}</Paragraph> - ) - }, - { - title: '鐘舵��', - dataIndex: 'status', - width: '10%', - render: (text, record) => record.status === 'false' ? - ( - <div> - {this.props.dict['model.status.forbidden']} - <Icon style={{marginLeft: '5px'}} type="stop" theme="twoTone" twoToneColor="#ff4d4f" /> - </div> - ) : - ( - <div> - {this.props.dict['model.status.open']} - <Icon style={{marginLeft: '5px'}} type="check-circle" theme="twoTone" twoToneColor="#52c41a" /> - </div> - ) - }, - { - title: '鎿嶄綔', - align: 'center', - width: '20%', - dataIndex: 'operation', - render: (text, record) => - (<div> - <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record)} style={{color: '#1890ff'}}><Icon type="edit" /></span> - <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> - <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> - <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record)} style={{color: '#8E44AD'}}><Icon type="swap" /></span> - <Popconfirm - overlayClassName="popover-confirm" - title={this.props.dict['model.query.delete']} - onConfirm={() => this.handleDelete(record) - }> - <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> - </Popconfirm> - </div>) - } - ] + defaultsql: '', + activeKey: 'setting', } UNSAFE_componentWillMount() { - let _formlist = fromJS(this.props.formlist).toJS() - let interType = 'inner' + const { config } = this.props - _formlist.forEach(item => { - if (item.key === 'interType') { - interType = item.initVal - } - }) - - let _setting = fromJS(this.props.config.setting).toJS() - _setting.scripts = _setting.scripts || [] - _setting.default = _setting.default || 'true' + let _setting = fromJS(config.setting).toJS() + let _scripts = _setting.scripts || [] this.setState({ setting: _setting, - formlist: _formlist.map(item => { - if (interType === 'inner' && ['sysInterface', 'interface', 'outerFunc'].includes(item.key)) { - item.hidden = true - } else if (interType === 'outer' && ['innerFunc', 'dataresource', 'queryType'].includes(item.key)) { - item.hidden = true - } - - return item - }) + scripts: _scripts }) } - componentDidMount () { - this.getsysScript() - } - getsysScript = () => { - let _scriptSql = `Select distinct func+Remark as funcname,longparam, s.Sort from聽 s_custom_script s inner join (select OpenID from sapp where ID=@Appkey@) p on s.openid = case when s.appkey='' then s.openid else p.OpenID end order by s.Sort` - - _scriptSql = Utils.formatOptions(_scriptSql) - - let _sParam = { - func: 'sPC_Get_SelectedList', - LText: _scriptSql, - obj_name: 'data', - arr_field: 'funcname,longparam' - } + handleConfirm = () => { + const { activeKey, setting, scripts } = this.state - _sParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _sParam.secretkey = Utils.encrypt(_sParam.LText, _sParam.timestamp) - _sParam.open_key = Utils.encryptOpenKey(_sParam.secretkey, _sParam.timestamp) // 浜戠鏁版嵁楠岃瘉 - - Api.getSystemConfig(_sParam).then(res => { - if (res.status) { - let _scripts = res.data.map(item => { - let _item = { - name: item.funcname, - value: Utils.UnformatOptions(item.longparam) - } + let _scripts = scripts.filter(script => script.status !== 'false') - return _item - }) - - this.setState({ - systemScripts: [...this.state.systemScripts, ..._scripts] - }) - } else { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } - }) - } - - handleConfirm = (otype) => { - const { menu } = this.props - const { view, setting } = this.state - // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� - - if (view !== 'custom') { + if (activeKey === 'setting') { return new Promise((resolve, reject) => { - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - values = {...setting, ...values} - - // 鏁版嵁婧愬墠绔獙璇� - if (values.interType === 'inner' && !values.innerFunc && values.default !== 'false' && !values.dataresource) { - notification.warning({ - top: 92, - message: '璇峰~鍐欏唴閮ㄥ嚱鏁版垨鏁版嵁婧愶紒', - duration: 5 - }) - reject() - return - } else if (values.interType === 'inner' && !values.innerFunc && values.default !== 'false' && values.dataresource) { - let error = Utils.verifySql(values.dataresource) - - if (error) { - notification.warning({ - top: 92, - message: '鏁版嵁婧愪腑涓嶅彲浣跨敤' + error, - duration: 5 - }) - reject() - return - } - } - - // 鏁版嵁婧愪繚瀛� - if ( - values.interType === 'inner' && !values.innerFunc && - values.default !== 'false' && - /[^\s]+\s+[^\s]+/ig.test(values.dataresource) && - this.props.config.setting.dataresource !== values.dataresource - ) { - let param = { - func: 's_DataSrc_Save', - LText: values.dataresource, - MenuID: menu.MenuID - } - - 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) - - Api.getLocalConfig(param) - } - - if (otype === 'change') { - this.setState({ - setting: values, - }, () => { - resolve() - }) - } else { - values.customScript = this.getCustomScript(values) - - this.sqlverify(values, resolve, reject) - } - } else { - reject(err) + this.settingForm.handleConfirm().then(res => { + if (res.interType === 'system' && res.default === 'false' && _scripts.length === 0) { + notification.warning({ + top: 92, + message: '涓嶆墽琛岄粯璁ql鏃讹紝璇锋坊鍔犺嚜瀹氫箟鑴氭湰锛�', + duration: 5 + }) + reject() + return } + + this.setState({ + setting: res + }, () => { + this.sqlverify(() => { resolve({...res, scripts}) }, reject, 'submit') + }) + }, () => { + reject() }) }) } else { - let _setting = fromJS(this.state.setting).toJS() - _setting.customScript = this.getCustomScript(_setting) - - let _this = this - return new Promise((resolve, reject) => { - if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { - confirm({ - content: `瀛樺湪鏈繚瀛橀」锛岀‘瀹氭彁浜ゅ悧锛焋, - onOk() { - _this.sqlverify(_setting, resolve, reject) - }, - onCancel() { - reject() - } + let _loading = false + if (this.scriptsForm && this.scriptsForm.state.editItem) { + _loading = true + } else if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { + _loading = true + } + + if (_loading) { + notification.warning({ + top: 92, + message: '瀛樺湪鏈繚瀛樿剼鏈紝璇风偣鍑荤‘瀹氫繚瀛橈紝鎴栫偣鍑诲彇娑堟斁寮冧慨鏀癸紒', + duration: 5 }) + reject() + } else if (setting.interType === 'system' && setting.default === 'false' && _scripts.length === 0) { + notification.warning({ + top: 92, + message: '涓嶆墽琛岄粯璁ql鏃讹紝璇锋坊鍔犺嚜瀹氫箟鑴氭湰锛�', + duration: 5 + }) + reject() } else { - this.sqlverify(_setting, resolve, reject) + this.sqlverify(() => { + resolve({...setting, scripts}) + }, () => { + reject() + }, 'submit') } }) } } - getCustomScript = (setting) => { - let _customScript = '' - if (setting.scripts && setting.scripts.length > 0) { - setting.scripts.forEach(item => { - if (item.status === 'false') return - _customScript += ` - ${item.sql} - ` - }) - } + sqlverify = (_resolve, _reject, type, uscripts) => { + const { setting, scripts } = this.state - if (_customScript) { - _customScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000) select @ErrorCode='',@retmsg ='' - ${_customScript} - ` - } - - return _customScript - } - - sqlverify = (_setting, _resolve, _reject, isChange = false) => { - if (!isChange && _setting.interType === 'inner' && !_setting.innerFunc && _setting.default === 'false' && !_setting.customScript) { - notification.warning({ - top: 92, - message: '涓嶆墽琛岄粯璁ql鏃讹紝璇锋坊鍔犺嚜瀹氫箟鑴氭湰锛�', - duration: 5 - }) - _reject() + if (setting.interType !== 'system') { // 涓嶄娇鐢ㄧ郴缁熸帴鍙f椂锛屼笉闇�瑕乻ql楠岃瘉 + _resolve() return } - if (_setting.interType === 'inner' && !_setting.innerFunc && _setting.default !== 'false') { + let _scripts = [] + if (uscripts) { // 杩囨护绂佺敤鐨勮剼鏈� + _scripts = uscripts.filter(script => script.status !== 'false') + } else { + _scripts = scripts.filter(script => script.status !== 'false') + } + + if (type === 'setting' && setting.default === 'false') { + _resolve() + } else if (type === 'scripts' && _scripts.length === 0) { + _resolve() + } else { // type 涓� submit 銆� verify 锛屼互鍙婂叾浠栭渶瑕侀獙璇佺殑鍦烘櫙 let param = { func: 's_debug_sql', - LText: SettingUtils.getDebugSql(_setting) + LText: SettingUtils.getDebugSql(setting, _scripts) } param.LText = Utils.formatOptions(param.LText) param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' @@ -291,7 +133,7 @@ Api.getLocalConfig(param).then(result => { if (result.status) { - _resolve(_setting) + _resolve() } else { _reject() Modal.error({ @@ -299,444 +141,124 @@ }) } }) - } else { - _resolve(_setting) } } - selectChange = (key, val) => { - if (key === 'primaryKey' && val) { - this.props.form.setFieldsValue({ - order: `${val} desc` - }) - } - } + changeTab = (val) => { + const { activeKey } = this.state - onRadioChange = (e, key) => { - let value = e.target.value - let _formlist = fromJS(this.state.formlist).toJS() - - if (key === 'interType') { - this.setState({ - formlist: _formlist.map(item => { - item.hidden = false - - if (value === 'inner' && ['sysInterface', 'interface', 'outerFunc'].includes(item.key)) { - item.initVal = this.props.form.getFieldValue(item.key) - item.hidden = true - } else if (value === 'outer' && ['innerFunc', 'dataresource', 'queryType'].includes(item.key)) { - item.initVal = this.props.form.getFieldValue(item.key) - item.hidden = true - } - - return item - }) - }) - } else if (key === 'sysInterface') { - if (value === 'true') { - this.props.form.setFieldsValue({ - interface: window.GLOB.mainSystemApi || '' - }) - } - this.setState({ - formlist: _formlist.map(item => { - if (item.key === 'interface') { - item.readonly = value === 'true' - } - - return item - }) - }) - } - } - - changeView = () => { - const { view } = this.state - let _this = this - - if (view === 'normal') { - this.handleConfirm('change').then(() => { - const { setting } = this.state - - if (setting.interType !== 'inner' || (setting.interType === 'inner' && setting.innerFunc)) { + if (activeKey === 'setting') { + this.settingForm.handleConfirm().then(res => { + if (res.interType !== 'system') { notification.warning({ top: 92, - message: '浣跨敤澶栭儴鎺ュ彛鎴栧唴閮ㄦ帴鍙g殑鑷畾涔夊嚱鏁帮紝涓嶅彲娣诲姞鑷畾涔夎缃紒', + message: '浣跨敤绯荤粺鎺ュ彛鏃讹紝鎵嶅彲浠ヨ缃嚜瀹氫箟鑴氭湰锛�', duration: 5 }) return } - let _dataresource = setting.dataresource + let _defaultSql = '' + if (res.dataresource) { + let _dataresource = res.dataresource + let arr_field = `${res.valueField},${res.labelField},${res.parentField}` - if (/\s/.test(_dataresource)) { - _dataresource = '(' + _dataresource + ') tb' + if (/\s/.test(_dataresource)) { + _dataresource = '(' + _dataresource + ') tb' + } + + _defaultSql = ` select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${res.order}) as rows from ${_dataresource}) tmptable order by tmptable.rows ` } - - let arr_field = `${setting.valueField}, ${setting.labelField}, ${setting.parentField}` - - let LText = `select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by @orderBy@) as rows from ${_dataresource}) tmptable order by tmptable.rows` - let _scripts = fromJS(this.state.systemScripts).toJS() - _scripts[0].value = LText - - - if (setting.default === 'false') { - this.setState({ - view: 'custom', - btnloading: false, - systemScripts: _scripts - }) - this.scrolltop() - } else { - this.setState({ - btnloading: true - }) - new Promise((resolve, reject) => { - this.sqlverify(setting, resolve, reject, true) - }).then(() => { + this.setState({ + setting: res, + defaultsql: _defaultSql + }, () => { + this.setState({loading: true}) + this.sqlverify(() => { // 楠岃瘉鎴愬姛 this.setState({ - view: 'custom', - btnloading: false, - systemScripts: _scripts + activeKey: val, + loading: false }) - this.scrolltop() - }, () => { + }, () => { // 楠岃瘉澶辫触 this.setState({ - btnloading: false + loading: false }) - }) - } + }, activeKey) + }) }) } else { let _loading = false - - if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { + if (this.scriptsForm && this.scriptsForm.state.editItem) { + _loading = true + } else if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { _loading = true } if (_loading) { - confirm({ - content: `瀛樺湪鏈繚瀛橀」锛岀‘瀹氬垏鎹㈠悧锛焋, - onOk() { - _this.setState({ - view: 'normal' - }) - - _this.scrolltop() - }, - onCancel() {} + notification.warning({ + top: 92, + message: '瀛樺湪鏈繚瀛樿剼鏈紝璇风偣鍑荤‘瀹氫繚瀛橈紝鎴栫偣鍑诲彇娑堟斁寮冧慨鏀癸紒', + duration: 5 }) - } else { - _this.setState({ - view: 'normal' + return + } + this.setState({loading: true}) + this.sqlverify(() => { // 楠岃瘉鎴愬姛 + this.setState({ + activeKey: val, + loading: false }) - - _this.scrolltop() - } + }, () => { // 楠岃瘉澶辫触 + this.setState({ + loading: false + }) + }, activeKey) } } - handleSubmit = (e) => { - e.preventDefault() - - if (this.props.inputSubmit) { - this.props.inputSubmit() - } - } - - getFields(formlist) { - const { getFieldDecorator } = this.props.form - const fields = [] - - formlist.forEach((item, index) => { - if (item.hidden || item.forbid) return - - if (item.type === 'text') { // 鏂囨湰鎼滅储 - let rules = item.rules || [] - - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.tooltip ? - <Tooltip placement={item.placement || 'topLeft'} title={item.tooltip}> - <Icon type="question-circle" /> - {item.label} - </Tooltip> : item.label - }> - {getFieldDecorator(item.key, { - initialValue: item.initVal || '', - rules: [ - { - required: !!item.required, - message: this.props.dict['form.required.input'] + item.label + '!' - }, - ...rules - ] - })(<Input placeholder={item.placeholder || ''} autoComplete="off" disabled={item.readonly} onPressEnter={this.handleSubmit} />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'number') { - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.tooltip ? - <Tooltip placement="topLeft" title={item.tooltip}> - <Icon type="question-circle" /> - {item.label} - </Tooltip> : item.label - }> - {getFieldDecorator(item.key, { - initialValue: item.initVal || 6, - rules: [ - { - required: item.required, - message: this.props.dict['form.required.input'] + item.label + '!' - } - ] - })(<InputNumber min={item.min} max={item.max} precision={0} />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'select') { // 涓嬫媺鎼滅储 - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.key, { - initialValue: item.initVal || '', - rules: [ - { - required: !!item.required, - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <Select - showSearch - filterOption={(input, option) => { - return option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 || - option.props.value.toLowerCase().indexOf(input.toLowerCase()) >= 0 - }} - onChange={(value) => {this.selectChange(item.key, value)}} - getPopupContainer={() => document.getElementById('model-table-setting-form')} - > - {item.options.map((option, i) => - <Select.Option id={i} key={i} value={option.value}> - {option.text} - </Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'radio') { - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.tooltip ? - <Tooltip placement="topLeft" title={item.tooltip}> - <Icon type="question-circle" /> - {item.label} - </Tooltip> : item.label - }> - {getFieldDecorator(item.key, { - initialValue: item.initVal, - rules: [ - { - required: !!item.required, - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <Radio.Group onChange={(e) => {this.onRadioChange(e, item.key)}}> - { - item.options.map((option, i) => { - return ( - <Radio key={i} value={option.value}>{option.text}</Radio> - ) - }) - } - </Radio.Group>, - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'datasource') { - fields.push( - <Col span={24} key={index} style={{paddingLeft: '7px'}}> - <Form.Item className="text-area" labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } help={item.help} label={ - <Tooltip placement="topLeft" title={item.tooltip}> - <Icon type="question-circle" /> - {item.label} - </Tooltip> - }> - {getFieldDecorator(item.key, { - initialValue: item.initVal - })(<CodeMirror />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'multiselect') { // 澶氶�� - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.key, { - initialValue: item.initVal || [] - })( - <Select - showSearch - mode="multiple" - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - > - {item.options.map((option, i) => - <Select.Option id={i} key={i} value={option.value}>{option.text}</Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - ) - } - }) - - return fields - } - - handleEdit = (record) => { - this.scriptsForm.edit(record) - - this.scrolltop() - } - - scrolltop = () => { - let node = document.getElementById('model-tree-setting-form-box').parentNode - - if (node && node.scrollTop) { - let inter = Math.ceil(node.scrollTop / 10) - - let timer = setInterval(() => { - if (node.scrollTop - inter > 0) { - node.scrollTop = node.scrollTop - inter - } else { - node.scrollTop = 0 - clearInterval(timer) - } - }, 10) - } - } - - handleUpDown = (record, direction) => { - let scripts = fromJS(this.state.setting.scripts).toJS() - let index = 0 - - scripts = scripts.filter((item, i) => { - if (item.uuid === record.uuid) { - index = i - } - - return item.uuid !== record.uuid - }) - if ((index === 0 && direction === 'up') || (index === scripts.length && direction === 'down')) { - return - } - - if (direction === 'up') { - scripts.splice(index - 1, 0, record) - } else { - scripts.splice(index + 1, 0, record) - } - - this.setState({ - setting: {...this.state.setting, scripts: scripts} + // 鑷畾涔夎剼鏈慨鏀� + scriptsChange = (scripts) => { + return new Promise((resolve, reject) => { + this.sqlverify(resolve, reject, 'verify', scripts) }) } - handleStatus = (record) => { - let scripts = fromJS(this.state.setting.scripts).toJS() - record.status = record.status === 'false' ? 'true' : 'false' - - scripts = scripts.map(item => { - if (item.uuid === record.uuid) { - return record - } else { - return item - } - }) - - this.setState({ - setting: {...this.state.setting, scripts: scripts} - }) - } - - handleDelete = (record) => { - let scripts = fromJS(this.state.setting.scripts).toJS() - scripts = scripts.filter(item => item.uuid !== record.uuid) - - this.setState({ setting: {...this.state.setting, scripts: scripts} }) - } - - scriptsChange = (values) => { - let scripts = fromJS(this.state.setting.scripts).toJS() - - if (values.uuid) { - scripts = scripts.map(item => { - if (item.uuid === values.uuid) { - return values - } else { - return item - } - }) - } else { - values.uuid = Utils.getuuid() - scripts.push(values) - } - - this.setState({ - setting: {...this.state.setting, scripts: scripts} - }) + // 鑷畾涔夎剼鏈洿鏂� + scriptsUpdate = (scripts) => { + this.setState({scripts}) } render() { - const { config, type } = this.props - const { formlist, view, setting, scriptsColumns, systemScripts, btnloading } = this.state - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 8 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 16 } - } - } + const { menu } = this.props + const { activeKey, setting, loading, scripts } = this.state return ( - <div className="model-tree-setting-form-box" id="model-tree-setting-form-box"> - {view ==='custom' ? <div> - <Icon className="setting-custom-back" onClick={this.changeView} type="arrow-left" /> - <CustomScript - type={type} - setting={setting} - dict={this.props.dict} - searches={config.search} - systemScripts={systemScripts} - scriptsChange={this.scriptsChange} - wrappedComponentRef={(inst) => this.scriptsForm = inst} - /> - <Table - bordered - rowKey="uuid" - className="custom-table" - dataSource={setting.scripts} - columns={scriptsColumns} - pagination={false} - /> - </div> : null } - <Form {...formItemLayout} className="model-tree-setting-form" id="model-table-setting-form"> - {view !=='custom' ? <Row gutter={24}>{this.getFields(formlist)}</Row> : null} - <Row gutter={24}> - {view !=='custom' ? <Button onClick={this.changeView} className="to-custom-script" loading={btnloading}>鑷畾涔夎缃�<Icon style={{marginLeft: 5}} type="right" /></Button> : null} - {view ==='custom' ? <span onClick={this.changeView} style={{float: 'left', color: '#1890ff', marginLeft: 12, marginTop: 15, cursor: 'pointer'}}><Icon style={{marginRight: 5}} type="left" />鍩虹璁剧疆</span> : null} - </Row> - </Form> + <div className="model-tree-setting-form-box" id="model-setting-form-body"> + {loading && <Spin size="large" />} + <Tabs activeKey={activeKey} className="verify-card-box" onChange={this.changeTab}> + <TabPane tab="鏁版嵁婧�" key="setting"> + <DataSource + menu={menu} + dict={this.props.dict} + setting={setting} + permFuncField={this.props.permFuncField} + inputSubmit={this.props.inputSubmit} + wrappedComponentRef={(inst) => this.settingForm = inst} + /> + </TabPane> + <TabPane tab="鑷畾涔夎剼鏈�" key="scripts"> + <CustomScript + dict={this.props.dict} + setting={setting} + scripts={scripts} + defaultSql={this.state.defaultsql} + searches={[]} + scriptsChange={this.scriptsChange} + scriptsUpdate={this.scriptsUpdate} + wrappedComponentRef={(inst) => this.scriptsForm = inst} + /> + </TabPane> + </Tabs> </div> ) } diff --git a/src/templates/sharecomponent/treesettingcomponent/settingform/index.scss b/src/templates/sharecomponent/treesettingcomponent/settingform/index.scss index 3db3b45..a129595 100644 --- a/src/templates/sharecomponent/treesettingcomponent/settingform/index.scss +++ b/src/templates/sharecomponent/treesettingcomponent/settingform/index.scss @@ -1,5 +1,10 @@ .model-tree-setting-form-box { position: relative; + >.ant-spin { + position: absolute; + top: 150px; + left: calc(50% - 16px); + } .model-tree-setting-form { .text-area { .CodeMirror { @@ -39,4 +44,8 @@ border: 0; box-shadow: unset; } + + .verify-card-box .ant-tabs-nav-scroll { + text-align: center; + } } \ No newline at end of file diff --git a/src/templates/sharecomponent/treesettingcomponent/settingform/utils.jsx b/src/templates/sharecomponent/treesettingcomponent/settingform/utils.jsx index ae1a6b6..0358ea7 100644 --- a/src/templates/sharecomponent/treesettingcomponent/settingform/utils.jsx +++ b/src/templates/sharecomponent/treesettingcomponent/settingform/utils.jsx @@ -2,27 +2,45 @@ export default class SettingUtils { /** * @description 鐢熸垚椤甸潰鏌ヨ璇彞 + * @return {String} scripts 鑷畾涔夎剼鏈� * @return {Object} setting 椤甸潰璁剧疆 */ - static getDebugSql (setting) { + static getDebugSql (setting, scripts) { + let arr_field = `${setting.valueField},${setting.labelField},${setting.parentField}` let sql = '' - let _dataresource = setting.dataresource - let _customScript = setting.customScript + let _dataresource = setting.dataresource || '' + let _customScript = '' - if (setting.interType === 'inner' && !setting.innerFunc && setting.default === 'false') { + scripts && scripts.forEach(script => { + _customScript += ` + ${script.sql} + ` + }) + + if (_customScript) { + _customScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000) select @ErrorCode='',@retmsg ='' + ${_customScript} + ` + } + + if (setting.default === 'false') { _dataresource = '' } - if (_dataresource) { - _dataresource = _dataresource.replace(/@\$|\$@/ig, '') - } - if (_customScript) { - _customScript = _customScript.replace(/@\$|\$@/ig, '') - } + _dataresource = _dataresource.replace(/@\$|\$@/ig, '') + _customScript = _customScript.replace(/@\$|\$@/ig, '') + + // 姝e垯鏇挎崲 + let _regoptions = [ + { + reg: new RegExp('@orderBy@', 'ig'), + value: setting.order + } + ] - if (_customScript) { - _customScript = _customScript.replace(/@orderBy@/ig, setting.order) - } + _regoptions.forEach(item => { + _customScript = _customScript.replace(item.reg, item.value) + }) // 鏁版嵁婧愬鐞� if (_dataresource) { @@ -30,9 +48,7 @@ _dataresource = '(' + _dataresource + ') tb' } - let arr_field = `${setting.valueField}, ${setting.labelField}, ${setting.parentField}` - - _dataresource = `select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${setting.order}) as rows from ${_dataresource}) tmptable order by tmptable.rows` + _dataresource = ` select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${setting.order}) as rows from ${_dataresource}) tmptable order by tmptable.rows ` } if (_customScript) { diff --git a/src/templates/treepageconfig/index.jsx b/src/templates/treepageconfig/index.jsx index 24d1e68..0422389 100644 --- a/src/templates/treepageconfig/index.jsx +++ b/src/templates/treepageconfig/index.jsx @@ -96,6 +96,11 @@ }) } + // 鏁版嵁婧� + if (_config.setting.interType === 'inner' && !_config.setting.innerFunc) { + _config.setting.interType = 'system' + } + this.setState({ config: _config, openEdition: menu.open_edition || '', diff --git a/src/templates/zshare/customscript/index.jsx b/src/templates/zshare/customscript/index.jsx new file mode 100644 index 0000000..d487caa --- /dev/null +++ b/src/templates/zshare/customscript/index.jsx @@ -0,0 +1,436 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { fromJS } from 'immutable' +import { Form, Row, Col, Icon, Button, notification, Select, Table, Popconfirm, Typography } from 'antd' +import moment from 'moment' + +import Utils from '@/utils/utils.js' +// import SettingUtils from '../utils.jsx' +import Api from '@/api' +import CodeMirror from '@/templates/zshare/codemirror' +import './index.scss' + +const { Paragraph } = Typography + +class CustomForm extends Component { + static propTpyes = { + dict: PropTypes.object, // 瀛楀吀椤� + setting: PropTypes.object, // 璁剧疆 + scripts: PropTypes.array, // 鑷畾涔夎剼鏈垪琛� + searches: PropTypes.array, // 鎼滅储鏉′欢 + defaultSql: PropTypes.string, // 榛樿sql + scriptsChange: PropTypes.func, // 鑷畾涔夎剼鏈垏鎹㈡椂楠岃瘉 + scriptsUpdate: PropTypes.func // 琛ㄥ崟 + } + + state = { + editItem: null, + loading: false, + usefulFields: '', + systemScripts: [], + scriptsColumns: [ + { + title: 'SQL', + dataIndex: 'sql', + width: '70%', + render: (text) => ( + <Paragraph copyable ellipsis={{ rows: 5, expandable: true }}>{text}</Paragraph> + ) + }, + { + title: '鐘舵��', + dataIndex: 'status', + width: '10%', + render: (text, record) => record.status === 'false' ? + ( + <div> + {this.props.dict['model.status.forbidden']} + <Icon style={{marginLeft: '5px'}} type="stop" theme="twoTone" twoToneColor="#ff4d4f" /> + </div> + ) : + ( + <div> + {this.props.dict['model.status.open']} + <Icon style={{marginLeft: '5px'}} type="check-circle" theme="twoTone" twoToneColor="#52c41a" /> + </div> + ) + }, + { + title: '鎿嶄綔', + align: 'center', + width: '20%', + dataIndex: 'operation', + render: (text, record) => + (<div> + <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record)} style={{color: '#1890ff'}}><Icon type="edit" /></span> + <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> + <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> + <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record)} style={{color: '#8E44AD'}}><Icon type="swap" /></span> + <Popconfirm + overlayClassName="popover-confirm" + title={this.props.dict['model.query.delete']} + onConfirm={() => this.handleDelete(record) + }> + <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> + </Popconfirm> + </div>) + } + ] + } + + UNSAFE_componentWillMount() { + const { searches, scripts } = this.props + + let _usefulFields = [] + searches.forEach(item => { + if (item.type === 'group') { + if (item.transfer === 'true') { + _usefulFields.push(item.field) + } + _usefulFields.push(item.datefield) + _usefulFields.push(item.datefield + '1') + } else if (['dateweek', 'datemonth', 'daterange'].includes(item.type)) { + _usefulFields.push(item.field) + _usefulFields.push(item.field + '1') + } else if (_usefulFields.includes(item.field)) { + _usefulFields.push(item.field + '1') + } else { + _usefulFields.push(item.field) + } + }) + + this.setState({ + usefulFields: _usefulFields.join(', '), + scripts: fromJS(scripts).toJS() + }) + } + + componentDidMount () { + this.getsysScript() + } + + getsysScript = () => { + let _scriptSql = `Select distinct func+Remark as funcname,longparam, s.Sort from聽 s_custom_script s inner join (select OpenID from sapp where ID=@Appkey@) p on s.openid = case when s.appkey='' then s.openid else p.OpenID end order by s.Sort` + + _scriptSql = Utils.formatOptions(_scriptSql) + + let _sParam = { + func: 'sPC_Get_SelectedList', + LText: _scriptSql, + obj_name: 'data', + arr_field: 'funcname,longparam' + } + + _sParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + _sParam.secretkey = Utils.encrypt(_sParam.LText, _sParam.timestamp) + _sParam.open_key = Utils.encryptOpenKey(_sParam.secretkey, _sParam.timestamp) // 浜戠鏁版嵁楠岃瘉 + + Api.getSystemConfig(_sParam).then(res => { + if (res.status) { + let _scripts = res.data.map(item => { + let _item = { + name: item.funcname, + value: Utils.UnformatOptions(item.longparam) + } + return _item + }) + + this.setState({ + systemScripts: _scripts + }) + } else { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + } + }) + } + + + + handleCancel = () => { + this.setState({ + editItem: null + }) + this.props.form.setFieldsValue({ + sql: '' + }) + } + + handleConfirm = () => { + const { scripts, editItem } = this.state + + let _sql = this.props.form.getFieldValue('sql') + + if (!_sql) { + notification.warning({ + top: 92, + message: '璇峰~鍐欒嚜瀹氫箟鑴氭湰锛�', + duration: 5 + }) + return + } else if (/^\s+$/.test(_sql)) { + notification.warning({ + top: 92, + message: '鑷畾涔夎剼鏈笉鍙负绌猴紒', + duration: 5 + }) + return + } + + let values = { + uuid: editItem && editItem.uuid ? editItem.uuid : Utils.getuuid(), + sql: _sql + } + + let _quot = values.sql.match(/'{1}/g) + let _lparen = values.sql.match(/\({1}/g) + let _rparen = values.sql.match(/\){1}/g) + + _quot = _quot ? _quot.length : 0 + _lparen = _lparen ? _lparen.length : 0 + _rparen = _rparen ? _rparen.length : 0 + + if (_quot % 2 !== 0) { + notification.warning({ + top: 92, + message: 'sql涓璡'蹇呴』鎴愬鍑虹幇', + duration: 5 + }) + return + } else if (_lparen !== _rparen) { + notification.warning({ + top: 92, + message: 'sql涓�()蹇呴』鎴愬鍑虹幇', + duration: 5 + }) + return + } else if (/--/ig.test(values.sql)) { + notification.warning({ + top: 92, + message: '鑷畾涔塻ql璇彞涓紝涓嶅彲鍑虹幇瀛楃 -- 锛屾敞閲婅鐢� /*鍐呭*/', + duration: 5 + }) + return + } + + let error = Utils.verifySql(values.sql, 'customscript') + + if (error) { + notification.warning({ + top: 92, + message: 'sql涓笉鍙娇鐢�' + error, + duration: 5 + }) + return + } + + let _scripts = fromJS(scripts).toJS() + + if (editItem && editItem.uuid) { + _scripts = _scripts.map(item => { + if (item.uuid === values.uuid) { + return values + } else { + return item + } + }) + } else { + _scripts.push(values) + } + + this.setState({loading: true}) + this.props.scriptsChange(_scripts).then(res => { + this.setState({ + loading: false, + scripts: _scripts, + editItem: null + }) + + this.props.scriptsUpdate(_scripts) + this.props.form.setFieldsValue({ + sql: '' + }) + }, () => { + this.setState({loading: false}) + }) + } + + selectScript = (value, option) => { + let _sql = this.props.form.getFieldValue('sql') + if (_sql) { + _sql = _sql + ` + + ` + } + + _sql = _sql.replace(/\s{6}$/, '') + _sql = _sql + `/*${option.props.children}*/ + ` + _sql = _sql.replace(/\s{4}$/, '') + _sql = _sql + value + + this.props.form.setFieldsValue({ + sql: _sql + }) + } + + handleEdit = (record) => { + this.setState({ + editItem: record + }) + + this.props.form.setFieldsValue({ + sql: record.sql + }) + + this.scrolltop() + } + + scrolltop = () => { + let node = document.getElementById('model-setting-form-body').parentNode + + if (node && node.scrollTop) { + let inter = Math.ceil(node.scrollTop / 10) + + let timer = setInterval(() => { + if (node.scrollTop - inter > 0) { + node.scrollTop = node.scrollTop - inter + } else { + node.scrollTop = 0 + clearInterval(timer) + } + }, 10) + } + } + + handleUpDown = (record, direction) => { + let scripts = fromJS(this.state.scripts).toJS() + let index = 0 + + scripts = scripts.filter((item, i) => { + if (item.uuid === record.uuid) { + index = i + } + + return item.uuid !== record.uuid + }) + if ((index === 0 && direction === 'up') || (index === scripts.length && direction === 'down')) { + return + } + + if (direction === 'up') { + scripts.splice(index - 1, 0, record) + } else { + scripts.splice(index + 1, 0, record) + } + + this.setState({scripts}) + this.props.scriptsUpdate(scripts) + } + + handleStatus = (record) => { + let scripts = fromJS(this.state.scripts).toJS() + record.status = record.status === 'false' ? 'true' : 'false' + + scripts = scripts.map(item => { + if (item.uuid === record.uuid) { + return record + } else { + return item + } + }) + + this.setState({scripts}) + this.props.scriptsUpdate(scripts) + } + + handleDelete = (record) => { + let scripts = fromJS(this.state.scripts).toJS() + scripts = scripts.filter(item => item.uuid !== record.uuid) + + this.setState({ scripts }) + this.props.scriptsUpdate(scripts) + } + + render() { + const { setting, defaultSql, scripts } = this.props + const { getFieldDecorator } = this.props.form + const { usefulFields, scriptsColumns, systemScripts } = this.state + const formItemLayout = { + labelCol: { + xs: { span: 24 }, + sm: { span: 8 } + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 16 } + } + } + + return ( + <div> + <Form {...formItemLayout} className="modal-menu-setting-script"> + <Row gutter={24}> + {setting.tableName ? <Col span={8}> + <Form.Item label={'琛ㄥ悕'} style={{whiteSpace: 'nowrap', margin: 0}}> + {setting.tableName} + </Form.Item> + </Col> : null} + <Col span={16}> + <Form.Item label={'鎶ラ敊瀛楁'} style={{margin: 0}}> + ErrorCode, retmsg + </Form.Item> + </Col> + <Col span={24} className="sqlfield"> + <Form.Item label={'鍙敤瀛楁'}> + id, bid, loginuid, sessionuid, userid, appkey, time_id, orderBy{setting.laypage === 'true' ? ', pageSize, pageIndex': ''}{usefulFields ? ', ' + usefulFields : ''} + </Form.Item> + </Col> + <Col span={10} className="quick-add"> + <Form.Item label={'蹇嵎娣诲姞'} style={{marginBottom: 0}}> + <Select + showSearch + 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> + )} + </Select> + </Form.Item> + </Col> + <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'}> + {getFieldDecorator('sql', { + initialValue: '' + })(<CodeMirror />)} + </Form.Item> + </Col> + </Row> + </Form> + <Table + bordered + rowKey="uuid" + className="custom-table" + dataSource={scripts} + columns={scriptsColumns} + pagination={false} + /> + </div> + ) + } +} + +export default Form.create()(CustomForm) \ No newline at end of file diff --git a/src/templates/sharecomponent/settingcalcomponent/verifycard/customscript/index.scss b/src/templates/zshare/customscript/index.scss similarity index 83% rename from src/templates/sharecomponent/settingcalcomponent/verifycard/customscript/index.scss rename to src/templates/zshare/customscript/index.scss index 2a1d2d8..09f7165 100644 --- a/src/templates/sharecomponent/settingcalcomponent/verifycard/customscript/index.scss +++ b/src/templates/zshare/customscript/index.scss @@ -19,6 +19,14 @@ width: 89.5%; } } + .quick-add { + .ant-col-sm-8 { + width: 26%; + } + .ant-col-sm-16 { + width: 74%; + } + } .sql { .ant-col-sm-8 { width: 10.5%; diff --git a/src/templates/zshare/editcomponent/index.jsx b/src/templates/zshare/editcomponent/index.jsx index 7c52871..adb6bd8 100644 --- a/src/templates/zshare/editcomponent/index.jsx +++ b/src/templates/zshare/editcomponent/index.jsx @@ -1,9 +1,11 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' +import { fromJS } from 'immutable' import { Menu, Dropdown, Icon, Modal, Spin, notification } from 'antd' import Api from '@/api' import PasteForm from '@/templates/zshare/pasteform' +import ReplaceForm from '@/templates/zshare/replaceform' import TransferForm from '@/templates/zshare/basetransferform' import zhCN from '@/locales/zh-CN/model.js' import enUS from '@/locales/en-US/model.js' @@ -22,7 +24,8 @@ dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, thawVisible: false, thawbtnlist: null, - pasteVisible: false + pasteVisible: false, + replaceVisible: false } handleMenuClick = e => { @@ -30,6 +33,8 @@ this.handleThaw() } else if (e.key === 'paste') { this.setState({pasteVisible: true}) + } else if (e.key === 'replace') { + this.setState({replaceVisible: true}) } } @@ -127,10 +132,10 @@ } pasteSubmit = () => { - const { config } = this.props + const { config, type } = this.props this.pasteFormRef.handleConfirm().then(res => { - if (res.copyType === 'action') { + if (['maintable', 'subtable'].includes(type) && res.copyType === 'action') { if (this.props.type === 'subtable' && !['pop', 'prompt', 'exec', 'excelIn', 'excelOut', 'popview'].includes(res.OpenType)) { notification.warning({ top: 92, @@ -147,7 +152,7 @@ content: res }) }) - } else if (res.copyType === 'search') { + } else if (['maintable', 'subtable'].includes(type) && res.copyType === 'search') { this.setState({ pasteVisible: false }, () => { @@ -156,7 +161,7 @@ content: res }) }) - } else if (res.copyType === 'columns') { + } else if (['maintable', 'subtable'].includes(type) && res.copyType === 'columns') { let _columns = config.columns.filter(col => !col.origin) if (_columns.length > 0) { notification.warning({ @@ -175,6 +180,78 @@ content: res }) }) + } else if (['form'].includes(type) && res.copyType === 'form') { + if (res.type === 'linkMain') { + notification.warning({ + top: 92, + message: '涓嶆敮鎸佹琛ㄥ崟绫诲瀷锛�', + duration: 10 + }) + return + } + + let _config = fromJS(config).toJS() + let fieldrepet = false + let labelrepet = false + + if (_config.groups.length > 0) { + _config.groups.forEach(group => { + group.sublist.forEach(item => { + if (item.uuid === res.uuid) { + fieldrepet = true + } else if (item.field === res.field) { + fieldrepet = true + } else if (item.label === res.label) { + labelrepet = true + } + }) + }) + } else { + _config.fields.forEach(item => { + if (item.uuid === res.uuid) { + fieldrepet = true + } else if (item.field === res.field) { + fieldrepet = true + } else if (item.label === res.label) { + labelrepet = true + } + }) + } + + if (fieldrepet) { + notification.warning({ + top: 92, + message: '瀛楁宸插瓨鍦紒', + duration: 10 + }) + return + } else if (labelrepet) { + notification.warning({ + top: 92, + message: '鍚嶇О宸插瓨鍦紒', + duration: 10 + }) + return + } + + if (_config.groups.length > 0) { + _config.groups.forEach(group => { + if (group.default) { + group.sublist.push(res) + } + }) + } else { + _config.fields.push(res) + } + + this.setState({ + pasteVisible: false + }, () => { + this.props.refresh({ + type: 'paste', + content: _config + }) + }) } else { notification.warning({ top: 92, @@ -185,12 +262,25 @@ }) } + replaceSubmit = () => { + this.replaceFormRef.handleConfirm().then(res => { + this.props.refresh({ + type: 'replace', + ...res + }) + this.setState({ + replaceVisible: false + }) + }) + } + render() { + const { type } = this.props const { dict } = this.state const menu = ( <Menu onClick={this.handleMenuClick}> - {this.props.type !== 'TreePage' ? <Menu.Item key="thaw"><Icon type="unlock" />{dict['header.form.thawbutton']}</Menu.Item> : null} - <Menu.Item key="paste"><Icon type="snippets" />{dict['header.form.paste']}</Menu.Item> + {['maintable', 'subtable'].includes(type) ? <Menu.Item key="thaw"><Icon type="unlock" />{dict['header.form.thawbutton']}</Menu.Item> : null} + {['maintable', 'subtable', 'form'].includes(type) ? <Menu.Item key="paste"><Icon type="snippets" />{dict['header.form.paste']}</Menu.Item> : null} {/* <Menu.Item key="replace"><Icon type="retweet" />鏇挎崲</Menu.Item> */} </Menu> ) @@ -228,6 +318,22 @@ wrappedComponentRef={(inst) => this.pasteFormRef = inst} /> </Modal> + {/* 鏇挎崲 */} + <Modal + title={'鏇挎崲'} + visible={this.state.replaceVisible} + width={600} + maskClosable={false} + onOk={this.replaceSubmit} + onCancel={() => {this.setState({replaceVisible: false})}} + destroyOnClose + > + <ReplaceForm + dict={dict} + inputSubmit={this.replaceSubmit} + wrappedComponentRef={(inst) => this.replaceFormRef = inst} + /> + </Modal> </div> ) } diff --git a/src/templates/zshare/replaceform/index.jsx b/src/templates/zshare/replaceform/index.jsx new file mode 100644 index 0000000..0c0f745 --- /dev/null +++ b/src/templates/zshare/replaceform/index.jsx @@ -0,0 +1,119 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { Form, Row, Col, Input, Radio } from 'antd' +import './index.scss' + +class MainSearch extends Component { + static propTpyes = { + dict: PropTypes.object, // 瀛楀吀椤� + inputSubmit: PropTypes.func // 鎻愪氦 + } + + componentDidMount () { + try { + let _form = document.getElementById('origin') + if (_form && _form.select) { + _form.select() + } + } catch { + console.warn('Form focusing error锛�') + } + } + + handleConfirm = () => { + // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� + return new Promise((resolve, reject) => { + this.props.form.validateFieldsAndScroll((err, values) => { + if (!err) { + resolve(values) + } else { + reject(err) + } + }) + }) + } + + handleSubmit = (e) => { + e.preventDefault() + + let origin = this.props.form.getFieldValue('origin') + let value = this.props.form.getFieldValue('value') + + if (!origin) { + const input = document.getElementById('origin') + if (input) { + input.focus() + } + } else if (!value) { + const input = document.getElementById('value') + if (input) { + input.focus() + } + } else { + if (this.props.inputSubmit) { + this.props.inputSubmit() + } + } + } + + render() { + const { dict } = this.props + const { getFieldDecorator } = this.props.form + const formItemLayout = { + labelCol: { + xs: { span: 24 }, + sm: { span: 8 } + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 12 } + } + } + return ( + <Form {...formItemLayout} className="config-replace-form"> + <Row gutter={24}> + <Col span={24}> + <Form.Item label="绫诲瀷"> + {getFieldDecorator('repType', { + initialValue: 'field' + })( + <Radio.Group> + <Radio value="label">鍚嶇О</Radio> + <Radio value="field">瀛楁</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> + <Col span={24}> + <Form.Item label="鍘熷��"> + {getFieldDecorator('origin', { + initialValue: '', + rules: [ + { + required: true, + message: dict['form.required.input'] + '鍘熷��!' + }, + ] + })(<Input placeholder={''} autoComplete="off" onPressEnter={this.handleSubmit} />)} + </Form.Item> + </Col> + <Col span={24}> + <Form.Item label="鐩爣鍊�"> + {getFieldDecorator('value', { + initialValue: '', + rules: [ + { + required: true, + message: dict['form.required.input'] + '鐩爣鍊�!' + }, + ] + })(<Input placeholder={''} autoComplete="off" onPressEnter={this.handleSubmit} />)} + </Form.Item> + </Col> + </Row> + </Form> + ) + } +} + +export default Form.create()(MainSearch) \ No newline at end of file diff --git a/src/templates/zshare/replaceform/index.scss b/src/templates/zshare/replaceform/index.scss new file mode 100644 index 0000000..04aede0 --- /dev/null +++ b/src/templates/zshare/replaceform/index.scss @@ -0,0 +1,3 @@ +.config-replace-form { + min-height: 150px; +} \ No newline at end of file -- Gitblit v1.8.0