Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vue-composition-api
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
宁路鹏
vue-composition-api
Commits
f70ebd2c
Commit
f70ebd2c
authored
Feb 27, 2023
by
wangshuangqing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
勾选展示当前时间字段
parent
048a0eab
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
126 additions
and
70 deletions
+126
-70
src/utils/formatTime.js
+107
-67
src/views/outClinicalpathway.vue
+19
-3
No files found.
src/utils/formatTime.js
View file @
f70ebd2c
...
...
@@ -10,9 +10,9 @@
* @returns 返回拼接后的时间字符串
*/
export
function
formatDate
(
date
,
format
)
{
const
we
=
date
.
getDay
();
// 星期
const
z
=
getWeek
(
date
);
// 周
const
qut
=
Math
.
floor
((
date
.
getMonth
()
+
3
)
/
3
).
toString
();
// 季度
const
we
=
date
.
getDay
()
// 星期
const
z
=
getWeek
(
date
)
// 周
const
qut
=
Math
.
floor
((
date
.
getMonth
()
+
3
)
/
3
).
toString
()
// 季度
const
opt
=
{
'Y+'
:
date
.
getFullYear
().
toString
(),
// 年
'm+'
:
(
date
.
getMonth
()
+
1
).
toString
(),
// 月(月份从0开始,要+1)
...
...
@@ -21,7 +21,7 @@ export function formatDate(date, format) {
'M+'
:
date
.
getMinutes
().
toString
(),
// 分
'S+'
:
date
.
getSeconds
().
toString
(),
// 秒
'q+'
:
qut
,
// 季度
};
}
// 中文数字 (星期)
const
week
=
{
0
:
'日'
,
...
...
@@ -31,25 +31,44 @@ export function formatDate(date, format) {
4
:
'四'
,
5
:
'五'
,
6
:
'六'
,
};
}
// 中文数字(季度)
const
quarter
=
{
1
:
'一'
,
2
:
'二'
,
3
:
'三'
,
4
:
'四'
,
};
}
if
(
/
(
W+
)
/
.
test
(
format
))
{
format
=
format
.
replace
(
RegExp
.
$1
,
RegExp
.
$1
.
length
>
1
?
(
RegExp
.
$1
.
length
>
2
?
'星期'
+
week
[
we
]
:
'周'
+
week
[
we
])
:
week
[
we
]);
format
=
format
.
replace
(
RegExp
.
$1
,
RegExp
.
$1
.
length
>
1
?
RegExp
.
$1
.
length
>
2
?
'星期'
+
week
[
we
]
:
'周'
+
week
[
we
]
:
week
[
we
],
)
}
if
(
/
(
Q+
)
/
.
test
(
format
))
format
=
format
.
replace
(
RegExp
.
$1
,
RegExp
.
$1
.
length
==
4
?
'第'
+
quarter
[
qut
]
+
'季度'
:
quarter
[
qut
]);
if
(
/
(
Z+
)
/
.
test
(
format
))
format
=
format
.
replace
(
RegExp
.
$1
,
RegExp
.
$1
.
length
==
3
?
'第'
+
z
+
'周'
:
z
+
''
);
if
(
/
(
Q+
)
/
.
test
(
format
))
format
=
format
.
replace
(
RegExp
.
$1
,
RegExp
.
$1
.
length
==
4
?
'第'
+
quarter
[
qut
]
+
'季度'
:
quarter
[
qut
],
)
if
(
/
(
Z+
)
/
.
test
(
format
))
format
=
format
.
replace
(
RegExp
.
$1
,
RegExp
.
$1
.
length
==
3
?
'第'
+
z
+
'周'
:
z
+
''
,
)
for
(
const
k
in
opt
)
{
const
r
=
new
RegExp
(
'('
+
k
+
')'
).
exec
(
format
);
const
r
=
new
RegExp
(
'('
+
k
+
')'
).
exec
(
format
)
// 若输入的长度不为1,则前面补零
if
(
r
)
format
=
format
.
replace
(
r
[
1
],
RegExp
.
$1
.
length
==
1
?
opt
[
k
]
:
opt
[
k
].
padStart
(
RegExp
.
$1
.
length
,
'0'
));
if
(
r
)
format
=
format
.
replace
(
r
[
1
],
RegExp
.
$1
.
length
==
1
?
opt
[
k
]
:
opt
[
k
].
padStart
(
RegExp
.
$1
.
length
,
'0'
),
)
}
return
format
;
return
format
}
/**
...
...
@@ -58,19 +77,19 @@ export function formatDate(date, format) {
* @returns 返回第几周数字值
*/
export
function
getWeek
(
dateTime
)
{
const
temptTime
=
new
Date
(
dateTime
.
getTime
());
const
temptTime
=
new
Date
(
dateTime
.
getTime
())
// 周几
const
weekday
=
temptTime
.
getDay
()
||
7
;
const
weekday
=
temptTime
.
getDay
()
||
7
// 周1+5天=周六
temptTime
.
setDate
(
temptTime
.
getDate
()
-
weekday
+
1
+
5
);
let
firstDay
=
new
Date
(
temptTime
.
getFullYear
(),
0
,
1
);
const
dayOfWeek
=
firstDay
.
getDay
();
let
spendDay
=
1
;
if
(
dayOfWeek
!=
0
)
spendDay
=
7
-
dayOfWeek
+
1
;
firstDay
=
new
Date
(
temptTime
.
getFullYear
(),
0
,
1
+
spendDay
);
const
d
=
Math
.
ceil
((
temptTime
.
valueOf
()
-
firstDay
.
valueOf
())
/
86400000
);
const
result
=
Math
.
ceil
(
d
/
7
);
return
result
;
temptTime
.
setDate
(
temptTime
.
getDate
()
-
weekday
+
1
+
5
)
let
firstDay
=
new
Date
(
temptTime
.
getFullYear
(),
0
,
1
)
const
dayOfWeek
=
firstDay
.
getDay
()
let
spendDay
=
1
if
(
dayOfWeek
!=
0
)
spendDay
=
7
-
dayOfWeek
+
1
firstDay
=
new
Date
(
temptTime
.
getFullYear
(),
0
,
1
+
spendDay
)
const
d
=
Math
.
ceil
((
temptTime
.
valueOf
()
-
firstDay
.
valueOf
())
/
86400000
)
const
result
=
Math
.
ceil
(
d
/
7
)
return
result
}
/**
...
...
@@ -86,36 +105,38 @@ export function getWeek(dateTime) {
*/
export
function
formatPast
(
param
,
format
)
{
// 传入格式处理、存储转换值
let
t
,
s
;
let
t
,
s
// 获取js 时间戳
let
time
=
new
Date
().
getTime
();
let
time
=
new
Date
().
getTime
()
// 是否是对象
typeof
param
===
'string'
||
'object'
?
(
t
=
new
Date
(
param
).
getTime
())
:
(
t
=
param
);
typeof
param
===
'string'
||
'object'
?
(
t
=
new
Date
(
param
).
getTime
())
:
(
t
=
param
)
// 当前时间戳 - 传入时间戳
time
=
Number
.
parseInt
(
`
${
time
-
t
}
`
);
time
=
Number
.
parseInt
(
`
${
time
-
t
}
`
)
if
(
time
<
10000
)
{
// 10秒内
return
'刚刚'
;
return
'刚刚'
}
else
if
(
time
<
60000
&&
time
>=
10000
)
{
// 超过10秒少于1分钟内
s
=
Math
.
floor
(
time
/
1000
);
return
`
${
s
}
秒前`
;
s
=
Math
.
floor
(
time
/
1000
)
return
`
${
s
}
秒前`
}
else
if
(
time
<
3600000
&&
time
>=
60000
)
{
// 超过1分钟少于1小时
s
=
Math
.
floor
(
time
/
60000
);
return
`
${
s
}
分钟前`
;
s
=
Math
.
floor
(
time
/
60000
)
return
`
${
s
}
分钟前`
}
else
if
(
time
<
86400000
&&
time
>=
3600000
)
{
// 超过1小时少于24小时
s
=
Math
.
floor
(
time
/
3600000
);
return
`
${
s
}
小时前`
;
s
=
Math
.
floor
(
time
/
3600000
)
return
`
${
s
}
小时前`
}
else
if
(
time
<
259200000
&&
time
>=
86400000
)
{
// 超过1天少于3天内
s
=
Math
.
floor
(
time
/
86400000
);
return
`
${
s
}
天前`
;
s
=
Math
.
floor
(
time
/
86400000
)
return
`
${
s
}
天前`
}
else
{
// 超过3天
const
date
=
typeof
param
===
'string'
||
'object'
?
new
Date
(
param
)
:
param
;
return
formatDate
(
date
,
format
);
const
date
=
typeof
param
===
'string'
||
'object'
?
new
Date
(
param
)
:
param
return
formatDate
(
date
,
format
)
}
}
...
...
@@ -126,39 +147,58 @@ export function formatPast(param, format) {
* @returns 返回拼接后的时间字符串
*/
export
function
formatAxis
(
param
)
{
const
hour
=
new
Date
(
param
).
getHours
();
if
(
hour
<
6
)
return
'凌晨好'
;
else
if
(
hour
<
9
)
return
'早上好'
;
else
if
(
hour
<
12
)
return
'上午好'
;
else
if
(
hour
<
14
)
return
'中午好'
;
else
if
(
hour
<
17
)
return
'下午好'
;
else
if
(
hour
<
19
)
return
'傍晚好'
;
else
if
(
hour
<
22
)
return
'晚上好'
;
else
return
'夜里好'
;
const
hour
=
new
Date
(
param
).
getHours
()
if
(
hour
<
6
)
return
'凌晨好'
else
if
(
hour
<
9
)
return
'早上好'
else
if
(
hour
<
12
)
return
'上午好'
else
if
(
hour
<
14
)
return
'中午好'
else
if
(
hour
<
17
)
return
'下午好'
else
if
(
hour
<
19
)
return
'傍晚好'
else
if
(
hour
<
22
)
return
'晚上好'
else
return
'夜里好'
}
export
function
transformTimestamp
(
timestamp
)
{
const
date
=
new
Date
(
timestamp
);
const
Y
=
date
.
getFullYear
();
const
M
=
date
.
getMonth
()
+
1
<
10
?
'0'
+
(
date
.
getMonth
()
+
1
)
:
date
.
getMonth
()
+
1
;
const
D
=
date
.
getDate
()
<
10
?
'0'
+
date
.
getDate
()
:
date
.
getDate
();
const
h
=
(
date
.
getHours
()
<
10
?
'0'
+
date
.
getHours
()
:
date
.
getHours
())
+
':'
;
const
m
=
(
date
.
getMinutes
()
<
10
?
'0'
+
date
.
getMinutes
()
:
date
.
getMinutes
())
+
':'
;
const
s
=
date
.
getSeconds
()
<
10
?
'0'
+
date
.
getSeconds
()
:
date
.
getSeconds
();
// 秒
const
dateString
=
`
${
Y
}
-
${
M
}
-
${
D
}
${
h
}${
m
}${
s
}
`
;
return
dateString
;
const
date
=
new
Date
(
timestamp
)
const
Y
=
date
.
getFullYear
()
const
M
=
date
.
getMonth
()
+
1
<
10
?
'0'
+
(
date
.
getMonth
()
+
1
)
:
date
.
getMonth
()
+
1
const
D
=
date
.
getDate
()
<
10
?
'0'
+
date
.
getDate
()
:
date
.
getDate
()
const
h
=
(
date
.
getHours
()
<
10
?
'0'
+
date
.
getHours
()
:
date
.
getHours
())
+
':'
const
m
=
(
date
.
getMinutes
()
<
10
?
'0'
+
date
.
getMinutes
()
:
date
.
getMinutes
())
+
':'
const
s
=
date
.
getSeconds
()
<
10
?
'0'
+
date
.
getSeconds
()
:
date
.
getSeconds
()
// 秒
const
dateString
=
`
${
Y
}
-
${
M
}
-
${
D
}
${
h
}${
m
}${
s
}
`
return
dateString
}
//获取实时时间
export
function
transformTimestampnow
()
{
const
date
=
new
Date
()
const
Y
=
date
.
getFullYear
()
const
M
=
date
.
getMonth
()
+
1
<
10
?
'0'
+
(
date
.
getMonth
()
+
1
)
:
date
.
getMonth
()
+
1
const
D
=
date
.
getDate
()
<
10
?
'0'
+
date
.
getDate
()
:
date
.
getDate
()
const
h
=
(
date
.
getHours
()
<
10
?
'0'
+
date
.
getHours
()
:
date
.
getHours
())
+
':'
const
m
=
(
date
.
getMinutes
()
<
10
?
'0'
+
date
.
getMinutes
()
:
date
.
getMinutes
())
+
':'
const
s
=
date
.
getSeconds
()
<
10
?
'0'
+
date
.
getSeconds
()
:
date
.
getSeconds
()
// 秒
const
dateString
=
`
${
Y
}
-
${
M
}
-
${
D
}
${
h
}${
m
}${
s
}
`
return
dateString
}
export
function
transformTimestamps
(
timestamp
)
{
const
date
=
new
Date
(
timestamp
);
const
Y
=
date
.
getFullYear
();
const
M
=
date
.
getMonth
()
+
1
<
10
?
'0'
+
(
date
.
getMonth
()
+
1
)
:
date
.
getMonth
()
+
1
;
const
D
=
date
.
getDate
()
<
10
?
'0'
+
date
.
getDate
()
:
date
.
getDate
();
const
h
=
(
date
.
getHours
()
<
10
?
'0'
+
date
.
getHours
()
:
date
.
getHours
())
+
':'
;
const
m
=
(
date
.
getMinutes
()
<
10
?
'0'
+
date
.
getMinutes
()
:
date
.
getMinutes
())
+
':'
;
const
s
=
date
.
getSeconds
()
<
10
?
'0'
+
date
.
getSeconds
()
:
date
.
getSeconds
();
// 秒
const
dateString
=
`
${
Y
}
-
${
M
}
-
${
D
}
`
;
return
dateString
;
const
date
=
new
Date
(
timestamp
)
const
Y
=
date
.
getFullYear
()
const
M
=
date
.
getMonth
()
+
1
<
10
?
'0'
+
(
date
.
getMonth
()
+
1
)
:
date
.
getMonth
()
+
1
const
D
=
date
.
getDate
()
<
10
?
'0'
+
date
.
getDate
()
:
date
.
getDate
()
const
h
=
(
date
.
getHours
()
<
10
?
'0'
+
date
.
getHours
()
:
date
.
getHours
())
+
':'
const
m
=
(
date
.
getMinutes
()
<
10
?
'0'
+
date
.
getMinutes
()
:
date
.
getMinutes
())
+
':'
const
s
=
date
.
getSeconds
()
<
10
?
'0'
+
date
.
getSeconds
()
:
date
.
getSeconds
()
// 秒
const
dateString
=
`
${
Y
}
-
${
M
}
-
${
D
}
`
return
dateString
}
src/views/outClinicalpathway.vue
View file @
f70ebd2c
...
...
@@ -2,7 +2,7 @@
* @Author: wsq
* @Date: 2022-04-22 15:20:58
* @LastEditors: wsq
* @LastEditTime: 2023-02-27 15:
05:14
* @LastEditTime: 2023-02-27 15:
53:26
* @Description:
-->
<
template
>
...
...
@@ -158,7 +158,19 @@
label=
"路径名称"
width=
"120"
/>
<el-table-column
show-overflow-tooltip
property=
"tickTime"
label=
"当前时间"
width=
"90"
>
<
template
#
default=
"scope"
>
<span
v-if=
"scope.row.advice_name == null && scope.row.ischeck == 1"
>
{{
transformTime
()
}}
</span
>
</
template
>
</el-table-column>
<el-table-column
show-overflow-tooltip
property=
"orderType"
...
...
@@ -507,7 +519,7 @@ import { useRoute, useRouter } from "../utils/useVueRouter";
import
{
setItem
,
getItem
}
from
"../utils/auth"
;
import
{
Loading
}
from
"element-ui"
;
import
_
from
"lodash"
;
import
{
transformTimestampnow
}
from
"../utils/formatTime"
;
export
default
{
name
:
"outClinicalpathway"
,
setup
()
{
...
...
@@ -522,6 +534,9 @@ export default {
}
const
monthlyPlanTable
=
ref
();
const
multipleTable
=
ref
();
const
transformTime
=
computed
(()
=>
{
return
transformTimestampnow
;
});
let
state
=
reactive
({
//患者信息
topdata
:
{
...
...
@@ -948,6 +963,7 @@ export default {
gemedicUsePlanoptions
,
radiochange
,
getmedicalPurposeoptions
,
transformTime
,
};
},
};
...
...
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