From a9d1e281bb355d083e9d9e42236907e6fb0805b0 Mon Sep 17 00:00:00 2001 From: vapao Date: Tue, 21 Jan 2020 23:29:44 +0800 Subject: [PATCH] =?UTF-8?q?F=20=E4=BF=AE=E5=A4=8D=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E5=92=8C=E7=9B=91=E6=8E=A7=E4=B8=AD=E5=BF=83?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=97=B6=E9=97=B4=E4=BC=9A=E8=A2=AB=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E5=88=B7=E6=96=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spug_web/src/pages/monitor/Table.js | 1 - spug_web/src/pages/monitor/store.js | 9 ++++++++- spug_web/src/pages/schedule/Table.js | 3 +-- spug_web/src/pages/schedule/store.js | 5 +++++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/spug_web/src/pages/monitor/Table.js b/spug_web/src/pages/monitor/Table.js index ff0be36..0b27409 100644 --- a/spug_web/src/pages/monitor/Table.js +++ b/spug_web/src/pages/monitor/Table.js @@ -85,7 +85,6 @@ class ComTable extends React.Component { }, { title: '更新于', dataIndex: 'latest_run_time', - render: value => value ? moment(value).fromNow() : null }, { title: '操作', render: info => ( diff --git a/spug_web/src/pages/monitor/store.js b/spug_web/src/pages/monitor/store.js index 6ea9cfc..cf6901f 100644 --- a/spug_web/src/pages/monitor/store.js +++ b/spug_web/src/pages/monitor/store.js @@ -5,6 +5,7 @@ */ import { observable } from "mobx"; import http from 'libs/http'; +import moment from "moment"; class Store { @observable records = []; @@ -18,7 +19,13 @@ class Store { fetchRecords = () => { this.isFetching = true; http.get('/api/monitor/') - .then(res => this.records = res) + .then(res => { + res.map(item => { + const value = item['latest_run_time']; + item['latest_run_time'] = value ? moment(value).fromNow() : null + }); + this.records = res + }) .finally(() => this.isFetching = false) }; diff --git a/spug_web/src/pages/schedule/Table.js b/spug_web/src/pages/schedule/Table.js index e27dd3d..92a058e 100644 --- a/spug_web/src/pages/schedule/Table.js +++ b/spug_web/src/pages/schedule/Table.js @@ -58,9 +58,8 @@ class ComTable extends React.Component { } }, }, { - title: '最近时间', + title: '更新于', dataIndex: 'latest_run_time', - render: value => value ? moment(value).fromNow() : 'N/A' }, { title: '描述信息', dataIndex: 'desc', diff --git a/spug_web/src/pages/schedule/store.js b/spug_web/src/pages/schedule/store.js index 4a45879..5f6558d 100644 --- a/spug_web/src/pages/schedule/store.js +++ b/spug_web/src/pages/schedule/store.js @@ -5,6 +5,7 @@ */ import { observable } from "mobx"; import http from 'libs/http'; +import moment from "moment"; class Store { @observable records = []; @@ -23,6 +24,10 @@ class Store { this.isFetching = true; http.get('/api/schedule/') .then(({types, tasks}) => { + tasks.map(item => { + const value = item['latest_run_time']; + item['latest_run_time'] = value ? moment(value).fromNow() : null + }); this.records = tasks; this.types = types })