From e8edfdadb561cd83bf6e1c3e00d55b8cc2aee6d5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 17 十月 2022 17:57:34 +0800 Subject: [PATCH] 2022-10-17 --- src/templates/sharecomponent/treesettingcomponent/index.jsx | 134 ++++++++++++-------------------------------- 1 files changed, 36 insertions(+), 98 deletions(-) diff --git a/src/templates/sharecomponent/treesettingcomponent/index.jsx b/src/templates/sharecomponent/treesettingcomponent/index.jsx index 13283e1..867f295 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 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 { Modal } from 'antd' +import { SettingOutlined } from '@ant-design/icons' import SettingForm from './settingform' -import CreateFunc from '@/templates/zshare/createfunc' -import CreateInterface from '@/templates/zshare/createinterface' +import MKEmitter from '@/utils/events.js' import './index.scss' @@ -19,15 +12,11 @@ static propTpyes = { MenuID: PropTypes.string, // 鑿滃崟ID config: PropTypes.object, // 鑿滃崟閰嶇疆淇℃伅 - permFuncField: PropTypes.array, // 瀛樺偍杩囩▼鍙敤寮�澶村瓧娈� - menuformRef: PropTypes.any, // 鑿滃崟鍩烘湰淇℃伅琛ㄥ崟 updatesetting: PropTypes.func } state = { - dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, menu: null, // 鑿滃崟淇℃伅 - formlist: null, // 琛ㄥ崟淇℃伅 visible: false, // 妯℃�佹鎺у埗 loading: false // 璁剧疆淇℃伅楠岃瘉淇濆瓨涓� } @@ -36,21 +25,14 @@ * @description 鍏ㄥ眬璁剧疆瑙﹀彂 */ changeSetting = () => { - const { menuformRef, MenuID, config, permFuncField } = this.props - let menu = {MenuID: MenuID} - - if (menuformRef) { - menu = {MenuID: MenuID, MenuName: menuformRef.props.form.getFieldValue('MenuName') || '', MenuNo: menuformRef.props.form.getFieldValue('MenuNo') || ''} - } - - let _config = fromJS(config).toJS() + const { MenuID, config } = this.props + let menu = {MenuID: MenuID, MenuName: config.MenuName, MenuNo: config.MenuNo} this.setState({ visible: true, - formlist: getTreeSettingForm(config.setting, permFuncField, MenuID), - menu: menu, - config: _config + menu: menu }) + MKEmitter.emit('modalStatus', '鏁版嵁婧�') } /** @@ -63,74 +45,36 @@ loading: true }) this.settingRef.handleConfirm().then(res => { + if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { + window.GLOB.funcs.forEach(m => { + let reg = new RegExp('\\$ex@' + m.func_code + '@ex\\$', 'ig') + res.scripts.forEach(item => { + item.sql = item.sql.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`) + }) + if (res.dataresource) { + res.dataresource = res.dataresource.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`) + } + }) + } this.setState({ visible: false, loading: false }) + + res.show = config.setting.show || 'true' + res.advanceType = config.setting.advanceType || 'modal' + res.advanceWidth = config.setting.advanceWidth || 1000 + res.drawerPlacement = config.setting.drawerPlacement || 'right' + res.searchRatio = config.setting.searchRatio || 6 + res.searchLwidth = config.setting.searchLwidth !== undefined ? config.setting.searchLwidth : 33.3 + this.props.updatesetting({...config, setting: res}) + + MKEmitter.emit('modalStatus', false) }, () => { 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) }) } @@ -144,33 +88,27 @@ } render() { - const { dict, visible, config } = this.state + const { config } = this.props + const { visible, loading } = this.state return ( <div className="model-tree-menu-setting"> - <Icon type="setting" onClick={this.changeSetting} /> + <SettingOutlined onClick={this.changeSetting} /> {/* 璁剧疆鍏ㄥ眬閰嶇疆鍙婂垪琛ㄦ暟鎹簮 */} <Modal - wrapClassName="model-tree-setting-verify-modal" - title={dict['model.edit']} + wrapClassName="mk-pop-modal" visible={visible} - width={900} + width={'75vw'} 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> - ]} + onCancel={() => { MKEmitter.emit('modalStatus', false); this.setState({ visible: false })}} + confirmLoading={loading} + onOk={this.settingSave} destroyOnClose > <SettingForm - dict={dict} config={config} menu={this.state.menu} inputSubmit={this.settingSave} - formlist={this.state.formlist} wrappedComponentRef={(inst) => this.settingRef = inst} /> </Modal> -- Gitblit v1.8.0