From 81e50ca10197278a158452e918ed76a3edfe543e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 04 四月 2020 21:21:21 +0800
Subject: [PATCH] 2020-04-04

---
 src/index.js                               |    8 ++++
 src/tabviews/zshare/normalTable/index.jsx  |   88 +++++++++++++++++++++++++++----------------
 public/options.js                          |    3 +
 src/tabviews/zshare/normalTable/index.scss |   18 +-------
 4 files changed, 68 insertions(+), 49 deletions(-)

diff --git a/public/options.js b/public/options.js
index 3b5b015..2a66cdd 100644
--- a/public/options.js
+++ b/public/options.js
@@ -14,5 +14,6 @@
   lineColor: '',
   webSite: '',
   doclogo: '',
-  style: ''
+  style: '',
+  filter: 'false'
 }
\ No newline at end of file
diff --git a/src/index.js b/src/index.js
index d6a8961..3da6d82 100644
--- a/src/index.js
+++ b/src/index.js
@@ -55,6 +55,14 @@
 
 document.title = window.GLOB.platTitle
 
+if (window.GLOB.filter === 'true') {
+  let html = document.getElementsByTagName('html')[0]
+  
+  if (html) {
+    html.style.filter = 'grayscale(100%)'
+  }
+}
+
 
 const option = {
   white: 'mk-white'
diff --git a/src/tabviews/zshare/normalTable/index.jsx b/src/tabviews/zshare/normalTable/index.jsx
index ee39144..ab5a446 100644
--- a/src/tabviews/zshare/normalTable/index.jsx
+++ b/src/tabviews/zshare/normalTable/index.jsx
@@ -1,6 +1,6 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
-import { Table, message, Affix, Button, Typography, Icon, Modal } from 'antd'
+import { Table, message, Affix, Button, Typography, Modal } from 'antd'
 import './index.scss'
 
 const { Paragraph } = Typography
@@ -41,7 +41,7 @@
       let cell = {
         align: item.Align,
         dataIndex: item.field || item.uuid,
-        title: <span>{item.label}{item.linkThdMenu ? <Icon type="link"/> : null}</span>,
+        title: item.label,
         sorter: item.field && item.IsSort === 'true',
         width: item.Width || 120,
         render: (text, record) => {
@@ -130,36 +130,47 @@
     } else if (item.type === 'number') {
       let content = ''
       let match = false
-      if (item.field && record.hasOwnProperty(item.field)) {
-        content = +record[item.field]
-      }
 
-      if (content && item.match && item.matchVal) {
-        if (item.match === '>') {
-          if (content > item.matchVal) {
-            match = true
+      if (item.field && record.hasOwnProperty(item.field)) {
+        try {
+          content = parseFloat(record[item.field])
+          if (isNaN(content)) {
+            content = ''
           }
-        } else if (item.match === '<') {
-          if (content < item.matchVal) {
-            match = true
-          }
-        } else if (item.match === '>=') {
-          if (content >= item.matchVal) {
-            match = true
-          }
-        } else if (item.match === '<=') {
-          if (content <= item.matchVal) {
-            match = true
-          }
+        } catch {
+          content = ''
         }
       }
 
-      if (content && item.format === 'thdSeparator') {
-        content = `${content}`
-        content = content.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
+      if (content !== '') {
+        if (item.match && item.matchVal) {
+          if (item.match === '>') {
+            if (content > item.matchVal) {
+              match = true
+            }
+          } else if (item.match === '<') {
+            if (content < item.matchVal) {
+              match = true
+            }
+          } else if (item.match === '>=') {
+            if (content >= item.matchVal) {
+              match = true
+            }
+          } else if (item.match === '<=') {
+            if (content <= item.matchVal) {
+              match = true
+            }
+          }
+        }
+  
+        content = content.toFixed(item.decimal || 0)
+  
+        if (item.format === 'thdSeparator') {
+          content = content.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
+        }
+  
+        content = (item.prefix || '') + content + (item.postfix || '')
       }
-
-      content = (item.prefix || '') + content + (item.postfix || '')
 
       if (item.linkThdMenu) {
         return (
@@ -241,15 +252,26 @@
       item.subColumn.forEach(col => {
         if (!col.field || !record.hasOwnProperty(col.field)) return
         
-        if (col.type === 'number' && typeof(record[col.field]) === 'number') {
-          let content = record[col.field]
-
-          if (col.format === 'thdSeparator') {
-            content = `${content}`
-            content = content.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
+        if (col.type === 'number') {
+          let content = ''
+          try {
+            content = parseFloat(record[col.field])
+            if (isNaN(content)) {
+              content = ''
+            }
+          } catch {
+            content = ''
           }
+    
+          if (content !== '') {
+            content = content.toFixed(col.decimal || 0)
+      
+            if (col.format === 'thdSeparator') {
+              content = content.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
+            }
 
-          content = (col.prefix || '') + content + (col.postfix || '')
+            content = (col.prefix || '') + content + (col.postfix || '')
+          }
 
           contents.push(content)
         } else if (col.type === 'picture') {
diff --git a/src/tabviews/zshare/normalTable/index.scss b/src/tabviews/zshare/normalTable/index.scss
index 38d09a1..28bc4ae 100644
--- a/src/tabviews/zshare/normalTable/index.scss
+++ b/src/tabviews/zshare/normalTable/index.scss
@@ -7,18 +7,8 @@
       tr {
         th {
           position: relative;
-
           .ant-table-column-title {
             white-space: nowrap;
-            position: static!important;
-            .anticon-link {
-              // color: #1890ff;
-              opacity: 0.5;
-              position: absolute;
-              left: 0px;
-              bottom: 0px;
-              font-size: 12px;
-            }
           }
         }
       }
@@ -126,14 +116,12 @@
             color: #1890ff;
             box-shadow: none;
             padding: 0 5px;
-          }
-          button + button {
-            margin-left: 10px;
+            margin: 0px 5px;
           }
         }
         .button {
-          button + button {
-            margin-left: 10px;
+          button {
+            margin: 0px 5px;
           }
         }
       }

--
Gitblit v1.8.0