重构:优化配置管理的 date 格式化

This commit is contained in:
YunaiV 2023-03-10 09:45:40 +08:00
parent 72b0ec23f5
commit 0dd3b77f2d
2 changed files with 28 additions and 10 deletions

View File

@ -1,3 +1,5 @@
import dayjs from 'dayjs'
/** /**
* *
* @param date new Date() * @param date new Date()
@ -174,3 +176,18 @@ export function formatPast2(ms) {
return 0 + '秒' return 0 + '秒'
} }
} }
/**
* element plus Formatter 使 YYYY-MM-DD HH:mm:ss
*
* @param row
* @param column
* @param cellValue
*/
// @ts-ignore
export const dateFormatter = (row, column, cellValue) => {
if (!cellValue) {
return
}
return dayjs(cellValue).format('YYYY-MM-DD HH:mm:ss')
}

View File

@ -88,7 +88,7 @@
</el-row> </el-row>
<!-- 列表 --> <!-- 列表 -->
<el-table v-loading="loading" :data="list"> <el-table v-loading="loading" :data="list" align="center">
<el-table-column label="参数主键" align="center" prop="id" /> <el-table-column label="参数主键" align="center" prop="id" />
<el-table-column label="参数分类" align="center" prop="category" /> <el-table-column label="参数分类" align="center" prop="category" />
<el-table-column label="参数名称" align="center" prop="name" :show-overflow-tooltip="true" /> <el-table-column label="参数名称" align="center" prop="name" :show-overflow-tooltip="true" />
@ -105,13 +105,13 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" /> <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" />
<!-- TODO 芋艿时间写的有点复杂 --> <el-table-column
<el-table-column label="创建时间" align="center" prop="createTime" width="180"> label="创建时间"
<template #default="scope"> align="center"
<!-- <span>{{ parseTime(scope.row.createTime) }}</span>--> prop="createTime"
<span>{{ dayjs(scope.row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span> width="180"
</template> :formatter="dateFormatter"
</el-table-column> />
<!-- TODO 芋艿宽度里面的 css --> <!-- TODO 芋艿宽度里面的 css -->
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope"> <template #default="scope">
@ -141,10 +141,10 @@
</template> </template>
<script setup lang="ts" name="Config"> <script setup lang="ts" name="Config">
import { DICT_TYPE, getDictOptions } from '@/utils/dict' import { DICT_TYPE, getDictOptions } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import * as ConfigApi from '@/api/infra/config' import * as ConfigApi from '@/api/infra/config'
import ConfigForm from './form.vue' import ConfigForm from './form.vue'
import dayjs from 'dayjs'
import download from '@/utils/download'
const message = useMessage() // const message = useMessage() //
const { t } = useI18n() // const { t } = useI18n() //
@ -206,6 +206,7 @@ const handleDelete = async (id: number) => {
} catch {} } catch {}
} }
/** 导出按钮操作 */
const handleExport = async () => { const handleExport = async () => {
try { try {
// //