import { GetDictTree } from '@/apis/api';

const naturelist = [{
    name: '不限',
    value: '0',
    checked: true
}, {
    name: '全职',
    value: 'fulltime',
    checked: false
}, {
    name: '兼职',
    value: 'parttime',
    checked: false
}, {
    name: '临时',
    value: 'casual',
    checked: false
}, {
    name: '实习',
    value: 'practical',
    checked: false
}, {
    name: '校园招聘',
    value: 'campus',
    checked: false
}]


export default {
    state: {
        xiaolanzhenList: [], // 小榄镇地区 code: 2009000100030002
        zhongshanList: [], // 中山市地区 code: 200900010003
        areaList: [], // 地区分类 code: 2009
        jobNatureList: naturelist, // 职位性质
        classificationList: [], // 职业分类 code: 2000
        positionList: [], // 职位分类 code: 2004
        educationList: [], // code: 2006
        payList: [], // code: 2005
        scaleList: [],  // code: 2003
        natureList: [], // code: 2002
        updateList: [], // code: 2022
        maritalList: [], // code: 2011
        ethnicityList: [], // code: 2012
        politicalList: [], // code: 2010
        titleList: [], // code: 2014
        degreeList: [], // code: 2008
        otherLanguageList: [], // code: 2007
        jobTypeList: [], // code: 2019
        talentTypeList: [], // code: 2020
        workExperienceList: [], // code: 2021
        availableDateList: [], // code: 2013
        skillCertificationeList: [], // code: 2015
        accommodationRequirementList: [], // code: 2016
        holidayRestList: [], // code: 2017
        licenseList: [], // code: 2018
        vehicleList: [], // code: 2023
        overtimeList: [], // code: 2024
        industryPostList: [] // code: 2027

    },
    reducers: {
        setXiaolanzhenList(state: any, { payload }: any) {
            return {
                ...state,
                xiaolanzhenList: payload
            }
        },
        setZhongshanList(state: any, { payload }: any) {
            return {
                ...state,
                zhongshanList: payload
            }
        },
        setAreaList(state: any, { payload }: any) {
            return {
                ...state,
                areaList: payload
            }
        },
        setClassificationList(state: any, { payload }: any) {
            return {
                ...state,
                classificationList: payload
            }
        },
        setPositionList(state: any, { payload }: any) {
            return {
                ...state,
                positionList: payload
            }
        },
        setEducationList(state: any, { payload }: any) {
            return {
                ...state,
                educationList: payload
            }
        },
        setPayList(state: any, { payload }: any) {
            return {
                ...state,
                payList: payload
            }
        },
        setScaleList(state: any, { payload }: any) {
            return {
                ...state,
                scaleList: payload
            }
        },
        setNatureList(state: any, { payload }: any) {
            return {
                ...state,
                natureList: payload
            }
        },
        setUpdateList(state: any, { payload }: any) {
            return {
                ...state,
                updateList: payload
            }
        },
        setMaritalList(state: any, { payload }: any) {
            return {
                ...state,
                maritalList: payload
            }
        },
        setEthnicityList(state: any, { payload }: any) {
            return {
                ...state,
                ethnicityList: payload
            }
        },
        setPoliticalList(state: any, { payload }: any) {
            return {
                ...state,
                politicalList: payload
            }
        },
        setTitleList(state: any, { payload }: any) {
            return {
                ...state,
                titleList: payload
            }
        },
        setDegreeList(state: any, { payload }: any) {
            return {
                ...state,
                degreeList: payload
            }
        },
        setOtherLanguageList(state: any, { payload }: any) {
            return {
                ...state,
                otherLanguageList: payload
            }
        }
        ,
        setTalentTypeList(state: any, { payload }: any) {
            return {
                ...state,
                talentTypeList: payload
            }
        },
        setJobTypeList(state: any, { payload }: any) {
            return {
                ...state,
                jobTypeList: payload
            }
        },
        setWorkExperienceList(state: any, { payload }: any) {
            return {
                ...state,
                workExperienceList: payload
            }
        },
        setAvailableDateList(state: any, { payload }: any) {
            return {
                ...state,
                availableDateList: payload
            }
        },
        setSkillCertificationeList(state: any, { payload }: any) {
            return {
                ...state,
                skillCertificationeList: payload
            }
        },
        setAccommodationRequirementList(state: any, { payload }: any) {
            return {
                ...state,
                accommodationRequirementList: payload
            }
        },
        setHolidayRestList(state: any, { payload }: any) {
            return {
                ...state,
                holidayRestList: payload
            }
        },
        setLicenseList(state: any, { payload }: any) {
            return {
                ...state,
                licenseList: payload
            }
        },
        setVehicleList(state: any, { payload }: any) {
            return {
                ...state,
                vehicleList: payload
            }
        },
        setOvertimeList(state: any, { payload }: any) {
            return {
                ...state,
                overtimeList: payload
            }
        },
        setIndustryPostList(state: any, { payload }: any) {
            return {
                ...state,
                industryPostList: payload
            }
        },
        
        
    },
    effects: {
        *getList({ payload }: any, { put }: any): any {
            try {
                const res: any = yield (GetDictTree({ code: payload.code }))
                yield put({
                    type: payload.type,
                    payload: res.data.dicts
                })
            } catch (error) {
                console.log(error)
            }
        },
    }
}
