//显示治疗方案
export const showTreat = (state, action) => {
    const res = Object.assign({}, state);
    res.show = true;
    return res
}

export const hideTreat = (state, action) => {
    const res = Object.assign({}, state);
    res.show = false;
    return res
}

export const clearTreat = (state, action) => {
    const res = Object.assign({}, state);
    res.generalTreat = '';
    res.surgeryTreat = '';
    res.treatment = [];
    return res
}

export const setTreatment = (state, action) => {
    const res = Object.assign({}, state);
    res.treatment = action.treatment;
    res.generalTreat = action.generalTreat;
    res.surgeryTreat = action.surgeryTreat;
    return res
}

//选择取消药品
export const selectDrug = (state, action) => {
    const res = JSON.parse(JSON.stringify(state));
    const drugTreat = res.treatment.slice();
    const index = action.index  //药品类的索引
    const ii = action.ii   //药品索引
    const selectItem = drugTreat[index].medicitionsList[ii]
    const selected =  selectItem.selected//所选择药品的选择状态
    selectItem.selected = !selected;
    return res
}

//其他药品推荐
export const setOtherDrug = (state, action) => {
    // const res = Object.assign({}, state)
    const res = JSON.parse(JSON.stringify(state));
    res.treatDesc = {};
    res.treatDesc.title = '药品推荐';
    res.treatDesc.otherDrugIndex = action.index;
    return res
}

//药品说明
export const setDrugInfo = (state, action) => {
    const res = JSON.parse(JSON.stringify(state));
    const instroduce = action.instroduce;
    res.drugInfo = {};
    res.drugInfo.title = action.name;
    res.drugInfo.drugDesc = instroduce;
    return res
}

export const setRecommendBasic = (state, action) => {
    // const res = Object.assign({}, state)
    const res = JSON.parse(JSON.stringify(state));
    const treatDesc = res.treatDesc;
    treatDesc.basic = action.recommendBasic
    return res
}

export const showDrugInfo = (state, action) => {
    const res = Object.assign({}, state);
    res.showDrugInfo = true;
    return res;
}

export const hideDrugInfo = (state, action) => {
    const res = Object.assign({}, state);
    res.showDrugInfo = false;
    return res;
}

