From cb3390688b8dd1a79307810c4a7f3b8c0c19be6b Mon Sep 17 00:00:00 2001 From: huayj Date: Mon, 26 Aug 2019 15:53:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E6=97=B6,=E4=B8=8D=E6=8D=A2=E8=A1=8C=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/api.md | 2 +- src/Table.js | 6 +++--- src/Table.scss | 6 ++++++ src/TableCell.js | 20 ++++++++++++-------- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/docs/api.md b/docs/api.md index da1cb3e..4dff4ef 100644 --- a/docs/api.md +++ b/docs/api.md @@ -128,7 +128,7 @@ import 'bee-table/build/Table.css'; | filterDropdownIncludeKeys | 能够设置指定的下拉条件项,通过设置keys 其中string条件可设置:LIKE,ULIKE,EQ,UEQ,START,END.number条件可设置:GT,GTEQ,LT,LTEQ,EQ,UEQ | array | [] 不设置此属性为显示所有 | filterInputNumberOptions | 数值框接收的props,具体属性参考bee-input-number | object | null | textAlign | 列对齐方式,默认是左对齐('left、right、center') | string | -| $\color{red}{*}$sortEnable | 开启默认排序,根据fieldType属性确定排序规则,默认按字符串排序;优先级低于sorter属性 | bool | false | +| $\color{red}{*}$sortEnable | 开启默认排序,根据fieldType属性确定排序规则,默认按字符串排序;优先级低于sorter属性;需配合高阶函数`multiSelect`使用 | bool | false | | $\color{red}{*}$fieldType | 列类型,可选`string`,`number`,`currency`,`bool`,`link` | string | 'string' | | $\color{red}{*}$fontColor | 列文本颜色 | string | - | | $\color{red}{*}$bgColor | 列背景颜色 | string | - | diff --git a/src/Table.js b/src/Table.js index 5fa33f0..9b55df4 100644 --- a/src/Table.js +++ b/src/Table.js @@ -686,15 +686,15 @@ class Table extends Component { if ( props.showRowNum ){ switch(props.showRowNum.type){ case 'number':{ - data[i][props.showRowNum.key || '_index'] = i + (props.showRowNum.base || 0); + data[i][props.showRowNum.key || '_index'] = (props.showRowNum.base || 0) + 1; break; } case 'ascii': { - data[i][props.showRowNum.key || '_index'] = String.fromCharCode(i + (props.showRowNum.base || 0).charCodeAt()); + data[i][props.showRowNum.key || '_index'] = String.fromCharCode(i + (props.showRowNum.base || '0').charCodeAt()); break; } default: { - data[i][props.showRowNum.key || '_index'] = i + (props.showRowNum.base || 0); + data[i][props.showRowNum.key || '_index'] = (props.showRowNum.base || 0) + 1; break; } } diff --git a/src/Table.scss b/src/Table.scss index 2613fd3..dede769 100644 --- a/src/Table.scss +++ b/src/Table.scss @@ -1044,6 +1044,12 @@ $icon-color:#505F79; vertical-align: middle; overflow: hidden; } + .u-table-fieldtype{ + text-overflow: ellipsis; + white-space: nowrap; + vertical-align: middle; + overflow: hidden; + } } .u-table-drag-hidden-cont{ position: absolute; diff --git a/src/TableCell.js b/src/TableCell.js index d8691ea..65c9ff6 100644 --- a/src/TableCell.js +++ b/src/TableCell.js @@ -45,7 +45,7 @@ class TableCell extends Component{ let link = () => { window.open(linkUrl,linkType || '_blank'); } - let cls = 'u-table-link '; + let cls = 'u-table-link u-table-fieldtype '; if(className){ cls += `${className} `; } @@ -88,16 +88,20 @@ class TableCell extends Component{ // 渲染整数/货币类型 renderNumber = (data, config={}, width=200) => { - console.log(config); - let number = formatMoney(data, config.precision, config.thousand); - if(config.makeUp === false && number !== '0') { + const { precision, thousand, makeUp, preSymbol, nextSymbol } = config; + let number = formatMoney(data, precision, thousand); + if(makeUp === false && number !== '0') { number = number.replace(/0*$/,'').replace(/\.$/,''); } let numberWidth = parseInt(width) - 16; // 减去默认的左右padding共计16px let res = {number}; - let pre = config.preSymbol ? {config.preSymbol} : null; - let next = config.nextSymbol ? {config.nextSymbol} : null; - return + let pre = preSymbol ? {preSymbol} : null; + let next = nextSymbol ? {nextSymbol} : null; + let title = ''; + title += typeof preSymbol === 'string' ? preSymbol : ''; + title += number; + title += typeof nextSymbol === 'string' ? nextSymbol : ''; + return {pre} {res} {next} @@ -151,7 +155,7 @@ class TableCell extends Component{ } case 'number':{ let config = { - precision: 2, // 精度值,需要大于0 + precision: 0, // 精度值,需要大于0 thousand: true, // 是否显示千分符号 makeUp: false, // 末位是否补零 preSymbol: '', // 前置符号