Commit f70ebd2c by wangshuangqing

勾选展示当前时间字段

parent 048a0eab
...@@ -10,46 +10,65 @@ ...@@ -10,46 +10,65 @@
* @returns 返回拼接后的时间字符串 * @returns 返回拼接后的时间字符串
*/ */
export function formatDate(date, format) { export function formatDate(date, format) {
const we = date.getDay(); // 星期 const we = date.getDay() // 星期
const z = getWeek(date); // 周 const z = getWeek(date) // 周
const qut = Math.floor((date.getMonth() + 3) / 3).toString(); // 季度 const qut = Math.floor((date.getMonth() + 3) / 3).toString() // 季度
const opt = { const opt = {
'Y+': date.getFullYear().toString(), // 年 'Y+': date.getFullYear().toString(), // 年
'm+': (date.getMonth() + 1).toString(), // 月(月份从0开始,要+1) 'm+': (date.getMonth() + 1).toString(), // 月(月份从0开始,要+1)
'd+': date.getDate().toString(), // 日 'd+': date.getDate().toString(), // 日
'H+': date.getHours().toString(), // 时 'H+': date.getHours().toString(), // 时
'M+': date.getMinutes().toString(), // 分 'M+': date.getMinutes().toString(), // 分
'S+': date.getSeconds().toString(), // 秒 'S+': date.getSeconds().toString(), // 秒
'q+': qut, // 季度 'q+': qut, // 季度
}; }
// 中文数字 (星期) // 中文数字 (星期)
const week = { const week = {
0: '日', 0: '日',
1: '一', 1: '一',
2: '二', 2: '二',
3: '三', 3: '三',
4: '四', 4: '四',
5: '五', 5: '五',
6: '六', 6: '六',
}; }
// 中文数字(季度) // 中文数字(季度)
const quarter = { const quarter = {
1: '一', 1: '一',
2: '二', 2: '二',
3: '三', 3: '三',
4: '四', 4: '四',
}; }
if (/(W+)/.test(format)) { 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,
if (/(Q+)/.test(format)) format = format.replace(RegExp.$1, RegExp.$1.length == 4 ? '第' + quarter[qut] + '季度' : quarter[qut]); RegExp.$1.length > 1
if (/(Z+)/.test(format)) format = format.replace(RegExp.$1, RegExp.$1.length == 3 ? '第' + z + '周' : z + ''); ? RegExp.$1.length > 2
for (const k in opt) { ? '星期' + week[we]
const r = new RegExp('(' + k + ')').exec(format); : '周' + week[we]
// 若输入的长度不为1,则前面补零 : week[we],
if (r) format = format.replace(r[1], RegExp.$1.length == 1 ? opt[k] : opt[k].padStart(RegExp.$1.length, '0')); )
} }
return format; 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)
// 若输入的长度不为1,则前面补零
if (r)
format = format.replace(
r[1],
RegExp.$1.length == 1 ? opt[k] : opt[k].padStart(RegExp.$1.length, '0'),
)
}
return format
} }
/** /**
...@@ -58,19 +77,19 @@ export function formatDate(date, format) { ...@@ -58,19 +77,19 @@ export function formatDate(date, format) {
* @returns 返回第几周数字值 * @returns 返回第几周数字值
*/ */
export function getWeek(dateTime) { 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天=周六 // 周1+5天=周六
temptTime.setDate(temptTime.getDate() - weekday + 1 + 5); temptTime.setDate(temptTime.getDate() - weekday + 1 + 5)
let firstDay = new Date(temptTime.getFullYear(), 0, 1); let firstDay = new Date(temptTime.getFullYear(), 0, 1)
const dayOfWeek = firstDay.getDay(); const dayOfWeek = firstDay.getDay()
let spendDay = 1; let spendDay = 1
if (dayOfWeek != 0) spendDay = 7 - dayOfWeek + 1; if (dayOfWeek != 0) spendDay = 7 - dayOfWeek + 1
firstDay = new Date(temptTime.getFullYear(), 0, 1 + spendDay); firstDay = new Date(temptTime.getFullYear(), 0, 1 + spendDay)
const d = Math.ceil((temptTime.valueOf() - firstDay.valueOf()) / 86400000); const d = Math.ceil((temptTime.valueOf() - firstDay.valueOf()) / 86400000)
const result = Math.ceil(d / 7); const result = Math.ceil(d / 7)
return result; return result
} }
/** /**
...@@ -85,38 +104,40 @@ export function getWeek(dateTime) { ...@@ -85,38 +104,40 @@ export function getWeek(dateTime) {
* @returns 返回拼接后的时间字符串 * @returns 返回拼接后的时间字符串
*/ */
export function formatPast(param, format) { export function formatPast(param, format) {
// 传入格式处理、存储转换值 // 传入格式处理、存储转换值
let t, s; let t, s
// 获取js 时间戳 // 获取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())
time = Number.parseInt(`${time - t}`); : (t = param)
if (time < 10000) { // 当前时间戳 - 传入时间戳
// 10秒内 time = Number.parseInt(`${time - t}`)
return '刚刚'; if (time < 10000) {
} else if (time < 60000 && time >= 10000) { // 10秒内
// 超过10秒少于1分钟内 return '刚刚'
s = Math.floor(time / 1000); } else if (time < 60000 && time >= 10000) {
return `${s}秒前`; // 超过10秒少于1分钟内
} else if (time < 3600000 && time >= 60000) { s = Math.floor(time / 1000)
// 超过1分钟少于1小时 return `${s}秒前`
s = Math.floor(time / 60000); } else if (time < 3600000 && time >= 60000) {
return `${s}分钟前`; // 超过1分钟少于1小时
} else if (time < 86400000 && time >= 3600000) { s = Math.floor(time / 60000)
// 超过1小时少于24小时 return `${s}分钟前`
s = Math.floor(time / 3600000); } else if (time < 86400000 && time >= 3600000) {
return `${s}小时前`; // 超过1小时少于24小时
} else if (time < 259200000 && time >= 86400000) { s = Math.floor(time / 3600000)
// 超过1天少于3天内 return `${s}小时前`
s = Math.floor(time / 86400000); } else if (time < 259200000 && time >= 86400000) {
return `${s}天前`; // 超过1天少于3天内
} else { s = Math.floor(time / 86400000)
// 超过3天 return `${s}天前`
const date = typeof param === 'string' || 'object' ? new Date(param) : param; } else {
return formatDate(date, format); // 超过3天
} const date = typeof param === 'string' || 'object' ? new Date(param) : param
return formatDate(date, format)
}
} }
/** /**
...@@ -126,39 +147,58 @@ export function formatPast(param, format) { ...@@ -126,39 +147,58 @@ export function formatPast(param, format) {
* @returns 返回拼接后的时间字符串 * @returns 返回拼接后的时间字符串
*/ */
export function formatAxis(param) { export function formatAxis(param) {
const hour = new Date(param).getHours(); const hour = new Date(param).getHours()
if (hour < 6) return '凌晨好'; if (hour < 6) return '凌晨好'
else if (hour < 9) return '早上好'; else if (hour < 9) return '早上好'
else if (hour < 12) return '上午好'; else if (hour < 12) return '上午好'
else if (hour < 14) return '中午好'; else if (hour < 14) return '中午好'
else if (hour < 17) return '下午好'; else if (hour < 17) return '下午好'
else if (hour < 19) return '傍晚好'; else if (hour < 19) return '傍晚好'
else if (hour < 22) return '晚上好'; else if (hour < 22) return '晚上好'
else return '夜里好'; else return '夜里好'
} }
export function transformTimestamp(timestamp) { export function transformTimestamp(timestamp) {
const date = new Date(timestamp); const date = new Date(timestamp)
const Y = date.getFullYear(); const Y = date.getFullYear()
const M = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1; const M =
const D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate(); date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
const h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':'; const D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
const m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':'; const h =
const s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds(); // 秒 (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':'
const dateString = `${Y}-${M}-${D} ${h}${m}${s}`; const m =
return dateString; (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) { export function transformTimestamps(timestamp) {
const date = new Date(timestamp); const date = new Date(timestamp)
const Y = date.getFullYear(); const Y = date.getFullYear()
const M = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1; const M =
const D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate(); date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
const h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':'; const D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
const m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':'; const h =
const s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds(); // 秒 (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':'
const dateString = `${Y}-${M}-${D}`; const m =
return dateString; (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
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: wsq * @Author: wsq
* @Date: 2022-04-22 15:20:58 * @Date: 2022-04-22 15:20:58
* @LastEditors: wsq * @LastEditors: wsq
* @LastEditTime: 2023-02-27 15:05:14 * @LastEditTime: 2023-02-27 15:53:26
* @Description: * @Description:
--> -->
<template> <template>
...@@ -158,7 +158,19 @@ ...@@ -158,7 +158,19 @@
label="路径名称" label="路径名称"
width="120" 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 <el-table-column
show-overflow-tooltip show-overflow-tooltip
property="orderType" property="orderType"
...@@ -507,7 +519,7 @@ import { useRoute, useRouter } from "../utils/useVueRouter"; ...@@ -507,7 +519,7 @@ import { useRoute, useRouter } from "../utils/useVueRouter";
import { setItem, getItem } from "../utils/auth"; import { setItem, getItem } from "../utils/auth";
import { Loading } from "element-ui"; import { Loading } from "element-ui";
import _ from "lodash"; import _ from "lodash";
import { transformTimestampnow } from "../utils/formatTime";
export default { export default {
name: "outClinicalpathway", name: "outClinicalpathway",
setup() { setup() {
...@@ -522,6 +534,9 @@ export default { ...@@ -522,6 +534,9 @@ export default {
} }
const monthlyPlanTable = ref(); const monthlyPlanTable = ref();
const multipleTable = ref(); const multipleTable = ref();
const transformTime = computed(() => {
return transformTimestampnow;
});
let state = reactive({ let state = reactive({
//患者信息 //患者信息
topdata: { topdata: {
...@@ -948,6 +963,7 @@ export default { ...@@ -948,6 +963,7 @@ export default {
gemedicUsePlanoptions, gemedicUsePlanoptions,
radiochange, radiochange,
getmedicalPurposeoptions, getmedicalPurposeoptions,
transformTime,
}; };
}, },
}; };
......
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