Commit 770430ac by Kyle_Li

fix: 时间格式化

parent bb72ee83
......@@ -19,7 +19,7 @@
maxlength="32"
clearable>
</el-input>
<el-button type="primary" @click="dialogVisible = true">移除白名单</el-button>
<!-- <el-button type="primary" @click="dialogVisible = true">移除白名单</el-button> -->
</header>
......@@ -33,7 +33,7 @@
label="更新时间"
show-overflow-tooltip>
<template slot-scope="{row}">
{{ row.updateTime }}
{{ row.updateTime | formatDate('ymd') }} <br /> {{ row.updateTime | formatDate('hms') }}
</template>
</el-table-column>
......@@ -139,6 +139,25 @@ export default {
}
},
filters: {
formatDate(val, format) {
if(!val) return '--';
val = new Date(val);
let y = val.getFullYear();
let m = (val.getMonth() + 1).toString().padStart(2, '0');
let d = val.getDate().toString().padStart(2, '0');
let h = val.getHours().toString().padStart(2, '0');
let mm = val.getMinutes().toString().padStart(2, '0');
let s = val.getSeconds().toString().padStart(2, '0');
if(format == 'ymd') {
return `${y}-${m}-${d}`;
} else if(format == 'hms') {
return `${h}:${mm}:${s}`;
}
return `${y}-${m}-${d}\xa0\xa0\xa0${h}:${mm}:${s}`;
}
},
methods: {
getList() {
this.load = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment