From e0cac33690a8bfdff2102d03a106c44c36df8ba1 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 18 二月 2022 16:26:28 +0800
Subject: [PATCH] 2022-02-18

---
 src/tabviews/custom/components/table/edit-table/normalTable/index.jsx |   37 +++++++++++++++++++++----------------
 1 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
index fe08fdc..1464bfa 100644
--- a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
+++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
@@ -267,6 +267,8 @@
         if (col.format === 'percent') {
           content = content * 100
           decimal = decimal > 2 ? decimal - 2 : 0
+        } else if (col.format === 'abs') {
+          content = Math.abs(content)
         }
   
         content = content.toFixed(decimal)
@@ -472,7 +474,7 @@
         _copy.sorter = false
 
         if (item.editable === 'true') {
-          _copy.title = <span>{item.label}<EditOutlined className="system-color" style={{position: 'absolute', bottom: 0, right: 0}}/></span>
+          _copy.title = <span>{item.label}<EditOutlined className="system-color" style={{position: 'absolute', bottom: '2px', right: '5px'}}/></span>
         }
         edColumns.push(_copy)
       }
@@ -526,24 +528,24 @@
   }
 
   componentDidMount () {
-    const { fields, columns } = this.props
+    const { fields, setting } = this.props
     const { data, editable } = this.state
 
-    let _fields = []
+    // let _fields = [] // 瀹氫箟鍏ㄩ儴瀛楁锛屼笉鍦ㄤ粠鍙紪杈戝垪涓�夊彇
 
-    let fieldType = {}
-    fields.forEach(item => {
-      fieldType[item.field] = item.datatype
-    })
+    // let fieldType = {}
+    // fields.forEach(item => {
+    //   fieldType[item.field] = item.datatype
+    // })
 
-    columns.forEach(col => {
-      if (!col.field || col.type === 'index') return
+    // columns.forEach(col => {
+    //   if (!col.field || col.type === 'index') return
 
-      _fields.push({...col, datatype: fieldType[col.field] || 'Nvarchar(50)'})
-    })
+    //   _fields.push({...col, datatype: fieldType[col.field] || 'Nvarchar(50)'})
+    // })
 
     this.setState({
-      fields: _fields,
+      fields: fields.filter(item => item.field !== setting.primaryKey),
     })
 
     if (editable === 'true' && data && data.length > 0) {
@@ -613,8 +615,6 @@
     item.$Index = item.key + 1 + ''
 
     fields.forEach(col => {
-      item[col.field] = item[col.field] !== undefined ? item[col.field] : ''
-
       if (col.initval !== '$copy') {
         item[col.field] = col.initval
       }
@@ -623,6 +623,9 @@
         if (isNaN(item[col.field])) {
           item[col.field] = 0
         }
+      }
+      if (item[col.field] === undefined) {
+        item[col.field] = ''
       }
     })
 
@@ -693,8 +696,6 @@
     }
 
     fields.forEach(col => {
-      item[col.field] = item[col.field] !== undefined ? item[col.field] : ''
-
       if (col.initval !== '$copy') {
         item[col.field] = col.initval
       }
@@ -704,6 +705,10 @@
           item[col.field] = 0
         }
       }
+
+      if (item[col.field] === undefined) {
+        item[col.field] = ''
+      }
     })
 
     this.setState({edData: [...edData, item]})

--
Gitblit v1.8.0