Skip to content

Commit 33f3a66

Browse files
committed
主机列表添加过期时间信息展示
1 parent d4ea1e4 commit 33f3a66

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

spug_web/src/pages/host/Table.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import IPAddress from './IPAddress';
1212
import { http, hasPermission } from 'libs';
1313
import store from './store';
1414
import icons from './icons';
15+
import moment from 'moment';
1516

1617
function ComTable() {
1718
function handleDelete(text) {
@@ -38,6 +39,21 @@ function ComTable() {
3839
}
3940
}
4041

42+
function ExpTime(props) {
43+
if (!props.value) return null
44+
let value = moment(props.value)
45+
const days = value.diff(moment(), 'days')
46+
if (days > 30) {
47+
return <span>剩余 <b style={{color: '#389e0d'}}>{days}</b></span>
48+
} else if (days > 7) {
49+
return <span>剩余 <b style={{color: '#faad14'}}>{days}</b></span>
50+
} else if (days >= 0) {
51+
return <span>剩余 <b style={{color: '#d9363e'}}>{days}</b></span>
52+
} else {
53+
return <span>过期 <b style={{color: '#d9363e'}}>{Math.abs(days)}</b></span>
54+
}
55+
}
56+
4157
return (
4258
<TableCard
4359
tKey="hi"
@@ -116,6 +132,7 @@ function ComTable() {
116132
<span>{info.cpu}{info.memory}GB</span>
117133
</Space>
118134
)}/>
135+
<Table.Column hide title="到期信息" dataIndex="expired_time" render={v => <ExpTime value={v}/>}/>
119136
<Table.Column hide title="备注信息" dataIndex="desc"/>
120137
<Table.Column
121138
title="状态"

0 commit comments

Comments
 (0)