From eb31b84962c192de57abbb473cb4733a09bf4363 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 14 五月 2020 18:09:40 +0800 Subject: [PATCH] 2020-05-14 --- src/tabviews/commontable/index.jsx | 123 ++++++++++++++++++----------------------- 1 files changed, 54 insertions(+), 69 deletions(-) diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx index d9c0954..c35d367 100644 --- a/src/tabviews/commontable/index.jsx +++ b/src/tabviews/commontable/index.jsx @@ -72,7 +72,8 @@ revertLoading: false, // 鎭㈠榛樿璁剧疆 settingVisible: false,// 鑷畾涔夎缃ā鎬佹 triggerBtn: null, // 鐐瑰嚮琛ㄦ牸涓垨蹇嵎閿Е鍙戠殑鎸夐挳 - tabActive: null // 鏍囩椤靛睍寮�鎺у埗 + tabActive: null, // 鏍囩椤靛睍寮�鎺у埗 + chartId: '' // 灞曞紑鍥捐〃ID } /** @@ -148,8 +149,9 @@ } // 鍏煎鍥捐〃 + let chartId = '' if (!config.charts) { - config.expand = false + config.expand = true config.charts = [{ uuid: Utils.getuuid(), label: '', @@ -159,7 +161,10 @@ Hide: 'false', blacklist: [] }] + } else if (config.charts.length === 1) { + config.expand = true } + chartId = config.charts[0].uuid // 鏉冮檺杩囨护 config.action = config.action.filter(item => permAction[item.uuid]) @@ -349,6 +354,7 @@ this.setState({ loadingview: false, + chartId: chartId, config: config, tabActive: _tabActive, userConfig: userConfig, @@ -503,6 +509,13 @@ arr_field: _option.field } + if (this.props.dataManager) { // 鏁版嵁鏉冮檺 + param.LText = param.LText.replace(/\$@/ig, '/*') + param.LText = param.LText.replace(/@\$/ig, '*/') + } else { + param.LText = param.LText.replace(/@\$|\$@/ig, '') + } + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' param.secretkey = Utils.encrypt(param.LText, param.timestamp) @@ -634,6 +647,7 @@ let param = { OrderCol: orderBy || setting.order, + dataM: this.props.dataManager ? 'Y' : '', ..._search } @@ -683,7 +697,8 @@ obj_name: 'data', arr_field: arr_field, custom_script: setting.customScript || '', - default_sql: setting.default || 'true' + default_sql: setting.default || 'true', + dataM: this.props.dataManager ? 'Y' : '' } let _orderBy = orderBy || setting.order @@ -691,6 +706,16 @@ if (/\s/.test(_dataresource)) { _dataresource = '(' + _dataresource + ') tb' + } + + if (this.props.dataManager) { // 鏁版嵁鏉冮檺 + _dataresource = _dataresource.replace(/\$@/ig, '/*') + _dataresource = _dataresource.replace(/@\$/ig, '*/') + param.custom_script = param.custom_script.replace(/\$@/ig, '/*') + param.custom_script = param.custom_script.replace(/@\$/ig, '*/') + } else { + _dataresource = _dataresource.replace(/@\$|\$@/ig, '') + param.custom_script = param.custom_script.replace(/@\$|\$@/ig, '') } let regoptions = null @@ -1225,6 +1250,13 @@ }) } + /** + * @description 鍥捐〃瑙嗗浘鍒囨崲 + */ + changeChart = (uuid) => { + this.setState({chartId: uuid}) + } + UNSAFE_componentWillMount () { // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁 this.loadconfig() @@ -1270,7 +1302,7 @@ } render() { - const { view, setting, searchlist, actions, columns, loadingview, viewlost, pickup, config, triggerBtn, userConfig, tabActive, search } = this.state + const { view, setting, searchlist, actions, columns, loadingview, viewlost, pickup, config, triggerBtn, userConfig, tabActive, chartId, search } = this.state return ( <div> @@ -1286,73 +1318,14 @@ } {setting && setting.onload !== 'false' ? <div className="chart-view"> {/* 瑙嗗浘缁� */} - {!config.expand ? <Tabs> + {!config.expand ? <Tabs activeKey={chartId} onChange={this.changeChart}> {config.charts.map(item => ( - <TabPane tab={ - <Icon type={item.icon} /> - } key={item.uuid}> - {item.chartType === 'table' ? - <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'}}> - <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> - <div className="main-table-box"> - <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} - config={config} - setting={setting} - columns={columns} - dict={this.state.dict} - data={this.state.data} - total={this.state.total} - MenuID={this.props.MenuID} - memberLevel={this.props.memberLevel} - loading={this.state.loading} - pagination={setting.laypage !== 'false'} - refreshdata={this.refreshbytable} - buttonTrigger={this.buttonTrigger} - linkTrigger={this.linkTrigger} - handleTableId={this.handleTableId} - /> - </div> - </Col> : null - } - {item.chartType !== 'table' ? - <Col span={item.width} key={item.uuid}> - <ChartComponent - plot={item} - data={this.state.data} - config={config} - /> - </Col> : null - } - </TabPane> + <TabPane tab={<Icon type={item.icon} />} key={item.uuid}></TabPane> ))} </Tabs> : null} - {config.expand && config.charts.map(item => { + {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}> @@ -1368,6 +1341,7 @@ dict={this.state.dict} MenuID={this.props.MenuID} permRoles={this.props.permRoles} + dataManager={this.props.dataManager} logcolumns={this.state.logcolumns} ContainerId={this.state.ContainerId} refreshdata={this.refreshbyaction} @@ -1401,6 +1375,16 @@ handleTableId={this.handleTableId} /> </div> + </Col> + ) + } else if (item.chartType === 'card') { + return ( + <Col span={item.width} key={item.uuid}> + <ChartComponent + plot={item} + data={this.state.data} + config={config} + /> </Col> ) } else { @@ -1545,7 +1529,8 @@ permAction: state.permAction, permMenus: state.permMenus, permRoles: state.permRoles, - memberLevel: state.memberLevel + memberLevel: state.memberLevel, + dataManager: state.dataManager } } -- Gitblit v1.8.0