<el-table :data="tableData" style="width: 100%" height="100%" border>
<el-table-column prop="sbks" label="科室" align="center">
</el-table-column>
<el-table-column prop="status" label="提交状态" sortable align="center">
<template slot-scope="scope">
<span v-if="scope.row.status=='2'" style="color: rgb(1 210 20);font-weight: 800;">已提交</span>
<span v-else-if="scope.row.status=='1'" style="color: red;font-weight: 800;">未提交</span>
</template>
</el-table-column>
<!-- <el-table-column prop="submit_date" label="提交时间" sortable align="center">
</el-table-column> -->
<el-table-column label="提交时间" sortable align="center">
<template slot-scope="scope">
<span>{{scope.row.submit_date|formatDate}}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<template slot-scope="scope">
<el-button @click.native.prevent="showXq(scope.$index, tableData)" type="text" size="small">
查看详情
</el-button>
</template>
</el-table-column>
方式一:
//过滤器
filters: {
//过滤时间为年-月-日 hh:mm:ss
formatDate: function (oldDate) {
debugger
// 方式1 转换为'yyyy-MM-dd HH:mm:ss'
function add0(num) { return num < 10 ? '0' + num : num } // 个位数的值在前面补0
const date = new Date(oldDate)
const Y = date.getFullYear()
const M = date.getMonth() + 1
const D = date.getDate()
const h = date.getHours()
const m = date.getMinutes()
const s = date.getSeconds()
const dateString = Y + '-' + add0(M) + '-' + add0(D) + ' ' + add0(h) + ':' + add0(m) + ':' + add0(s)
return dateString
// 方式2 转换为'yyyy/MM/dd HH:mm:ss'
// return new Date(oldDate).toLocaleString()
},
//过滤器
filters: {
//过滤时间为年-月-日 hh:mm:ss
formatDate: function (timestamp) {
debugger
if (timestamp) {
var date = new Date(parseInt(timestamp));//时间戳为10位需*1000,时间戳为13位的话不需乘1000
let Y = date.getFullYear() + '-';
let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
let D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' ';
let h = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours()) + ':';
let m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes()) + ':';
let s = (date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds());
return Y + M + D + h + m + s;
} else {
return "";
}
}
},