From 46f79b491173d284a4900d19e7aecf7509481438 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 21 一月 2022 17:21:25 +0800
Subject: [PATCH] 2022-01-21

---
 src/tabviews/custom/components/table/normal-table/index.jsx |   54 ++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 46 insertions(+), 8 deletions(-)

diff --git a/src/tabviews/custom/components/table/normal-table/index.jsx b/src/tabviews/custom/components/table/normal-table/index.jsx
index 2f53d2c..72585ec 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: {},           // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷寜閽�佹悳绱€�佹樉绀哄垪銆佹爣绛剧瓑
@@ -61,6 +58,15 @@
     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') {
@@ -79,9 +85,17 @@
       _data = _data.map((item, index) => {
         item.key = index
         item.$$uuid = item[_config.setting.primaryKey] || ''
+        item.$$key = '' + item.key + item.$$uuid
         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
       })
 
@@ -123,6 +137,8 @@
       _config.wrap.title = _config.wrap.title || ' '
     }
 
+    _config.style = _config.style || {}
+
     this.setState({
       pageSize: setting.pageSize || 10,
       BID: BID || '',
@@ -156,7 +172,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: [],
@@ -219,9 +235,17 @@
         data: result.data.map((item, index) => {
           item.key = index
           item.$$uuid = item[setting.primaryKey] || ''
+          item.$$key = '' + item.key + item.$$uuid
           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: [],
@@ -277,6 +301,7 @@
           data = data.map(item => {
             if (item.$$uuid === _data.$$uuid) {
               _data.key = item.key
+              _data.$$key = '' + item.key + item.$$uuid
               _data.$Index = item.$Index
               return _data
             } else {
@@ -318,7 +343,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: []
       })
@@ -537,9 +562,17 @@
         _data = _data.map((item, index) => {
           item.key = index
           item.$$uuid = item[config.setting.primaryKey] || ''
+          item.$$key = '' + item.key + item.$$uuid
           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
         })
 
@@ -586,10 +619,15 @@
   }
 
   render() {
-    const { BID, setting, searchlist, actions, config, columns, selectedData, BData } = 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 ?
@@ -608,7 +646,7 @@
                 setting={setting}
                 columns={columns}
                 MenuID={config.uuid}
-                data={this.state.data}
+                data={data}
                 fields={config.columns}
                 total={this.state.total}
                 lineMarks={config.lineMarks}

--
Gitblit v1.8.0