| | |
| | | import { is, fromJS } from 'immutable' |
| | | import { DndProvider } from 'react-dnd' |
| | | import HTML5Backend from 'react-dnd-html5-backend' |
| | | import { Button, Card, Modal, Collapse, notification, Spin, Switch, Tooltip, Row, Col, Tree } from 'antd' |
| | | import { Button, Card, Collapse, notification, Spin, Tooltip, Row, Col, Tree } from 'antd' |
| | | import { QuestionCircleOutlined, RedoOutlined, SearchOutlined, FileOutlined, FolderOpenOutlined } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | |
| | | import './index.scss' |
| | | |
| | | const { Panel } = Collapse |
| | | const { confirm } = Modal |
| | | // const { confirm } = Modal |
| | | const { TreeNode } = Tree |
| | | |
| | | const UpdateTable = asyncComponent(() => import('./updatetable')) |
| | |
| | | /** |
| | | * @description 三级菜单保存 |
| | | */ |
| | | submitConfig = () => { |
| | | const { menu } = this.props |
| | | const { delTabs, openEdition } = this.state |
| | | // submitConfig = () => { |
| | | // const { menu } = this.props |
| | | // const { delTabs, openEdition } = this.state |
| | | |
| | | let _config = fromJS(this.state.config).toJS() |
| | | // let _config = fromJS(this.state.config).toJS() |
| | | |
| | | // 基本信息验证 |
| | | if (!_config.fstMenuId || !_config.ParentId || !_config.MenuName || !_config.MenuNo) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请完善菜单基本信息!', |
| | | duration: 5 |
| | | }) |
| | | this.setState({activeKey: '0'}) |
| | | return |
| | | } |
| | | // // 基本信息验证 |
| | | // if (!_config.fstMenuId || !_config.ParentId || !_config.MenuName || !_config.MenuNo) { |
| | | // notification.warning({ |
| | | // top: 92, |
| | | // message: '请完善菜单基本信息!', |
| | | // duration: 5 |
| | | // }) |
| | | // this.setState({activeKey: '0'}) |
| | | // return |
| | | // } |
| | | |
| | | // 新建验证 |
| | | if (_config.isAdd) { |
| | | _config.tabgroups[0].sublist = _config.tabgroups[0].sublist.filter(item => !item.origin) |
| | | } |
| | | // // 新建验证 |
| | | // if (_config.isAdd) { |
| | | // _config.tabgroups[0].sublist = _config.tabgroups[0].sublist.filter(item => !item.origin) |
| | | // } |
| | | |
| | | // 使用已有菜单时,默认添加关联标签id |
| | | if (_config.type === 'user') { |
| | | _config.tabgroups.forEach(group => { |
| | | group.sublist = group.sublist.map(tab => { |
| | | if (!tab.linkTab) { |
| | | tab.linkTab = Utils.getuuid() |
| | | } |
| | | return tab |
| | | }) |
| | | }) |
| | | } |
| | | // // 使用已有菜单时,默认添加关联标签id |
| | | // if (_config.type === 'user') { |
| | | // _config.tabgroups.forEach(group => { |
| | | // group.sublist = group.sublist.map(tab => { |
| | | // if (!tab.linkTab) { |
| | | // tab.linkTab = Utils.getuuid() |
| | | // } |
| | | // return tab |
| | | // }) |
| | | // }) |
| | | // } |
| | | |
| | | // 未设置数据源或标签不合法时,启用状态为false |
| | | let vresult = this.verifyconfig(_config) |
| | | if (vresult !== true) { |
| | | _config.enabled = false |
| | | } |
| | | // // 未设置数据源或标签不合法时,启用状态为false |
| | | // let vresult = this.verifyconfig(_config) |
| | | // if (vresult !== true) { |
| | | // _config.enabled = false |
| | | // } |
| | | |
| | | if (this.state.closeVisible) { // 显示关闭对话框时,模态框中保存按钮,显示保存中状态 |
| | | this.setState({ |
| | | menucloseloading: true |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | | menuloading: true |
| | | }) |
| | | } |
| | | // if (this.state.closeVisible) { // 显示关闭对话框时,模态框中保存按钮,显示保存中状态 |
| | | // this.setState({ |
| | | // menucloseloading: true |
| | | // }) |
| | | // } else { |
| | | // this.setState({ |
| | | // menuloading: true |
| | | // }) |
| | | // } |
| | | |
| | | // 保存时删除配置类型,system 、user |
| | | delete _config.type |
| | | delete _config.isAdd |
| | | // // 保存时删除配置类型,system 、user |
| | | // delete _config.type |
| | | // delete _config.isAdd |
| | | |
| | | let _LongParam = '' |
| | | // let _LongParam = '' |
| | | |
| | | try { |
| | | _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config))) |
| | | } catch (e) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '编译错误', |
| | | duration: 5 |
| | | }) |
| | | this.setState({ |
| | | menucloseloading: false, |
| | | menuloading: false |
| | | }) |
| | | return |
| | | } |
| | | // try { |
| | | // _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config))) |
| | | // } catch (e) { |
| | | // notification.warning({ |
| | | // top: 92, |
| | | // message: '编译错误', |
| | | // duration: 5 |
| | | // }) |
| | | // this.setState({ |
| | | // menucloseloading: false, |
| | | // menuloading: false |
| | | // }) |
| | | // return |
| | | // } |
| | | |
| | | // let _sort = 0 |
| | | // let btntabs = [] |
| | | // // let _sort = 0 |
| | | // // let btntabs = [] |
| | | |
| | | // let tabParam = { // 添加菜单tab页 |
| | | // func: 'sPC_sMenusTab_AddUpt', |
| | | // MenuID: menu.MenuID |
| | | // } |
| | | // // let tabParam = { // 添加菜单tab页 |
| | | // // func: 'sPC_sMenusTab_AddUpt', |
| | | // // MenuID: menu.MenuID |
| | | // // } |
| | | |
| | | // let _LText = [] |
| | | // // let _LText = [] |
| | | |
| | | // btntabs.forEach(item => { |
| | | // _LText.push(`select '${item.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${item.sort * 10}' as Sort`) |
| | | // }) |
| | | // _config.tabgroups.forEach(group => { |
| | | // group.sublist.forEach(item => { |
| | | // _sort++ |
| | | // _LText.push(`select '${menu.MenuID}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${_sort * 10}' as Sort`) |
| | | // }) |
| | | // }) |
| | | // // btntabs.forEach(item => { |
| | | // // _LText.push(`select '${item.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${item.sort * 10}' as Sort`) |
| | | // // }) |
| | | // // _config.tabgroups.forEach(group => { |
| | | // // group.sublist.forEach(item => { |
| | | // // _sort++ |
| | | // // _LText.push(`select '${menu.MenuID}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${_sort * 10}' as Sort`) |
| | | // // }) |
| | | // // }) |
| | | |
| | | // _LText = _LText.join(' union all ') |
| | | // // _LText = _LText.join(' union all ') |
| | | |
| | | // tabParam.LText = Utils.formatOptions(_LText) |
| | | // tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | // tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp) |
| | | // // tabParam.LText = Utils.formatOptions(_LText) |
| | | // // tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | // // tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp) |
| | | |
| | | let _funcs = [] |
| | | let _tables = [] |
| | | // let _funcs = [] |
| | | // let _tables = [] |
| | | |
| | | if (_config.setting.tableName) { |
| | | _tables.push(_config.setting.tableName) |
| | | } |
| | | if (_config.setting.innerFunc) { |
| | | _funcs.push({func: _config.setting.innerFunc, label: _config.MenuName || ''}) |
| | | } |
| | | if (_config.setting.outerFunc) { |
| | | _funcs.push({func: _config.setting.outerFunc, label: _config.MenuName || ''}) |
| | | } |
| | | // if (_config.setting.tableName) { |
| | | // _tables.push(_config.setting.tableName) |
| | | // } |
| | | // if (_config.setting.innerFunc) { |
| | | // _funcs.push({func: _config.setting.innerFunc, label: _config.MenuName || ''}) |
| | | // } |
| | | // if (_config.setting.outerFunc) { |
| | | // _funcs.push({func: _config.setting.outerFunc, label: _config.MenuName || ''}) |
| | | // } |
| | | |
| | | let param = { |
| | | func: 'sPC_TrdMenu_AddUpt', |
| | | FstID: _config.fstMenuId, |
| | | SndID: _config.ParentId, |
| | | ParentID: _config.ParentId, |
| | | MenuID: menu.MenuID, |
| | | MenuNo: _config.MenuNo, |
| | | EasyCode: _config.easyCode, |
| | | Template: _config.Template, |
| | | MenuName: _config.MenuName, |
| | | PageParam: JSON.stringify({...menu.PageParam, Template: _config.Template, OpenType: _config.OpenType}), |
| | | LongParam: _LongParam, |
| | | LText: _funcs.map(item => `select '${menu.MenuID}' as MenuID,'${item.func}' as ProcName,'${item.label}' as MenuName`), |
| | | LTexttb: _tables.map(item => `select '${menu.MenuID}' as MenuID,'${item}' as tbName`) |
| | | } |
| | | // let param = { |
| | | // func: 'sPC_TrdMenu_AddUpt', |
| | | // FstID: _config.fstMenuId, |
| | | // SndID: _config.ParentId, |
| | | // ParentID: _config.ParentId, |
| | | // MenuID: menu.MenuID, |
| | | // MenuNo: _config.MenuNo, |
| | | // EasyCode: _config.easyCode, |
| | | // Template: _config.Template, |
| | | // MenuName: _config.MenuName, |
| | | // PageParam: JSON.stringify({...menu.PageParam, Template: _config.Template, OpenType: _config.OpenType}), |
| | | // LongParam: _LongParam, |
| | | // LText: _funcs.map(item => `select '${menu.MenuID}' as MenuID,'${item.func}' as ProcName,'${item.label}' as MenuName`), |
| | | // LTexttb: _tables.map(item => `select '${menu.MenuID}' as MenuID,'${item}' as tbName`) |
| | | // } |
| | | |
| | | if (menu.menuSort) { // 菜单新建时设置排序 |
| | | param.Sort = menu.menuSort |
| | | } |
| | | // if (menu.menuSort) { // 菜单新建时设置排序 |
| | | // param.Sort = menu.menuSort |
| | | // } |
| | | |
| | | param.LText = param.LText.join(' union all ') |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | param.LTexttb = param.LTexttb.join(' union all ') |
| | | param.LTexttb = Utils.formatOptions(param.LTexttb) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | // param.LText = param.LText.join(' union all ') |
| | | // param.LText = Utils.formatOptions(param.LText) |
| | | // param.LTexttb = param.LTexttb.join(' union all ') |
| | | // param.LTexttb = Utils.formatOptions(param.LTexttb) |
| | | // param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | // param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | |
| | | if (openEdition) { // 版本管理 |
| | | param.open_edition = openEdition |
| | | } |
| | | // if (openEdition) { // 版本管理 |
| | | // param.open_edition = openEdition |
| | | // } |
| | | |
| | | // 有按钮或标签删除时,先进行删除操作 |
| | | // 删除成功后,保存页面配置 |
| | | new Promise(resolve => { |
| | | if (delTabs.length > 0) { |
| | | let deffers = delTabs.map(item => { |
| | | let _param = { |
| | | func: 'sPC_MainMenu_Del', |
| | | MenuID: item.uuid |
| | | } |
| | | // // 有按钮或标签删除时,先进行删除操作 |
| | | // // 删除成功后,保存页面配置 |
| | | // new Promise(resolve => { |
| | | // if (delTabs.length > 0) { |
| | | // let deffers = delTabs.map(item => { |
| | | // let _param = { |
| | | // func: 'sPC_MainMenu_Del', |
| | | // MenuID: item.uuid |
| | | // } |
| | | |
| | | return new Promise(resolve => { |
| | | Api.getCloudConfig(_param).then(response => { |
| | | resolve(response) |
| | | }) |
| | | }) |
| | | }) |
| | | Promise.all(deffers).then(result => { |
| | | let error = null |
| | | result.forEach(response => { |
| | | if (!response.status) { |
| | | error = response |
| | | } |
| | | }) |
| | | // return new Promise(resolve => { |
| | | // Api.getCloudConfig(_param).then(response => { |
| | | // resolve(response) |
| | | // }) |
| | | // }) |
| | | // }) |
| | | // Promise.all(deffers).then(result => { |
| | | // let error = null |
| | | // result.forEach(response => { |
| | | // if (!response.status) { |
| | | // error = response |
| | | // } |
| | | // }) |
| | | |
| | | if (error) { |
| | | this.setState({ |
| | | menuloading: false, |
| | | menucloseloading: false |
| | | }) |
| | | notification.warning({ |
| | | top: 92, |
| | | message: error.message, |
| | | duration: 5 |
| | | }) |
| | | resolve(false) |
| | | } else { |
| | | this.setState({ |
| | | delTabs: [] |
| | | }) |
| | | resolve(true) |
| | | } |
| | | }) |
| | | } else if (delTabs.length === 0) { |
| | | resolve(true) |
| | | } |
| | | }).then(resp => { |
| | | if (resp === false) return |
| | | // if (error) { |
| | | // this.setState({ |
| | | // menuloading: false, |
| | | // menucloseloading: false |
| | | // }) |
| | | // notification.warning({ |
| | | // top: 92, |
| | | // message: error.message, |
| | | // duration: 5 |
| | | // }) |
| | | // resolve(false) |
| | | // } else { |
| | | // this.setState({ |
| | | // delTabs: [] |
| | | // }) |
| | | // resolve(true) |
| | | // } |
| | | // }) |
| | | // } else if (delTabs.length === 0) { |
| | | // resolve(true) |
| | | // } |
| | | // }).then(resp => { |
| | | // if (resp === false) return |
| | | |
| | | Api.getCloudConfig(param).then(response => { |
| | | if (response.status) { |
| | | this.setState({ |
| | | config: _config, |
| | | openEdition: response.open_edition || '', |
| | | originMenu: fromJS(_config).toJS(), |
| | | menuloading: false, |
| | | menucloseloading: false |
| | | }) |
| | | // Api.getCloudConfig(param).then(response => { |
| | | // if (response.status) { |
| | | // this.setState({ |
| | | // config: _config, |
| | | // openEdition: response.open_edition || '', |
| | | // originMenu: fromJS(_config).toJS(), |
| | | // menuloading: false, |
| | | // menucloseloading: false |
| | | // }) |
| | | |
| | | notification.success({ |
| | | top: 92, |
| | | message: '保存成功', |
| | | duration: 2 |
| | | }) |
| | | // notification.success({ |
| | | // top: 92, |
| | | // message: '保存成功', |
| | | // duration: 2 |
| | | // }) |
| | | |
| | | this.props.reloadmenu() |
| | | // this.props.reloadmenu() |
| | | |
| | | if (this.state.closeVisible) { |
| | | this.props.handleView() |
| | | } |
| | | } else { |
| | | this.setState({ |
| | | menuloading: false, |
| | | menucloseloading: false |
| | | }) |
| | | notification.warning({ |
| | | top: 92, |
| | | message: response.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | // if (this.state.closeVisible) { |
| | | // this.props.handleView() |
| | | // } |
| | | // } else { |
| | | // this.setState({ |
| | | // menuloading: false, |
| | | // menucloseloading: false |
| | | // }) |
| | | // notification.warning({ |
| | | // top: 92, |
| | | // message: response.message, |
| | | // duration: 5 |
| | | // }) |
| | | // } |
| | | // }) |
| | | // }) |
| | | // } |
| | | |
| | | /** |
| | | * @description 点击返回时,判断配置保存状态 |
| | | */ |
| | | cancelConfig = () => { |
| | | const { config, originMenu } = this.state |
| | | let _this = this |
| | | // const { config, originMenu } = this.state |
| | | // let _this = this |
| | | |
| | | if (config.isAdd) { |
| | | confirm({ |
| | | content: '菜单尚未提交,确定放弃保存吗?', |
| | | onOk() { |
| | | _this.props.handleView() |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | } else { |
| | | if (!is(fromJS(originMenu), fromJS(config))) { |
| | | this.setState({ |
| | | closeVisible: true |
| | | }) |
| | | } else { |
| | | this.props.handleView() |
| | | } |
| | | } |
| | | // if (config.isAdd) { |
| | | // confirm({ |
| | | // content: '菜单尚未提交,确定放弃保存吗?', |
| | | // onOk() { |
| | | // _this.props.handleView() |
| | | // }, |
| | | // onCancel() {} |
| | | // }) |
| | | // } else { |
| | | // if (!is(fromJS(originMenu), fromJS(config))) { |
| | | // this.setState({ |
| | | // closeVisible: true |
| | | // }) |
| | | // } else { |
| | | // this.props.handleView() |
| | | // } |
| | | // } |
| | | this.props.handleView() |
| | | } |
| | | |
| | | /** |
| | |
| | | } bordered={false} extra={ |
| | | <div> |
| | | <UpdateTable config={config}/> |
| | | <Switch className="big" checkedChildren="启" unCheckedChildren="停" checked={this.state.config.enabled} onChange={this.onEnabledChange} /> |
| | | <Button type="primary" id="save-config" onClick={this.submitConfig} loading={this.state.menuloading}>保存</Button> |
| | | {/* <Switch className="big" checkedChildren="启" unCheckedChildren="停" checked={this.state.config.enabled} onChange={this.onEnabledChange} /> */} |
| | | {/* <Button type="primary" id="save-config" onClick={this.submitConfig} loading={this.state.menuloading}>保存</Button> */} |
| | | <Button onClick={this.cancelConfig}>关闭</Button> |
| | | </div> |
| | | } style={{ width: '100%' }}> |
| | |
| | | </div> |
| | | </DndProvider> |
| | | {/* 返回时未保存提示 */} |
| | | <Modal |
| | | {/* <Modal |
| | | bodyStyle={{textAlign: 'center', color: '#000000', fontSize: '16px'}} |
| | | closable={false} |
| | | maskClosable={false} |
| | |
| | | destroyOnClose |
| | | > |
| | | 配置已修改,是否保存配置信息? |
| | | </Modal> |
| | | </Modal> */} |
| | | {this.state.loading && <Spin size="large" />} |
| | | </div> |
| | | ) |