import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import {connect} from 'react-redux'
|
import { is, fromJS } from 'immutable'
|
import { notification, Spin, Tabs, Icon, Modal, Button, message, Tree, Typography, Row, Col, Card, Input, Empty } from 'antd'
|
import moment from 'moment'
|
|
import Api from '@/api'
|
import options from '@/store/options.js'
|
import zhCN from '@/locales/zh-CN/main.js'
|
import enUS from '@/locales/en-US/main.js'
|
import Utils from '@/utils/utils.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'
|
|
const VerifyCard = asyncComponent(() => import('@/tabviews/zshare/verifycard'))
|
const SubTable = asyncSpinComponent(() => import('@/tabviews/subtable'))
|
|
const { TabPane } = Tabs
|
const { TreeNode } = Tree
|
const { Search } = Input
|
const { Paragraph } = Typography
|
|
class TreePage extends Component {
|
static propTpyes = {
|
param: PropTypes.string, // 其他页面传递的参数
|
MenuID: PropTypes.string, // 菜单Id
|
MenuNo: PropTypes.string, // 菜单参数
|
MenuName: PropTypes.string // 菜单名称
|
}
|
|
state = {
|
dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
|
ContainerId: Utils.getuuid(), // 菜单外层html Id
|
loadingview: true, // 页面加载中
|
BID: null, // 页面跳转时携带ID
|
viewlost: false, // 页面丢失:1、未获取到配置-页面丢失;2、页面未启用
|
lostmsg: '', // 页面丢失时的提示信息
|
config: {}, // 页面配置信息,包括按钮、搜索、显示列、标签等
|
userConfig: null, // 用户自定义设置
|
userParam: null, // 保存用户编辑中的配置
|
setting: null, // 页面全局设置:数据源、按钮及显示列固定、主键等
|
treedata: null, // 列表数据集
|
treeNodes: null, // 列表数据集
|
loading: false, // 列表数据加载中
|
BIDs: {}, // 上级表id
|
visible: false, // 弹框显示隐藏控制
|
treevisible: false, // 菜单结构树弹框显示隐藏控制
|
refreshtabs: null, // 需要刷新的标签集
|
confirmLoading: false,// 自定义设置模态框加载中
|
revertLoading: false, // 恢复默认设置
|
settingVisible: false,// 自定义设置模态框
|
triggerBtn: null, // 点击表格中或快捷键触发的按钮
|
tabActive: null, // 标签页展开控制
|
expandedKeys: [], // 展开的树节点
|
selectedKeys: [] // 选中的树节点
|
}
|
|
/**
|
* @description 获取页面配置信息
|
*/
|
async loadconfig () {
|
const { permAction, param } = this.props
|
|
let _param = {
|
func: 'sPC_Get_LongParam',
|
MenuID: this.props.MenuID
|
}
|
let result = await Api.getCacheConfig(_param)
|
|
if (result.status) {
|
let config = ''
|
let userConfig = null
|
let _curUserConfig = ''
|
|
try { // 配置信息解析
|
config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
|
} catch (e) {
|
console.warn('Parse Failure')
|
config = ''
|
}
|
|
if (result.LongParamUser) {
|
try { // 配置信息解析
|
userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser)))
|
_curUserConfig = userConfig[this.props.MenuID]
|
} catch (e) {
|
console.warn('Parse Failure')
|
userConfig = null
|
}
|
}
|
|
// 页面配置解析错误时提示
|
if (!config) {
|
this.setState({
|
loadingview: false,
|
viewlost: true
|
})
|
return
|
}
|
|
// 页面未启用时,显示未启用页面
|
if (!config.enabled) {
|
this.setState({
|
loadingview: false,
|
viewlost: true,
|
lostmsg: this.state.dict['main.view.unenabled']
|
})
|
return
|
}
|
|
// 权限过滤
|
config.tabgroups.forEach(group => {
|
group.sublist = group.sublist.filter(tab => {
|
if (tab.supMenu === 'mainTable' || (!tab.supMenu && tab.level === 0)) {
|
tab.isTreeNode = true
|
}
|
return permAction[tab.linkTab]}
|
)
|
})
|
|
if (_curUserConfig) {
|
config.setting = {...config.setting, ..._curUserConfig.setting}
|
config.easyCode = _curUserConfig.easyCode || config.easyCode || ''
|
}
|
|
let _tabActive = {} // 筛选展开的tab页
|
let _tabgroups = []
|
|
config.tabgroups.forEach(group => {
|
let _group = fromJS(group).toJS()
|
_group.sublist = _group.sublist.filter(tab => tab.level === 0)
|
|
if (_group.sublist.length > 0) {
|
_tabActive[_group.uuid] = _group.sublist[0].uuid
|
_tabgroups.push(_group)
|
}
|
})
|
|
this.setState({
|
BID: param && param.BID ? param.BID : '',
|
loadingview: false,
|
config: config,
|
tabActive: _tabActive,
|
userConfig: userConfig,
|
setting: config.setting,
|
tabgroups: _tabgroups
|
}, () => {
|
this.loadmaindata()
|
this.setShortcut()
|
})
|
} else {
|
this.setState({
|
loadingview: false,
|
viewlost: true
|
})
|
notification.warning({
|
top: 92,
|
message: result.message,
|
duration: 5
|
})
|
}
|
}
|
|
setShortcut = () => {
|
const { userConfig, config } = this.state
|
if (!userConfig) return
|
|
document.onkeydown = (event) => {
|
let e = event || window.event
|
let keyCode = e.keyCode || e.which || e.charCode
|
let preKey = ''
|
|
if (e.ctrlKey) {
|
preKey = 'ctrl'
|
} else if (e.shiftKey) {
|
preKey = 'shift'
|
} else if (e.altKey) {
|
preKey = 'alt'
|
}
|
|
if (!preKey) return
|
|
let istrigger = false
|
|
Object.keys(userConfig).forEach(key => {
|
if (key === this.props.MenuID || !userConfig[key].action || istrigger) return
|
|
let _actions = userConfig[key].action
|
|
Object.keys(_actions).forEach(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]) {
|
e.preventDefault()
|
istrigger = true
|
|
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 (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
|
}
|
})
|
})
|
}
|
}
|
})
|
})
|
}
|
}
|
|
/**
|
* @description 主表数据加载
|
*/
|
async loadmaindata () {
|
const { setting, searchKey, BID } = this.state
|
let param = ''
|
|
this.setState({
|
loading: true
|
})
|
|
if (setting.interType !== 'inner' || (setting.interType === 'inner' && setting.innerFunc)) {
|
param = this.getCustomParam()
|
} else {
|
param = this.getDefaultParam()
|
}
|
|
if (BID) {
|
param.BID = BID
|
}
|
|
// 数据管理权限
|
if (this.props.dataManager) {
|
param.dataM = 'Y'
|
}
|
|
let result = await Api.genericInterface(param)
|
if (result.status) {
|
let parentNodes = []
|
let _options = []
|
result.data.forEach(item => {
|
let pval = item[setting.parentField]
|
let val = item[setting.valueField]
|
|
if (!val) return
|
|
if (pval === setting.mark) {
|
parentNodes.push({
|
title: item[setting.labelField] || '',
|
key: val,
|
parentId: '',
|
level: 1
|
})
|
} else if (pval) {
|
_options.push({
|
title: item[setting.labelField] || '',
|
key: val,
|
parentId: pval
|
})
|
}
|
})
|
let _treedata = this.getTree(parentNodes, _options)
|
|
let _treeNodes = []
|
|
if (!searchKey) {
|
_treeNodes = fromJS(_treedata).toJS()
|
} else {
|
_treeNodes = this.getFilterTree(fromJS(_treedata).toJS(), searchKey.toLowerCase())
|
}
|
|
this.setState({
|
treedata: _treedata,
|
treeNodes: _treeNodes,
|
loading: false
|
})
|
} else {
|
this.setState({
|
loading: false,
|
treeNodes: [],
|
treedata: []
|
})
|
notification.error({
|
top: 92,
|
message: result.message,
|
duration: 10
|
})
|
}
|
}
|
|
/**
|
* @description 获取结构树信息
|
*/
|
getTree = (parents, options) => {
|
parents.forEach(parent => {
|
parent.children = []
|
// 添加菜单的子元素
|
options = options.filter(option => {
|
if (option.parentId === parent.key) {
|
option.level = parent.level + 1
|
|
parent.children.push(option)
|
return false
|
}
|
return true
|
})
|
|
if (parent.children.length === 0) {
|
parent.children = null
|
} else {
|
parent.children = this.getTree(parent.children, options)
|
}
|
})
|
return parents
|
}
|
|
/**
|
* @description 获取树节点
|
*/
|
renderTreeNodes = (nodes) => {
|
return nodes.map(item => {
|
if (item.children) {
|
return (
|
<TreeNode icon={<span><Icon type="folder-open" /><Icon type="folder" /></span>} title={item.title} key={item.key} dataRef={item}>
|
{this.renderTreeNodes(item.children)}
|
</TreeNode>
|
)
|
}
|
return <TreeNode icon={<Icon type="file" />} key={item.key} title={item.title} dataRef={item} isLeaf />
|
})
|
}
|
|
treeFilter = (value) => {
|
const { treedata } = this.state
|
|
let _treeNodes = []
|
|
if (!value) {
|
_treeNodes = fromJS(treedata).toJS()
|
} else {
|
_treeNodes = this.getFilterTree(fromJS(treedata).toJS(), value.toLowerCase())
|
}
|
|
this.setState({
|
searchKey: value,
|
treeNodes: _treeNodes
|
})
|
}
|
|
/**
|
* @description 获取结构树信息
|
*/
|
getFilterTree = (parents, searchKey) => {
|
return parents.filter(node => {
|
if (!node.children) {
|
return (node.title.toLowerCase().indexOf(searchKey) >= 0 || node.key.toLowerCase().indexOf(searchKey) >= 0)
|
} else {
|
if (node.title.toLowerCase().indexOf(searchKey) >= 0 || node.key.toLowerCase().indexOf(searchKey) >= 0) {
|
return true
|
}
|
|
node.children = this.getFilterTree(node.children, searchKey)
|
if (node.children.length === 0) {
|
return false
|
} else {
|
return true
|
}
|
}
|
})
|
}
|
|
selectTreeNode = (selectedKeys, {selected, node}) => {
|
const { config } = this.state
|
let _expandedKeys = fromJS(this.state.expandedKeys).toJS()
|
let _data = fromJS(node.props.dataRef).toJS()
|
|
if (_expandedKeys.indexOf(_data.key) >= 0) {
|
_expandedKeys = _expandedKeys.filter(key => key !== _data.key)
|
} else {
|
if (_data.children) {
|
_expandedKeys.push(_data.key)
|
_expandedKeys = Array.from(new Set(_expandedKeys))
|
}
|
}
|
|
if (selected) {
|
let _tabgroups = []
|
let _tabActive = {}
|
|
config.tabgroups.forEach(group => {
|
let _group = fromJS(group).toJS()
|
_group.sublist = _group.sublist.filter(tab => (!tab.level && tab.level !== 0) || tab.level === _data.level)
|
|
if (_group.sublist.length > 0) {
|
_tabActive[_group.uuid] = _group.sublist[0].uuid
|
_tabgroups.push(_group)
|
}
|
})
|
|
delete _data.children
|
this.handleTableId('mainTable', _data.key, _data)
|
this.setState({
|
tabgroups: _tabgroups,
|
tabActive: _tabActive,
|
expandedKeys: _expandedKeys,
|
selectedKeys: [_data.key]
|
})
|
} else {
|
this.setState({
|
expandedKeys: _expandedKeys,
|
selectedKeys: [_data.key]
|
})
|
}
|
}
|
|
/**
|
* @description 获取用户自定义存储过程传参
|
*/
|
getCustomParam = () => {
|
const { setting } = this.state
|
|
let param = {
|
OrderCol: setting.order
|
}
|
|
if (setting.interType === 'inner') {
|
param.func = setting.innerFunc
|
} else {
|
if (this.props.menuType === 'HS') {
|
if (setting.sysInterface === 'true' && options.cloudServiceApi) {
|
param.rduri = options.cloudServiceApi
|
} else if (setting.sysInterface !== 'true') {
|
param.rduri = setting.interface
|
}
|
} else {
|
if (setting.sysInterface === 'true' && window.GLOB.mainSystemApi) {
|
param.rduri = window.GLOB.mainSystemApi
|
} else if (setting.sysInterface !== 'true') {
|
param.rduri = setting.interface
|
}
|
}
|
|
if (setting.outerFunc) {
|
param.func = setting.outerFunc
|
}
|
}
|
|
return param
|
}
|
|
/**
|
* @description 获取系统存储过程 sPC_Get_TableData 的参数
|
*/
|
getDefaultParam = () => {
|
const { setting } = this.state
|
|
let arr_field = `${setting.valueField},${setting.labelField},${setting.parentField}`
|
|
let param = {
|
func: 'sPC_Get_TableData',
|
obj_name: 'data',
|
arr_field: arr_field,
|
custom_script: setting.customScript || '',
|
default_sql: setting.default || 'true'
|
}
|
|
let _dataresource = setting.dataresource
|
|
if (/\s/.test(_dataresource)) {
|
_dataresource = '(' + _dataresource + ') tb'
|
}
|
|
if (this.props.dataManager) { // 数据权限
|
_dataresource = _dataresource.replace(/\$@/ig, '/*')
|
_dataresource = _dataresource.replace(/@\$/ig, '*/')
|
param.custom_script = param.custom_script.replace(/\$@/ig, '/*')
|
param.custom_script = param.custom_script.replace(/@\$/ig, '*/')
|
} else {
|
_dataresource = _dataresource.replace(/@\$|\$@/ig, '')
|
param.custom_script = param.custom_script.replace(/@\$|\$@/ig, '')
|
}
|
|
let LText = ''
|
|
if (setting.default !== 'false') {
|
LText = ` select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${setting.order}) as rows from ${_dataresource}) tmptable order by tmptable.rows `
|
}
|
|
if (param.custom_script) {
|
param.custom_script = param.custom_script.replace(/@orderBy@/ig, setting.order)
|
|
if (LText) {
|
LText += `
|
aaa:
|
if @ErrorCode!=''
|
insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@
|
`
|
} else {
|
param.custom_script += `
|
aaa:
|
if @ErrorCode!=''
|
insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@
|
`
|
}
|
}
|
|
// 测试系统打印查询语句
|
if ((options.sysType === 'local' && !window.GLOB.systemType) || window.debugger === true) {
|
param.custom_script && console.log(`${LText ? '' : '/*不执行默认sql*/\n'}${param.custom_script}`)
|
LText && console.log(LText)
|
}
|
|
param.custom_script = Utils.formatOptions(param.custom_script)
|
param.LText = Utils.formatOptions(LText)
|
param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
|
param.secretkey = Utils.encrypt(param.LText, param.timestamp)
|
param.DateCount = ''
|
|
if (this.props.menuType === 'HS') { // 云端数据验证
|
param.open_key = Utils.encrypt(param.secretkey, param.timestamp, true)
|
}
|
|
return param
|
}
|
|
/**
|
* @description 页面刷新,重新获取配置
|
*/
|
reloadview = () => {
|
this.setState({
|
loadingview: true,
|
viewlost: false,
|
config: {},
|
userConfig: null,
|
setting: null,
|
treedata: null,
|
treeNodes: null,
|
loading: false,
|
BIDs: {},
|
expandedKeys: [],
|
selectedKeys: []
|
}, () => {
|
this.loadconfig()
|
})
|
}
|
|
/**
|
* @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) => {
|
const { BIDs } = this.state
|
|
this.setState({
|
BIDs: {
|
...BIDs,
|
[type]: id,
|
[type + 'data']: data
|
}
|
})
|
}
|
|
handleviewconfig = (e) => {
|
e.stopPropagation()
|
|
const { MenuNo } = this.props
|
const { config } = this.state
|
|
if (config && config.funcs && config.funcs.length > 0) {
|
this.setState({
|
treevisible: true
|
})
|
} else {
|
let oInput = document.createElement('input')
|
oInput.value = MenuNo || ''
|
document.body.appendChild(oInput)
|
oInput.select()
|
document.execCommand('Copy')
|
document.body.removeChild(oInput)
|
message.success(this.state.dict['main.copy.success'])
|
}
|
}
|
|
getTreeNode = (data) => {
|
let _type = {
|
view: '页面',
|
btn: '按钮',
|
tab: '标签'
|
}
|
|
return data.map(item => {
|
let _title = _type[item.subtype]
|
let _others = []
|
|
_others.push(
|
(item.menuNo ? item.menuNo + '(菜单参数)' : ''),
|
(item.tableName ? item.tableName + '(表名) ' : ''),
|
(item.innerFunc ? item.innerFunc + '(内部函数) ' : ''),
|
(item.outerFunc ? item.outerFunc + '(外部函数)' : '')
|
)
|
_others = _others.filter(Boolean)
|
_others = _others.join('、')
|
|
if (item.label) {
|
_title = _title + '(' + item.label + ')'
|
}
|
if (_others) {
|
_title = _title + ': ' + _others
|
}
|
|
if (item.subfuncs && item.subfuncs.length > 0) {
|
return (
|
<TreeNode title={_title} key={item.uuid} dataRef={item} selectable={false}>
|
{this.getTreeNode(item.subfuncs)}
|
</TreeNode>
|
)
|
}
|
return <TreeNode key={item.uuid} title={_title} isLeaf selectable={false} />
|
})
|
}
|
|
controlCustomSetting = () => {
|
this.setState({
|
settingVisible: true,
|
confirmLoading: false,
|
revertLoading: false
|
})
|
}
|
|
changeMenuParam = (param) => {
|
this.setState({userParam: param})
|
}
|
|
settingRevert = () => {
|
let param = {
|
func: 's_TrdMenu_UserParam_del',
|
MenuID: this.props.MenuID
|
}
|
this.setState({
|
revertLoading: true
|
})
|
|
Api.getSystemConfig(param).then(result => {
|
if (!result.status) {
|
this.setState({
|
revertLoading: false
|
})
|
notification.warning({
|
top: 92,
|
message: result.message,
|
duration: 5
|
})
|
return
|
}
|
this.setState({
|
settingVisible: false,
|
revertLoading: false
|
}, () => {
|
window.GLOB.CacheMap = new Map()
|
this.reloadview()
|
})
|
})
|
}
|
|
settingSubmit = () => {
|
const { userParam } = this.state
|
let _LongParam = ''
|
|
try {
|
_LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(userParam)))
|
} catch (e) {
|
notification.warning({
|
top: 92,
|
message: '编译错误',
|
duration: 5
|
})
|
return
|
}
|
|
let easyCode = userParam[this.props.MenuID] ? userParam[this.props.MenuID].easyCode : ''
|
|
let param = {
|
func: 'sPC_TrdMenu_UserParam',
|
MenuID: this.props.MenuID,
|
EasyCode: easyCode || '',
|
LongParam: _LongParam
|
}
|
|
this.setState({
|
confirmLoading: true
|
})
|
|
Api.getSystemConfig(param).then(result => {
|
if (!result.status) {
|
this.setState({
|
confirmLoading: false
|
})
|
notification.warning({
|
top: 92,
|
message: result.message,
|
duration: 5
|
})
|
return
|
}
|
this.setState({
|
settingVisible: false,
|
confirmLoading: false
|
}, () => {
|
window.GLOB.CacheMap = new Map()
|
this.reloadview()
|
})
|
})
|
}
|
|
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))
|
}
|
|
/**
|
* @description 组件销毁,清除state更新,清除快捷键设置
|
*/
|
componentWillUnmount () {
|
this.setState = () => {
|
return
|
}
|
document.onkeydown = () => {}
|
}
|
|
changeExpandedKeys = (expandedKeys) => {
|
this.setState({
|
expandedKeys: expandedKeys
|
})
|
}
|
|
// 右键展开节点下的全部分支
|
changeExpandedAllKeys = ({event, node}) => {
|
const { expandedKeys } = this.state
|
let _node = node.props.dataRef
|
event.stopPropagation()
|
|
let keys = []
|
this.getExpandKeys(_node, keys)
|
|
this.setState({
|
expandedKeys: Array.from(new Set([...keys, ...expandedKeys])),
|
})
|
}
|
|
getExpandKeys = (node, keys) => {
|
if (node.children) {
|
keys.push(node.key)
|
node.children.forEach(_node => {
|
this.getExpandKeys(_node, keys)
|
})
|
}
|
}
|
|
render() {
|
const { setting, loadingview, viewlost, config, triggerBtn, userConfig, tabActive, tabgroups, treeNodes, treedata, expandedKeys, selectedKeys } = this.state
|
|
return (
|
<div className="tree-page" id={this.state.ContainerId}>
|
{loadingview && <Spin size="large" />}
|
{setting ? <Row gutter={16}>
|
<Col span={setting.width}>
|
<Card
|
className="tree-card"
|
title={
|
<span className="tree-title">
|
<span className="title">{setting.title}</span>
|
{setting.searchable !== 'false' ? <Search allowClear onSearch={this.treeFilter} /> : null}
|
</span>
|
}
|
bordered={false}
|
>
|
{treeNodes && treeNodes.length > 0 ? <div className="tree-box">
|
<Tree
|
blockNode
|
onSelect={this.selectTreeNode}
|
expandedKeys={expandedKeys}
|
selectedKeys={selectedKeys}
|
onRightClick={this.changeExpandedAllKeys}
|
onExpand={this.changeExpandedKeys}
|
showIcon={setting.showIcon === 'true'}
|
showLine={setting.showLine === 'true'}
|
>
|
{this.renderTreeNodes(treeNodes)}
|
</Tree>
|
</div> : null}
|
{treeNodes && treeNodes.length === 0 ? <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} /> : null}
|
{!treedata ? <Spin /> : null}
|
</Card>
|
</Col>
|
<Col span={24 - setting.width}>
|
{tabgroups.map(group => (
|
<Tabs activeKey={tabActive[group.uuid]} key={group.uuid} onChange={(key) => this.setState({tabActive: {...tabActive, [group.uuid]: key}})}>
|
{group.sublist.map(_tab => {
|
return (
|
<TabPane tab={
|
<span>
|
{_tab.icon ? <Icon type={_tab.icon} /> : null}
|
{_tab.label}
|
</span>
|
} key={_tab.uuid}>
|
{_tab.type === 'SubTable' ?
|
<SubTable
|
Tab={_tab}
|
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>
|
)
|
})}
|
</Tabs>)
|
)}
|
</Col>
|
</Row> : null}
|
|
{options.sysType !== 'cloud' ? <Button
|
icon="copy"
|
shape="circle"
|
className="tree-page-copy"
|
onClick={this.handleviewconfig}
|
/> : null}
|
<Modal
|
className="menu-tree-modal"
|
title={'菜单结构树'}
|
width={'650px'}
|
maskClosable={false}
|
visible={this.state.treevisible}
|
onCancel={() => this.setState({treevisible: false})}
|
footer={[
|
<Button key="close" onClick={() => this.setState({treevisible: false})}>{this.state.dict['main.close']}</Button>
|
]}
|
destroyOnClose
|
>
|
<div className="menu-header">
|
<span>菜单名称:{this.props.MenuName}</span>
|
<span>菜单参数:{<Paragraph copyable>{this.props.MenuNo}</Paragraph>}</span>
|
</div>
|
{this.state.treevisible ? <Tree defaultExpandAll showLine={true}>
|
{this.getTreeNode(config.funcs)}
|
</Tree> : null}
|
</Modal>
|
{/* 按钮使用系统存储过程时,验证信息模态框 */}
|
<Modal
|
wrapClassName="common-table-custom-modal"
|
title={'自定义设置'}
|
maskClosable={false}
|
width={950}
|
visible={this.state.settingVisible}
|
onCancel={() => { this.setState({ settingVisible: false }) }}
|
footer={[
|
<Button key="revert" type="danger" loading={this.state.revertLoading} onClick={this.settingRevert}>{this.state.dict['main.revert.default']}</Button>,
|
<Button key="cancel" onClick={() => { this.setState({ settingVisible: false }) }}>{this.state.dict['main.cancel']}</Button>,
|
<Button key="confirm" type="primary" loading={this.state.confirmLoading} onClick={this.settingSubmit}>{this.state.dict['main.submit']}</Button>
|
]}
|
destroyOnClose
|
>
|
{this.state.settingVisible ?
|
<VerifyCard
|
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={[]}
|
handleParam={this.changeMenuParam}
|
/> : null
|
}
|
</Modal>
|
{viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
|
</div>
|
)
|
}
|
}
|
|
const mapStateToProps = (state) => {
|
return {
|
menuType: state.editLevel,
|
tabviews: state.tabviews,
|
refreshTab: state.refreshTab,
|
permAction: state.permAction,
|
permMenus: state.permMenus,
|
permRoles: state.permRoles,
|
memberLevel: state.memberLevel,
|
dataManager: state.dataManager
|
}
|
}
|
|
const mapDispatchToProps = (dispatch) => {
|
return {
|
refreshTabView: (refreshTab) => dispatch(refreshTabView(refreshTab)),
|
modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews))
|
}
|
}
|
|
export default connect(mapStateToProps, mapDispatchToProps)(TreePage)
|