Initial commit
This commit is contained in:
29
src/filters/index.js
Normal file
29
src/filters/index.js
Normal file
@ -0,0 +1,29 @@
|
||||
import dayjs from "dayjs";
|
||||
// https://dayjs.fenxianglu.cn/category/display.html#%E6%A0%BC%E5%BC%8F%E5%8C%96
|
||||
|
||||
const dateFilter = (val, format = "YYYY-MM-DD HH:mm:ss") => {
|
||||
if (val) {
|
||||
if (!isNaN(val)) {
|
||||
val = parseInt(val);
|
||||
}
|
||||
return dayjs(val).format(format);
|
||||
} else {
|
||||
return '--'
|
||||
}
|
||||
};
|
||||
|
||||
const isAvailable = (val) => {
|
||||
if (val === 0) return true;
|
||||
if (val == null || val == undefined || val == '' || val == 'undefined' || val == 'null') {
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
export default (app) => {
|
||||
app.config.globalProperties.$filters = {
|
||||
dateFilter,
|
||||
isAvailable
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user