Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0dd3b77f
authored
Mar 10, 2023
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重构:优化配置管理的 date 格式化
parent
72b0ec23
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
10 deletions
+28
-10
src/utils/formatTime.ts
+17
-0
src/views/infra/config/index.vue
+11
-10
No files found.
src/utils/formatTime.ts
View file @
0dd3b77f
import
dayjs
from
'dayjs'
/**
/**
* 时间日期转换
* 时间日期转换
* @param date 当前时间,new Date() 格式
* @param date 当前时间,new Date() 格式
...
@@ -174,3 +176,18 @@ export function formatPast2(ms) {
...
@@ -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'
)
}
src/views/infra/config/index.vue
View file @
0dd3b77f
...
@@ -88,7 +88,7 @@
...
@@ -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 @@
...
@@ -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 @@
...
@@ -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) => {
...
@@ -206,6 +206,7 @@ const handleDelete = async (id: number) => {
}
catch
{}
}
catch
{}
}
}
/** 导出按钮操作 */
const
handleExport
=
async
()
=>
{
const
handleExport
=
async
()
=>
{
try
{
try
{
// 导出的二次确认
// 导出的二次确认
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment