This commit is contained in:
2023-08-11 10:45:20 +08:00
commit 161ca982f3
31850 changed files with 2706500 additions and 0 deletions

30
src/utils/common.js Normal file
View File

@ -0,0 +1,30 @@
const formatDate = date => {
let tempDate = new Date(date)
const year = tempDate.getFullYear()
const month = tempDate.getMonth() + 1
const day = tempDate.getDate()
return `${[year, month, day].map(formatNumber).join('-')}`
}
const formatNumber = n => {
n = n.toString()
return n[1] ? n : `0${n}`
}
const leftCopy = (obj, source) => {
let sourceKey = Object.keys(source)
if (obj && source) {
Object.keys(obj).forEach(key => {
if (sourceKey.includes(key)) {
obj[key] = source[key] == null ? '' : source[key]
}
})
}
}
module.exports = {
formatNumber,
formatDate,
leftCopy,
}