
export default {
    state: {
        openModal: false,
        openRegisterModal: false, // 简历列表的就业服务登记表开关
        openExportModal: false, // 简历登记表导出的开关
        openResumeDetailModal: false, // 预览简历
        openResumeHelpModal: false, // 帮扶简历
        editRegisterKey: '',
        editRegister: {
            seekername: false,
            gender: false,
            dob: false,
            title: false,
            marital: false,
            education: false
        },
        needConfirmation: false, // 显示退出确认框
        openDispenseModal: false, // 为角色分配权限开关
        openFeeModal: false, // vip变更费用开关
        openFairDetailModal: false, // 预览招聘会
        openBindModal: false, // 预览招聘会
        openParentModal: false, // 更换父级的开关

    },
    reducers: {
        setOpenModal(state: any, { payload }: any) {
            return {
                ...state,
                openModal: payload
            }
        },
        setOpenRegisterModal(state: any, { payload }: any) {
            return {
                ...state,
                openRegisterModal: payload
            }
        },
        setOpenExportModal(state: any, { payload }: any) {
            return {
                ...state,
                openExportModal: payload
            }
        },
        setOpenDispenseModal(state: any, { payload }: any) {
            return {
                ...state,
                openDispenseModal: payload
            }
        },
        setOpenResumeDetailModal(state: any, { payload }: any) {
            return {
                ...state,
                openResumeDetailModal: payload
            }
        },
        setOpenResumeHelpModal(state: any, { payload }: any) {
            return {
                ...state,
                openResumeHelpModal: payload
            }
        },
        setOpenFeeModal(state: any, { payload }: any) {
            return {
                ...state,
                openFeeModal: payload
            }
        },
        setOpenFairDetailModal(state: any, { payload }: any) {
            return {
                ...state,
                openFairDetailModal: payload
            }
        },
        setOpenBindModal(state: any, { payload }: any) {
            return {
                ...state,
                openBindModal: payload
            }
        },
        setOpenParentModal(state: any, { payload }: any) {
            return {
                ...state,
                openParentModal: payload
            }
        },
        
        setEditRegister(state: any, { payload }: any) {
            if (state.editRegisterKey && state.editRegisterKey !== payload.key) {
                return {
                    ...state,
                    needConfirmation: true
                }
            } else {
                return {
                    ...state,
                    editRegisterKey: payload.key,
                    editRegister: {
                        ...state.editRegister,
                        [payload.key]: true,
                    },
                    needConfirmation: false
                }
            }
        },
        confirmEditRegister(state: any, { payload }: any) {
            return {
                ...state,
                editRegisterKey: payload.key,
                editRegister: {
                    ...state.editRegister,
                    [state.editRegisterKey]: false,
                    [payload.key]: true,
                },
                needConfirmation: false
            }
        },
        cancelEditRegister(state: any) {
            return {
                ...state,
                needConfirmation: false,
            };
        },
        setQuitEditRegister(state: any) {
            return {
                ...state,
                editRegisterKey: '',
                editRegister: {
                    seekername: false,
                    gender: false,
                    dob: false,
                    title: false,
                    marital: false,
                    education: false
                },
                needConfirmation: false, // 显示退出确认框
            };
        },
        setCloseModel(state: any) {
            return {
                ...state,
                needConfirmation: false, // 显示退出确认框
            };
        },
    },
    effects: {
        *getOpenModal({ payload }: any, { put }: any): any {
            try {
                yield put({
                    type: 'setOpenModal',
                    payload: payload
                })
            } catch (error) {
                console.log(error)
            }
        },
        *getOpenRegisterModal({ payload }: any, { put }: any): any {
            try {
                yield put({
                    type: 'setOpenRegisterModal',
                    payload: payload
                })
            } catch (error) {
                console.log(error)
            }
        },
        *getOpenExportModal({ payload }: any, { put }: any): any {
            try {
                yield put({
                    type: 'setOpenExportModal',
                    payload: payload
                })
            } catch (error) {
                console.log(error)
            }
        },
        *getOpenDispenseModal({ payload }: any, { put }: any): any {
            try {
                yield put({
                    type: 'setOpenDispenseModal',
                    payload: payload
                })
            } catch (error) {
                console.log(error)
            }
        },
        *getOpenResumeDetailModal({ payload }: any, { put }: any): any {
            try {
                yield put({
                    type: 'setOpenResumeDetailModal',
                    payload: payload
                })
            } catch (error) {
                console.log(error)
            }
        },
        *getOpenResumeHelpModal({ payload }: any, { put }: any): any {
            try {
                yield put({
                    type: 'setOpenResumeHelpModal',
                    payload: payload
                })
            } catch (error) {
                console.log(error)
            }
        },
        *getOpenFeeModal({ payload }: any, { put }: any): any {
            try {
                yield put({
                    type: 'setOpenFeeModal',
                    payload: payload
                })
            } catch (error) {
                console.log(error)
            }
        },
        *getOpenFairDetailModal({ payload }: any, { put }: any): any {
            try {
                yield put({
                    type: 'setOpenFairDetailModal',
                    payload: payload
                })
            } catch (error) {
                console.log(error)
            }
        },
        *getOpenBindModal({ payload }: any, { put }: any): any {
            try {
                yield put({
                    type: 'setOpenBindModal',
                    payload: payload
                })
            } catch (error) {
                console.log(error)
            }
        },
        *getOpenParentModal({ payload }: any, { put }: any): any {
            try {
                yield put({
                    type: 'setOpenParentModal',
                    payload: payload
                })
            } catch (error) {
                console.log(error)
            }
        },

        
        
        *getEditRegister({ payload }: any, { put }: any): any {
            try {
                yield put({
                    type: 'setEditRegister',
                    payload: payload
                })
            } catch (error) {
                console.log(error)
            }
        },
        *getConfirmEditRegister({ payload }: any, { put }: any): any {
            try {
                yield put({
                    type: 'confirmEditRegister',
                    payload: payload
                })
            } catch (error) {
                console.log(error)
            }
        },
        *getCancelEditRegister({ payload }: any, { put }: any): any {
            try {
                yield put({
                    type: 'cancelEditRegister',
                    payload: payload
                })
            } catch (error) {
                console.log(error)
            }
        },
        *getQuitEditRegister({ payload }: any, { put }: any): any {
            try {
                yield put({
                    type: 'setQuitEditRegister',
                    payload: payload
                })
            } catch (error) {
                console.log(error)
            }
        },
        *getCloseModel({ payload }: any, { put }: any): any { // 及时关闭弹框
            try {
                yield put({
                    type: 'setCloseModel',
                    payload: payload
                })
            } catch (error) {
                console.log(error)
            }
        },
    }
}
