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/subtable/index.jsx |  109 ++++++++++++++++++++----------------------------------
 1 files changed, 40 insertions(+), 69 deletions(-)

diff --git a/src/tabviews/subtable/index.jsx b/src/tabviews/subtable/index.jsx
index a1ae990..4b73175 100644
--- a/src/tabviews/subtable/index.jsx
+++ b/src/tabviews/subtable/index.jsx
@@ -65,7 +65,8 @@
     popData: false,       // 寮规椤甸潰锛屾墍閫夌殑琛ㄦ牸鏁版嵁
     visible: false,       // 寮规鏄剧ず闅愯棌鎺у埗
     pickup: false,        // 瀛愯〃鏁版嵁闅愯棌鏄剧ず鍒囨崲
-    triggerBtn: null      // 鎸夐挳瑙﹀彂
+    triggerBtn: null,     // 鎸夐挳瑙﹀彂
+    chartId: ''           // 灞曞紑鍥捐〃ID
   }
 
   /**
@@ -139,8 +140,9 @@
       let colMap = new Map()
 
       // 鍏煎鍥捐〃
+      let chartId = ''
       if (!config.charts) {
-        config.expand = false
+        config.expand = true
         config.charts = [{
           uuid: Utils.getuuid(),
           label: '',
@@ -150,7 +152,10 @@
           Hide: 'false',
           blacklist: []
         }]
+      } else if (config.charts.length === 1) {
+        config.expand = true
       }
+      chartId = config.charts[0].uuid
 
       // 鏉冮檺杩囨护
       if (this.props.menuType !== 'HS') {
@@ -320,6 +325,7 @@
 
       this.setState({
         loadingview: false,
+        chartId: chartId,
         config: config,
         setting: config.setting,
         searchlist: config.search,
@@ -380,6 +386,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'
@@ -531,6 +543,7 @@
 
     let param = {
       OrderCol: orderBy || setting.order,
+      dataM: this.props.dataManager ? 'Y' : '',
       BID: BID,
       ..._search
     }
@@ -586,7 +599,8 @@
       arr_field: arr_field,
       BID: 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
@@ -594,6 +608,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
@@ -866,6 +890,13 @@
     this.refreshbyaction(this.state.popAction, 'pop')
   }
 
+  /**
+   * @description 鍥捐〃瑙嗗浘鍒囨崲
+   */
+  changeChart = (uuid) => {
+    this.setState({chartId: uuid})
+  }
+
   UNSAFE_componentWillMount() {
     // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁
     this.loadconfig()
@@ -885,7 +916,7 @@
   }
 
   render() {
-    const { config, setting, searchlist, actions, columns, loadingview, viewlost, pickup, triggerBtn } = this.state
+    const { config, setting, searchlist, actions, columns, loadingview, viewlost, pickup, triggerBtn, chartId } = this.state
 
     return (
       <div className="subtable" id={'subtable' + this.props.MenuID}>
@@ -899,75 +930,13 @@
         }
         {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 className="sub-action">
-                      <SubAction
-                        type="sub"
-                        menuType={this.props.menuType}
-                        triggerBtn={triggerBtn}
-                        setting={setting}
-                        actions={actions}
-                        Tab={this.props.Tab}
-                        BID={this.props.BID}
-                        BData={this.props.BData}
-                        dict={this.state.dict}
-                        MenuID={this.props.MenuID}
-                        permRoles={this.props.permRoles}
-                        logcolumns={this.state.logcolumns}
-                        refreshdata={this.refreshbyaction}
-                        ContainerId={this.props.ContainerId}
-                        triggerPopview={this.triggerPopview}
-                        getexceloutparam={this.getexceloutparam}
-                        gettableselected={this.gettableselected}
-                      />
-                    </div>
-                    <div className="subtable-box">
-                      {this.state.data && this.state.data.length > 0 ?
-                        <Switch title="鏀惰捣" className="subtable-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={pickup} onChange={this.pickupChange} /> : null
-                      }
-                      <SubTable
-                        ref="subTable"
-                        menuType={this.props.menuType}
-                        tableId={this.props.Tab.uuid}
-                        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 => {
+            if (!config.expand && chartId !== item.uuid) return null
             if (item.chartType === 'table') {
               return (
                 <Col span={item.width || 24} key={item.uuid}>
@@ -984,6 +953,7 @@
                       BData={this.props.BData}
                       dict={this.state.dict}
                       MenuID={this.props.MenuID}
+                      dataManager={this.props.dataManager}
                       permRoles={this.props.permRoles}
                       logcolumns={this.state.logcolumns}
                       refreshdata={this.refreshbyaction}
@@ -1068,6 +1038,7 @@
     permAction: state.permAction,
     permRoles: state.permRoles,
     permMenus: state.permMenus,
+    dataManager: state.dataManager,
     memberLevel: state.memberLevel
   }
 }

--
Gitblit v1.8.0