import Vue from 'vue'

// 合并数组
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: "退团"
  }
  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:'网管课'
  }
  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('formatTimer', (value) => {
  if (value) {
    return value.split(' ')[0]
  } else {
    return value
  }
})

// 时间处理
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) => {
  let template = {
    PART_TIME: "兼职",
    FULL_TIME: "全职",
    TEMPORARY: "临时工"
  }
  return template[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 => {
  let template = {
    TEACHING: "助教",
    BISHOP: "主教"
  }
  return template[value]
})
// 交易类型
Vue.filter('orderType', value => {
  let template = {
    APPLY: "报名",
    RENEW: "续费",
    OTHER: "其他",
    SMALL_CLASS_TO_BUY: "VIP购买",
    SPORADIC: '零星收费',
    LUCK: "福袋活动",
    PRACTICE:'网管课',
    PRACTICE_GROUP_BUY:'网管课购买'

  }
  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('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: '审核失败'
  }
  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:'网管课'
  }
  return template[value]
})

Vue.filter('teachMode', value => {
  let template = {
    ONLINE: "线上课",
    OFFLINE: '线下课'
  }
  return template[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: "取消"
  }
  return template[value]
})

// 交易状态
Vue.filter('paymentChannelStatus', value => {
  let template = {
    YQPAY: "双乾",
    BALANCE: "余额"
  }
  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]
})

// 课程组状态 FINISH
Vue.filter('courseGroup', value => {
  let template = {
    NORMAL: "正常",
    LOCK: "锁定",
    FINISH:'结束',
    CANCEL:'取消',
  }
  return template[value]
})