Skip to content

Commit

Permalink
chore: update demo
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk committed Jul 28, 2023
1 parent 994e2be commit ebbb58b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
32 changes: 27 additions & 5 deletions packages/abc/st/demo/basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,48 @@ Quickly generate tables; use `res` to adapted backend data format.

```ts
import { Component, ViewChild } from '@angular/core';

import { STColumn, STComponent } from '@delon/abc/st';

interface User {
id: number;
picture: {
thumbnail: string;
};
name: {
last: string;
first: string;
};
nat: string;
gender: string;
email: string;
phone: string;
price: number;
registered: Date;
}

@Component({
selector: 'app-demo',
template: `
<button nz-button nzType="primary" (click)="setRow()">setRow Method</button>
<st #st [widthMode]="{ type: 'strict' }" [data]="url" [req]="{ params: params }" [columns]="columns"></st>
`,
`
})
export class DemoComponent {
url = `/users?total=2&field=list`;
params = { a: 1, b: 2 };
@ViewChild('st', { static: false }) private st!: STComponent;
columns: STColumn[] = [
columns: Array<STColumn<User>> = [
{ title: '编号', index: 'id', width: 80 },
{ title: '头像', type: 'img', width: 60, index: 'picture.thumbnail' },
{ title: '头像', index: 'picture.thumbnail', type: 'img', width: 60 },
{ title: '邮箱', index: 'email', width: 80 },
{ title: '电话', index: 'phone' },
{ title: { text: '佣金', optional: '(单位:元)', optionalHelp: '计算公式=订单金额 * 0.6%' }, index: 'price', type: 'currency' },
{ title: '注册时间', type: 'date', index: 'registered' },
{
title: { text: '佣金', optional: '(单位:元)', optionalHelp: '计算公式=订单金额 * 0.6%' },
index: 'price',
type: 'currency'
},
{ title: '注册时间', type: 'date', index: 'registered' }
];

setRow(): void {
Expand Down
2 changes: 1 addition & 1 deletion packages/abc/st/st.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export interface STColumn<T extends STData = any> {
title?: string | STColumnTitle;
/**
* 列数据在数据项中对应的 key,支持 `a.b.c` 的嵌套写法,例如:
* - `id`
* - `id` (需要指定类型才能智能提示)
* - `price.market`
* - `[ 'price', 'market' ]`
*/
Expand Down

0 comments on commit ebbb58b

Please sign in to comment.