| | |
| | | viewlost: false, // 页面丢失:1、未获取到配置-页面丢失;2、页面未启用 |
| | | lostmsg: '', // 页面丢失时的提示信息 |
| | | config: {}, // 页面配置信息,包括按钮、搜索、显示列、标签等 |
| | | userConfig: null, // 用户自定义设置 |
| | | shortcuts: null, // 快捷键 |
| | | searchlist: null, // 搜索条件 |
| | | actions: null, // 按钮集 |
| | | columns: null, // 显示列 |
| | |
| | | search: '', // 搜索条件数组,使用时需分场景处理 |
| | | BIDs: {}, // 上级表id |
| | | pickup: false, // 主表数据隐藏显示切换 |
| | | tabActive: null, // 标签页展开控制 |
| | | chartId: '', // 展开图表ID |
| | | statFields: [], // 合计字段 |
| | | statFValue: [], // 合计值 |
| | |
| | | |
| | | if (result.status) { |
| | | let config = '' |
| | | let userConfig = null |
| | | let shortcuts = [] |
| | | let _curUserConfig = '' |
| | | |
| | | try { // 配置信息解析 |
| | |
| | | // HS不使用自定义设置 |
| | | if (result.LongParamUser && this.props.menuType !== 'HS') { |
| | | try { // 配置信息解析 |
| | | userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser))) |
| | | let userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser))) |
| | | userConfig = [] |
| | | |
| | | // if (window.GLOB.UserCacheMap.has(_param)) { |
| | | // return Promise.resolve(window.GLOB.UserCacheMap.get(_param)) |
| | | // } else { |
| | | // param = this.encryptParam(param) |
| | | // return new Promise(resolve => { |
| | | // axios({ |
| | | // url: `/webapi/dostars${param.func ? '/' + param.func : ''}`, |
| | | // data: param |
| | | // }).then(res => { |
| | | // if (res.status) { |
| | | // window.GLOB.UserCacheMap.set(_param, res) |
| | | // } |
| | | // resolve(res) |
| | | // }) |
| | | // }) |
| | | // } |
| | | _curUserConfig = userConfig[this.props.MenuID] |
| | | } catch (e) { |
| | | console.warn('Parse Failure') |
| | | userConfig = null |
| | | } |
| | | } |
| | | console.log(config) |
| | | console.log(shortcuts) |
| | | |
| | | // 页面配置解析错误时提示 |
| | | if (!config) { |
| | |
| | | } |
| | | |
| | | if (_curUserConfig) { |
| | | config.easyCode = _curUserConfig.easyCode || config.easyCode || '' |
| | | |
| | | config.action = config.action.map(item => { |
| | | if (_curUserConfig.action[item.uuid]) { |
| | | delete _curUserConfig.action[item.uuid].label |
| | |
| | | return item |
| | | }) |
| | | } |
| | | |
| | | let _tabActive = {} // 筛选展开的tab页 |
| | | |
| | | config.tabgroups.forEach(group => { |
| | | _tabActive[group.uuid] = group.sublist[0].uuid |
| | | }) |
| | | |
| | | let _arrField = [] // 字段集 |
| | | let _columns = [] // 显示列 |
| | |
| | | return _item |
| | | }) |
| | | |
| | | if (_curUserConfig) { |
| | | _columns = _columns.map(item => { |
| | | if (_curUserConfig.columns[item.uuid]) { |
| | | delete _curUserConfig.columns[item.uuid].label |
| | | item = {...item, ..._curUserConfig.columns[item.uuid]} |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | _columns.sort((pre, next) => { |
| | | return pre.sort - next.sort |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | | loadingview: false, |
| | | absFields, |
| | | chartId, |
| | | config, |
| | | statFields, |
| | | userConfig, |
| | | tabActive: _tabActive, |
| | | shortcuts, |
| | | setting: config.setting, |
| | | searchlist: config.search, |
| | | actions: _actions, |
| | |
| | | } |
| | | |
| | | setShortcut = () => { |
| | | const { actions, userConfig, config } = this.state |
| | | if (!userConfig) return |
| | | const { shortcuts } = this.state |
| | | |
| | | if (!shortcuts || shortcuts.length === 0) { |
| | | document.onkeydown = () => {} |
| | | return |
| | | } |
| | | |
| | | document.onkeydown = (event) => { |
| | | let e = event || window.event |
| | |
| | | preKey = 'alt' |
| | | } |
| | | |
| | | if (!preKey) return |
| | | if (!preKey || !keyCode) return |
| | | |
| | | let triggerId = '' |
| | | let _shortcut = preKey + keyCode |
| | | |
| | | actions.some(item => { |
| | | if (Array.isArray(item.shortcut) && preKey === item.shortcut[0] && keyCode === item.shortcut[1]) { |
| | | e.preventDefault() |
| | | triggerId = item.uuid |
| | | shortcuts.some(item => { |
| | | if (item.shortcut === _shortcut) { |
| | | MKEmitter.emit('triggerBtnId', item.uuid) |
| | | |
| | | let element = item.parentId ? document.getElementById(item.parentId) : '' // 标签切换 |
| | | if (element && element.click) { |
| | | element.click() |
| | | } |
| | | |
| | | return true |
| | | } |
| | | return false |
| | | }) |
| | | |
| | | if (triggerId) { |
| | | MKEmitter.emit('triggerBtnId', triggerId) |
| | | return |
| | | } |
| | | |
| | | Object.keys(userConfig).some(key => { |
| | | if (key === this.props.MenuID || !userConfig[key].action) return false |
| | | |
| | | let _actions = userConfig[key].action |
| | | |
| | | Object.keys(_actions).some(btnkey => { |
| | | let item = _actions[btnkey] |
| | | |
| | | if (Array.isArray(item.shortcut) && preKey === item.shortcut[0] && keyCode === item.shortcut[1]) { |
| | | e.preventDefault() |
| | | triggerId = btnkey |
| | | |
| | | let _groupId = '' |
| | | let _ActiveTabId = '' |
| | | config.tabgroups.forEach(group => { |
| | | let _tab = group.sublist.filter(tab => tab.uuid === key)[0] |
| | | |
| | | if (!_tab) return |
| | | |
| | | _groupId = group.uuid |
| | | _ActiveTabId = _tab.uuid |
| | | }) |
| | | |
| | | if (_ActiveTabId && this.state.tabActive[_groupId] === _ActiveTabId) { |
| | | MKEmitter.emit('triggerBtnId', triggerId) |
| | | return true |
| | | } |
| | | } |
| | | return false |
| | | }) |
| | | |
| | | if (triggerId) return true |
| | | return false |
| | | }) |
| | | } |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { menuType, MenuName } = this.props |
| | | const { BID, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, config, userConfig, tabActive, chartId, search, selectedData } = this.state |
| | | const { menuType } = this.props |
| | | const { BID, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, config, chartId, search, selectedData } = this.state |
| | | |
| | | return ( |
| | | <div className="commontable" id={this.state.ContainerId}> |
| | |
| | | /> |
| | | </div> |
| | | <div className="main-table-box"> |
| | | {this.props.menuType !== 'HS' ? <SettingComponent |
| | | config={config} |
| | | columns={columns} |
| | | MenuName={MenuName} |
| | | dict={this.state.dict} |
| | | MenuID={this.props.MenuID} |
| | | permAction={this.props.permAction} |
| | | userConfig={this.state.userConfig} |
| | | reloadview={this.reloadview} |
| | | /> : null} |
| | | {(setting.tableType === 'radio' || setting.tableType === 'checkbox') && this.state.data && this.state.data.length > 0 ? |
| | | <Switch title="收起" className="main-pickup" checkedChildren="开" unCheckedChildren="关" defaultChecked={pickup} onChange={this.pickupChange} /> : null |
| | | } |
| | |
| | | })} |
| | | </Row> : null } |
| | | {setting && config.tabgroups.map(group => ( |
| | | <Tabs key={group.uuid} onChange={(key) => this.setState({tabActive: {...tabActive, [group.uuid]: key}})}> |
| | | <Tabs key={group.uuid}> |
| | | {group.sublist.map(_tab => { |
| | | return ( |
| | | <TabPane tab={ |
| | | <span> |
| | | <span id={_tab.uuid}> |
| | | {_tab.icon ? <Icon type={_tab.icon} /> : null} |
| | | {_tab.label} |
| | | </span> |
| | |
| | | Tab={_tab} |
| | | MenuID={_tab.linkTab} |
| | | mainSearch={_tab.searchPass === 'true' ? search : null} |
| | | userConfig={userConfig ? userConfig[_tab.uuid] : null} |
| | | SupMenuID={this.props.MenuID} |
| | | ContainerId={this.state.ContainerId} |
| | | BID={this.state.BIDs[_tab.supMenu] || ''} |
| | |
| | | </Tabs>)) |
| | | } |
| | | {menuType !== 'HS' ? <PagemsgComponent menu={{MenuName: this.props.MenuName, MenuNo: this.props.MenuNo}} config={config} dict={this.state.dict} /> : null} |
| | | {menuType !== 'HS' ? <SettingComponent config={config} dict={this.state.dict} MenuID={this.props.MenuID} permAction={this.props.permAction}/> : null} |
| | | {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} |
| | | </div> |
| | | ) |