From cb9ade2afd2a367ad767bc605ab7086c695dd010 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 09 十二月 2022 15:53:32 +0800 Subject: [PATCH] 2022-12-09 --- src/tabviews/subtable/index.jsx | 156 ++++++++++++++++++++++++++++++---------------------- 1 files changed, 90 insertions(+), 66 deletions(-) diff --git a/src/tabviews/subtable/index.jsx b/src/tabviews/subtable/index.jsx index 5f39261..b261601 100644 --- a/src/tabviews/subtable/index.jsx +++ b/src/tabviews/subtable/index.jsx @@ -1,8 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import {connect} from 'react-redux' import { is, fromJS } from 'immutable' -import { notification, Spin, Switch, Row, Col, Tabs} from 'antd' +import { notification, Spin, Switch, Row, Col, Tabs, Modal } from 'antd' import Api from '@/api' import zhCN from '@/locales/zh-CN/main.js' @@ -34,7 +33,6 @@ MenuID: PropTypes.string, // 鑿滃崟Id SupMenuID: PropTypes.string, // 涓婄骇鑿滃崟Id mainSearch: PropTypes.any, // 涓昏〃鎼滅储鏉′欢 - ContainerId: PropTypes.any, // 涓夌骇鑿滃崟Container(html) ID } state = { @@ -46,7 +44,7 @@ searchlist: null, // 鎼滅储鏉′欢 actions: null, // 鎸夐挳闆� columns: null, // 鏄剧ず鍒� - arr_field: '', // 浣跨敤 sPC_Get_TableData 鏃剁殑鏌ヨ瀛楁闆� + arr_field: '', // 鏌ヨ瀛楁闆� setting: null, // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑 data: [], // 鍒楄〃鏁版嵁闆� selectedData: [], // 宸查�夎〃鏍兼暟鎹� @@ -84,7 +82,7 @@ * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 */ async loadconfig () { - const { permAction, permMenus, Tab } = this.props + const { Tab } = this.props let param = { func: 'sPC_Get_LongParam', @@ -98,6 +96,9 @@ config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) config.setting.MenuName = Tab.label config.setting.$name = Tab.label + config.setting.foreignKey = Tab.foreignKey || '' + config.setting.supModule = Tab.supMenu || '' + config.setting.ContainerId = Tab.ContainerId || '' } catch (e) { console.warn('Parse Failure') config = '' @@ -133,9 +134,7 @@ config = updateSubTable(config) // 鏉冮檺杩囨护 - if (this.props.menuType !== 'HS') { - config.action = config.action.filter(item => permAction[item.uuid]) - } + config.action = config.action.filter(item => item.hidden !== 'true') config.search = Utils.initSearchVal(config.search) @@ -158,18 +157,21 @@ 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 = '' + if (config.charts) { + // 瑙嗗浘鏉冮檺 + 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 + } + + chartId = config.charts[0] ? config.charts[0].uuid : '' } - - let chartId = config.charts[0] ? config.charts[0].uuid : '' // 1銆佺瓫閫夊瓧娈甸泦锛�2銆佽繃婊ら殣钘忓垪鍙婂悎骞跺垪涓殑瀛楁uuid config.columns.forEach(col => { @@ -178,9 +180,18 @@ if (col.linkmenu && col.linkmenu.length > 0) { let menu_id = col.linkmenu.slice(-1)[0] - col.linkThdMenu = permMenus.filter(m => m.MenuID === menu_id)[0] || '' + col.linkThdMenu = window.GLOB.mkThdMenus.filter(m => m.MenuID === menu_id)[0] || '' } else { col.linkThdMenu = '' + } + + if (col.type === 'number') { + col.decimal = col.decimal || 0 + col.round = Math.pow(10, col.decimal) + + if (col.format === 'percent') { + col.decimal = col.decimal > 2 ? col.decimal - 2 : 0 + } } col.nameField && _arrField.push(col.nameField) // 閾炬帴鍚嶅瓧娈� @@ -246,6 +257,7 @@ } } if (item.position === 'toolbar') { + item.$toolbtn = true _actions.push(item) } else if (item.position === 'grid') { _operations.push(item) @@ -296,7 +308,6 @@ let userName = sessionStorage.getItem('User_Name') || '' let fullName = sessionStorage.getItem('Full_Name') || '' - let city = sessionStorage.getItem('city') || '' if (sessionStorage.getItem('isEditState') === 'true') { userName = sessionStorage.getItem('CloudUserName') || '' @@ -305,8 +316,7 @@ let regs = [ { reg: /@userName@/ig, value: `'${userName}'` }, - { reg: /@fullName@/ig, value: `'${fullName}'` }, - { reg: /@login_city@/ig, value: `'${city}'` } + { reg: /@fullName@/ig, value: `'${fullName}'` } ] regs.forEach(cell => { @@ -393,7 +403,7 @@ statFValue: [], total: 0 }) - MKEmitter.emit('changeTableLine', this.props.ContainerId, this.props.Tab.uuid, '', '') + MKEmitter.emit('changeTableLine', this.props.Tab.ContainerId, this.props.Tab.uuid, '', '') return } else if (window.GLOB.systemType === 'production' && setting.interType === 'custom' && !setting.proInterface) { notification.warning({ @@ -407,7 +417,7 @@ this.setState({ selectedData: [] }) - MKEmitter.emit('changeTableLine', this.props.ContainerId, this.props.Tab.uuid, '', '') + MKEmitter.emit('changeTableLine', this.props.Tab.ContainerId, this.props.Tab.uuid, '', '') if (setting.interType === 'custom' && loadCustomApi) { if (setting.execTime === 'once') { @@ -426,7 +436,7 @@ loadOutResource = (searches) => { const { setting, BID } = this.state - let param = UtilsDM.getPrevQueryParams(setting, searches, BID, this.props.menuType) + let param = UtilsDM.getPrevQueryParams(setting, searches, BID) if (setting.execType === 'sync') { this.setState({ @@ -540,15 +550,7 @@ `)) sql = sql.join('') - param = UtilsDM.getCallBackQueryParams(setting, sql, errSql) - - if (BID) { - param.BID = BID - } - - if (this.props.menuType === 'HS') { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉 - param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) - } + param = UtilsDM.getCallBackQueryParams(setting, sql, errSql, BID) } else { param.func = 's_ex_result_back' param.s_ex_result = lines.map((item, index) => ({ @@ -607,7 +609,7 @@ }) let _orderBy = orderBy || setting.order - let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, this.props.menuType) + let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID) let result = await Api.genericInterface(param) @@ -662,11 +664,17 @@ loading: false }) - notification.error({ - top: 92, - message: prex + result.message, - duration: 10 - }) + if (result.ErrCode === 'N') { + Modal.error({ + title: prex + result.message, + }) + } else { + notification.error({ + top: 92, + message: prex + result.message, + duration: 10 + }) + } } } @@ -687,7 +695,7 @@ }) let _orderBy = orderBy || setting.order - let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, this.props.menuType, id) + let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, id) let result = await Api.genericInterface(param) if (result.status) { @@ -756,7 +764,7 @@ if (statFields.length === 0 || !(setting.interType === 'system' || (setting.interType === 'custom' && setting.requestMode === 'system')) || !setting.dataresource) return let _orderBy = orderBy || setting.order - let param = UtilsDM.getStatQueryDataParams(setting, statFields, searches, _orderBy, BID, this.props.menuType) + let param = UtilsDM.getStatQueryDataParams(setting, statFields, searches, _orderBy, BID) Api.genericInterface(param).then(res => { if (res.status) { @@ -846,7 +854,7 @@ /** * @description 瀵煎嚭Excel鏃讹紝鑾峰彇椤甸潰鎼滅储鎺掑簭绛夊弬鏁� */ - queryModuleParam = (menuId, btnId) => { + queryModuleParam = (menuId, callback) => { const { Tab, mainSearch, MenuID } = this.props const { arr_field, orderBy, search, setting} = this.state @@ -857,7 +865,7 @@ searches = [...mainSearch, ...search] } - MKEmitter.emit('returnModuleParam', MenuID, btnId, { + callback({ arr_field: arr_field, orderBy: orderBy || setting.order, search: searches, @@ -995,9 +1003,9 @@ <div className="subtable" id={'subtable' + this.props.MenuID}> {loadingview && <Spin />} {searchlist && searchlist.length ? - <SubSearch BID={BID} setting={setting} searchlist={searchlist} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null + <SubSearch BID={BID} setting={setting} searchlist={searchlist} refreshdata={this.refreshbysearch}/> : null } - {config ? <Row className="chart-view" gutter={16}> + {config && config.charts ? <Row className="chart-view" gutter={16}> {/* 瑙嗗浘缁� */} {!config.expand ? <Tabs activeKey={chartId} onChange={this.changeChart}> {config.charts.map(item => ( @@ -1017,10 +1025,8 @@ setting={setting} actions={actions} columns={columns} - Tab={this.props.Tab} MenuID={this.props.MenuID} selectedData={selectedData} - ContainerId={this.props.ContainerId} /> </div> <div className="subtable-box"> @@ -1040,7 +1046,6 @@ MenuID={this.props.MenuID} loading={this.state.loading} statFValue={this.state.statFValue} - ContainerId={this.props.ContainerId} refreshdata={this.refreshbytable} chgSelectData={this.changeSelectedData} /> @@ -1056,12 +1061,10 @@ BData={BData} config={config} columns={columns} - Tab={this.props.Tab} data={this.state.data} MenuID={this.props.MenuID} loading={this.state.loading} tableId={this.props.Tab.uuid} - ContainerId={this.props.ContainerId} /> </Col> ) @@ -1072,7 +1075,6 @@ BID={BID} plot={item} config={config} - Tab={this.props.Tab} data={this.state.data} loading={this.state.loading} /> @@ -1081,22 +1083,44 @@ } })} </Row> : null } + {config && !config.charts ? <> + <div className="sub-action"> + <SubAction + BID={BID} + BData={BData} + setting={setting} + actions={actions} + columns={columns} + MenuID={this.props.MenuID} + selectedData={selectedData} + /> + </div> + <div className="subtable-box"> + {(setting.tableType === 'radio' || setting.tableType === 'checkbox') && this.state.data && this.state.data.length > 0 ? + <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} + columns={columns} + pageSize={pageSize} + dict={this.state.dict} + data={this.state.data} + total={this.state.total} + MenuID={this.props.MenuID} + loading={this.state.loading} + statFValue={this.state.statFValue} + refreshdata={this.refreshbytable} + chgSelectData={this.changeSelectedData} + /> + </div> + </> : null } {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} </div> ) } } -const mapStateToProps = (state) => { - return { - menuType: state.editLevel, - permAction: state.permAction, - permMenus: state.permMenus, - } -} - -const mapDispatchToProps = () => { - return {} -} - -export default connect(mapStateToProps, mapDispatchToProps)(SubTabViewTable) \ No newline at end of file +export default SubTabViewTable \ No newline at end of file -- Gitblit v1.8.0