From 4b6a4e2f04f492d770573cf48ca52d4e748a086a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 18 十月 2021 18:30:50 +0800 Subject: [PATCH] 2021-10-18 --- src/tabviews/treepage/index.jsx | 41 +- src/tabviews/formtab/index.jsx | 64 +-- src/utils/utils-update.js | 38 ++ src/tabviews/verupmanage/subtabtable/index.jsx | 77 ++-- src/tabviews/zshare/normalTable/index.jsx | 52 +++ src/tabviews/verupmanage/config.jsx | 4 src/tabviews/zshare/actionList/printbutton/index.jsx | 54 ++ src/tabviews/zshare/automatic/index.jsx | 125 ++++++++ src/tabviews/scriptmanage/index.jsx | 7 src/tabviews/subtable/index.jsx | 110 +++--- src/tabviews/subtabtable/index.jsx | 144 ++------- src/tabviews/commontable/index.jsx | 65 ++- src/tabviews/zshare/actionList/normalbutton/index.jsx | 56 +++ src/tabviews/verupmanage/index.jsx | 45 +- src/tabviews/zshare/cardcomponent/index.jsx | 4 15 files changed, 536 insertions(+), 350 deletions(-) diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx index 5e6d483..d37f4be 100644 --- a/src/tabviews/commontable/index.jsx +++ b/src/tabviews/commontable/index.jsx @@ -392,7 +392,9 @@ _actions.forEach(item => { if (item.uuid === config.autoMatic.action && (['pop', 'prompt', 'exec'].includes(item.OpenType) || (item.OpenType === 'funcbutton' && item.funcType === 'print'))) { autoMatic = config.autoMatic + autoMatic.OpenType = item.execMode || item.OpenType config.setting.selected = 'false' + item.autoMatic = true } }) } @@ -474,15 +476,12 @@ } loadData = () => { + const { MenuID } = this.props const { setting, search, BIDs, loadCustomApi, hasReqFields } = this.state this.setState({ selectedData: [], - BIDs: { - ...BIDs, - mainTable: '', - mainTabledata: '' - } + BIDs: { ...BIDs, [MenuID]: '', [MenuID + 'data']: '' } }) if (hasReqFields) { @@ -690,7 +689,7 @@ * @description 涓昏〃鏁版嵁鍔犺浇 */ async loadmaindata () { - const { setting, arr_field, search, orderBy, BID, pageIndex, pageSize, absFields } = this.state + const { setting, arr_field, search, orderBy, BID, pageIndex, pageSize, absFields, autoMatic } = this.state this.setState({ loading: true @@ -740,10 +739,21 @@ loading: false, pickup: false }) + + if (autoMatic) { + if (result.data && result.data.length > 0) { + MKEmitter.emit('autoGetData', this.props.MenuID) + } else { + MKEmitter.emit('autoMaticOver', this.props.MenuID) + } + } } else { this.setState({ loading: false }) + if (autoMatic) { + MKEmitter.emit('autoMaticError', this.props.MenuID) + } notification.error({ top: 92, message: result.message, @@ -881,7 +891,7 @@ this.loadData() }) } else { - MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.MenuID) // 鍒楄〃閲嶇疆 this.setState({ pageIndex: 1, search: searches @@ -895,6 +905,15 @@ * @description 琛ㄦ牸鏉′欢鏀瑰彉鏃堕噸缃暟鎹紙鍒嗛〉鎴栨帓搴忥級 */ refreshbytable = (pagination, filters, sorter) => { + if (!sorter) { + this.setState({ + pageIndex: pagination.pageIndex + }, () => { + this.loadData() + }) + return + } + if (sorter.order) { let _chg = { ascend: 'asc', @@ -917,14 +936,14 @@ */ reloadtable = (btn) => { if (!btn || btn.resetPageIndex !== 'false') { - MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.MenuID) // 鍒楄〃閲嶇疆 this.setState({ pageIndex: 1 }, () => { this.loadData() }) } else { - MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable', 'false') // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.MenuID, 'false') // 鍒楄〃閲嶇疆 this.loadData() } } @@ -963,21 +982,6 @@ */ changeSelectedData = (selectedData) => { this.setState({selectedData}) - } - - /** - * @description 琛ㄦ牸Id鍙樺寲 - */ - handleTableId = (type, id, data) => { - const { BIDs } = this.state - - this.setState({ - BIDs: { - ...BIDs, - [type]: id, - [type + 'data']: data - } - }) } /** @@ -1035,6 +1039,14 @@ this.setShortcut() } + changeTableLine = (ContainerId, tableId, id, data) => { + if (this.state.ContainerId !== ContainerId) return + + this.setState({ + BIDs: {...this.state.BIDs, [tableId]: id, [tableId + 'data']: data} + }) + } + /** * @description 鎸夐挳鎵ц瀹屾垚鍚庨〉闈㈠埛鏂� * @param {*} menuId // 鑿滃崟Id @@ -1061,6 +1073,7 @@ componentDidMount () { MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('reloadMenuView', this.reloadMenuView) + MKEmitter.addListener('changeTableLine', this.changeTableLine) MKEmitter.addListener('resetActiveMenu', this.resetActiveMenu) MKEmitter.addListener('queryModuleParam', this.queryModuleParam) MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) @@ -1076,6 +1089,7 @@ document.onkeydown = () => {} MKEmitter.removeListener('reloadData', this.reloadData) MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) + MKEmitter.removeListener('changeTableLine', this.changeTableLine) MKEmitter.removeListener('resetActiveMenu', this.resetActiveMenu) MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) @@ -1135,7 +1149,6 @@ statFValue={this.state.statFValue} ContainerId={this.state.ContainerId} refreshdata={this.refreshbytable} - handleTableId={this.handleTableId} chgSelectData={this.changeSelectedData} /> </div> @@ -1154,7 +1167,6 @@ data={this.state.data} loading={this.state.loading} ContainerId={this.state.ContainerId} - handleTableId={this.handleTableId} /> </Col> ) @@ -1191,7 +1203,6 @@ ContainerId={this.state.ContainerId} BID={this.state.BIDs[_tab.supMenu] || ''} BData={this.state.BIDs[_tab.supMenu + 'data'] || ''} - handleTableId={this.handleTableId} /> </TabPane> ) diff --git a/src/tabviews/formtab/index.jsx b/src/tabviews/formtab/index.jsx index 69bdf15..f831a71 100644 --- a/src/tabviews/formtab/index.jsx +++ b/src/tabviews/formtab/index.jsx @@ -48,11 +48,11 @@ * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 */ async loadconfig () { - const { permAction } = this.props + const { permAction, MenuID } = this.props let param = { func: 'sPC_Get_LongParam', - MenuID: this.props.MenuID + MenuID: MenuID } let result = await Api.getCacheConfig(param) if (result.status) { @@ -103,13 +103,15 @@ config.tabgroups = _tabgroups } - // 鏉冮檺杩囨护 - if (this.props.menuType !== 'HS') { - config.action = config.action.filter(item => permAction[item.uuid]) - config.tabgroups.forEach(group => { - group.sublist = group.sublist.filter(tab => permAction[tab.linkTab]) + config.action = config.action.filter(item => permAction[item.uuid]) + config.tabgroups.forEach(group => { + group.sublist = group.sublist.filter(tab => { + if (tab.supMenu === 'mainTable') { + tab.supMenu = MenuID + } + return permAction[tab.linkTab] }) - } + }) // 鎸夐挳绫诲瀷鍏煎 config.action = config.action.map(item => { @@ -141,8 +143,8 @@ primaryId: this.props.param.primaryId || '', data: this.props.param.data || null, BIDs: { - mainTable: config.setting.onload !== 'false' ? (this.props.param.primaryId || '') : '', - mainTabledata: config.setting.onload !== 'false' ? (config.setting.datatype === 'query' ? '' : this.props.param.data) : '' + [MenuID]: config.setting.onload !== 'false' ? (this.props.param.primaryId || '') : '', + [MenuID + 'data']: config.setting.onload !== 'false' ? (config.setting.datatype === 'query' ? '' : this.props.param.data) : '' } }, () => { this.improveSelectOption(config.groups) @@ -340,11 +342,7 @@ this.setState({ data: _data, primaryId: _primaryId, - BIDs: { - ...BIDs, - mainTable: _primaryId, - mainTabledata: _data - } + BIDs: { ...BIDs, [this.props.MenuID]: _primaryId, [this.props.MenuID + 'data']: _data } }) if (_data && (setting.interType !== 'inner' || (setting.interType === 'inner' && setting.innerFunc))) { @@ -493,11 +491,7 @@ } this.setState({ - BIDs: { - ...BIDs, - mainTable: primaryId, - mainTabledata: data - } + BIDs: { ...BIDs, [this.props.MenuID]: primaryId, [this.props.MenuID + 'data']: data } }) } }) @@ -517,21 +511,6 @@ } MKEmitter.emit('closeTabView', this.props.MenuID) } - } - - /** - * @description 琛ㄦ牸Id鍙樺寲 - */ - handleTableId = (type, id, data) => { - const { BIDs } = this.state - - this.setState({ - BIDs: { - ...BIDs, - [type]: id, - [type + 'data']: data - } - }) } /** @@ -574,6 +553,14 @@ this.loadmaindata() } + changeTableLine = (ContainerId, tableId, id, data) => { + if (this.state.ContainerId !== ContainerId) return + + this.setState({ + BIDs: {...this.state.BIDs, [tableId]: id, [tableId + 'data']: data} + }) + } + UNSAFE_componentWillMount () { // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁 this.loadconfig() @@ -584,8 +571,9 @@ } componentDidMount () { - MKEmitter.addListener('reloadMenuView', this.reloadMenuView) MKEmitter.addListener('reloadData', this.reloadData) + MKEmitter.addListener('reloadMenuView', this.reloadMenuView) + MKEmitter.addListener('changeTableLine', this.changeTableLine) } /** @@ -596,8 +584,9 @@ return } - MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) MKEmitter.removeListener('reloadData', this.reloadData) + MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) + MKEmitter.removeListener('changeTableLine', this.changeTableLine) } render() { @@ -653,7 +642,6 @@ ContainerId={this.state.ContainerId} BID={this.state.BIDs[_tab.supMenu] || ''} BData={this.state.BIDs[_tab.supMenu + 'data'] || ''} - handleTableId={this.handleTableId} /> </TabPane> ) diff --git a/src/tabviews/scriptmanage/index.jsx b/src/tabviews/scriptmanage/index.jsx index 868fc97..06d760a 100644 --- a/src/tabviews/scriptmanage/index.jsx +++ b/src/tabviews/scriptmanage/index.jsx @@ -196,7 +196,7 @@ * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃� */ refreshbysearch = (searches) => { - MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.MenuID) // 鍒楄〃閲嶇疆 this.setState({ loading: true, pageIndex: 1, @@ -234,7 +234,7 @@ * @description 琛ㄦ牸鍒锋柊 */ reloadtable = () => { - MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.MenuID) // 鍒楄〃閲嶇疆 this.setState({ loading: true, pageIndex: 1, @@ -327,7 +327,7 @@ </div> : null } <MainTable - tableId="mainTable" + tableId={this.props.MenuID} pickup={pickup} setting={setting} columns={columns} @@ -338,7 +338,6 @@ loading={this.state.loading} refreshdata={this.refreshbytable} buttonTrigger={() => {}} - handleTableId={() => {}} chgSelectData={this.changeSelectedData} /> </div> diff --git a/src/tabviews/subtable/index.jsx b/src/tabviews/subtable/index.jsx index f716868..e17dc76 100644 --- a/src/tabviews/subtable/index.jsx +++ b/src/tabviews/subtable/index.jsx @@ -34,7 +34,6 @@ SupMenuID: PropTypes.string, // 涓婄骇鑿滃崟Id mainSearch: PropTypes.any, // 涓昏〃鎼滅储鏉′欢 ContainerId: PropTypes.any, // 涓夌骇鑿滃崟Container(html) ID - handleTableId: PropTypes.func, // 鎺у埗琛ㄦ牸鏁版嵁鍒囨崲鏃讹紝鏇存柊鍦ㄤ富琛ㄤ腑鐨刬d } state = { @@ -62,23 +61,18 @@ statFValue: [], // 鍚堣鍊� absFields: [], // 缁濆鍊煎瓧娈� loadCustomApi: true, // 鍔犺浇澶栭儴璧勬簮 - hasReqFields: false + hasReqFields: false, + BID: '', + BData: '' } /** * @description 涓婄骇鑿滃崟id鍙樺寲鏃讹紝鍒锋柊鏁版嵁 */ UNSAFE_componentWillReceiveProps(nextProps) { - const { config, setting } = this.state + const { setting } = this.state - if (config && setting && this.props.Tab.supMenu && !is(fromJS(this.props.BID), fromJS(nextProps.BID))) { - MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 鍒楄〃閲嶇疆 - this.setState({ - pageIndex: 1 - }, () => { - this.loadData() - }) - } else if (setting && !this.props.Tab.supMenu && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { + if (setting && !this.props.Tab.supMenu && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { this.setState({}, () => { this.loadData() }) @@ -89,7 +83,7 @@ * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 */ async loadconfig () { - const { permAction, permMenus, Tab, BID } = this.props + const { permAction, permMenus, Tab, BID, BData } = this.props let param = { func: 'sPC_Get_LongParam', @@ -327,6 +321,8 @@ } this.setState({ + BID: BID || '', + BData: BData || '', loadingview: false, chartId, config, @@ -360,8 +356,8 @@ } loadData = () => { - const { mainSearch, BID } = this.props - const { setting, search, loadCustomApi, hasReqFields } = this.state + const { mainSearch } = this.props + const { setting, BID, search, loadCustomApi, hasReqFields } = this.state let searches = fromJS(search).toJS() if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 @@ -385,7 +381,7 @@ statFValue: [], total: 0 }) - this.handleTableId() + MKEmitter.emit('changeTableLine', this.props.ContainerId, this.props.Tab.uuid, '', '') return } else if (window.GLOB.systemType === 'production' && setting.interType === 'custom' && !setting.proInterface) { notification.warning({ @@ -399,7 +395,7 @@ this.setState({ selectedData: [] }) - this.handleTableId() + MKEmitter.emit('changeTableLine', this.props.ContainerId, this.props.Tab.uuid, '', '') if (setting.interType === 'custom' && loadCustomApi) { if (setting.execTime === 'once') { @@ -416,8 +412,7 @@ } loadOutResource = (searches) => { - const { BID } = this.props - const { setting } = this.state + const { setting, BID } = this.state let param = UtilsDM.getPrevQueryParams(setting, searches, BID, this.props.menuType) @@ -511,7 +506,7 @@ } customCallbackRequest = (result) => { - const { setting } = this.state + const { setting, BID } = this.state let errSql = '' if (result.$ErrCode === 'E') { errSql = ` @@ -535,8 +530,8 @@ param = UtilsDM.getCallBackQueryParams(setting, sql, errSql) - if (this.props.BID) { - param.BID = this.props.BID + if (BID) { + param.BID = BID } if (this.props.menuType === 'HS') { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉 @@ -587,8 +582,8 @@ * @description 瀛愯〃鏁版嵁鍔犺浇 */ async loadmaindata () { - const { mainSearch, BID } = this.props - const { setting, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state + const { mainSearch } = this.props + const { setting, BID, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state let searches = fromJS(search).toJS() if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 @@ -660,8 +655,8 @@ * @description 鑾峰彇鍗曡鏁版嵁 */ async loadmainLinedata (id) { - const { mainSearch, BID } = this.props - const { setting, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state + const { mainSearch } = this.props + const { setting, BID, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state let searches = fromJS(search).toJS() if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 @@ -736,8 +731,7 @@ * @description 鑾峰彇鍚堣瀛楁鍊� */ getStatFieldsValue = (searches) => { - const { BID } = this.props - const { setting, orderBy, statFields } = this.state + const { setting, BID, orderBy, statFields } = this.state if (statFields.length === 0 || !(setting.interType === 'system' || (setting.interType === 'custom' && setting.requestMode === 'system')) || !setting.dataresource) return @@ -782,7 +776,7 @@ * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃� */ refreshbysearch = (searches) => { - MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.Tab.uuid) // 鍒楄〃閲嶇疆 this.setState({ pageIndex: 1, search: searches, @@ -817,14 +811,14 @@ */ reloadtable = (btn) => { if (!btn || btn.resetPageIndex !== 'false') { - MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.Tab.uuid) // 鍒楄〃閲嶇疆 this.setState({ pageIndex: 1 }, () => { this.loadData() }) } else { - MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid, 'false') // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.Tab.uuid, 'false') // 鍒楄〃閲嶇疆 this.loadData() } } @@ -856,13 +850,6 @@ */ changeSelectedData = (selectedData) => { this.setState({selectedData}) - } - - /** - * @description 琛ㄦ牸Id鍙樺寲 - */ - handleTableId = (type = this.props.Tab.uuid, id = '', data = '') => { - this.props.handleTableId(type, id, data) } /** @@ -907,15 +894,14 @@ if (MenuID !== menuId) return - const { Tab, SupMenuID, BID } = this.props + const { Tab, SupMenuID } = this.props + const { BID } = this.state if (position === 'grid' || position === 'view') { this.reloadtable(btn) } else if (position === 'maingrid' || position === 'mainline') { this.reloadtable(btn) - if (Tab.supMenu === 'mainTable') { - MKEmitter.emit('reloadData', SupMenuID, (BID || 'empty')) // 涓昏〃閲嶇疆 - } else if (Tab.supMenu) { + if (Tab.supMenu) { MKEmitter.emit('reloadData', Tab.supMenu, (BID || 'empty')) // 涓昏〃閲嶇疆 } else if (!Tab.supMenu && Tab.level === 0) { MKEmitter.emit('reloadData', SupMenuID, (BID || 'empty')) // 鏍戝舰缁撴瀯锛�0绾ф爣绛� @@ -928,17 +914,35 @@ } } + changeTableLine = (ContainerId, tableId, id, data) => { + const { Tab } = this.props + + if (!Tab.supMenu || tableId !== Tab.supMenu) return + + this.setState({BData: data, BID: id}) + + if (id !== this.state.BID) { + MKEmitter.emit('resetTable', this.props.Tab.uuid) // 鍒楄〃閲嶇疆 + this.setState({ + pageIndex: 1 + }, () => { + this.loadData() + }) + } + } + UNSAFE_componentWillMount() { // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁 this.loadconfig() } - shouldComponentUpdate (nextProps, nextState) { // handleTableId 鍑芥暟鍒ゆ柇鏃朵笉鐩哥瓑 - return !is(fromJS({...this.props, handleTableId: ''}), fromJS({...nextProps, handleTableId: ''})) || !is(fromJS(this.state), fromJS(nextState)) + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.state), fromJS(nextState)) } componentDidMount () { MKEmitter.addListener('reloadData', this.reloadData) + MKEmitter.addListener('changeTableLine', this.changeTableLine) MKEmitter.addListener('queryModuleParam', this.queryModuleParam) MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) } @@ -951,18 +955,19 @@ return } MKEmitter.removeListener('reloadData', this.reloadData) + MKEmitter.removeListener('changeTableLine', this.changeTableLine) MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) } render() { - const { config, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, chartId, selectedData } = this.state + const { config, BID, BData, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, chartId, selectedData } = this.state return ( <div className="subtable" id={'subtable' + this.props.MenuID}> {loadingview && <Spin />} {searchlist && searchlist.length ? - <SubSearch BID={this.props.BID} setting={setting} searchlist={searchlist} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null + <SubSearch BID={BID} setting={setting} searchlist={searchlist} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null } {config ? <Row className="chart-view" gutter={16}> {/* 瑙嗗浘缁� */} @@ -979,12 +984,12 @@ {config.charts.length > 1 ? <p className="chart-table chart-title">{item.title}</p> : null} <div className="sub-action"> <SubAction + BID={BID} + BData={BData} setting={setting} actions={actions} columns={columns} Tab={this.props.Tab} - BID={this.props.BID} - BData={this.props.BData} MenuID={this.props.MenuID} selectedData={selectedData} ContainerId={this.props.ContainerId} @@ -995,6 +1000,7 @@ <Switch title="鏀惰捣" className="subtable-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" checked={pickup} onChange={this.pickupChange} /> : null } <SubTable + BData={BData} tableId={this.props.Tab.uuid} pickup={pickup} setting={setting} @@ -1002,14 +1008,12 @@ pageSize={pageSize} dict={this.state.dict} data={this.state.data} - BData={this.props.BData} total={this.state.total} MenuID={this.props.MenuID} loading={this.state.loading} statFValue={this.state.statFValue} ContainerId={this.props.ContainerId} refreshdata={this.refreshbytable} - handleTableId={this.handleTableId} chgSelectData={this.changeSelectedData} /> </div> @@ -1019,17 +1023,17 @@ return ( <Col className="card-view" span={item.width} key={item.uuid}> <CardComponent + BID={BID} plot={item} + BData={BData} config={config} columns={columns} Tab={this.props.Tab} - BID={this.props.BID} - BData={this.props.BData} data={this.state.data} MenuID={this.props.MenuID} loading={this.state.loading} tableId={this.props.Tab.uuid} - handleTableId={this.handleTableId} + ContainerId={this.props.ContainerId} /> </Col> ) @@ -1037,9 +1041,9 @@ return ( <Col span={item.width} key={item.uuid}> <ChartComponent + BID={BID} plot={item} config={config} - BID={this.props.BID} Tab={this.props.Tab} data={this.state.data} loading={this.state.loading} diff --git a/src/tabviews/subtabtable/index.jsx b/src/tabviews/subtabtable/index.jsx index c7b66d1..42a3497 100644 --- a/src/tabviews/subtabtable/index.jsx +++ b/src/tabviews/subtabtable/index.jsx @@ -2,7 +2,7 @@ import PropTypes from 'prop-types' import {connect} from 'react-redux' import { is, fromJS } from 'immutable' -import { notification, Spin, Col, Row, Icon, Tabs} from 'antd' +import { notification, Spin} from 'antd' import Api from '@/api' import zhCN from '@/locales/zh-CN/main.js' @@ -10,7 +10,7 @@ import Utils from '@/utils/utils.js' import options from '@/store/options.js' import UtilsDM from '@/utils/utils-datamanage.js' -import { updateSubTable } from '@/utils/utils-update.js' +import { updateSubTabTable } from '@/utils/utils-update.js' import asyncComponent from '@/utils/asyncComponent' import asyncSpinComponent from '@/utils/asyncSpinComponent' import NotFount from '@/components/404' @@ -18,12 +18,9 @@ import './index.scss' -const { TabPane } = Tabs const SubSearch = asyncComponent(() => import('@/tabviews/zshare/topSearch')) const SubAction = asyncComponent(() => import('@/tabviews/zshare/actionList')) const SubTable = asyncSpinComponent(() => import('@/tabviews/zshare/normalTable')) -const CardComponent = asyncSpinComponent(() => import('@/tabviews/zshare/cardcomponent')) -const ChartComponent = asyncSpinComponent(() => import('@/tabviews/zshare/chartcomponent')) class SubTabModalTable extends Component { static propTpyes = { @@ -54,7 +51,6 @@ pageSize: 10, // 姣忛〉鏁版嵁鏉℃暟 orderBy: '', // 鎺掑簭 search: '', // 鎼滅储鏉′欢鏁扮粍锛屼娇鐢ㄦ椂闇�鍒嗗満鏅鐞� - chartId: '', // 灞曞紑鍥捐〃ID statFields: [], // 鍚堣瀛楁 statFValue: [], // 鍚堣鍊� absFields: [], // 缁濆鍊煎瓧娈� @@ -112,7 +108,7 @@ let absFields = [] // 缁濆鍊煎瓧娈� // 鐗堟湰鍏煎 - config = updateSubTable(config) + config = updateSubTabTable(config) // 涓嶆敮鎸乫uncbutton銆乸opview 绫诲瀷鎸夐挳 let labels = [] @@ -157,19 +153,6 @@ return col }) - - // 瑙嗗浘鏉冮檺 - config.charts = config.charts.filter(item => { - if (item.Hide === 'true') return false - if (!item.blacklist || item.blacklist.length === 0) return true - return item.blacklist.filter(v => roleId.indexOf(v) > -1).length === 0 - }) - - if (config.charts.length <= 1) { - config.expand = true - } - - let chartId = config.charts[0] ? config.charts[0].uuid : '' // 1銆佺瓫閫夊瓧娈甸泦锛�2銆佽繃婊ら殣钘忓垪鍙婂悎骞跺垪涓殑瀛楁uuid config.columns.forEach(col => { @@ -302,7 +285,6 @@ this.setState({ loadingview: false, - chartId, config, absFields, statFields, @@ -496,8 +478,8 @@ param = UtilsDM.getCallBackQueryParams(setting, sql, errSql) - if (this.state.BID) { - param.BID = this.state.BID + if (this.props.BID) { + param.BID = this.props.BID } if (this.props.menuType === 'HS') { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉 @@ -665,7 +647,7 @@ * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃� */ refreshbysearch = (searches) => { - MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.Tab.uuid) // 鍒楄〃閲嶇疆 this.setState({ pageIndex: 1, search: searches @@ -700,14 +682,14 @@ */ reloadtable = (btn) => { if (!btn || btn.resetPageIndex !== 'false') { - MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.Tab.uuid) // 鍒楄〃閲嶇疆 this.setState({ pageIndex: 1 }, () => { this.loadData() }) } else { - MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid, 'false') // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.Tab.uuid, 'false') // 鍒楄〃閲嶇疆 this.loadData() } @@ -757,13 +739,6 @@ MKEmitter.emit('refreshPopButton', this.props.Tab.uuid) } - /** - * @description 鍥捐〃瑙嗗浘鍒囨崲 - */ - changeChart = (uuid) => { - this.setState({chartId: uuid}) - } - UNSAFE_componentWillMount () { // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁 this.loadconfig() @@ -790,7 +765,7 @@ } render() { - const { config, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, chartId, selectedData } = this.state + const { config, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, selectedData } = this.state return ( <div className="subtabtable" id={'subtabtable' + this.props.MenuID}> @@ -798,80 +773,33 @@ {searchlist && searchlist.length ? <SubSearch BID={this.props.BID} setting={setting} searchlist={searchlist} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null } - {config ? <Row className="chart-view" gutter={16}> - {/* 瑙嗗浘缁� */} - {!config.expand ? <Tabs activeKey={chartId} onChange={this.changeChart}> - {config.charts.map(item => ( - <TabPane tab={<Icon type={item.icon} />} key={item.uuid}></TabPane> - ))} - </Tabs> : null} - {config.charts.map(item => { - if (!config.expand && chartId !== item.uuid) return null - - if (item.chartType === 'table') { - return ( - <Col span={item.width || 24} key={item.uuid}> - {config.charts.length > 1 ? <p className="chart-table chart-title">{item.title}</p> : null} - <div style={{minHeight: '25px'}}> - <SubAction - setting={setting} - actions={actions} - columns={columns} - BID={this.props.BID} - dict={this.state.dict} - BData={this.props.BData} - selectedData={selectedData} - MenuID={this.props.SupMenuID} - /> - </div> - <SubTable - tableId={this.props.Tab.uuid} - setting={setting} - columns={columns} - pageSize={pageSize} - data={this.state.data} - dict={this.state.dict} - BData={this.props.BData} - total={this.state.total} - MenuID={this.props.MenuID} - loading={this.state.loading} - refreshdata={this.refreshbytable} - statFValue={this.state.statFValue} - chgSelectData={this.changeSelectedData} - handleTableId={() => {}} - /> - </Col> - ) - } else if (item.chartType === 'card') { - return ( - <Col className="card-view" span={item.width} key={item.uuid}> - <CardComponent - tableId="" - plot={item} - config={config} - columns={columns} - BID={this.props.BID} - data={this.state.data} - BData={this.props.BData} - loading={this.state.loading} - handleTableId={() => {}} - /> - </Col> - ) - } else { - return ( - <Col span={item.width} key={item.uuid}> - <ChartComponent - plot={item} - config={config} - data={this.state.data} - loading={this.state.loading} - /> - </Col> - ) - } - })} - </Row> : null } + {config ? <div style={{minHeight: '25px'}}> + <SubAction + setting={setting} + actions={actions} + columns={columns} + BID={this.props.BID} + dict={this.state.dict} + BData={this.props.BData} + selectedData={selectedData} + MenuID={this.props.SupMenuID} + /> + </div> : null} + {config ? <SubTable + tableId={this.props.Tab.uuid} + setting={setting} + columns={columns} + pageSize={pageSize} + data={this.state.data} + dict={this.state.dict} + BData={this.props.BData} + total={this.state.total} + MenuID={this.props.MenuID} + loading={this.state.loading} + refreshdata={this.refreshbytable} + statFValue={this.state.statFValue} + chgSelectData={this.changeSelectedData} + /> : null} {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} </div> ) diff --git a/src/tabviews/treepage/index.jsx b/src/tabviews/treepage/index.jsx index c5ef22b..b80863d 100644 --- a/src/tabviews/treepage/index.jsx +++ b/src/tabviews/treepage/index.jsx @@ -56,11 +56,11 @@ * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 */ async loadconfig () { - const { permAction, param, MenuName } = this.props + const { permAction, param, MenuName, MenuID } = this.props let _param = { func: 'sPC_Get_LongParam', - MenuID: this.props.MenuID + MenuID: MenuID } let result = await Api.getCacheConfig(_param) @@ -70,7 +70,7 @@ try { // 閰嶇疆淇℃伅瑙f瀽 config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) - config.MenuID = this.props.MenuID + config.MenuID = MenuID config.MenuName = MenuName config.setting.$name = MenuName } catch (e) { @@ -116,6 +116,9 @@ group.sublist = group.sublist.filter(tab => { if (tab.supMenu === 'mainTable' || (!tab.supMenu && tab.level === 0)) { tab.isTreeNode = true + } + if (tab.supMenu === 'mainTable') { + tab.supMenu = MenuID } return permAction[tab.linkTab]} ) @@ -408,7 +411,7 @@ } selectTreeNode = (selectedKeys, {selected, node}) => { - const { config } = this.state + const { config, ContainerId } = this.state let _expandedKeys = fromJS(this.state.expandedKeys).toJS() let _data = fromJS(node.props.dataRef).toJS() @@ -434,7 +437,9 @@ }) delete _data.children - this.handleTableId('mainTable', _data.key, _data) + + MKEmitter.emit('changeTableLine', ContainerId, this.props.MenuID, _data.key, _data) + this.setState({ tabgroups: _tabgroups, expandedKeys: _expandedKeys, @@ -469,21 +474,6 @@ }) } - /** - * @description 琛ㄦ牸Id鍙樺寲 - */ - handleTableId = (type, id, data) => { - const { BIDs } = this.state - - this.setState({ - BIDs: { - ...BIDs, - [type]: id, - [type + 'data']: data - } - }) - } - reloadData = (menuId) => { const { MenuID } = this.props @@ -508,6 +498,14 @@ this.setShortcut() } + changeTableLine = (ContainerId, tableId, id, data) => { + if (this.state.ContainerId !== ContainerId) return + + this.setState({ + BIDs: {...this.state.BIDs, [tableId]: id, [tableId + 'data']: data} + }) + } + UNSAFE_componentWillMount () { // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁 this.loadconfig() @@ -521,6 +519,7 @@ MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('reloadMenuView', this.reloadMenuView) MKEmitter.addListener('resetActiveMenu', this.resetActiveMenu) + MKEmitter.addListener('changeTableLine', this.changeTableLine) } /** @@ -534,6 +533,7 @@ MKEmitter.removeListener('reloadData', this.reloadData) MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) MKEmitter.removeListener('resetActiveMenu', this.resetActiveMenu) + MKEmitter.removeListener('changeTableLine', this.changeTableLine) } changeExpandedKeys = (expandedKeys) => { @@ -622,7 +622,6 @@ ContainerId={this.state.ContainerId} BID={this.state.BIDs[_tab.supMenu] || ''} BData={this.state.BIDs[_tab.supMenu + 'data'] || ''} - handleTableId={this.handleTableId} /> : null} </TabPane> ) diff --git a/src/tabviews/verupmanage/config.jsx b/src/tabviews/verupmanage/config.jsx index c18bf14..32add62 100644 --- a/src/tabviews/verupmanage/config.jsx +++ b/src/tabviews/verupmanage/config.jsx @@ -47,8 +47,8 @@ ], gridBtn: {display: false}, tabs:[ - {label:'鑴氭湰',type:'SubTable',linkTab:'15839835082267ac69e4gm0ig6ac00ob',icon:'',supMenu:'mainTable',equalTab:[],uuid:'1583979660949hguu6ildhut1ig5mco1'}, - {label:'宸叉墽琛�',type:'SubTable',linkTab:'1583984646423lo60vt7snppb55lslbt',icon:'',supMenu:'mainTable',equalTab:[],uuid:'1583984632864kedhlvu7l31us7pkmbq'} + {label:'鑴氭湰',type:'SubTable',linkTab:'15839835082267ac69e4gm0ig6ac00ob',icon:'',supMenu:'1583979633842550imkchl4qt4qppsiv'/* mainTable */,equalTab:[],uuid:'1583979660949hguu6ildhut1ig5mco1'}, + {label:'宸叉墽琛�',type:'SubTable',linkTab:'1583984646423lo60vt7snppb55lslbt',icon:'',supMenu:'1583979633842550imkchl4qt4qppsiv'/* mainTable */,equalTab:[],uuid:'1583984632864kedhlvu7l31us7pkmbq'} ] } diff --git a/src/tabviews/verupmanage/index.jsx b/src/tabviews/verupmanage/index.jsx index 8aa29d5..57d29bb 100644 --- a/src/tabviews/verupmanage/index.jsx +++ b/src/tabviews/verupmanage/index.jsx @@ -127,7 +127,7 @@ * @description 涓昏〃鏁版嵁鍔犺浇 */ async loadmaindata () { - const { setting, BIDs } = this.state + const { setting, ContainerId } = this.state let param = '' if (setting.interType !== 'inner' || (setting.interType === 'inner' && setting.innerFunc)) { @@ -141,7 +141,7 @@ pickup: false }) - this.handleTableId('mainTable', '', '') + MKEmitter.emit('changeTableLine', ContainerId, this.props.MenuID, '', '') if (!param) { // 鏈幏鍙栧弬鏁版椂锛屼笉鍙戣姹� return @@ -157,10 +157,7 @@ }), total: result.total, loading: false, - BIDs: { - ...BIDs, - mainTable: '' - } + BIDs: {[this.props.MenuID] : ''} }) } else { this.setState({ @@ -283,7 +280,7 @@ * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃� */ refreshbysearch = (searches) => { - MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.MenuID) // 鍒楄〃閲嶇疆 this.setState({ loading: true, pageIndex: 1, @@ -319,7 +316,7 @@ * @description 琛ㄦ牸鍒锋柊 */ reloadtable = () => { - MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.MenuID) // 鍒楄〃閲嶇疆 this.setState({ pageIndex: 1, loading: true @@ -332,7 +329,7 @@ * @description 椤甸潰鍒锋柊锛岄噸鏂拌幏鍙栭厤缃� */ reloadview = () => { - MKEmitter.emit('resetTable', this.props.MenuID + 'mainTable') // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.MenuID) // 鍒楄〃閲嶇疆 this.setState({ config: {}, searchlist: [], @@ -400,21 +397,6 @@ changeSelectedData = (selectedData) => { this.setState({selectedData}) } - - /** - * @description 琛ㄦ牸Id鍙樺寲 - */ - handleTableId = (type, id, data) => { - const { BIDs } = this.state - - this.setState({ - BIDs: { - ...BIDs, - [type]: id, - [type + 'data']: data - } - }) - } /** * @description 鏁版嵁灞曞紑鍚堝苟鍒囨崲 @@ -434,6 +416,14 @@ this.reloadview() } + changeTableLine = (ContainerId, tableId, id, data) => { + if (this.state.ContainerId !== ContainerId) return + + this.setState({ + BIDs: {...this.state.BIDs, [tableId]: id, [tableId + 'data']: data} + }) + } + UNSAFE_componentWillMount () { // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁 this.loadconfig() @@ -445,6 +435,7 @@ componentDidMount () { MKEmitter.addListener('reloadMenuView', this.reloadMenuView) + MKEmitter.addListener('changeTableLine', this.changeTableLine) } /** @@ -455,6 +446,7 @@ return } MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) + MKEmitter.removeListener('changeTableLine', this.changeTableLine) } render() { @@ -482,7 +474,7 @@ </div> : null } <MainTable - tableId="mainTable" + tableId={this.props.MenuID} pickup={pickup} setting={setting} columns={columns} @@ -493,7 +485,7 @@ loading={this.state.loading} refreshdata={this.refreshbytable} buttonTrigger={() => {}} - handleTableId={this.handleTableId} + ContainerId={this.state.ContainerId} chgSelectData={this.changeSelectedData} /> </div> @@ -514,7 +506,6 @@ 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)} /> </TabPane> diff --git a/src/tabviews/verupmanage/subtabtable/index.jsx b/src/tabviews/verupmanage/subtabtable/index.jsx index f33788b..d33454c 100644 --- a/src/tabviews/verupmanage/subtabtable/index.jsx +++ b/src/tabviews/verupmanage/subtabtable/index.jsx @@ -29,7 +29,6 @@ MenuID: PropTypes.string, // 鑿滃崟Id SupMenuID: PropTypes.string, // 涓婄骇鑿滃崟Id ContainerId: PropTypes.any, // 涓夌骇鑿滃崟Container(html) ID - handleTableId: PropTypes.func, // 鎺у埗琛ㄦ牸鏁版嵁鍒囨崲鏃讹紝鏇存柊鍦ㄤ富琛ㄤ腑鐨刬d handleMainTable: PropTypes.func, // 鍒锋柊涓昏〃 refreshtabs:PropTypes.any } @@ -54,22 +53,15 @@ popData: false, // 寮规椤甸潰锛屾墍閫夌殑琛ㄦ牸鏁版嵁 visible: false, // 寮规鏄剧ず闅愯棌鎺у埗 pickup: false, // 瀛愯〃鏁版嵁闅愯棌鏄剧ず鍒囨崲 + BID: '', + BData: '' } /** * @description 涓婄骇鑿滃崟id鍙樺寲鏃讹紝鍒锋柊鏁版嵁 */ UNSAFE_componentWillReceiveProps(nextProps) { - if (this.state.config && this.props.Tab.supMenu && !is(fromJS(this.props.BID), fromJS(nextProps.BID))) { - this.setState({ - pageIndex: 1, - selectedData: [] - }, () => { - MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 鍒楄〃閲嶇疆 - this.loadmaindata(nextProps.BID, 'refresh') - }) - } else if (this.state.config && nextProps.refreshtabs && nextProps.refreshtabs.includes(this.props.Tab.uuid)) { - + if (this.state.config && nextProps.refreshtabs && nextProps.refreshtabs.includes(this.props.Tab.uuid)) { this.reloadtable() } } @@ -78,7 +70,7 @@ * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 */ async loadconfig () { - const { Tab, BID } = this.props + const { Tab, BID, BData } = this.props let config = tabConfig[this.props.MenuID] @@ -127,6 +119,8 @@ } this.setState({ + BID: BID || '', + BData: BData || '', config: config, setting: config.setting, searchlist: config.search, @@ -152,14 +146,12 @@ /** * @description 瀛愯〃鏁版嵁鍔犺浇 */ - async loadmaindata (bid, type) { - const { setting } = this.state + async loadmaindata (type) { + const { setting, BID } = this.state let param = '' - let _BID = this.props.BID if (type === 'refresh') { - _BID = bid - if (!bid) { // 涓昏〃ID涓嶅瓨鍦ㄦ椂锛屼笉鏌ヨ瀛愯〃 + if (!BID) { // 涓昏〃ID涓嶅瓨鍦ㄦ椂锛屼笉鏌ヨ瀛愯〃 this.setState({ data: [], total: 0, @@ -171,12 +163,10 @@ } if (setting.interType === 'system') { - param = this.getDefaultParam(_BID) + param = this.getDefaultParam(BID) } else { - param = this.getCustomParam(_BID) + param = this.getCustomParam(BID) } - - this.handleTableId() let result = await Api.genericInterface(param) if (result.status) { @@ -184,7 +174,7 @@ data: result.data.map((item, index) => { item.key = index item.$$uuid = item[setting.primaryKey] || '' - item.$$BID = _BID || '' + item.$$BID = BID || '' return item }), total: result.total, @@ -304,7 +294,7 @@ * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃� */ refreshbysearch = (searches) => { - MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.Tab.uuid) // 鍒楄〃閲嶇疆 this.setState({ loading: true, pageIndex: 1, @@ -342,7 +332,7 @@ * @description 琛ㄦ牸鍒锋柊 */ reloadtable = () => { - MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 鍒楄〃閲嶇疆 + MKEmitter.emit('resetTable', this.props.Tab.uuid) // 鍒楄〃閲嶇疆 this.setState({ loading: true, pageIndex: 1, @@ -404,13 +394,6 @@ } /** - * @description 琛ㄦ牸Id鍙樺寲 - */ - handleTableId = (type = this.props.Tab.uuid, id = '', data = '') => { - this.props.handleTableId(type, id, data) - } - - /** * @description 鏁版嵁灞曞紑鍚堝苟鍒囨崲 */ pickupChange = () => { @@ -421,13 +404,35 @@ }) } + changeTableLine = (ContainerId, tableId, id, data) => { + const { Tab } = this.props + + if (tableId !== Tab.supMenu) return + + this.setState({BData: data, BID: id}) + + if (id !== this.state.BID) { + MKEmitter.emit('resetTable', this.props.Tab.uuid) // 鍒楄〃閲嶇疆 + this.setState({ + pageIndex: 1, + selectedData: [] + }, () => { + this.loadmaindata('refresh') + }) + } + } + UNSAFE_componentWillMount() { // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁 this.loadconfig() } + componentDidMount () { + MKEmitter.addListener('changeTableLine', this.changeTableLine) + } + shouldComponentUpdate (nextProps, nextState) { // handleMainTable 鍑芥暟鍒ゆ柇鏃朵笉鐩哥瓑 - return !is(fromJS({...this.props, handleMainTable: '', handleTableId: ''}), fromJS({...nextProps, handleMainTable: '', handleTableId: ''})) || !is(fromJS(this.state), fromJS(nextState)) + return !is(fromJS(this.state), fromJS(nextState)) } /** @@ -437,10 +442,11 @@ this.setState = () => { return } + MKEmitter.removeListener('changeTableLine', this.changeTableLine) } render() { - const { setting, searchlist, actions, columns, pickup, selectedData } = this.state + const { BID, BData, setting, searchlist, actions, columns, pickup, selectedData } = this.state return ( <div className="verup-subtable" id={'subtable' + this.props.MenuID}> @@ -451,12 +457,12 @@ <div className="sub-action"> <SubAction type="sub" + BID={BID} + BData={BData} setting={setting} actions={actions} columns={columns} Tab={this.props.Tab} - BID={this.props.BID} - BData={this.props.BData} dict={this.state.dict} selectedData={selectedData} MenuID={this.props.SupMenuID} @@ -482,7 +488,6 @@ loading={this.state.loading} refreshdata={this.refreshbytable} buttonTrigger={() => {}} - handleTableId={this.handleTableId} chgSelectData={this.changeSelectedData} /> </div> : null diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx index 0a9d684..5a6deb4 100644 --- a/src/tabviews/zshare/actionList/normalbutton/index.jsx +++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx @@ -43,7 +43,8 @@ loading: false, loadingNumber: '', disabled: false, - checkParam: null + checkParam: null, + autoMatic: false } moduleParams = null @@ -68,13 +69,17 @@ } componentDidMount () { - const { position } = this.props + const { position, btn } = this.props MKEmitter.addListener('triggerBtnId', this.actionTrigger) if (position === 'form') { MKEmitter.addListener('triggerFormSubmit', this.actionSubmit) } MKEmitter.addListener('returnModuleParam', this.resetModuleParam) + + if (btn.autoMatic) { + MKEmitter.addListener('triggerBtnPopSubmit', this.triggerBtnPopSubmit) + } } UNSAFE_componentWillReceiveProps (nextProps) { @@ -102,6 +107,15 @@ MKEmitter.removeListener('triggerBtnId', this.actionTrigger) MKEmitter.removeListener('triggerFormSubmit', this.actionSubmit) MKEmitter.removeListener('returnModuleParam', this.resetModuleParam) + MKEmitter.removeListener('triggerBtnPopSubmit', this.triggerBtnPopSubmit) + } + + triggerBtnPopSubmit = (id) => { + const { btn } = this.props + + if (btn.uuid !== id) return + + this.handleOk() } actionSubmit = (res) => { @@ -154,6 +168,8 @@ return } } + + this.setState({autoMatic: type === 'autoMatic'}) let _this = this let data = record || selectedData || [] @@ -1344,9 +1360,9 @@ */ execSuccess = (res) => { const { btn } = this.props - const { btnconfig } = this.state + const { btnconfig, autoMatic } = this.state - if (res && res.ErrCode === 'S') { // 鎵ц鎴愬姛 + if ((res && res.ErrCode === 'S') || autoMatic) { // 鎵ц鎴愬姛 notification.success({ top: 92, message: res.ErrMesg || this.state.dict['main.action.confirm.success'], @@ -1360,7 +1376,14 @@ } - if (btn.OpenType !== 'pop' || !btnconfig || btnconfig.setting.finish !== 'unclose') { + if (autoMatic) { + this.setState({ + loading: false, + visible: false + }) + MKEmitter.emit('autoExecOver', btn.uuid, 'success') + return + } else if (btn.OpenType !== 'pop' || !btnconfig || btnconfig.setting.finish !== 'unclose') { this.setState({ loading: false, visible: false @@ -1526,13 +1549,13 @@ */ execError = (res) => { const { btn } = this.props - const { btnconfig } = this.state + const { btnconfig, autoMatic } = this.state - if (res.ErrCode === 'E') { + if (res.ErrCode === 'E' && !autoMatic) { Modal.error({ title: res.message || res.ErrMesg, }) - } else if (res.ErrCode === 'N') { + } else if (res.ErrCode === 'N' || autoMatic) { notification.error({ top: 92, message: res.message || res.ErrMesg, @@ -1547,6 +1570,16 @@ }) } else if (res.ErrCode === 'NM') { message.error(res.message || res.ErrMesg) + } + + if (autoMatic) { + this.setState({ + loading: false, + loadingNumber: '', + visible: false + }) + MKEmitter.emit('autoExecOver', btn.uuid, 'error') + return } this.setState({ @@ -1644,10 +1677,10 @@ */ improveAction = () => { const { btn } = this.props - const { btnconfig } = this.state + const { btnconfig, autoMatic } = this.state if (btnconfig) { - if (btnconfig.setting.display === 'prompt') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず + if (!autoMatic && btnconfig.setting.display === 'prompt') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず this.modelconfirm() } else { this.setState({ @@ -1691,7 +1724,7 @@ this.setState({ btnconfig: _LongParam }, () => { - if (_LongParam.setting.display === 'prompt') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず + if (!autoMatic && _LongParam.setting.display === 'prompt') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず this.modelconfirm() } else { this.setState({ @@ -1708,6 +1741,7 @@ * @description 妯℃�佹锛堣〃鍗曪級锛岀‘璁� */ handleOk = () => { + if (!this.formRef) return this.formRef.handleConfirm().then(res => { this.setState({ confirmLoading: true }) diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx index ef3fe55..2c0f0f3 100644 --- a/src/tabviews/zshare/actionList/printbutton/index.jsx +++ b/src/tabviews/zshare/actionList/printbutton/index.jsx @@ -41,7 +41,8 @@ btnconfig: null, loading: false, disabled: false, - loadingNumber: '' + loadingNumber: '', + autoMatic: false } UNSAFE_componentWillMount () { @@ -64,7 +65,13 @@ } componentDidMount () { + const { btn } = this.props + MKEmitter.addListener('triggerBtnId', this.actionTrigger) + + if (btn.autoMatic) { + MKEmitter.addListener('triggerBtnPopSubmit', this.triggerBtnPopSubmit) + } } UNSAFE_componentWillReceiveProps (nextProps) { @@ -90,6 +97,15 @@ return } MKEmitter.removeListener('triggerBtnId', this.actionTrigger) + MKEmitter.removeListener('triggerBtnPopSubmit', this.triggerBtnPopSubmit) + } + + triggerBtnPopSubmit = (id) => { + const { btn } = this.props + + if (btn.uuid !== id) return + + this.handleOk() } /** @@ -113,6 +129,8 @@ return } } + + this.setState({autoMatic: type === 'autoMatic'}) let _this = this let data = record || selectedData || [] @@ -1206,8 +1224,9 @@ */ execSuccess = (res) => { const { btn } = this.props + const { autoMatic } = this.state - if (res && res.ErrCode === 'S') { // 鎵ц鎴愬姛 + if ((res && res.ErrCode === 'S') || autoMatic) { // 鎵ц鎴愬姛 notification.success({ top: 92, message: res.ErrMesg || this.state.dict['main.action.confirm.success'], @@ -1220,10 +1239,15 @@ } else if (res && res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず } - + this.setState({ loading: false }) + + if (autoMatic) { + MKEmitter.emit('autoExecOver', btn.uuid, 'success') + return + } if (btn.execSuccess !== 'never') { MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn) @@ -1238,13 +1262,13 @@ */ execError = (res) => { const { btn } = this.props - const { btnconfig } = this.state + const { btnconfig, autoMatic } = this.state - if (res.ErrCode === 'E') { + if (res.ErrCode === 'E' && !autoMatic) { Modal.error({ title: res.message || res.ErrMesg, }) - } else if (res.ErrCode === 'N') { + } else if (res.ErrCode === 'N' || autoMatic) { notification.error({ top: 92, message: res.message || res.ErrMesg, @@ -1264,6 +1288,11 @@ this.setState({ loading: false }) + + if (autoMatic) { + MKEmitter.emit('autoExecOver', btn.uuid, 'error') + return + } if (btnconfig && btnconfig.setting && btnconfig.setting.errFocus) { MKEmitter.emit('mkFC', 'focus', btnconfig.setting.errFocus) @@ -1313,10 +1342,10 @@ */ improveAction = () => { const { btn } = this.props - const { btnconfig } = this.state + const { btnconfig, autoMatic } = this.state if (btnconfig) { - if (btnconfig.setting.display === 'prompt') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず + if (!autoMatic && btnconfig.setting.display === 'prompt') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず this.modelconfirm() } else { this.setState({ @@ -1360,7 +1389,7 @@ this.setState({ btnconfig: _LongParam }, () => { - if (_LongParam.setting.display === 'prompt') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず + if (!autoMatic && _LongParam.setting.display === 'prompt') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず this.modelconfirm() } else { this.setState({ @@ -1377,9 +1406,12 @@ * @description 妯℃�佹锛堣〃鍗曪級锛岀‘璁� */ handleOk = () => { - const { btnconfig } = this.state + const { btnconfig, autoMatic } = this.state + + if (!this.formRef) return + this.formRef.handleConfirm().then(res => { - if (btnconfig.setting.finish !== 'unclose') { + if (btnconfig.setting.finish !== 'unclose' || autoMatic) { this.setState({ visible: false }) diff --git a/src/tabviews/zshare/automatic/index.jsx b/src/tabviews/zshare/automatic/index.jsx index e89a1b0..717528c 100644 --- a/src/tabviews/zshare/automatic/index.jsx +++ b/src/tabviews/zshare/automatic/index.jsx @@ -3,7 +3,7 @@ import { is, fromJS } from 'immutable' import { Button } from 'antd' -// import MKEmitter from '@/utils/events.js' +import MKEmitter from '@/utils/events.js' import './index.scss' class AutoMatic extends Component { @@ -14,7 +14,18 @@ state = { running: false, - line: 0 + line: 1, + init: true + } + + timer = null + + componentDidMount () { + MKEmitter.addListener('autoGetData', this.autoGetData) + MKEmitter.addListener('autoExecOver', this.autoExecOver) + MKEmitter.addListener('autoMaticOver', this.autoMaticOver) + MKEmitter.addListener('autoMaticError', this.autoMaticError) + MKEmitter.addListener('autoTransSelectData', this.autoTransSelectData) } shouldComponentUpdate (nextProps, nextState) { @@ -28,15 +39,119 @@ this.setState = () => { return } + MKEmitter.removeListener('autoGetData', this.autoGetData) + MKEmitter.removeListener('autoExecOver', this.autoExecOver) + MKEmitter.removeListener('autoMaticOver', this.autoMaticOver) + MKEmitter.removeListener('autoMaticError', this.autoMaticError) + MKEmitter.removeListener('autoTransSelectData', this.autoTransSelectData) + } + + autoExecOver = (btnId, type) => { + const { autoMatic, config } = this.props + + if (!this.state.running || btnId !== autoMatic.action) return + + if (type === 'error') { + if (autoMatic.onFail === 'next') { + this.setState({line: this.state.line + 1}, () => { + setTimeout(() => { + MKEmitter.emit('autoQueryData', config.MenuID, this.state.line) + }, 1000) + }) + } else if (autoMatic.onFail === 'stay') { + setTimeout(() => { + MKEmitter.emit('autoQueryData', config.MenuID, this.state.line) + }, 1000) + } else { + this.setState({running: false}) + } + } else { + if (autoMatic.onSuccess === 'next') { + this.setState({line: this.state.line + 1}, () => { + setTimeout(() => { + MKEmitter.emit('autoQueryData', config.MenuID, this.state.line) + }, 1000) + }) + } else if (autoMatic.onSuccess === 'stay') { + setTimeout(() => { + MKEmitter.emit('autoQueryData', config.MenuID, this.state.line) + }, 1000) + } else { + this.setState({running: false}) + } + } + } + + autoTransSelectData = (MenuID, data) => { + const { config, autoMatic } = this.props + + if (!this.state.running || MenuID !== config.MenuID) return + + setTimeout(() => { + MKEmitter.emit('triggerBtnId', autoMatic.action, [data], 'autoMatic') + if (['prompt', 'pop'].includes(autoMatic.OpenType)) { + let delay = this.state.init && autoMatic.OpenType === 'pop' ? 2000 : 200 + + setTimeout(() => { + if (autoMatic.OpenType === 'prompt') { + let node = document.querySelector('.ant-modal-confirm-btns >.ant-btn-primary') + node && node.click() + } else if (autoMatic.OpenType === 'pop') { + MKEmitter.emit('triggerBtnPopSubmit', autoMatic.action) + } + }, delay) + } + }, 100) + } + + autoMaticError = (MenuID) => { + const { config } = this.props + + if (!this.state.running || MenuID !== config.MenuID) return + + this.setState({running: false}) + } + + autoGetData = (MenuID) => { + const { config } = this.props + + if (!this.state.running || MenuID !== config.MenuID) return + setTimeout(() => { + MKEmitter.emit('autoSelectData', config.MenuID, this.state.line) + }, 100) } trigger = () => { - // const { config } = this.props + const { config } = this.props let running = !this.state.running - // MKEmitter.emit('autoQueryData', config.MenuID, 0) + MKEmitter.emit('autoQueryData', config.MenuID, 1) - this.setState({running: running}) + this.setState({running: running, line: 1}) + clearTimeout(this.timer) + } + + autoMaticOver = (MenuID) => { + const { config, autoMatic } = this.props + + if (!this.state.running || MenuID !== config.MenuID) return + + this.setState({running: false}) + + if (autoMatic.onFinish !== 'over') { + let interval = autoMatic.interval * 1000 || 10 + + if (autoMatic.restart === 'first') { + this.setState({line: 1}) + } else { + this.setState({line: this.state.line + 1}) + } + + this.timer = setTimeout(() => { + this.setState({running: true}) + MKEmitter.emit('autoQueryData', config.MenuID, this.state.line) + }, interval) + } } render() { diff --git a/src/tabviews/zshare/cardcomponent/index.jsx b/src/tabviews/zshare/cardcomponent/index.jsx index a689085..df34ca4 100644 --- a/src/tabviews/zshare/cardcomponent/index.jsx +++ b/src/tabviews/zshare/cardcomponent/index.jsx @@ -5,6 +5,7 @@ import asyncComponent from '@/utils/asyncComponent' import asyncExcelComponent from './asyncButtonComponent' +import MKEmitter from '@/utils/events.js' import '@/assets/css/table.scss' import './index.scss' @@ -513,7 +514,6 @@ tableId: PropTypes.string, loading: PropTypes.bool, data: PropTypes.array, - handleTableId: PropTypes.func } state = { @@ -735,7 +735,7 @@ this.setState({selectKey: data.key}) - this.props.handleTableId(this.props.tableId, _id, data) + MKEmitter.emit('changeTableLine', this.props.ContainerId, this.props.tableId, _id, data) } render() { diff --git a/src/tabviews/zshare/normalTable/index.jsx b/src/tabviews/zshare/normalTable/index.jsx index 02a78f8..5c49361 100644 --- a/src/tabviews/zshare/normalTable/index.jsx +++ b/src/tabviews/zshare/normalTable/index.jsx @@ -45,7 +45,6 @@ total: PropTypes.any, // 鎬绘暟 loading: PropTypes.bool, // 琛ㄦ牸鍔犺浇涓� refreshdata: PropTypes.func, // 琛ㄦ牸涓帓搴忓垪銆侀〉鐮佺殑鍙樺寲鏃跺埛鏂� - handleTableId: PropTypes.func, // 鏁版嵁鍒囨崲 chgSelectData: PropTypes.func, // 鏁版嵁鍒囨崲 } @@ -237,6 +236,8 @@ componentDidMount () { MKEmitter.addListener('resetTable', this.resetTable) + MKEmitter.addListener('autoQueryData', this.autoQueryData) + MKEmitter.addListener('autoSelectData', this.autoSelectData) MKEmitter.addListener('mkTableCheckTopLine', this.mkTableCheckTopLine) } @@ -248,6 +249,8 @@ return } MKEmitter.removeListener('resetTable', this.resetTable) + MKEmitter.removeListener('autoQueryData', this.autoQueryData) + MKEmitter.removeListener('autoSelectData', this.autoSelectData) MKEmitter.removeListener('mkTableCheckTopLine', this.mkTableCheckTopLine) } @@ -257,6 +260,43 @@ if (this.props.data.length > 0) { this.changeRow(null, 0) } + } + + autoSelectData = (id, index) => { + if (id !== this.props.MenuID) return + + const { pageSize, pageIndex } = this.state + + let i = index - (pageIndex - 1) * pageSize - 1 + + if (this.props.data[i]) { + this.changeRow(null, i) + MKEmitter.emit('autoTransSelectData', this.props.MenuID, this.props.data[i]) + } else { + MKEmitter.emit('autoMaticOver', this.props.MenuID) + } + } + + autoQueryData = (id, index) => { + if (id !== this.props.MenuID) return + + const { total } = this.props + const { pageSize } = this.state + + if (index !== 1 && (!total || index > total)) { + MKEmitter.emit('autoMaticOver', this.props.MenuID) + return + } + + let pageIndex = Math.ceil(index / pageSize) + + this.setState({ + pageIndex: pageIndex, + selectedRowKeys: [], + activeIndex: null + }) + + this.props.refreshdata({pageIndex}) } // 瀛楁閫忚 @@ -1016,7 +1056,9 @@ } changedata = (index) => { - const { data, setting } = this.props + const { data, setting, tableId, ContainerId } = this.props + + if (!tableId || !ContainerId) return let _id = '' let _data = '' @@ -1026,13 +1068,13 @@ _data = data[index] || '' } - this.props.handleTableId(this.props.tableId, _id, _data) + MKEmitter.emit('changeTableLine', ContainerId, tableId, _id, _data) } resetTable = (id, repage) => { - const { MenuID, tableId } = this.props + const { tableId } = this.props - if (id !== (MenuID + tableId)) return + if (id !== tableId) return if (repage === 'false') { this.setState({ diff --git a/src/utils/utils-update.js b/src/utils/utils-update.js index 2d851a6..18e49e3 100644 --- a/src/utils/utils-update.js +++ b/src/utils/utils-update.js @@ -220,4 +220,42 @@ config.Template = 'SubTable' return config +} + +/** + * @description 鍗囩骇寮圭獥瀛愯〃淇℃伅 + * @param {Object} config 椤甸潰閰嶇疆淇℃伅 + * @return {Object} config + */ +export function updateSubTabTable (config) { + if (!config.version || config.version < '1.1') { + config.version = '1.1' + if (config.setting.interType === 'inner' && !config.setting.innerFunc) { + config.setting.interType = 'system' + } + // 鍏煎鎺ュ彛绫诲瀷 + config.action = config.action.map(item => { + if (item.intertype === 'inner' && !item.innerFunc) { + item.intertype = 'system' + } + return item + }) + } + + if (config.version < '1.2') { + config.version = '1.2' + // 鍏煎鍔熻兘鎸夐挳 + config.action = config.action.map(item => { + if (item.execMode) { + item.OpenType = 'funcbutton' + } else if (item.OpenType === 'blank') { + item.OpenType = 'tab' + } + return item + }) + } + + config.Template = 'SubTable' + + return config } \ No newline at end of file -- Gitblit v1.8.0