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/tabviews/zshare/normalTable/index.jsx | 88 +++++++++++++++++++++++++++---------------- 1 files changed, 55 insertions(+), 33 deletions(-) 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') { -- Gitblit v1.8.0