import { MessageTimeFormat } from '@/utils/date'
import { ocAccess, taskPriority, taskStatus, taskType } from '@/utils/tool'

// 通用方法混入
const commonMethodMixin = {
  // 医院分类
  hosCatFilter(id: any) {
    const enums = new Map()
    enums.set(1, '综合医院')
    enums.set(2, '专科医院')
    enums.set(3, '教学医院')
    enums.set(4, '诊所')
    return enums.get(id)
  },

  // 医院等级
  hosGradeFilter(code: string | number) {
    const enums = {
      1: '一级丙等',
      2: '一级乙等',
      3: '一级甲等',
      4: '二级丙等',
      5: '二级乙等',
      6: '二级甲等',
      7: '三级丙等',
      8: '三级乙等',
      9: '三级甲等',
      10: '三级特等',
    }
    return code && enums[code as unknown as keyof typeof enums]
  },
  taskTypeFilter(val: any) {
    return taskType(val)
  },
  taskPriorityFilter(val: any) {
    return taskPriority(val)
  },
  taskStatusFilter(val: any) {
    return taskStatus(val)
  },
  niceDateFilter(d: any) {
    return MessageTimeFormat(d)
  },
  accessFilter(val: any) {
    return ocAccess(val)
  },
  textSplitArray(string: string, flag = '；') {
    if (string) {
      return string.split(flag)
    }
  },
}

export default commonMethodMixin
