// 食堂购物车商品信息管理
let canteen = {
    state: {
        shoppingCar: JSON.parse(localStorage.getItem('shoppingCar')) // 购物车列表
    },
    mutations: {
        updateShoppingCar (state, list) {
            state.shoppingCar = list
            try {
                localStorage.setItem('shoppingCar', JSON.stringify(list))
            } catch (e) {}
        }
    }
}
// 周工作安排
let weekData = localStorage.getItem('weeklyWork') || null
let weeklyWork = {
    state: {
        week: weekData ? JSON.parse(weekData).week : 0,
        permission: weekData ? JSON.parse(weekData).permission : 0
    },
    mutations: {
        saveWeeklyWorkData (state, obj) {
            state.week = obj.week
            state.permission = obj.permission
            try {
                localStorage.setItem('weeklyWork', JSON.stringify(obj))
            } catch (e) {}
        }
    }
}

let sqeData = localStorage.getItem('ExamAndEvalData') || ''
let SQESystem = {
    state: {
        data: sqeData
    },
    mutations: {
        saveSQEData (state, data) {
            state.data = data
            try {
                localStorage.setItem('ExamAndEvalData', data)
            } catch (e) { }
        }
    }
}

// 智能通讯录

const SMART_ADDRESS_LIST = {
    state: {
        receiverList: localStorage.getItem('receiverList')
            ? JSON.parse(localStorage.getItem('receiverList'))
            : [], // 收信人列表
        emojiMap: ['[右哼哼]', '[奸笑]', '[红包]', '[生病]', '[冷汗]', '[惊恐]', '[Emm]', '[得意]', '[菜刀]', '[太阳]', '[强壮]', '[无聊]', '[机智]', '[耶]', '[尴尬]', '[抓狂]', '[流汗]', '[社会社会]', '[擦汗]', '[西瓜]', '[抱抱]', '[破涕为笑]', '[皱眉]', '[小鸡]', '[微笑]', '[发怒]', '[吐]', '[憨笑]', '[旺柴]', '[抠鼻]', '[啤酒]', '[强]', '[开心]', '[调皮]', '[呲牙]', '[惊讶]', '[难过]', '[色]', '[悠闲]', '[疑问]', '[鼓掌]', '[害羞]', '[睡]', '[未修饰]', '[偷笑]', '[愉快]', '[白眼]', '[傲慢]', '[困]', '[发呆]', '[好的]', '[坏笑]', '[咖啡]', '[弱]', '[忧郁]', '[奋斗]', '[咒骂]', '[吃瓜]', '[加油]', '[汗]', '[天啊]', '[打脸]', '[左哼哼]', '[吃饭]', '[握手]', '[吐舌头]', '[哇]', '[嘘]', '[晕]', '[衰]', '[骷髅]', '[敲打]', '[再见]', '[嘿哈]', '[猪头]', '[胜利]', '[恐惧]', '[哈欠]', '[鄙视]', '[委屈]', '[流泪]', '[快哭了]', '[阴险]', '[亲亲]', '[可怜]', '[玫瑰]', '[抱拳]', '[脸红]', '[凋谢]', '[嘴唇]', '[爱心]', '[心碎]', '[蛋糕]', '[闭嘴]', '[炸弹]', '[便便]', '[月亮]', '[勾引]', '[感谢]', '[拳头]', '[OK]', '[大哭]', '[跳跳]', '[发抖]', '[怄火]', '[转圈]', '[礼物]', '[派对]', '[鬼魂]', '[撇嘴]'],
        receiverInfo: localStorage.getItem('receiverInfo') ? JSON.parse(localStorage.getItem('receiverInfo'))
            : {},
        currentClassId: localStorage.getItem('currentClassId') || ''
    },
    mutations: {
    // 保存收信人列表
        saveReceiverList (state, data) {
            state.receiverList = data
            try {
                localStorage.setItem('receiverList', JSON.stringify(data))
            } catch (e) { }
        },
        // 保存收信人信息
        saveReceiverInfo (state, data) {
            state.receiverInfo = data
            try {
                localStorage.setItem('receiverInfo', JSON.stringify(data))
            } catch (e) { }
        },
        // 保存当前编辑id
        saveCurrentClassId (state, data) {
            state.currentClassId = data
            try {
                localStorage.setItem('currentClassId', data)
            } catch (e) { }
        }
    }
}

// 学生请假
let classApplyLeave = {
    state: {
        data: localStorage.getItem('classApplyLeaveData')
            ? JSON.parse(localStorage.getItem('classApplyLeaveData'))
            : {
                classInfo: {},
                isHeadTeacher: false,
                flowEngineMainId: '',
                isApprovalUser: false
            }
    },
    mutations: {
        // 是否是班主任
        saveIsHeadTeacher (state, data) {
            state.data.isHeadTeacher = data
            try {
                localStorage.setItem('classApplyLeave', JSON.stringify(state.data))
            } catch (e) { }
        },
        // 流程管理main_id
        saveFlowEngineMainId (state, data) {
            state.data.flowEngineMainId = data
            try {
                localStorage.setItem('classApplyLeave', JSON.stringify(state.data))
            } catch (e) { }
        },
        // 是否是审批人
        saveIsApprovalUser (state, data) {
            state.data.isApprovalUser = data
            try {
                localStorage.setItem('classApplyLeave', JSON.stringify(state.data))
            } catch (e) { }
        },
        // 从班级管理进来，保存 classId、className
        saveTeacherClassInfo (state, data) {
            state.data.classInfo = data
            try {
                localStorage.setItem('classApplyLeave', JSON.stringify(state.data))
            } catch (e) { }
        }
    }
}

const form = {
    state: {
        scroll: {}
    },
    mutations: {
        saveScroll (state, payload) {
            state.scroll = payload
        }
    }
}

export default {
    canteen,
    weeklyWork,
    SQESystem,
    SMART_ADDRESS_LIST,
    classApplyLeave,
    form
}
