From 8a6ce370f1aa1c061b76fa3e9d2d4d1df53ca4c5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 21 五月 2024 16:38:09 +0800 Subject: [PATCH] Merge branch 'master' into positec --- src/tabviews/custom/components/tree/antd-tree/index.jsx | 151 +++++++++++++++++++++++++++----------------------- 1 files changed, 81 insertions(+), 70 deletions(-) diff --git a/src/tabviews/custom/components/tree/antd-tree/index.jsx b/src/tabviews/custom/components/tree/antd-tree/index.jsx index 1d974f3..35b14ec 100644 --- a/src/tabviews/custom/components/tree/antd-tree/index.jsx +++ b/src/tabviews/custom/components/tree/antd-tree/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Spin, Empty, notification, Input, Tree, Modal, Dropdown } from 'antd' +import { Spin, Empty, Input, Tree, Dropdown } from 'antd' import { FolderOpenOutlined, FolderOutlined, FileOutlined, MoreOutlined } from '@ant-design/icons' import Api from '@/api' @@ -31,6 +31,7 @@ treeNodes: null, // 鍒楄〃鏁版嵁闆� expandedKeys: [], // 灞曞紑鐨勬爲鑺傜偣 selectedKeys: [], // 閫変腑鐨勬爲鑺傜偣 + lineActions: [], selected: false // 閫変腑棣栬 } @@ -60,7 +61,7 @@ _data = window.GLOB.SyncData.get(_config.dataName) || [] if (_config.$cache) { - Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS()) + Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS(), BID) } _config.setting.sync = 'false' @@ -71,14 +72,28 @@ } } + let lineActions = [] + _config.action = _config.action || [] + _config.action = _config.action.filter(item => { + if (item.Ot === 'requiredSgl') { + lineActions.push(item) + return false + } + return true + }) + _config.wrap.contentHeight = config.wrap.title || config.wrap.searchable === 'true' ? 'calc(100% - 45px)' : '100%' + + if (_config.wrap.lineHeight) { + _config.style['--mk-tree-line-height'] = _config.wrap.lineHeight + 'px' + } this.setState({ selected: _config.wrap.selected === 'true', config: _config, data: _data, BID: BID || '', - arr_field: _config.columns.map(col => col.field).join(',') + lineActions }) } @@ -130,12 +145,12 @@ } initExec = () => { - const { config } = this.state + const { config, BID } = this.state if (config.$cache) { if (config.$time) { if (!this.loaded) { - Api.getLCacheConfig(config.uuid, config.$time).then(res => { + Api.getLCacheConfig(config.uuid, config.$time, BID).then(res => { if (!res.valid && config.setting.onload === 'true') { setTimeout(() => { this.loadData('init') @@ -153,7 +168,7 @@ } } else { if (!this.loaded) { - Api.getLCacheConfig(config.uuid, 0).then(res => { + Api.getLCacheConfig(config.uuid, 0, BID).then(res => { if (!res.data || this.loaded) return this.setState({data: res.data}, () => { @@ -180,14 +195,14 @@ } transferSyncData = (syncId) => { - const { config } = this.state + const { config, BID } = this.state if (config.$syncId !== syncId) return let _data = window.GLOB.SyncData.get(config.dataName) || [] if (config.$cache) { - Api.writeCacheConfig(config.uuid, fromJS(_data).toJS()) + Api.writeCacheConfig(config.uuid, fromJS(_data).toJS(), BID) } this.loaded = true @@ -234,7 +249,7 @@ * @description 瀵煎嚭Excel鏃讹紝鑾峰彇椤甸潰鎼滅储鎺掑簭绛夊弬鏁� */ queryModuleParam = (menuId, callback) => { - const { arr_field, config } = this.state + const { config } = this.state if (config.uuid !== menuId) return @@ -244,10 +259,8 @@ } callback({ - arr_field: arr_field, orderBy: config.setting.order || '', - search: searches, - menuName: config.name + search: searches }) } @@ -257,13 +270,13 @@ * @param {*} position // 鍒锋柊浣嶇疆 * @param {*} btn // 鎵ц鐨勬寜閽� */ - refreshByButtonResult = (menuId, position, btn) => { + refreshByButtonResult = (menuId, position) => { const { config, BID } = this.state if (config.uuid !== menuId) return - if ((position === 'mainline' || position === 'popclose') && config.setting.supModule && BID) { // 鍒锋柊婧愮粍浠舵椂锛岄檮甯﹀埛鏂颁笂绾ц涓庡綋鍓嶇粍浠� - MKEmitter.emit('reloadData', config.setting.supModule, BID) + if (['mainline', 'maingrid', 'popclose'].includes(position) && config.setting.supModule) { + MKEmitter.emit('reloadData', config.setting.supModule, position === 'maingrid' ? '' : BID) } else { this.loadData() } @@ -273,7 +286,7 @@ * @description 鏁版嵁鍔犺浇 */ async loadData (type) { - const { config, arr_field, BID } = this.state + const { config, BID } = this.state if (config.setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇� this.setState({ @@ -301,13 +314,13 @@ } let _orderBy = config.setting.order || '' - let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, '', '', BID) + let param = UtilsDM.getQueryDataParams(config.setting, searches, _orderBy, '', '', BID) let result = await Api.genericInterface(param) if (result.status) { this.loaded = true if (config.$cache && type === 'init') { - Api.writeCacheConfig(config.uuid, result.data || []) + Api.writeCacheConfig(config.uuid, result.data || [], BID) } this.setState({ @@ -324,37 +337,14 @@ } } - if (result.message) { - if (result.ErrCode === 'Y') { - Modal.success({ - title: result.message - }) - } else if (result.ErrCode === 'S') { - notification.success({ - top: 92, - message: result.message, - duration: 2 - }) - } - } + UtilsDM.querySuccess(result) } else { this.setState({ loading: false }) this.timer && this.timer.stop() - if (!result.message) return - if (result.ErrCode === 'N') { - Modal.error({ - title: result.message, - }) - } else if (result.ErrCode !== '-2') { - notification.error({ - top: 92, - message: result.message, - duration: 10 - }) - } + UtilsDM.queryFail(result) } } @@ -379,9 +369,9 @@ let hasSelectKey = false data.forEach(item => { - let pval = item[config.wrap.parentField] - let val = item[config.wrap.valueField] - let uuid = item[config.setting.primaryKey] || '' + let pval = item[config.wrap.parentField] + '' + let val = item[config.wrap.valueField] + '' + let uuid = item[config.setting.primaryKey] + '' if (!val || logMap.has(val)) return @@ -531,30 +521,45 @@ }) } - renderActionTreeNodes = (nodes) => { + renderActionTreeNodes = (nodes, actShow) => { return nodes.map(item => { - let title = <> - {item.$title} - <Dropdown overlay={ - <div className="mk-tree-dropdown-wrap" onClick={(e) => e.stopPropagation()}> - <MainAction - BID={this.state.BID} - BData={this.state.BData} - setting={this.state.config.setting} - actions={this.state.config.action} - columns={this.state.config.columns} - selectedData={[{...item, children: ''}]} - /> - </div> - } placement="bottomCenter" trigger={['hover']}> - <MoreOutlined onClick={(e) => e.stopPropagation()}/> - </Dropdown> - </> + let title = null + if (actShow === 'line') { + title = <> + {item.$title} + <MainAction + BID={this.state.BID} + BData={this.state.BData} + setting={this.state.config.setting} + actions={this.state.lineActions} + columns={this.state.config.columns} + selectedData={[{...item, children: ''}]} + /> + </> + } else { + title = <> + {item.$title} + <Dropdown overlay={ + <div className="mk-tree-dropdown-wrap" onClick={(e) => e.stopPropagation()}> + <MainAction + BID={this.state.BID} + BData={this.state.BData} + setting={this.state.config.setting} + actions={this.state.lineActions} + columns={this.state.config.columns} + selectedData={[{...item, children: ''}]} + /> + </div> + } placement="bottomCenter" trigger={['hover']}> + <MoreOutlined onClick={(e) => e.stopPropagation()}/> + </Dropdown> + </> + } if (item.children) { return ( <TreeNode icon={<span><FolderOpenOutlined /><FolderOutlined /></span>} title={title} key={item.$key} dataRef={item}> - {this.renderActionTreeNodes(item.children)} + {this.renderActionTreeNodes(item.children, actShow)} </TreeNode> ) } @@ -617,9 +622,7 @@ } render() { - const { config, loading, treeNodes, expandedKeys, selectedKeys } = this.state - - let extra = config.action && config.action.length > 0 + const { BID, BData, config, loading, treeNodes, expandedKeys, selectedKeys, lineActions } = this.state return ( <div className="custom-tree-box" id={'anchor' + config.uuid} style={config.style}> @@ -633,18 +636,26 @@ <span className={'title ' + (config.wrap.searchable !== 'true' ? 'search-unable' : '')}>{config.wrap.title}</span> {config.wrap.searchable === 'true' ? <Search allowClear onSearch={this.treeFilter} /> : null} </div> : null} + {config.action.length ? <MainAction + BID={BID} + setting={config.setting} + actions={config.action} + BData={BData} + columns={config.columns} + selectedData={[]} + /> : null} {treeNodes && treeNodes.length > 0 ? <div className="tree-box" style={{height: config.wrap.contentHeight}}> <Tree blockNode onSelect={this.selectTreeNode} expandedKeys={expandedKeys} selectedKeys={selectedKeys} - onRightClick={!extra ? this.changeExpandedAllKeys : null} + onRightClick={!lineActions.length ? this.changeExpandedAllKeys : null} onExpand={this.changeExpandedKeys} showIcon={config.wrap.showIcon === 'true'} showLine={config.wrap.showLine === 'true'} > - {!extra ? this.renderTreeNodes(treeNodes) : this.renderActionTreeNodes(treeNodes)} + {!lineActions.length ? this.renderTreeNodes(treeNodes) : this.renderActionTreeNodes(treeNodes, config.wrap.actShow)} </Tree> </div> : null} {treeNodes && treeNodes.length === 0 ? <Empty description={false}/> : null} -- Gitblit v1.8.0