From 8d66ff34fae5b048a6b7923cc75d34f13a08be9d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 02 八月 2022 11:42:43 +0800 Subject: [PATCH] Merge branch 'develop' --- src/templates/sharecomponent/settingcomponent/index.jsx | 64 +++++++++++++++++++++---------- 1 files changed, 43 insertions(+), 21 deletions(-) diff --git a/src/templates/sharecomponent/settingcomponent/index.jsx b/src/templates/sharecomponent/settingcomponent/index.jsx index dfd1ac0..ca098d1 100644 --- a/src/templates/sharecomponent/settingcomponent/index.jsx +++ b/src/templates/sharecomponent/settingcomponent/index.jsx @@ -1,12 +1,13 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Icon, Modal, Button } from 'antd' +import { Modal, Button } from 'antd' +import { SettingOutlined } from '@ant-design/icons' import Utils, { FuncUtils } from '@/utils/utils.js' import zhCN from '@/locales/zh-CN/model.js' import enUS from '@/locales/en-US/model.js' - +import MKEmitter from '@/utils/events.js' import SettingForm from './settingform' import CreateFunc from '@/templates/zshare/createfunc' import CreateInterface from '@/templates/zshare/createinterface' @@ -27,7 +28,9 @@ search: null, // 鎼滅储鏉′欢锛屽寘鎷富琛ㄦ悳绱� formlist: null, // 琛ㄥ崟淇℃伅 visible: false, // 妯℃�佹鎺у埗 - loading: false // 璁剧疆淇℃伅楠岃瘉淇濆瓨涓� + loading: false, // 璁剧疆淇℃伅楠岃瘉淇濆瓨涓� + record: null + } /** @@ -48,6 +51,8 @@ search: _search, menu: menu }) + + MKEmitter.emit('modalStatus', '鏁版嵁婧�') } /** @@ -60,7 +65,7 @@ loading: true }) this.settingRef.handleConfirm().then(setting => { - let res = this.resetSetting(setting) + let res = this.resetSetting(setting, config.setting) this.setState({ visible: false, loading: false @@ -69,6 +74,8 @@ res.columnfixed = res.columnfixed === 'true' this.props.updatesetting({...config, setting: res}) + + MKEmitter.emit('modalStatus', false) }, () => { this.setState({ loading: false @@ -83,17 +90,13 @@ const { config } = this.props const { menu } = this.state - this.settingRef.handleConfirm('func').then(setting => { - let res = this.resetSetting(setting) + this.settingRef.handleConfirm('loading').then(setting => { + let res = this.resetSetting(setting, config.setting) let _config = {...config, setting: res} let newLText = Utils.formatOptions(FuncUtils.getTableFunc(setting, menu, _config)) // 鍒涘缓瀛樺偍杩囩▼sql let DelText = Utils.formatOptions(FuncUtils.dropfunc(setting.innerFunc)) // 鍒犻櫎瀛樺偍杩囩▼sql - this.refs.funcCreatComponent.exec(setting.innerFunc, newLText, DelText).then(result => { - if (result === 'success') { - this.props.updatesetting(_config) - } - }) + this.refs.funcCreatComponent.exec(setting.innerFunc, newLText, DelText) }) } @@ -104,8 +107,8 @@ const { config } = this.props const { menu } = this.state - this.settingRef.handleConfirm('interface').then(setting => { - let res = this.resetSetting(setting) + this.settingRef.handleConfirm('loading').then(setting => { + let res = this.resetSetting(setting, config.setting) let _config = {...config, setting: res} let _menu = { type: config.Template === 'CommonTable' ? 'main' : 'subtable', @@ -118,14 +121,30 @@ }) } - resetSetting = (s) => { + resetSetting = (s, ori) => { let setting = fromJS(s).toJS() + let maxScript = 0 + + setting.show = ori.show || 'true' + setting.advanceType = ori.advanceType || 'modal' + setting.advanceWidth = ori.advanceWidth || 1000 + setting.drawerPlacement = ori.drawerPlacement || 'right' + setting.searchRatio = ori.searchRatio || 6 + setting.searchLwidth = ori.searchLwidth !== undefined ? ori.searchLwidth : 33.3 if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { window.GLOB.funcs.forEach(m => { let reg = new RegExp('\\$ex@' + m.func_code + '@ex\\$', 'ig') setting.scripts.forEach(item => { item.sql = item.sql.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`) + + if (item.status === 'false') return + + if (/exec\s/ig.test(item.sql)) { + maxScript = 1000 + } else if (item.sql.length > maxScript) { + maxScript = item.sql.length + } }) setting.preScripts.forEach(item => { item.sql = item.sql.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`) @@ -138,6 +157,8 @@ } }) } + + setting.maxScript = maxScript return setting } @@ -157,23 +178,23 @@ render() { const { config } = this.props - const { dict, visible, search, menu } = this.state + const { dict, visible, search, menu, record } = this.state return ( <div className="model-menu-setting"> - <Icon type="setting" onClick={this.changeSetting} /> + <SettingOutlined onClick={this.changeSetting} /> {/* 璁剧疆鍏ㄥ眬閰嶇疆鍙婂垪琛ㄦ暟鎹簮 */} <Modal wrapClassName="model-table-setting-verify-modal" - title={dict['model.edit']} + title="鏁版嵁婧愰厤缃�" visible={visible} width={900} maskClosable={false} - onCancel={() => { this.setState({ visible: false, loading: false })}} + onCancel={() => { MKEmitter.emit('modalStatus', false); this.setState({ visible: false, loading: false })}} footer={[ - <CreateInterface key="interface" loading={this.state.interloading} 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, loading: false }) }}>{this.state.dict['model.cancel']}</Button>, + record && record.interType === 'system' ? <CreateInterface key="interface" loading={this.state.interloading} dict={dict} ref="tableCreatInterface" trigger={this.tableCreatInterface}/> : null, + record && record.interType === 'inner' ? <CreateFunc key="create" dict={dict} ref="funcCreatComponent" trigger={this.tableCreatFunc}/> : null, + <Button key="cancel" onClick={() => { MKEmitter.emit('modalStatus', false); this.setState({ visible: false, loading: 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> ]} destroyOnClose @@ -183,6 +204,7 @@ menu={menu} config={config} search={search} + updRecord={(record) => this.setState({record: fromJS(record).toJS()})} wrappedComponentRef={(inst) => this.settingRef = inst} /> </Modal> -- Gitblit v1.8.0