| | |
| | | import enUS from '@/locales/en-US/main.js' |
| | | import Utils from '@/utils/utils.js' |
| | | import UtilsDM from '@/utils/utils-datamanage.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import asyncSpinComponent from '@/utils/asyncSpinComponent' |
| | | import {refreshTabView, modifyTabview} from '@/store/action' |
| | | |
| | | import NotFount from '@/components/404' |
| | | import './index.scss' |
| | | |
| | |
| | | BIDs: {}, // 上级表id |
| | | visible: false, // 弹框显示隐藏控制 |
| | | treevisible: false, // 菜单结构树弹框显示隐藏控制 |
| | | refreshtabs: null, // 需要刷新的标签集 |
| | | confirmLoading: false,// 自定义设置模态框加载中 |
| | | revertLoading: false, // 恢复默认设置 |
| | | settingVisible: false,// 自定义设置模态框 |
| | | triggerBtn: null, // 点击表格中或快捷键触发的按钮 |
| | | tabActive: null, // 标签页展开控制 |
| | | expandedKeys: [], // 展开的树节点 |
| | | selectedKeys: [] // 选中的树节点 |
| | | selectedKeys: [], // 选中的树节点 |
| | | debug: sessionStorage.getItem('debug') === 'true' |
| | | } |
| | | |
| | | /** |
| | |
| | | config.setting.dataresource = '(' + config.setting.dataresource + ') tb' |
| | | } |
| | | |
| | | if (this.props.dataManager) { // 数据权限 |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | config.setting.dataresource = config.setting.dataresource.replace(/\$@/ig, '/*') |
| | | config.setting.dataresource = config.setting.dataresource.replace(/@\$/ig, '*/') |
| | | config.setting.customScript = config.setting.customScript.replace(/\$@/ig, '/*') |
| | |
| | | |
| | | if (!preKey) return |
| | | |
| | | let istrigger = false |
| | | let triggerId = '' |
| | | |
| | | Object.keys(userConfig).forEach(key => { |
| | | if (key === this.props.MenuID || !userConfig[key].action || istrigger) return |
| | | Object.keys(userConfig).some(key => { |
| | | if (key === this.props.MenuID || !userConfig[key].action) return false |
| | | |
| | | let _actions = userConfig[key].action |
| | | |
| | | Object.keys(_actions).forEach(btnkey => { |
| | | Object.keys(_actions).some(btnkey => { |
| | | let item = _actions[btnkey] |
| | | |
| | | if (!item.shortcut || typeof(item.shortcut) !== 'object' || item.shortcut.length === 0 || istrigger) return |
| | | |
| | | if (preKey === item.shortcut[0] && keyCode === item.shortcut[1]) { |
| | | if (Array.isArray(item.shortcut) && preKey === item.shortcut[0] && keyCode === item.shortcut[1]) { |
| | | e.preventDefault() |
| | | istrigger = true |
| | | triggerId = btnkey |
| | | |
| | | let _groupId = '' |
| | | let _ActiveTabId = '' |
| | | config.tabgroups.forEach(group => { |
| | | if (group.sublist.length === 0) return |
| | | |
| | | let _tab = group.sublist.filter(tab => tab.uuid === key)[0] |
| | | if (_tab) { |
| | | _groupId = group.uuid |
| | | _ActiveTabId = _tab.uuid |
| | | } |
| | | |
| | | if (!_tab) return |
| | | |
| | | _groupId = group.uuid |
| | | _ActiveTabId = _tab.uuid |
| | | }) |
| | | |
| | | if (this.state.tabActive[_groupId] === _ActiveTabId) { |
| | | this.setState({ |
| | | triggerBtn: { |
| | | uuid: new Date().getTime(), |
| | | parentId: key, |
| | | button: {...item, uuid: btnkey}, |
| | | data: null |
| | | } |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | | tabActive: {...this.state.tabActive, [_groupId]: _ActiveTabId} |
| | | }, () => { |
| | | this.setState({ |
| | | triggerBtn: { |
| | | uuid: new Date().getTime(), |
| | | parentId: key, |
| | | button: {...item, uuid: btnkey}, |
| | | data: null |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | this.setState({ |
| | | tabActive: {...this.state.tabActive, [_groupId]: _ActiveTabId} |
| | | }, () => { |
| | | MKEmitter.emit('triggerBtnId', triggerId) |
| | | }) |
| | | |
| | | return true |
| | | } |
| | | return false |
| | | }) |
| | | |
| | | if (triggerId) return true |
| | | return false |
| | | }) |
| | | } |
| | | } |
| | |
| | | }) |
| | | |
| | | let arr_field = `${setting.valueField},${setting.labelField},${setting.parentField}` |
| | | let param = UtilsDM.getQueryDataParams(setting, arr_field, [], setting.order, '', '', BID, this.props.menuType, this.props.dataManager) |
| | | let param = UtilsDM.getQueryDataParams(setting, arr_field, [], setting.order, '', '', BID, this.props.menuType) |
| | | |
| | | let result = await Api.genericInterface(param) |
| | | if (result.status) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 子表操作完成后刷新主表 |
| | | */ |
| | | handleMainTable = (type, tab) => { |
| | | if (type === 'maingrid' && (tab.supMenu === 'mainTable' || (!tab.supMenu && tab.level === 0))) { |
| | | this.loadmaindata() |
| | | } else if (type === 'mainline' && (tab.supMenu === 'mainTable' || (!tab.supMenu && tab.level === 0))) { |
| | | this.loadmaindata() |
| | | } else if ((type === 'maingrid' || type === 'mainline') && tab.supMenu) { |
| | | this.setState({ |
| | | refreshtabs: [type, tab.supMenu] |
| | | }, () => { |
| | | this.setState({ |
| | | refreshtabs: null |
| | | }) |
| | | }) |
| | | } else if (type === 'equaltab' && tab.equalTab && tab.equalTab.length > 0) { |
| | | this.setState({ |
| | | refreshtabs: tab.equalTab |
| | | }, () => { |
| | | this.setState({ |
| | | refreshtabs: null |
| | | }) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 表格Id变化 |
| | | */ |
| | | handleTableId = (type, id, data) => { |
| | |
| | | }) |
| | | } |
| | | |
| | | reloadData = (menuId) => { |
| | | const { MenuID } = this.props |
| | | |
| | | if (MenuID !== menuId) return |
| | | |
| | | this.loadmaindata() |
| | | } |
| | | |
| | | reloadMenuView = (menuId) => { |
| | | const { MenuID } = this.props |
| | | |
| | | if (MenuID !== menuId) return |
| | | |
| | | this.reloadview() |
| | | } |
| | | |
| | | resetActiveMenu = (menuId) => { |
| | | const { MenuID } = this.props |
| | | |
| | | if (MenuID !== menuId) return |
| | | |
| | | this.setShortcut() |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | // 组件加载时,获取菜单数据 |
| | | this.loadconfig() |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps(nextProps) { |
| | | if (nextProps.refreshTab && nextProps.refreshTab.MenuID === this.props.MenuID) { |
| | | if (nextProps.refreshTab.position === 'view') { |
| | | this.reloadview() |
| | | } |
| | | this.props.refreshTabView('') |
| | | } else if (!is(fromJS(this.props.tabviews), fromJS(nextProps.tabviews))) { |
| | | let selectTab = nextProps.tabviews.filter(tab => tab.selected)[0] |
| | | if (selectTab && selectTab.MenuID === this.props.MenuID) { |
| | | this.setShortcut() |
| | | } |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('reloadMenuView', this.reloadMenuView) |
| | | MKEmitter.addListener('resetActiveMenu', this.resetActiveMenu) |
| | | } |
| | | |
| | | /** |
| | |
| | | return |
| | | } |
| | | document.onkeydown = () => {} |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) |
| | | MKEmitter.removeListener('resetActiveMenu', this.resetActiveMenu) |
| | | } |
| | | |
| | | changeExpandedKeys = (expandedKeys) => { |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { setting, loadingview, viewlost, config, triggerBtn, userConfig, tabActive, tabgroups, treeNodes, treedata, expandedKeys, selectedKeys } = this.state |
| | | const { menuType } = this.props |
| | | const { debug, setting, loadingview, viewlost, config, userConfig, tabActive, tabgroups, treeNodes, treedata, expandedKeys, selectedKeys } = this.state |
| | | |
| | | return ( |
| | | <div className="tree-page" id={this.state.ContainerId}> |
| | |
| | | MenuID={_tab.linkTab} |
| | | mainSearch={null} |
| | | userConfig={userConfig ? userConfig[_tab.uuid] : null} |
| | | triggerBtn={triggerBtn} |
| | | SupMenuID={this.props.MenuID} |
| | | refreshtabs={this.state.refreshtabs} |
| | | ContainerId={this.state.ContainerId} |
| | | BID={this.state.BIDs[_tab.supMenu] || ''} |
| | | BData={this.state.BIDs[_tab.supMenu + 'data'] || ''} |
| | | handleTableId={this.handleTableId} |
| | | handleMainTable={(type) => this.handleMainTable(type, _tab)} |
| | | /> : null} |
| | | </TabPane> |
| | | ) |
| | |
| | | )} |
| | | </Col> |
| | | </Row> : null} |
| | | |
| | | {options.sysType !== 'cloud' ? <Button |
| | | {debug && options.sysType !== 'cloud' && menuType !== 'HS' ? <Button |
| | | icon="copy" |
| | | shape="circle" |
| | | className="tree-page-copy" |
| | |
| | | MenuID={this.props.MenuID} |
| | | MenuName={this.props.MenuName} |
| | | permAction={this.props.permAction} |
| | | permRoles={this.props.permRoles} |
| | | config={this.state.config} |
| | | userConfig={this.state.userConfig} |
| | | columns={[]} |
| | |
| | | const mapStateToProps = (state) => { |
| | | return { |
| | | menuType: state.editLevel, |
| | | tabviews: state.tabviews, |
| | | refreshTab: state.refreshTab, |
| | | permAction: state.permAction, |
| | | permRoles: state.permRoles, |
| | | memberLevel: state.memberLevel, |
| | | dataManager: state.dataManager |
| | | memberLevel: state.memberLevel |
| | | } |
| | | } |
| | | |
| | | const mapDispatchToProps = (dispatch) => { |
| | | return { |
| | | refreshTabView: (refreshTab) => dispatch(refreshTabView(refreshTab)), |
| | | modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews)) |
| | | } |
| | | const mapDispatchToProps = () => { |
| | | return {} |
| | | } |
| | | |
| | | export default connect(mapStateToProps, mapDispatchToProps)(TreePage) |