From a7938fbc431502c0a631f188b6e8d7ae5e67a3d1 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 06 一月 2022 18:27:07 +0800
Subject: [PATCH] 2022-01-06

---
 src/tabviews/custom/components/table/normal-table/index.jsx |   88 ++++++++++++++++++++++++++++++++------------
 1 files changed, 64 insertions(+), 24 deletions(-)

diff --git a/src/tabviews/custom/components/table/normal-table/index.jsx b/src/tabviews/custom/components/table/normal-table/index.jsx
index 6fdb93b..1d24d3d 100644
--- a/src/tabviews/custom/components/table/normal-table/index.jsx
+++ b/src/tabviews/custom/components/table/normal-table/index.jsx
@@ -6,8 +6,6 @@
 
 import Api from '@/api'
 import Utils from '@/utils/utils.js'
-import zhCN from '@/locales/zh-CN/main.js'
-import enUS from '@/locales/en-US/main.js'
 import UtilsDM from '@/utils/utils-datamanage.js'
 import asyncComponent from '@/utils/asyncComponent'
 import MKEmitter from '@/utils/events.js'
@@ -31,7 +29,6 @@
   }
 
   state = {
-    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
     BID: '',              // 涓婄骇ID
     BData: '',            // 涓婄骇缁勪欢琛屾暟鎹�
     config: {},           // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷寜閽�佹悳绱€�佹樉绀哄垪銆佹爣绛剧瓑
@@ -56,11 +53,20 @@
    * 1銆� initdata 涓烘墦鍗版椂浣跨敤鐨勬暟鎹泦
    */
   UNSAFE_componentWillMount () {
-    const { data, initdata, BID } = this.props
+    const { data, initdata, BID, BData } = this.props
     let _config = fromJS(this.props.config).toJS()
     let _cols = new Map()
     let _data = null
     let _sync = _config.setting.sync === 'true'
+
+    if (_config.wrap.controlField) {
+      if (_config.wrap.controlVal) {
+        _config.wrap.controlVal = _config.wrap.controlVal.split(',')
+      } else {
+        _config.wrap.controlVal = ['']
+      }
+    }
+
     let setting = {..._config.setting, ..._config.wrap, style: {}}
 
     if (setting.selected !== 'always' && setting.selected !== 'init') {
@@ -80,11 +86,19 @@
         item.key = index
         item.$$uuid = item[_config.setting.primaryKey] || ''
         item.$$BID = BID || ''
+        item.$$BData = BData || ''
         item.$Index = index + 1 + ''
+
+        if (setting.controlField) {
+          if (setting.controlVal.includes(item[setting.controlField])) {
+            item.$disabled = true
+          }
+        }
+
         return item
       })
 
-      if (setting.selected !== 'false') {
+      if (setting.selected !== 'false' && _data && _data.length > 0) {
         setTimeout(() => {
           MKEmitter.emit('mkCheckTopLine', _config.uuid)
         }, 200)
@@ -122,8 +136,12 @@
       _config.wrap.title = _config.wrap.title || ' '
     }
 
+    _config.style = _config.style || {}
+
     this.setState({
+      pageSize: setting.pageSize || 10,
       BID: BID || '',
+      BData: BData || '',
       title: _config.wrap.title,
       sync: _sync,
       data: _data,
@@ -153,7 +171,7 @@
     const { mainSearch } = this.props
     const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize, BData } = this.state
 
-    if (setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇�
+    if (setting.supModule && !BID && setting.supKey !== 'false') { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇�
       this.setState({
         data: [],
         selectedData: [],
@@ -191,7 +209,7 @@
 
     let result = await Api.genericInterface(param)
     if (result.status) {
-      if (setting.selected !== 'false') {
+      if (setting.selected !== 'false' && result.data && result.data.length > 0) {
         setTimeout(() => {
           MKEmitter.emit('mkCheckTopLine', config.uuid)
         }, 200)
@@ -200,6 +218,9 @@
         }
       } else {
         MKEmitter.emit('resetSelectLine', config.uuid, '', '') // 骞挎挱鏁版嵁鍒囨崲
+        if (setting.$hasSyncModule) {
+          MKEmitter.emit('syncBalconyData', config.uuid, [], false)
+        }
       }
       
       reset && MKEmitter.emit('resetTable', config.uuid, repage) // 鍒楄〃閲嶇疆
@@ -216,15 +237,19 @@
           item.$$BID = BID || ''
           item.$$BData = BData || ''
           item.$Index = start + index + ''
+
+          if (setting.controlField) {
+            if (setting.controlVal.includes(item[setting.controlField])) {
+              item.$disabled = true
+            }
+          }
+          
           return item
         }),
         selectedData: [],
         total: result.total,
         loading: false
       })
-      if (setting.$hasSyncModule) {
-        MKEmitter.emit('syncBalconyData', config.uuid, [], false)
-      }
     } else {
       this.setState({
         loading: false
@@ -315,7 +340,7 @@
     const { mainSearch } = this.props
     const { setting, config, search, BID, orderBy } = this.state
 
-    if (setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇�
+    if (setting.supModule && !BID && setting.supKey !== 'false') { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇�
       this.setState({
         statFValue: []
       })
@@ -483,7 +508,7 @@
     const { setting } = this.state
 
     if (!setting.supModule || setting.supModule !== MenuID) return
-    if (id !== this.state.BID) {
+    if (id !== this.state.BID || id !== '') {
       this.setState({
         pageIndex: 1,
         BID: id,
@@ -501,12 +526,16 @@
    * @param {*} position   // 鍒锋柊浣嶇疆
    * @param {*} btn        // 鎵ц鐨勬寜閽�
    */
-  refreshByButtonResult = (menuId, position, btn) => {
+  refreshByButtonResult = (menuId, position, btn, id, lines) => {
     const { config, BID } = this.state
 
     if (config.uuid !== menuId) return
 
-    this.reloadtable(btn)                                                      // 鏁版嵁鍒锋柊
+    if (position === 'line' && lines && lines.length === 1) {
+      this.loadmainLinedata(lines[0].$$uuid)
+    } else {
+      this.reloadtable(btn)                                                    // 鏁版嵁鍒锋柊
+    }
 
     if (btn.syncComponentId && btn.syncComponentId !== config.uuid && btn.syncComponentId !== config.setting.supModule) {
       MKEmitter.emit('reloadData', btn.syncComponentId)                        // 鍚岀骇鏍囩鍒锋柊
@@ -521,7 +550,7 @@
   }
 
   UNSAFE_componentWillReceiveProps(nextProps) {
-    const { sync, config, setting, BID } = this.state
+    const { sync, config, setting, BID, BData } = this.state
 
     if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) {
       let _data = []
@@ -531,11 +560,19 @@
           item.key = index
           item.$$uuid = item[config.setting.primaryKey] || ''
           item.$$BID = BID || ''
+          item.$$BData = BData || ''
           item.$Index = index + 1 + ''
+
+          if (setting.controlField) {
+            if (setting.controlVal.includes(item[setting.controlField])) {
+              item.$disabled = true
+            }
+          }
+          
           return item
         })
 
-        if (setting.selected !== 'false') {
+        if (setting.selected !== 'false' && _data && _data.length > 0) {
           setTimeout(() => {
             MKEmitter.emit('mkCheckTopLine', config.uuid)
           }, 200)
@@ -578,10 +615,15 @@
   }
 
   render() {
-    const { BID, setting, searchlist, actions, config, columns, selectedData } = this.state
+    const { BID, setting, searchlist, actions, config, columns, selectedData, BData, data } = this.state
+
+    let style = {...config.style}
+    if (config.wrap.empty === 'hidden' && (!data || data.length === 0)) {
+      style.display = 'none'
+    }
 
     return (
-      <div className="custom-normal-table" style={config.style}>
+      <div className="custom-normal-table" style={style}>
         {config.wrap.collapse === 'true' ? <Collapse bordered={false} defaultActiveKey="1" expandIconPosition="right">
           <Panel forceRender={true} header={<NormalHeader config={config}/>} key="1">
             {searchlist && searchlist.length ?
@@ -591,7 +633,7 @@
               BID={BID}
               setting={setting}
               actions={actions}
-              BData={this.state.BData}
+              BData={BData}
               columns={config.columns}
               selectedData={selectedData}
             />
@@ -600,7 +642,7 @@
                 setting={setting}
                 columns={columns}
                 MenuID={config.uuid}
-                data={this.state.data}
+                data={data}
                 fields={config.columns}
                 total={this.state.total}
                 lineMarks={config.lineMarks}
@@ -620,7 +662,7 @@
             BID={BID}
             setting={setting}
             actions={actions}
-            BData={this.state.BData}
+            BData={BData}
             columns={config.columns}
             selectedData={selectedData}
           />
@@ -647,9 +689,7 @@
 
 const mapStateToProps = (state) => {
   return {
-    menuType: state.editLevel,
-    permAction: state.permAction,
-    permMenus: state.permMenus
+    menuType: state.editLevel
   }
 }
 

--
Gitblit v1.8.0