mt-yd-ui/src/utils/filters.js

40 lines
827 B
JavaScript

/*
* @Descripttion:
* @version:
* @Author: fzq
* @Date: 2022-11-25 09:51:46
* @LastEditors: fzq
* @LastEditTime: 2023-01-11 20:52:35
*/
/** filters */
import moment from 'moment'
export const dictFilter = dictTypeId => {
return val => {
return JSON.parse(localStorage.getItem('dictList'))[dictTypeId].find(item => item.dictValue === val)?.dictLabel || '-'
}
}
export const timeFilter = (val) => {
return moment(val).format('YYYY-MM-DD HH:mm:ss')
}
export const pick = (obj, paths) => {
let result = {}
paths.forEach(key => {
if (obj.hasOwnProperty(key)) {
result[key] = obj[key];
} else {
result[key] = null
}
})
return result
}
// export function timeFormatter(timeObj) {
// if (timeObj) {
// return moment(timeObj).format('YYYY-MM-DD HH:mm:ss')
// } else {
// return '-'
// }
// }