/* eslint-disable */
export const toUpperCase = (str) => {
    if (str[0]) {
        return str.replace(str[0], str[0].toUpperCase())
    } else {
        return ""
    }
}

export const toLowerCase = (str) => {
    if (str[0]) {
        return str.replace(str[0], str[0].toLowerCase())
    } else {
        return ""
    }
}

// 驼峰转换下划线
export const toSQLLine = (str) => {
    if (str == "ID") return "ID"
    return str.replace(/([A-Z])/g, "_$1").toLowerCase();
}

// 下划线转换驼峰
export const toHump = (name) => {
    return name.replace(/\_(\w)/g, function(all, letter) {
        return letter.toUpperCase();
    });
}

export const toType = (type) => {
    const types={1:'指定任务',2:'委托任务',3:'公开任务'}
	return types[type]||'---'
}

export const toTaskStatus = (type) => {
    const opts ={1: '编辑', 2:'发布', 3:'完成',0:'作废'}
	return opts[type]||'---'
}

export const toStage = ( task ) => {
    if( task && task.id ){
        task = getStage( task )
    }
    let stage =['未知', '审核中', '待交付', '已交付', '已完成' ]
	return stage[task]
}

export const getStage = (task) => {
    if( task.finish ) return 4;
    if( task.deliver_time>1 ) return 3;
    if( task.confirm ) return 2;
	return 1
}

export const toFee = (fee) => {
	return '￥'+ (fee/100)
}
// 
export const toStatus = (status) => {
	return status==1?'正常':'异常';
}

export const toConfirm = (status) => {
	return status==1?'确认':'未确认';
}

export const toSupply = (status) => {
	return status==1?'是':'否';
}

export const isTrue = (status) => {
	return status?'是':'否';
}

export const toFeeType = (status) => {
	return status==1?'按比收费':'税点收费';
}

export const toPoint= (status) => {
	return (status/100) +'%';
}

export const tow60= (data) => {
    if(!data) return "";
    return data.split("?")[0]+'?x-oss-process=image/resize,m_fill,w_60';
}

export const toLogStage = (stage) => {
    let data ={0:'不变',1:'待接单',2:'待交付',3:'已交付',4:'已完成',5:'删除'}
	return data[stage]||'未知'
}