import Vue from 'vue'
import dayjs from 'dayjs'
import numeral from 'numeral'
import * as constant from '../constant'
// 合并数组
Vue.filter('joinArray', (value, type) => {
  if (!type) {
    type = ' '
  }
  if (typeof value == 'object' && value != null) {
    return value.join(type)
  } else {
    return value
  }
})

// 合作单位
Vue.filter('branchType', (value) => {
  let template = {
    OWN: "自有",
    COOPERATION: "合作",
    LEASE: "租赁"
  }
  return template[value]
})

// 商品类型
Vue.filter('shopType', (value) => {
  let template = {
    "INSTRUMENT": "乐器",
    "ACCESSORIES": "辅件",
    "TEACHING": "教材",
    "STAFF": "教谱",
    "OTHER": "其它",
  }
  return template[value]
})

// 乐团状态
Vue.filter('musicGroupType', (value) => {
  let template = {
    APPLY: "报名中",
    PAY: "缴费中",
    PREPARE: "筹备中",
    PROGRESS: "进行中",
    CANCELED: '取消',
    PAUSE: '暂停',
    AUDIT: '审核中',
    DRAFT: '编辑中',
    AUDIT_FAILED: '审核失败'
  }
  return template[value]
})

// 乐团学员状态
Vue.filter('musicGroupStudentType', (value) => {
  let template = {
    NORMAL: "在读",
    LEAVE: "请假",
    QUIT: "退团",
    APPLY: '报名'
  }
  return template[value]
})

// 乐团学员状态
Vue.filter('instrumentType', (value) => {
  let template = {
    GROUP: "团购",
    OWNED: "自备",
    LEASE: "租赁"
  }
  return template[value]
})

// 课程类型
Vue.filter('coursesType', (value) => {
  let template = {
    NORMAL: '声部课',
    SINGLE: '声部课',
    MIX: "合奏课",
    HIGH: "基础技能课",
    VIP: "VIP课",
    DEMO: "试听课",
    COMPREHENSIVE: '综合课',
    // PRACTICE: '练习课',
    ENLIGHTENMENT: '启蒙课',
    TRAINING: '集训课',
    TRAINING_SINGLE: '集训声部课',
    TRAINING_MIX: '集训合奏课',
    CLASSROOM: '课堂课',
    PRACTICE: '网管课',
    COMM: '对外课',
    MUSIC: '乐团课',
    HIGH_ONLINE: '线上基础技能课',
    MUSIC_NETWORK: '乐团网管课'
  }
  return template[value]
})

// 课程状态
Vue.filter('coursesStatus', (value) => {
  let template = {
    NOT_START: "未开始",
    UNDERWAY: "进行中",
    OVER: "已结束"
  }
  return template[value]
})

// 考勤类型
Vue.filter('clockingIn', value => {
  let templateStatus = {
    NORMAL: "正常",
    TRUANT: "旷课",
    LEAVE: "请假",
    QUIT_SCHOOL: "休学",
    DROP_OUT: "退学"
  }
  return templateStatus[value]
})

// 学员状态
Vue.filter('studentTeamStatus', value => {
  let templateStatus = {
    NORMAL: "在读",
    QUIT: "退团",
    QUIT_SCHOOL: "休学",
    APPLY: '报名'
  }
  return templateStatus[value]
})

// 时间处理
Vue.filter('dayjsFormat', (value) => {
  if (value) {
    return dayjs(value).format('YYYY-MM-DD')
  } else {
    return value
  }
})

Vue.filter('dayjsFormatMinute', (value) => {
  if (value) {
    return dayjs(value).format('HH:mm')
  } else {
    return value
  }
})

Vue.filter('formatTimer', (value) => {
  if (value) {
    return value.split(' ')[0]
  } else {
    return value
  }
})
Vue.filter('timerForMinFormat', (value) => {
  if (value) {
    return value.substring(0, 5)
  } else {
    return value
  }
})
Vue.filter('dateForMinFormat', (value) => {
  if (value) {
    return value.substring(0, 16)
  } else {
    return value
  }
})

Vue.filter('paymentPatternTypeFormat', val => constant.paymentPatternType[val])
// 支付用户类型
Vue.filter('payUserTypeFormat', val => constant.payUserType[val])
// 支付缴费方式
Vue.filter('userPaymentTypeFormat', val => constant.userPaymentType[val])
// 课程类型格式化
Vue.filter('courseTypeFormat', val => constant.courseType[val])
// 格式化签到签退记录 updateAttendanceEnum
Vue.filter('updateAttendanceEnum', val => constant.updateAttendanceEnum[val])

// 时间处理
Vue.filter('timer', (value) => {
  if (value) {
    let tempDate = new Date(value)
    let month = tempDate.getHours() >= 10 ? tempDate.getHours() : '0' + tempDate.getHours()
    let days = tempDate.getMinutes() >= 10 ? tempDate.getMinutes() : '0' + tempDate.getMinutes()
    return month + ':' + days
  } else {
    return value
  }
})

// 格式化成星期
Vue.filter('formatWeek', date => {
  let nd = new Date(date)
  let temp = ['星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
  return temp[nd.getDay()]
})

// 职位
Vue.filter('jobType', value => {
  let template = {
    ADVISER: "指导老师",
    ACADEMIC: "乐团主管",
    TEACHING: "乐队指导"
  }
  return template[value]
})

// 工作类型
Vue.filter('jobNature', (value) => {
  return constant.jobNature[value]
})


// 考勤状态
Vue.filter('attendanceType', value => {
  let template = {
    0: "异常签到",
    1: "正常签到",
    3: "未签到"
  }
  return template[value]
})
// 考情签退
Vue.filter('attendanceOutType', value => {
  let template = {
    0: "异常签退",
    1: "正常签退",
    3: "未签退"
  }
  return template[value]
})

// 上课类型
Vue.filter('workType', value => {
  return constant.workType[value]
})
// 交易类型
Vue.filter('orderType', value => {
  let template = {
    APPLY: "报名",
    RENEW: "续费",
    OTHER: "其他",
    SMALL_CLASS_TO_BUY: "VIP购买",
    SPORADIC: '零星收费',
    LUCK: "福袋活动",
    PRACTICE: '网管课',
    PRACTICE_GROUP_BUY: '网管课购买',
    PRACTICE_GROUP_RENEW: '网管课续费',
    REPAIR: '乐器维修',
    OUTORDER: '外部收入',
    GOODS_SELL: '商品销售',
    SUBJECT_CHANGE: '声部更换',
    DOUBLE_ELEVEN2020: '双十一活动',
    DEGREE_REGISTRATION: '考级报名'

  }
  return template[value]
})

//
Vue.filter('paymentChannelType', value => {
  let template = {
    PER: "个人",
    COM: "公司"
  }
  return template[value]
})

// 交易状态
Vue.filter('dealStatus', value => {
  let template = {
    ING: "交易中",
    SUCCESS: "成功交易",
    FAILED: "交易失败",
    CLOSE: "交易关闭"
  }
  return template[value]
})

// 交易状态
Vue.filter('returnStatus', value => {
  let template = {
    ING: "审核中",
    REJECT: "拒绝",
    WAIT_PAYMENT: "待支付",
    DONE: "完成"
  }
  return template[value]
})

// 缴费状态
Vue.filter('payTypeStatus', val => {
  return constant.payStatus[val]
})

// 性别
Vue.filter('sex', value => {
  let template = ['女', '男']
  return template[value]
})

// 服从调剂 isAllowAdjust
Vue.filter('isAllowAdjust', value => {
  let template = ['否', '是']
  return template[value]
})
// 学员缴费状态 paymentStatus
Vue.filter('paymentStatus', value => {
  let template = ['未开启缴费', '开启缴费', '已缴费']
  return template[value]
})
// 乐团状态
Vue.filter('teamStatus', value => {
  let template = {
    APPLY: "报名中",
    PAY: "缴费中",
    PREPARE: "筹备中",
    PROGRESS: "进行中",
    CANCELED: '取消',
    PAUSE: '暂停',
    AUDIT: '乐团审核中',
    DRAFT: '编辑中',
    AUDIT_FAILED: '审核失败',
    FEE_AUDIT: '费用审核中'
  }
  return template[value]
})

// 学生状态
/**studentStatus */
Vue.filter('studentStatus', value => {
  let template = ['在读', '已退课', '退课中', '休学']
  return template[value]
})
// 学生点名
Vue.filter('studentRecord', value => {
  let template = {
    NORMAL: "正常",
    TRUANT: "旷课",
    LEAVE: "请假",
    DROP_OUT: "退学",
    '': '未签到'
  }
  return template[value]
})
// 是否
Vue.filter('yesOrNo', value => {
  let template = ['否', '是']
  return template[value]
})

// 学员缴费状态
Vue.filter('studentPay', value => {
  let template = {
    PAID_COMPLETED: "完成缴费",
    NON_PAYMENT: "未缴费",
    PROCESSING: "缴费中",
  }
  return template[value]
})

// 学员点名详情
Vue.filter('studentSign', value => {
  let template = {
    NORMAL: "正常",
    TRUANT: "旷课",
    LEAVE: "请假",
    DROP_OUT: '退学'
  }
  return template[value]
})
// 班级类型
Vue.filter('classType', value => {
  let template = {
    NORMAL: "声部班",
    MIX: '合奏班',
    HIGH: '基础技能班',
    VIP: 'VIP',
    DEMO: '试听',
    SNAP: "临时班",
    PRACTICE: '网管课',
    HIGH_ONLINE: '线上基础技能课',
    MUSIC_NETWORK: '乐团网管课'
  }
  return template[value]
})

Vue.filter('teachMode', value => {
  return constant.teachMode[value]
})

// 老师状态
Vue.filter('teacherStatus', value => {
  let template = {
    "0": '正常',
    "1": '冻结',
    "9": '锁定'
  }
  return template[value]
})

// vip课状态
Vue.filter('vipCourseStatus', value => {
  let template = {
    0: "未开始",
    1: "报名中",
    5: "报名结束",
    2: "进行中",
    4: "已结束",
    3: "取消",
    6:'暂停'
  }
  return template[value]
})

// 账号类型
Vue.filter('accountTypeFormat', value => {
  let template = {
    0: "对内",
    1: "对外",
  }
  return template[value]
})

// 扣减库存
Vue.filter('stockTypeFormat', value => {
  let template = {
    INTERNAL: "内部",
    EXTERNAL: "外部",
    ALL: "内部，外部",
  }
  return template[value]
})

// 交易状态
Vue.filter('paymentChannelStatus', value => {
  let template = {
    YQPAY: "双乾",
    BALANCE: "余额",
    ADAPAY: "汇付"
  }
  return template[value]
})

// edition
Vue.filter('editionFilter', value => {
  let template = {
    'ios-teacher': '苹果-老师端',
    'ios-student': '苹果-学生端',
    'ios-education': '苹果-教务端',
    'android-teacher': '安卓-老师端',
    'android-student': '安卓-学生端',
    'android-education': '安卓-教务端',
  }
  return template[value]
})


// payStatus  订单支付状态
Vue.filter('payStatus', value => {
  let template = {
    WAIT_PAY: "等待支付",
    ING: "交易中",
    SUCCESS: '成功交易',
    FAILED: '交易失败',
    CLOSE: '交易关闭'
  }
  return template[value]
})

// payType  交易类型
Vue.filter('payType', value => {
  let template = {
    RECHARGE: "充值",
    WITHDRAW: "提现",
    PAY_FEE: "缴费",
    SPORADIC: "零星收费",
    FILL_ACCOUNT: "人工补账",
    REFUNDS: "退费",
    REWARDS: "奖励",
    WAGE: "工资"
  }
  return template[value]
})

// 课程组状态 FINISH
Vue.filter('courseGroup', value => {
  let template = {
    NORMAL: "正常",
    LOCK: "锁定",
    FINISH: '结束',
    CANCEL: '取消',
  }
  return template[value]
})
// 网管课程组
Vue.filter('comCourseGroup', value => {
  let template = {
    NOT_START: "未开始",
    LOCK: "锁定",
    APPLYING: "报名中",
    NORMAL: "进行中",
    FINISH: '结束',
    CANCEL: '关闭',
  }
  return template[value]
})

//网管课类型
Vue.filter('comType', value => {
  let template = {
    FREE: "免费",
    CHARGE: '收费',
    TRIAL: '试听课',
  }
  return template[value]
})

// 首充续费

Vue.filter('firstOrRenewFilter', value => {
  let template = {
    '0': "续费",
    '1': "首次",
  }
  return template[value]
})

// 老师时间
Vue.filter('transTypeFilter', value => {
  let template = {
    'RECHARGE': "充值",
    'CONSUME': "建课",
    'RETURN': "退课",
    'MANUAL_ADD': "系统充值",
    'MANUAL_SUB': "系统扣除",
  }
  return template[value]
})

// paymentType
Vue.filter('paymentType', value => {
  let template = {
    'OFFLINE': "线下",
    'ONLINE': "线上",
    'ALL': "全部",
  }
  return template[value]
})

Vue.filter('paymentListStatus', value => {
  let template = {
    0: "未开始",
    1: "已开启",
    2: "已结束",
  }
  return template[value]
})

// paymentStatus
Vue.filter('paymentStatusDetall', value => {
  let template = {
    'PAID_COMPLETED': "已缴费",
    'PROCESSING': "缴费中",
    'NON_PAYMENT': "未缴费",
  }
  return template[value]
})

// 课时申诉
Vue.filter('complaintsStatusEnum', value => {
  let template = {
    0: "已拒绝",
    1: "已通过",
    2: "待处理",
    3: "已撤销",
  }
  return template[value]
})

//  人事状态 isProbationPeriod
Vue.filter('isProbationPeriod', value => {
  let template = {
    0: "正式",
    1: "试用",
    2: "离职",
  }
  return template[value]
})

Vue.filter('visiterType', value => {
  let template = {
    'TEACHER': "指导老师",
    'EDU_TEACHER': "乐团主管",
  }
  return template[value]
})

// 人力资源人员状态

Vue.filter('hrStatus', value => {
  let template = {
    'NOT_EMPLOYED': "未录用",
    'INTERVIEWING': "面试中",
    'RESERVE': "储备",
    'PART_TIME': "兼职",
    'FULL_TIME': "全职",
    'DIMISSION': "离职",
  }
  return template[value]
})

// 费用类型

Vue.filter('feeType', value => {
  return constant.feeType[value]
})

// 费用项目

Vue.filter('feeProject', value => {
  return constant.feeProject[value]
})

// 销售类型

Vue.filter('saleType', value => {
  return constant.saleType[value]
})

// 缴费状态

Vue.filter('teamPayStatus', value => {
  const tpl = {
    0: '按月',
    1: '按学期',
    2: '一次性',
  }
  return tpl[value]
})

// 金额格式化
Vue.filter('moneyFormat', value => {
  return numeral(value).format('0,0.00')
})

Vue.filter('stockTypeStatus', value => {
  const template = {
    INTERNAL: '内部',
    EXTERNAL: '外部',
    ALL: '全部',
  }
  return template[value]
})
// 确认收货类型
Vue.filter('receiveFormat', value => {
  let template = {
    'NO_RECEIVE': "未确认",
    'MANUAL_RECEIVE': "手动确认",
    'AUTO_RECEIVE': "自动确认",
  }
  return template[value]
})

// 缴费方式

Vue.filter('payOrderType', value => {
  return constant.payOrderType[value]
})

// 审核状态 auditType
Vue.filter('auditType', value => {
  return constant.auditType[value]
})

// 审核申请类型 auditPaymentType
Vue.filter('auditPaymentType', value => {
  return constant.auditPaymentType[value]
})

// 销售收入和服务收入
Vue.filter('orderServer', value => {
  return constant.orderServerType[value]
})

// 订单审核状态 orderAuditType
Vue.filter('orderAuditType', value => {
  constant.orderAuditType[''] = '审核通过'
  return constant.orderAuditType[value]
})

Vue.filter('songUseTypeFormat', value => {
  return constant.songUseType[value]
})

Vue.filter('rewardModeTypeFormat', value => {
  return constant.rewardModeType[value]
})
// 系统日志类型
Vue.filter('journalTypeFormat', value => {
  return constant.journalType[value]
})
