From d59f518f466274b2caeb2e01c10c92deafe7c93b Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 09 二月 2022 11:48:29 +0800
Subject: [PATCH] 2022-02-09

---
 src/tabviews/custom/components/table/normal-table/index.jsx |   68 ++++++++++++++++++++++++++++------
 1 files changed, 56 insertions(+), 12 deletions(-)

diff --git a/src/tabviews/custom/components/table/normal-table/index.jsx b/src/tabviews/custom/components/table/normal-table/index.jsx
index 3426437..b7e0ba2 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
       })
 
@@ -96,14 +110,15 @@
     }
 
     _config.columns.forEach(item => {
+      if (item.type !== 'number') return
       _cols.set(item.field, item)
     })
 
     _config.cols.forEach(column => {
       if (column.type === 'custom') {
         column.elements = column.elements.map(item => {
-          if (item.field && _cols.has(item.field)) {
-            item.col = _cols.get(item.field)
+          if (item.eleType === 'number' && item.field && _cols.has(item.field) && typeof(item.decimal) !== 'number') {
+            item.decimal = _cols.get(item.field).decimal || 0
           }
           return item
         })
@@ -123,7 +138,10 @@
       _config.wrap.title = _config.wrap.title || ' '
     }
 
+    _config.style = _config.style || {}
+
     this.setState({
+      pageSize: setting.pageSize || 10,
       BID: BID || '',
       BData: BData || '',
       title: _config.wrap.title,
@@ -155,7 +173,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: [],
@@ -218,9 +236,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: [],
@@ -276,6 +302,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 {
@@ -317,7 +344,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: []
       })
@@ -503,12 +530,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)                        // 鍚岀骇鏍囩鍒锋柊
@@ -532,9 +563,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
         })
 
@@ -581,10 +620,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 ?
@@ -603,7 +647,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