| | |
| | | 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' |
| | | |
| | |
| | | state = { |
| | | dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | menu: null, // 菜单信息 |
| | | formlist: null, // 表单信息 |
| | | visible: false, // 模态框控制 |
| | | loading: false // 设置信息验证保存中 |
| | | } |
| | |
| | | * @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 |
| | | }) |
| | | } |
| | | |
| | |
| | | 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) |
| | | }) |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { dict, visible, config } = this.state |
| | | const { config } = this.props |
| | | const { dict, visible, loading } = this.state |
| | | |
| | | return ( |
| | | <div className="model-tree-menu-setting"> |
| | |
| | | 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 |
| | |
| | | config={config} |
| | | menu={this.state.menu} |
| | | inputSubmit={this.settingSave} |
| | | formlist={this.state.formlist} |
| | | permFuncField={this.props.permFuncField} |
| | | wrappedComponentRef={(inst) => this.settingRef = inst} |
| | | /> |
| | | </Modal> |