2022-08-10 10:58:21 +08:00
|
|
|
/** filters */
|
2022-09-01 09:16:51 +08:00
|
|
|
import moment from 'moment'
|
2022-08-10 10:58:21 +08:00
|
|
|
|
|
|
|
export const dictFilter = dictTypeId => {
|
|
|
|
return val => {
|
|
|
|
return JSON.parse(localStorage.getItem('dictList'))[dictTypeId].find(item => item.dictValue === val)?.dictLabel || '-'
|
|
|
|
}
|
2022-09-01 09:16:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export const timeFilter = (val) => {
|
|
|
|
return moment(val).format('YYYY-MM-DD HH:mm:ss')
|
|
|
|
}
|
2022-10-09 11:31:54 +08:00
|
|
|
|
|
|
|
export const pick = (obj, paths) => {
|
|
|
|
let result = {}
|
|
|
|
paths.forEach(key => {
|
|
|
|
if (obj.hasOwnProperty(key)) {
|
|
|
|
result[key] = obj[key];
|
|
|
|
} else {
|
|
|
|
result[key] = null
|
|
|
|
}
|
|
|
|
})
|
|
|
|
return result
|
|
|
|
}
|