import Vue from 'vue'

// 乐团状态
Vue.filter('bandStatus', value => {
    let templateStatus = {
        APPLY: '报名中',
        PAY: '缴费中',
        PREPARE: '筹备中',
        UNDERWAY: '进行中',
        CANCELED: '取消'
    }
    return templateStatus[value]
})

// 合并数组
Vue.filter('joinArray', (value, type) => {
    if(!type) {
        type = ' '
    }
    if(typeof value == 'object' && value != null) {
        return value.join(type)
    } else {
        return value
    }
})

// 数据类型
Vue.filter('dataStatusCN', value => {
    let templateStatus = {
        '到课': '',
        '请假': 'truant',
        '旷课': 'leave'
    }
    return templateStatus[value]
})

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

// 课程类型
Vue.filter('teachModeStatus', value => {
    let templateStatus = {
        ONLINE: "线上课",
        OFFLINE: "线下课"
    }
    return templateStatus[value]
})

Vue.filter('formatDate', value => {
    let d = new Date(value.replace(/-/ig, '/'))
    let hour = d.getHours() >= 10 ? d.getHours() : '0' + d.getHours()
    let minute = d.getMinutes() >= 10 ? d.getMinutes() : '0' + d.getMinutes()
    return hour + ':' + minute
})