You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.0 KiB
72 lines
2.0 KiB
|
|
export const formatTimeText = (seconds) => { |
|
if (!seconds) { |
|
return '' |
|
} |
|
if (seconds < 0) { |
|
return formatTimeText(-seconds); |
|
} |
|
// 秒 |
|
if (seconds < 60) { |
|
return seconds + '秒' |
|
} |
|
// 分钟 |
|
if (seconds < 3600) { |
|
return `${Math.floor(seconds / 60)}分${seconds % 60}秒` |
|
} |
|
// 小时 |
|
if (seconds < 86400) { |
|
const remainder = seconds % 3600; |
|
return `${Math.floor(seconds / 3600)}时${parseInt(seconds % 3600 / 60)}分` |
|
} |
|
// 天 |
|
const remainder = seconds % 86400; |
|
return `${Math.floor(seconds / 86400)}天${parseInt(seconds % 86400 / 3600)}时` |
|
} |
|
|
|
export const getDictLable = (dictArr, value) => { |
|
if (!value) { |
|
return '' |
|
} |
|
if (!dictArr || !dictArr.length) { |
|
return '' |
|
} |
|
const obj = dictArr.find(item => item.value === value) |
|
if (!obj) { |
|
return '' |
|
} |
|
return obj.text; |
|
} |
|
|
|
export function getFlowTagType(flowName) { |
|
if (flowName === '待签收' || flowName === '待签收(协办)' || flowName === '信件退回' || flowName === '退回整改') { |
|
return 'danger' |
|
} |
|
if (flowName === '待下发' || flowName === '联系群众') { |
|
return 'warning' |
|
} |
|
if (flowName === '已办结') { |
|
return 'success' |
|
} |
|
return '' |
|
} |
|
|
|
export function dateFormat(date) { |
|
let year = date.getFullYear(); |
|
let month = date.getMonth() + 1; |
|
let day = date.getDate(); |
|
let hours = date.getHours(); |
|
let minutes = date.getMinutes(); |
|
let seconds = date.getSeconds(); |
|
|
|
// 将月、日小于 10 的数字前面补零 |
|
month = month < 10 ? '0' + month : month; |
|
day = day < 10 ? '0' + day : day; |
|
hours = hours < 10 ? '0' + hours : hours; |
|
minutes = minutes < 10 ? '0' + minutes : minutes; |
|
seconds = seconds < 10 ? '0' + seconds : seconds; |
|
|
|
// 格式化日期字符串 |
|
const formattedDate = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds; |
|
return formattedDate |
|
} |