From 6def3330d1d1cf4036916ed04c8bbc4128e1e5d0 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 03 五月 2020 19:42:17 +0800 Subject: [PATCH] 2020-05-03 --- src/tabviews/commontable/index.jsx | 716 ++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 586 insertions(+), 130 deletions(-) diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx index 44b4dc8..b80a1da 100644 --- a/src/tabviews/commontable/index.jsx +++ b/src/tabviews/commontable/index.jsx @@ -2,32 +2,37 @@ import PropTypes from 'prop-types' import {connect} from 'react-redux' import { is, fromJS } from 'immutable' -import { notification, Spin, Tabs, Icon, Switch, Modal, Button} from 'antd' +import { notification, Spin, Tabs, Icon, Switch, Modal, Button, message, Tree, Typography } from 'antd' import moment from 'moment' import Api from '@/api' 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/asyncLoadComponent' +import asyncLoadComponent from '@/utils/asyncLoadComponent' import {refreshTabView, modifyTabview} from '@/store/action' -import MainTable from './mainTable' -import MainAction from '@/tabviews/tableshare/actionList' -import MainSearch from '@/tabviews/tableshare/topSearch' -import SubTable from '@/tabviews/subtable' +import MainTable from '@/tabviews/zshare/normalTable' +import MainSearch from '@/tabviews/zshare/topSearch' import NotFount from '@/components/404' import './index.scss' -const SubTabTable = asyncComponent(() => import('@/tabviews/subtabtable')) -const FormTab = asyncComponent(() => import('@/tabviews/formtab')) +const VerifyCard = asyncLoadComponent(() => import('@/tabviews/zshare/verifycard')) +const MainAction = asyncLoadComponent(() => import('@/tabviews/zshare/actionList')) +const SubTable = asyncLoadComponent(() => import('@/tabviews/subtable')) +const SubTabTable = asyncLoadComponent(() => import('@/tabviews/subtabtable')) +const FormTab = asyncLoadComponent(() => import('@/tabviews/formtab')) + const { TabPane } = Tabs +const { TreeNode } = Tree +const { Paragraph } = Typography class NormalTable extends Component { static propTpyes = { + param: PropTypes.any, // 鍏朵粬椤甸潰浼犻�掔殑鎼滅储鏉′欢绛夊弬鏁� + MenuID: PropTypes.string, // 鑿滃崟Id MenuNo: PropTypes.string, // 鑿滃崟鍙傛暟 - MenuName: PropTypes.string, // 鑿滃崟鍙傛暟 - MenuID: PropTypes.string // 鑿滃崟Id + MenuName: PropTypes.string // 鑿滃崟鍚嶇О } state = { @@ -38,6 +43,8 @@ viewlost: false, // 椤甸潰涓㈠け锛�1銆佹湭鑾峰彇鍒伴厤缃�-椤甸潰涓㈠け锛�2銆侀〉闈㈡湭鍚敤 lostmsg: '', // 椤甸潰涓㈠け鏃剁殑鎻愮ず淇℃伅 config: {}, // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷寜閽�佹悳绱€�佹樉绀哄垪銆佹爣绛剧瓑 + userConfig: null, // 鐢ㄦ埛鑷畾涔夎缃� + userParam: null, // 淇濆瓨鐢ㄦ埛缂栬緫涓殑閰嶇疆 searchlist: null, // 鎼滅储鏉′欢 actions: null, // 鎸夐挳闆� columns: null, // 鏄剧ず鍒� @@ -52,36 +59,53 @@ orderBy: '', // 鎺掑簭 search: '', // 鎼滅储鏉′欢鏁扮粍锛屼娇鐢ㄦ椂闇�鍒嗗満鏅鐞� BIDs: {}, // 涓婄骇琛╥d - setsingle: false, // 涓昏〃鍗曢�夊閫夊垏鎹� pickup: false, // 涓昏〃鏁版嵁闅愯棌鏄剧ず鍒囨崲 - isLinkMain: false, // 鏄惁瀛樺湪涓庝富琛ㄥ叧鑱旂殑瀛愯〃 popAction: false, // 寮规椤甸潰锛屾寜閽俊鎭� popData: false, // 寮规椤甸潰锛屾墍閫夌殑琛ㄦ牸鏁版嵁 visible: false, // 寮规鏄剧ず闅愯棌鎺у埗 + treevisible: false, // 鑿滃崟缁撴瀯鏍戝脊妗嗘樉绀洪殣钘忔帶鍒� tabBtn: null, // 琛ㄥ崟鏍囩鎸夐挳 tabParam: null, // 琛ㄥ崟鏍囩鍙傛暟 - refreshtabs: null // 闇�瑕佸埛鏂扮殑鏍囩闆� + refreshtabs: null, // 闇�瑕佸埛鏂扮殑鏍囩闆� + confirmLoading: false,// 鑷畾涔夎缃ā鎬佹鍔犺浇涓� + revertLoading: false, // 鎭㈠榛樿璁剧疆 + settingVisible: false,// 鑷畾涔夎缃ā鎬佹 + triggerBtn: null, // 鐐瑰嚮琛ㄦ牸涓垨蹇嵎閿Е鍙戠殑鎸夐挳 + tabActive: null // 鏍囩椤靛睍寮�鎺у埗 } /** * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 */ async loadconfig () { - const { permAction } = this.props + const { permAction, permMenus, param } = this.props - let param = { + let _param = { func: 'sPC_Get_LongParam', MenuID: this.props.MenuID } - let result = await Api.getSystemCacheConfig(param) + let result = await Api.getSystemCacheConfig(_param) + if (result.status) { let config = '' + let userConfig = null + let _curUserConfig = '' try { // 閰嶇疆淇℃伅瑙f瀽 - config = window.decodeURIComponent(window.atob(result.LongParam)) - config = JSON.parse(config) + config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) } catch (e) { + console.warn('Parse Failure') config = '' + } + + if (result.LongParamUser) { + try { // 閰嶇疆淇℃伅瑙f瀽 + userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser))) + _curUserConfig = userConfig[this.props.MenuID] + } catch (e) { + console.warn('Parse Failure') + userConfig = null + } } // 椤甸潰閰嶇疆瑙f瀽閿欒鏃舵彁绀� @@ -103,28 +127,104 @@ return } + // 鏉冮檺杩囨护 + config.action = config.action.filter(item => permAction[item.uuid]) + config.tabgroups.forEach(group => { + if (!config[group]) return + + config[group] = config[group].filter(tab => permAction[tab.linkTab]) + }) + + // 瀛楁鏉冮檺榛戝悕鍗� + config.search = config.search.filter(item => { + if (!item.blacklist || item.blacklist.length === 0) return true + + let _black = item.blacklist.filter(v => { + return this.props.permRoles.indexOf(v) !== -1 + }) + + if (_black.length > 0) { + return false + } else { + return true + } + }) + + config.columns = config.columns.filter(col => { + if (!col.field || !col.blacklist || col.blacklist.length === 0 || config.setting.primaryKey === col.field) return true + + let _black = col.blacklist.filter(v => { + return this.props.permRoles.indexOf(v) !== -1 + }) + + if (_black.length > 0) { + return false + } else { + return true + } + }) + + if (_curUserConfig) { + config.setting = {...config.setting, ..._curUserConfig.setting} + config.easyCode = _curUserConfig.easyCode || config.easyCode || '' + + config.action = config.action.map(item => { + if (item.execMode) { + item.OpenType = 'funcbutton' + } + + if (_curUserConfig.action[item.uuid]) { + delete _curUserConfig.action[item.uuid].label + item = {...item, ..._curUserConfig.action[item.uuid]} + } + + if (item.OpenType === 'funcbutton' && item.funcType === 'print' && item.verify && item.printer) { + item.verify.defaultPrinter = item.printer.defaultPrinter || '' + if (item.verify.printerTypeList && item.printer.printerList) { + item.verify.printerTypeList = item.verify.printerTypeList.map(cell => { + cell.printer = item.printer.printerList[cell.Value] || '' + + return cell + }) + } + } + + return item + }) + } + + let _tabActive = {} // 绛涢�夊睍寮�鐨則ab椤� + + config.tabgroups.forEach(groupId => { + if (!config[groupId] || config[groupId].length === 0) return + _tabActive[groupId] = config[groupId][0].uuid + }) + let _arrField = [] // 瀛楁闆� let _columns = [] // 鏄剧ず鍒� let _logcolumns = [] // 鏃ュ織鏄剧ず鍒� let _hideCol = [] // 闅愯棌鍙婂悎骞跺垪涓瓧娈电殑uuid闆� let colMap = new Map() // 鐢ㄤ簬瀛楁杩囨护 - // 鏉冮檺杩囨护 - config.action = config.action.filter(item => permAction[item.uuid]) - // config.tabgroups.forEach(group => { - // if (!config[group]) return - // config[group] = config[group].filter(tab => permAction[tab.uuid]) - // }) + let _actions = [] // 宸ュ叿鏍忔寜閽� + let _operations = [] // 鎿嶄綔鍒楁寜閽紙瀛樺湪鏃讹級 + config.action.forEach(item => { + if (item.execMode) { + item.OpenType = 'funcbutton' + } + + if (item.position === 'toolbar') { + _actions.push(item) + } else if (item.position === 'grid') { + _operations.push(item) + } + }) // 1銆佺瓫閫夊瓧娈甸泦锛�2銆佽繃婊ら殣钘忓垪鍙婂悎骞跺垪涓殑瀛楁uuid config.columns.forEach(col => { if (col.field) { _arrField.push(col.field) - - // if () { // 鏉冮檺榛戝悕鍗� - // col.Hide = 'true' - // } _logcolumns.push(col) } @@ -137,8 +237,14 @@ }) // 鐢熸垚鏄剧ず鍒楋紝澶勭悊鍚堝苟鍒椾腑鐨勫瓧娈� - config.columns.forEach(col => { + config.columns.forEach((col, index) => { if (_hideCol.includes(col.uuid)) return + + if (col.linkThdMenu && !permMenus[col.linkThdMenu.MenuID]) { + col.linkThdMenu = '' + } + + col.sort = index if (col.type === 'colspan' && col.sublist) { let _col = JSON.parse(JSON.stringify(col)) @@ -155,9 +261,6 @@ } }) - let _actions = config.action.filter(item => item.position === 'toolbar') // 杩囨护宸ュ叿鏍忔寜閽� - let _operations = config.action.filter(item => item.position === 'grid') // 娣诲姞鎿嶄綔鍒楋紙瀛樺湪鏃讹級 - if (config.gridBtn && config.gridBtn.display && _operations.length > 0) { _columns.push({ ...config.gridBtn, @@ -165,38 +268,52 @@ }) } - - let _isLinkMain = false // 妫�鏌ユ槸鍚︽湁涓庝富琛ㄥ叧鑱旂殑瀛愯〃 - config.tabgroups.forEach(groupId => { - if (!config[groupId] || config[groupId].length === 0) return + let valid = true // 鎼滅储鏉′欢蹇呭~楠岃瘉, 鍒濆鎼滅储鏉′欢 + let initSearch = config.search.map(item => { + let _item = JSON.parse(JSON.stringify(item)) + if (_item.type === 'text' && param && param.searchkey === _item.field) { + _item.initval = param.searchval + } - config[groupId].forEach(tab => { - if (tab.supMenu === 'mainTable') { - _isLinkMain = true - } - }) + if (_item.required === 'true' && !_item.initval) { + valid = false + } + 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, config: config, + tabActive: _tabActive, + userConfig: userConfig, setting: config.setting, searchlist: config.search, actions: _actions, columns: _columns, logcolumns: _logcolumns, - isLinkMain: _isLinkMain, arr_field: _arrField.join(','), - search: Utils.initMainSearch(config.search) // 鎼滅储鏉′欢鍒濆鍖栵紙鍚湁鏃堕棿鏍煎紡锛岄渶瑕佽浆鍖栵級 + search: Utils.initMainSearch(initSearch) // 鎼滅储鏉′欢鍒濆鍖栵紙鍚湁鏃堕棿鏍煎紡锛岄渶瑕佽浆鍖栵級 }, () => { this.improveSearch() - - if (config.setting.onload !== 'false') { // 鍒濆鍖栧彲鍔犺浇 - this.setState({ - loading: true - }) + if (config.setting.onload !== 'false' && valid) { // 鍒濆鍖栧彲鍔犺浇 this.loadmaindata() } + this.setShortcut() }) } else { this.setState({ @@ -206,7 +323,103 @@ notification.warning({ top: 92, message: result.message, - duration: 10 + duration: 5 + }) + } + } + + setShortcut = () => { + const { actions, 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 + + actions.forEach(item => { + 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 + + this.setState({ + triggerBtn: { + uuid: new Date().getTime(), + parentId: this.props.MenuID, + button: item, + data: null + } + }) + } + }) + + if (istrigger) return + + 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(groupId => { + if (!config[groupId] || config[groupId].length === 0) return + + let _tab = config[groupId].filter(tab => tab.uuid === key)[0] + if (_tab) { + _groupId = groupId + _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 + } + }) + }) + } + } + }) }) } } @@ -253,7 +466,7 @@ notification.warning({ top: 92, message: item.label + ': ' + this.state.dict['main.datasource.settingerror'], - duration: 10 + duration: 5 }) } }) @@ -288,7 +501,7 @@ notification.warning({ top: 92, message: res.search.label + ':' + res.message, - duration: 10 + duration: 5 }) } }) @@ -301,18 +514,29 @@ * @description 涓昏〃鏁版嵁鍔犺浇 */ async loadmaindata () { - const { setting, BIDs } = this.state + const { setting, BIDs, search } = this.state let param = '' + + let requireFields = search.filter(item => item.required && !item.value) + + if (requireFields.length > 0) { + notification.warning({ + top: 92, + message: this.state.dict['form.required.input'] + requireFields.map(item => item.label).join('銆�') + ' !', + duration: 3 + }) + return + } + + this.setState({ + loading: true + }) if (setting.interType !== 'inner' || (setting.interType === 'inner' && setting.innerFunc)) { param = this.getCustomParam() } else { param = this.getDefaultParam() } - - this.setState({ - pickup: false - }) this.handleTableId('mainTable', '', '') @@ -329,6 +553,7 @@ }), total: result.total, loading: false, + pickup: false, BIDs: { ...BIDs, mainTable: '' @@ -341,7 +566,7 @@ notification.error({ top: 92, message: result.message, - duration: 15 + duration: 10 }) } } @@ -364,13 +589,11 @@ if (setting.interType === 'inner') { param.func = setting.innerFunc } else { - if (setting.sysInterface === 'true') { - param.rduri = window.GLOB.mainSystemApi || window.GLOB.subSystemApi - } else { + if (setting.sysInterface === 'true' && window.GLOB.mainSystemApi) { + param.rduri = window.GLOB.mainSystemApi + } else if (setting.sysInterface !== 'true') { param.rduri = setting.interface } - - param.appkey = window.GLOB.appkey || '' // 璋冪敤澶栭儴鎺ュ彛澧炲姞appkey if (setting.outerFunc) { param.func = setting.outerFunc @@ -390,7 +613,7 @@ notification.warning({ top: 92, message: '鏈缃樉绀哄垪锛�', - duration: 10 + duration: 5 }) return null } @@ -402,8 +625,7 @@ let param = { func: 'sPC_Get_TableData', obj_name: 'data', - arr_field: arr_field, - appkey: window.GLOB.appkey || '' + arr_field: arr_field } let _orderBy = orderBy || setting.order @@ -414,23 +636,14 @@ } if (setting.queryType === 'statistics') { // 缁熻鏁版嵁婧愶紝鍐呭鏇挎崲 - let fieldmap = new Map() - let options = search.map(item => { - let _field = item.key + let allSearch = Utils.getAllSearchOptions(search) - if (fieldmap.has(_field)) { - _field = _field + '1' - } - - fieldmap.set(item.key, true) - + let options = allSearch.map(item => { return { - reg: new RegExp('@' + _field, 'ig'), + reg: new RegExp('@' + item.key + '@', 'ig'), value: item.value } }) - - options.reverse() options.forEach(item => { _dataresource = _dataresource.replace(item.reg, `'${item.value}'`) @@ -459,7 +672,6 @@ if (setting.onload === 'false') { this.setState({ - loading: true, pageIndex: 1, search: searches, setting: {...setting, onload: 'true'} @@ -470,7 +682,6 @@ this.refs.mainTable.resetTable() this.setState({ - loading: true, pageIndex: 1, search: searches }, () => { @@ -492,7 +703,6 @@ } this.setState({ - loading: true, pageIndex: pagination.current, pageSize: pagination.pageSize, orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' @@ -507,7 +717,6 @@ reloadtable = () => { this.refs.mainTable.resetTable() this.setState({ - loading: true, pageIndex: 1 }, () => { this.loadmaindata() @@ -524,6 +733,8 @@ viewlost: false, lostmsg: '', config: {}, + userConfig: null, + userParam: null, searchlist: null, actions: null, columns: null, @@ -537,9 +748,7 @@ orderBy: '', search: '', BIDs: {}, - setsingle: false, - pickup: false, - isLinkMain: false + pickup: false }, () => { this.loadconfig() }) @@ -636,7 +845,14 @@ * @description 琛ㄦ牸涓紝鎸夐挳瑙﹀彂浜嬩欢浼犻�� */ buttonTrigger = (btn, record) => { - this.refs.mainButton.actionTrigger(btn, record) + this.setState({ + triggerBtn: { + uuid: new Date().getTime(), + parentId: this.props.MenuID, + button: btn, + data: record + } + }) } /** @@ -651,22 +867,6 @@ [type]: id, [type + 'data']: data } - }) - } - - /** - * @description 琛ㄦ牸鍗曢�夊閫夊垏鎹� - */ - checkChange = () => { - const { setsingle, BIDs } = this.state - - let _BIDs = JSON.parse(JSON.stringify(BIDs)) - _BIDs.mainTable = '' - - this.setState({ - setsingle: !setsingle, - pickup: false, - BIDs: _BIDs }) } @@ -707,6 +907,7 @@ type: btn.tabTemplate, selected: true, param: { + menuType: 'main', parentId: this.props.MenuID, btn: btn, data: data[0] || null, @@ -740,6 +941,7 @@ view: 'formtab', tabBtn: btn, tabParam: { + menuType: 'main', btn: btn, data: data[0] || null, primaryId: btn.Ot !== 'notRequired' ? _primaryId : '', @@ -756,6 +958,186 @@ this.refreshbyaction(this.state.popAction, 'pop') } + 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}) + } + + linkTrigger = (menu) => { + const { tabviews, MenuID } = this.props + + menu.selected = true + + let index = 0 + let isexit = false + let tabs = tabviews.map((tab, i) => { + tab.selected = false + + if (tab.MenuID === MenuID) { + index = i + } else if (tab.MenuID === menu.MenuID) { + tab.param = menu.param + tab.selected = true + isexit = true + } + + return tab + }) + + if (!isexit) { + tabs.splice(index + 1, 0, menu) + } + + this.props.modifyTabview(tabs) + } + + 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() @@ -769,6 +1151,20 @@ 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() + } + } else if (nextProps.param && !is(fromJS(this.props.param), fromJS(nextProps.param))) { + let search = this.state.search.map(item => { + if (item.type === 'text' && item.key === nextProps.param.searchkey) { + item.value = nextProps.param.searchval + } + + return item + }) + this.refreshbysearch(search) } } @@ -777,59 +1173,63 @@ } /** - * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 + * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 */ componentWillUnmount () { this.setState = () => { return } + document.onkeydown = () => {} } render() { - const { view, setting, searchlist, actions, columns, loadingview, viewlost, setsingle, pickup, isLinkMain, config } = this.state + const { view, setting, searchlist, actions, columns, loadingview, viewlost, pickup, config, triggerBtn, userConfig, tabActive, search } = this.state return ( <div> - {view === 'commontable' ? <div className={'commontable ' + (isLinkMain ? 'pick-control' : '')} id={this.state.ContainerId}> + {view === 'commontable' ? <div className="commontable pick-control" id={this.state.ContainerId}> {loadingview && <Spin size="large" />} {searchlist && searchlist.length > 0 ? <MainSearch + ref="mainSearch" dict={this.state.dict} searchlist={searchlist} refreshdata={this.refreshbysearch} /> : null } {actions && setting.onload !== 'false' ? - <MainAction - ref="mainButton" - BID="" - type="main" - setting={setting} - actions={actions} - dict={this.state.dict} - MenuID={this.props.MenuID} - logcolumns={this.state.logcolumns} - ContainerId={this.state.ContainerId} - refreshdata={this.refreshbyaction} - triggerPopview={this.triggerPopview} - getexceloutparam={this.getexceloutparam} - gettableselected={this.gettableselected} - /> : null + <div style={{minHeight: '25px'}}> + <MainAction + BID="" + type="main" + menuType="main" + setting={setting} + actions={actions} + triggerBtn={triggerBtn} + dict={this.state.dict} + MenuID={this.props.MenuID} + permRoles={this.props.permRoles} + logcolumns={this.state.logcolumns} + ContainerId={this.state.ContainerId} + refreshdata={this.refreshbyaction} + triggerPopview={this.triggerPopview} + getexceloutparam={this.getexceloutparam} + gettableselected={this.gettableselected} + /> + </div> : null } {columns && setting.onload !== 'false' ? <div className="main-table-box"> - {isLinkMain ? - <div className="pickchange"> - {setting.tableType === 'checkbox' ? <Switch title="鍗曢�夊垏鎹�" checkedChildren="鍗�" unCheckedChildren="澶�" defaultChecked={setsingle} onChange={this.checkChange} /> : null} - {this.state.BIDs.mainTable && (setting.tableType === 'radio' || setsingle) ? <Switch title="鏀惰捣" checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={pickup} onChange={this.pickupChange} /> : null} - </div> : null + <Icon className="custom-control" type="setting" onClick={this.controlCustomSetting} /> + {this.state.data && this.state.data.length > 0 ? + <Switch title="鏀惰捣" className="main-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={pickup} onChange={this.pickupChange} /> : null } <MainTable ref="mainTable" + tableId="mainTable" pickup={pickup} setting={setting} columns={columns} - setsingle={setsingle} dict={this.state.dict} data={this.state.data} total={this.state.total} @@ -837,6 +1237,7 @@ loading={this.state.loading} refreshdata={this.refreshbytable} buttonTrigger={this.buttonTrigger} + linkTrigger={this.linkTrigger} handleTableId={this.handleTableId} /> </div> : null @@ -846,19 +1247,23 @@ if (config[group].length === 0) return null return ( - <Tabs defaultActiveKey="0" key={group}> - {config[group].map((_tab, index) => { + <Tabs activeKey={tabActive[group]} key={group} onChange={(key) => this.setState({tabActive: {...tabActive, [group]: key}})}> + {config[group].map(_tab => { return ( <TabPane tab={ <span> {_tab.icon ? <Icon type={_tab.icon} /> : null} {_tab.label} </span> - } key={`${index}`}> + } key={_tab.uuid}> {_tab.type === 'SubTable' ? <SubTable Tab={_tab} + menuType="main" MenuID={_tab.linkTab} + mainSearch={_tab.searchPass === 'true' ? search : null} + userConfig={userConfig ? userConfig[_tab.uuid] : null} + triggerBtn={triggerBtn} SupMenuID={this.props.MenuID} refreshtabs={this.state.refreshtabs} ContainerId={this.state.ContainerId} @@ -878,7 +1283,7 @@ icon="copy" shape="circle" className="common-table-copy" - onClick={this.copyMenuNo} + onClick={this.handleviewconfig} /> <Modal className="popview-modal" @@ -894,6 +1299,7 @@ > {<SubTabTable BID={''} + menuType="main" SupMenuID={this.props.MenuID} MenuID={this.state.popAction.linkTab} BData={this.state.BIDs['mainTabledata'] || ''} @@ -901,6 +1307,54 @@ ID={this.state.popData ? this.state.popData[setting.primaryKey] : ''} refreshSupView={this.reloadtable} />} + </Modal> + <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={this.state.columns} + handleParam={this.changeMenuParam} + /> : null + } </Modal> {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} </div> : null} @@ -914,7 +1368,9 @@ return { tabviews: state.tabviews, refreshTab: state.refreshTab, - permAction: state.permAction + permAction: state.permAction, + permMenus: state.permMenus, + permRoles: state.permRoles } } -- Gitblit v1.8.0