
// import { openApiRes } from '@/api/openApi/type'

// type openApiGanZhiGet8ziByDate = openApiRes.openApiGanZhiGet8ziByDate["data"]
// interface ganZhiGet8ziByDate extends openApiGanZhiGet8ziByDate {
//     ganZhiProRowVoList: openApiGanZhiGet8ziByDate["ganZhiRowVoList"][]
// }

const switchTextToHexColor = (text) => {
    let color = '#333'
    switch (text) {
        case '棕':
            color = '#9C4B08'
            break;
        case '红':
            color = '#CB2C00'
            break;
        case '绿':
            color = '#53996B'
            break;
        case '蓝':
            color = '#006494'
            break;
        case '橙':
            color = '#D19C03'
            break;
        default:
            color = '#333'
    }
    return color
}
const switchTextToEnColor = (text) => {
    let color = ''
    switch (text) {
        case '棕':
            color = 'brown'
            break;
        case '红':
            color = 'red'
            break;
        case '绿':
            color = 'green'
            break;
        case '蓝':
            color = 'blue'
            break;
        case '橙':
            color = 'yellow'
            break;
        default:
            color = ''
    }
    return color


}
const get8ziByDateDecorator = function (responseData) {
    const respData = {
        ...responseData,
        ganZhiProRowVoList: []

    }
    for (let index = 0; index < (respData.ganZhiRowVoList.length / 2); index++) {
        const element1 = respData.ganZhiRowVoList[index * 2];
        const element2 = respData.ganZhiRowVoList[index * 2 + 1];
        element1.hexColor = switchTextToHexColor(element1.color)
        element2.hexColor = switchTextToHexColor(element2.color)

        element1.enColor = switchTextToEnColor(element1.color)
        element2.enColor = switchTextToEnColor(element2.color)

        respData.ganZhiProRowVoList.push([element1, element2])


    }
    return respData


}

export default {
    get8ziByDateDecorator
}