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/subtabtable/index.jsx |  100 ++++++++++++++++++++-----------------------------
 1 files changed, 41 insertions(+), 59 deletions(-)

diff --git a/src/tabviews/subtabtable/index.jsx b/src/tabviews/subtabtable/index.jsx
index 99f897e..ab920f0 100644
--- a/src/tabviews/subtabtable/index.jsx
+++ b/src/tabviews/subtabtable/index.jsx
@@ -53,7 +53,8 @@
     pageSize: 10,         // 姣忛〉鏁版嵁鏉℃暟
     orderBy: '',          // 鎺掑簭
     search: '',           // 鎼滅储鏉′欢鏁扮粍锛屼娇鐢ㄦ椂闇�鍒嗗満鏅鐞�
-    triggerBtn: null      // 鎸夐挳瑙﹀彂
+    triggerBtn: null,     // 鎸夐挳瑙﹀彂
+    chartId: ''           // 灞曞紑鍥捐〃ID
   }
 
   /**
@@ -103,8 +104,9 @@
       let colMap = new Map()
 
       // 鍏煎鍥捐〃
+      let chartId = ''
       if (!config.charts) {
-        config.expand = false
+        config.expand = true
         config.charts = [{
           uuid: Utils.getuuid(),
           label: '',
@@ -114,7 +116,10 @@
           Hide: 'false',
           blacklist: []
         }]
+      } else if (config.charts.length === 1) {
+        config.expand = true
       }
+      chartId = config.charts[0].uuid
 
       // 浠呮敮鎸乪xec銆乸rompt銆乸op 涓夌绫诲瀷鎸夐挳
       config.action = config.action.filter(item => ['exec', 'prompt', 'pop'].includes(item.OpenType))
@@ -241,6 +246,7 @@
 
       this.setState({
         loadingview: false,
+        chartId: chartId,
         config: config,
         setting: config.setting,
         searchlist: config.search,
@@ -299,6 +305,12 @@
 
         if (this.props.BID) {
           param.BID = this.props.BID
+        }
+        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'
@@ -414,6 +426,7 @@
 
     let param = {
       OrderCol: orderBy || setting.order,
+      dataM: this.props.dataManager ? 'Y' : '',
       ..._search
     }
 
@@ -462,7 +475,8 @@
       arr_field: arr_field,
       BID: this.props.BID,
       custom_script: setting.customScript || '',
-      default_sql: setting.default || 'true'
+      default_sql: setting.default || 'true',
+      dataM: this.props.dataManager ? 'Y' : ''
     }
 
     let _orderBy = orderBy || setting.order
@@ -470,6 +484,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
@@ -647,6 +671,13 @@
     })
   }
 
+  /**
+   * @description 鍥捐〃瑙嗗浘鍒囨崲
+   */
+  changeChart = (uuid) => {
+    this.setState({chartId: uuid})
+  }
+
   UNSAFE_componentWillMount () {
     // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁
     this.loadconfig()
@@ -666,7 +697,7 @@
   }
 
   render() {
-    const { config, setting, searchlist, actions, columns, loadingview, viewlost, triggerBtn } = this.state
+    const { config, setting, searchlist, actions, columns, loadingview, viewlost, triggerBtn, chartId } = this.state
 
     return (
       <div className="subtabtable" id={'subtabtable' + this.props.MenuID}>
@@ -680,65 +711,14 @@
         }
         {config ? <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'}}>
-                      <SubAction
-                        type="subtab"
-                        triggerBtn={triggerBtn}
-                        menuType={this.props.menuType}
-                        setting={setting}
-                        actions={actions}
-                        BID={this.props.BID}
-                        dict={this.state.dict}
-                        BData={this.props.BData}
-                        MenuID={this.props.SupMenuID}
-                        permRoles={this.props.permRoles}
-                        logcolumns={this.state.logcolumns}
-                        refreshdata={this.refreshbyaction}
-                        ContainerId={this.props.ContainerId}
-                        gettableselected={this.gettableselected}
-                      />
-                    </div>
-                    <SubTable
-                      ref="subTable"
-                      menuType={this.props.menuType}
-                      tableId=""
-                      dict={this.state.dict}
-                      MenuID={this.props.MenuID}
-                      config={config}
-                      setting={setting}
-                      columns={columns}
-                      data={this.state.data}
-                      total={this.state.total}
-                      memberLevel={this.props.memberLevel}
-                      loading={this.state.loading}
-                      pagination={setting.laypage !== 'false'}
-                      refreshdata={this.refreshbytable}
-                      buttonTrigger={this.buttonTrigger}
-                      handleTableId={() => {}}
-                    />
-                  </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 => {
+            if (!config.expand && chartId !== item.uuid) return null
+
             if (item.chartType === 'table') {
               return (
                 <Col span={item.width || 24} key={item.uuid}>
@@ -755,6 +735,7 @@
                       BData={this.props.BData}
                       MenuID={this.props.SupMenuID}
                       permRoles={this.props.permRoles}
+                      dataManager={this.props.dataManager}
                       logcolumns={this.state.logcolumns}
                       refreshdata={this.refreshbyaction}
                       ContainerId={this.props.ContainerId}
@@ -804,6 +785,7 @@
   return {
     permAction: state.permAction,
     permRoles: state.permRoles,
+    dataManager: state.dataManager,
     memberLevel: state.memberLevel
   }
 }

--
Gitblit v1.8.0