1、ng-alain其中的 st 表格,有STColumnButtonDrawer(抽屜)和STColumnButtonModal(模態框)傳值問題:
如列表內容太多,列表一行無法顯示,點擊一個按鈕,出來一個抽屜,抽屜裏面是這一行的全部內容,
columns: STColumn[] = [
{
title: '操作',//表頭名字
index: 'operate ',
buttons: [
{
text: '查看全部',//按鈕名字
type: 'drawer',
drawer: {
title: '編輯',
component: DrawerComponent,
},
}]
},
]
在DrawerComponent的ts文件裏面,只需要定義一個
reword:any;
這個reword就是對應這一行的全部數據
2、若要在前端的 st 表格直接實現排序功能,一句即可:
compare: (a, b) => (a.createTime < b.createTime ? -1 : a.createTime > b.createTime ? 1 : 0),
{ title: '時間', index: 'time', type: 'date',
sort: {
compare: (a, b) => (a.time < b.time? -1 : a.time > b.time ? 1 : 0),
},
},
3、關於這個時間,在 sf 表單裏面,有時候需要限制時間,如不能選擇今天以前,或者今天以後的時間,也很簡單的一句話:
showTime: false,
disabledDate: (current: Date) => {
return differenceInCalendarDays(current, this.time) > 0;
},
showTime: 是不顯示哪些時間,若是不加,做限制的時間不能選擇,但是可以顯示
大於(>)0是今天以後的時間
小於(>)0是今天以前的時間
format可以限制時間的格式
import { differenceInCalendarDays } from 'date-fns';
time = new Date(); // 當前時間
Stime: {
type: 'string',
title: '時間',
ui: {
widget: 'date',
format: 'YYYY-MM-DD',
showTime: false,
disabledDate: (current: Date) => {
return differenceInCalendarDays(current, this.time) > 0;
},
}
},
4、關於st表格的badge 徽標用法:
BADGE: STColumnBadge = {
0: { text: '未讀', color: 'error' },
1: { text: '已讀', color: 'success' },
};
columns: STColumn[] = [
{ title: '狀態', index: 'Mstate', type: 'badge', badge: this.BADGE, },
]