自定义类型时,不换行展示问题

This commit is contained in:
huayj 2019-08-26 15:53:30 +08:00
parent cdc19d51c0
commit cb3390688b
4 changed files with 22 additions and 12 deletions

View File

@ -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 | - |

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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 = <span className='u-table-currency-number' >{number}</span>;
let pre = config.preSymbol ? <span className='u-table-currency-pre'>{config.preSymbol}</span> : null;
let next = config.nextSymbol ? <span className='u-table-currency-next'>{config.nextSymbol}</span> : null;
return <span className='u-table-currency' style={{width:numberWidth}}>
let pre = preSymbol ? <span className='u-table-currency-pre'>{preSymbol}</span> : null;
let next = nextSymbol ? <span className='u-table-currency-next'>{nextSymbol}</span> : null;
let title = '';
title += typeof preSymbol === 'string' ? preSymbol : '';
title += number;
title += typeof nextSymbol === 'string' ? nextSymbol : '';
return <span className='u-table-currency u-table-fieldtype' style={{width:numberWidth}} title={title}>
{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: '', // 前置符号