mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 20:09:08 +08:00
feat: table 中的 combineNum 支持使用变量 (#2527)
This commit is contained in:
parent
ff2a577a9b
commit
545188d672
@ -1055,6 +1055,120 @@ order: 67
|
||||
}
|
||||
```
|
||||
|
||||
> 1.3.0 版本开始 combineNum 支持使用变量,如下所示
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "service",
|
||||
"data": {
|
||||
"rows": [
|
||||
{
|
||||
"engine": "Trident",
|
||||
"browser": "Internet Explorer 4.2",
|
||||
"platform": "Win 95+",
|
||||
"version": "4",
|
||||
"grade": "A"
|
||||
},
|
||||
{
|
||||
"engine": "Trident",
|
||||
"browser": "Internet Explorer 4.2",
|
||||
"platform": "Win 95+",
|
||||
"version": "4",
|
||||
"grade": "B"
|
||||
},
|
||||
{
|
||||
"engine": "Trident",
|
||||
"browser": "AOL browser (AOL desktop)",
|
||||
"platform": "Win 95+",
|
||||
"version": "4",
|
||||
"grade": "C"
|
||||
},
|
||||
{
|
||||
"engine": "Trident",
|
||||
"browser": "AOL browser (AOL desktop)",
|
||||
"platform": "Win 98",
|
||||
"version": "3",
|
||||
"grade": "A"
|
||||
},
|
||||
{
|
||||
"engine": "Trident",
|
||||
"browser": "AOL browser (AOL desktop)",
|
||||
"platform": "Win 98",
|
||||
"version": "4",
|
||||
"grade": "A"
|
||||
},
|
||||
{
|
||||
"engine": "Gecko",
|
||||
"browser": "Firefox 1.0",
|
||||
"platform": "Win 98+ / OSX.2+",
|
||||
"version": "4",
|
||||
"grade": "A"
|
||||
},
|
||||
{
|
||||
"engine": "Gecko",
|
||||
"browser": "Firefox 1.0",
|
||||
"platform": "Win 98+ / OSX.2+",
|
||||
"version": "5",
|
||||
"grade": "A"
|
||||
},
|
||||
{
|
||||
"engine": "Gecko",
|
||||
"browser": "Firefox 2.0",
|
||||
"platform": "Win 98+ / OSX.2+",
|
||||
"version": "5",
|
||||
"grade": "B"
|
||||
},
|
||||
{
|
||||
"engine": "Gecko",
|
||||
"browser": "Firefox 2.0",
|
||||
"platform": "Win 98+ / OSX.2+",
|
||||
"version": "5",
|
||||
"grade": "C"
|
||||
},
|
||||
{
|
||||
"engine": "Gecko",
|
||||
"browser": "Firefox 2.0",
|
||||
"platform": "Win 98+ / OSX.2+",
|
||||
"version": "5",
|
||||
"grade": "D"
|
||||
}
|
||||
],
|
||||
combineNum: 3
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "table",
|
||||
"source": "$rows",
|
||||
"className": "m-b-none",
|
||||
"combineNum": "$combineNum",
|
||||
"columnsTogglable": false,
|
||||
"columns": [
|
||||
{
|
||||
"name": "engine",
|
||||
"label": "Rendering engine"
|
||||
},
|
||||
{
|
||||
"name": "browser",
|
||||
"label": "Browser"
|
||||
},
|
||||
{
|
||||
"name": "platform",
|
||||
"label": "Platform(s)"
|
||||
},
|
||||
{
|
||||
"name": "version",
|
||||
"label": "Engine version"
|
||||
},
|
||||
{
|
||||
"name": "grade",
|
||||
"label": "CSS grade"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 超级表头
|
||||
|
||||
超级表头意思是,表头还可以再一次进行分组。额外添加个 `groupName` 属性即可。
|
||||
|
@ -263,7 +263,7 @@ export interface TableProps extends RendererProps {
|
||||
columnsTogglable?: boolean | 'auto';
|
||||
affixHeader?: boolean;
|
||||
affixColumns?: boolean;
|
||||
combineNum?: number;
|
||||
combineNum?: number | string;
|
||||
combineFromIndex?: number;
|
||||
footable?:
|
||||
| boolean
|
||||
@ -440,7 +440,6 @@ export default class Table extends React.Component<TableProps, object> {
|
||||
itemCheckableOn,
|
||||
itemDraggableOn,
|
||||
hideCheckToggler,
|
||||
combineNum,
|
||||
combineFromIndex,
|
||||
expandConfig,
|
||||
formItem,
|
||||
@ -448,6 +447,14 @@ export default class Table extends React.Component<TableProps, object> {
|
||||
maxKeepItemSelectionLength
|
||||
} = props;
|
||||
|
||||
let combineNum = props.combineNum;
|
||||
if (typeof combineNum === 'string') {
|
||||
combineNum = parseInt(
|
||||
resolveVariableAndFilter(combineNum, props.data, '| raw'),
|
||||
10
|
||||
);
|
||||
}
|
||||
|
||||
store.update({
|
||||
selectable,
|
||||
draggable,
|
||||
@ -556,6 +563,13 @@ export default class Table extends React.Component<TableProps, object> {
|
||||
props
|
||||
)
|
||||
) {
|
||||
let combineNum = props.combineNum;
|
||||
if (typeof combineNum === 'string') {
|
||||
combineNum = parseInt(
|
||||
resolveVariableAndFilter(combineNum, props.data, '| raw'),
|
||||
10
|
||||
);
|
||||
}
|
||||
store.update({
|
||||
selectable: props.selectable,
|
||||
columnsTogglable: props.columnsTogglable,
|
||||
@ -568,7 +582,7 @@ export default class Table extends React.Component<TableProps, object> {
|
||||
itemCheckableOn: props.itemCheckableOn,
|
||||
itemDraggableOn: props.itemDraggableOn,
|
||||
hideCheckToggler: props.hideCheckToggler,
|
||||
combineNum: props.combineNum,
|
||||
combineNum: combineNum,
|
||||
combineFromIndex: props.combineFromIndex,
|
||||
expandConfig: props.expandConfig
|
||||
});
|
||||
@ -850,9 +864,8 @@ export default class Table extends React.Component<TableProps, object> {
|
||||
forEach(
|
||||
table.querySelectorAll('thead>tr:last-child>th'),
|
||||
(item: HTMLElement) => {
|
||||
widths[
|
||||
item.getAttribute('data-index') as string
|
||||
] = item.getBoundingClientRect().width;
|
||||
widths[item.getAttribute('data-index') as string] =
|
||||
item.getBoundingClientRect().width;
|
||||
}
|
||||
);
|
||||
forEach(
|
||||
@ -895,9 +908,11 @@ export default class Table extends React.Component<TableProps, object> {
|
||||
);
|
||||
|
||||
if (affixHeader) {
|
||||
(dom.querySelector(
|
||||
`.${ns}Table-fixedTop>.${ns}Table-wrapper`
|
||||
) as HTMLElement).style.cssText += `width: ${this.outterWidth}px`;
|
||||
(
|
||||
dom.querySelector(
|
||||
`.${ns}Table-fixedTop>.${ns}Table-wrapper`
|
||||
) as HTMLElement
|
||||
).style.cssText += `width: ${this.outterWidth}px`;
|
||||
}
|
||||
|
||||
this.lastScrollLeft = -1;
|
||||
@ -2040,8 +2055,7 @@ export default class Table extends React.Component<TableProps, object> {
|
||||
|
||||
if (buffer) {
|
||||
var blob = new Blob([buffer], {
|
||||
type:
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
});
|
||||
saveAs(blob, filename + '.xlsx');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user