import Vue from "vue";
import { formatDate } from "../plugins/utils";
import { DATA_TASK_STATUS, DATA_TASK_RESULT } from "../constants/enumerate";

const DEFAULT_FIELD = "--";

Vue.filter("defaultFieldFilter", function (val) {
  return val || DEFAULT_FIELD;
});
Vue.filter("enableFilter", function (val) {
  return val ? "启用" : "禁用";
});
Vue.filter("booleanFilter", function (val) {
  return val ? "是" : "否";
});
Vue.filter("timestampFilter", function (val) {
  return val
    ? formatDate("YYYY-MM-DD HH:mm:ss", new Date(val * 1))
    : DEFAULT_FIELD;
});
Vue.filter("dataTaskStatusFilter", function (val) {
  return DATA_TASK_STATUS[val] || DEFAULT_FIELD;
});
Vue.filter("dataTaskResultFilter", function (val) {
  return DATA_TASK_RESULT[val] || DEFAULT_FIELD;
});
