import {
	WeaTools
} from 'ecCom'

export const getForm = (cPage, params = {}, currentStepIndex, formType, subDialogVisible) => {
	if (currentStepIndex === 0) {
		switch (cPage) {
			case 'personalInfo':
			case 'childEducation':
			case 'continualEducation':
			case 'loan':
			case 'rent':
			case 'supportOlder':
				return WeaTools.callApi('/api/hrm/pit/personalInfo/getForm', 'GET', params);
				break;
			case 'familyMember':
				return WeaTools.callApi('/api/hrm/pit/familyInfo/getForm', 'GET', params);
				break;
		}
	} else if (currentStepIndex === 1) {
		switch (cPage) {
			case 'childEducation':
				if (formType === '2') {
					if (subDialogVisible) {
						return WeaTools.callApi('/api/hrm/pit/familyInfo/getForm', 'GET', params);
					} else {
						return WeaTools.callApi('/api/hrm/pit/childrenEdu/getForm', 'GET', params);
					}
				} else {
					return WeaTools.callApi('/api/hrm/pit/childrenEdu/getCondition', 'GET', params);
				}
				break;
		}
	}
}

export const save = (cPage, params = {}) => {
	switch (cPage) {
		case 'personalInfo':
		case 'childEducation':
		case 'continualEducation':
		case 'loan':
		case 'rent':
		case 'supportOlder':
			return WeaTools.callApi('/api/hrm/pit/personalInfo/saveForm', 'POST', params);
			break;
		case 'familyMember':
			return WeaTools.callApi('/api/hrm/pit/familyInfo/saveForm', 'POST', params);
			break;
	}
}

export const getRightMenu = (cPage, params = {}) => {
	switch (cPage) {
		case 'personalInfo':
			return WeaTools.callApi('/api/hrm/pit/personalInfo/getRightMenu', 'GET', params);
			break;
		case 'familyMember':
			return WeaTools.callApi('/api/hrm/pit/familyInfo/getRightMenu', 'GET', params);
			break;
		case 'childEducation':
			return WeaTools.callApi('/api/hrm/pit/childrenEdu/getRightMenu', 'GET', params);
			break;
	}

}

export const getRecords = (cPage, params = {}) => {
	switch (cPage) {
		case 'familyMember':
			return WeaTools.callApi('/api/hrm/pit/familyInfo/getRecords', 'GET', params);
			break;
		case 'childEducation':
			return WeaTools.callApi('/api/hrm/pit/childrenEdu/getRecords', 'GET', params);
			break;
	}

}

export const del = (cPage, params = {}) => {
	switch (cPage) {
		case 'familyMember':
			return WeaTools.callApi('/api/hrm/pit/familyInfo/delete', 'POST', params);
			break;
		case 'childEducation':
			return WeaTools.callApi('/api/hrm/pit/childrenEdu/delete', 'POST', params);
			break;
	}

}

export const getPreInfo = (cPage, params = {}) => {
	switch (cPage) {
		case 'childEducation':
			return WeaTools.callApi('/api/hrm/pit/childrenEdu/getInfo', 'GET', params);
			break;
	}

}

export const getStep = (cPage, params = {}) => {
	switch (cPage) {
		case 'childEducation':
			return WeaTools.callApi('/api/hrm/pit/childrenEdu/getStep', 'GET', params);
			break;
	}
}

export const getCondition = (cPage, params = {}) => {
	switch (cPage) {
		case 'childEducation':
			return WeaTools.callApi('/api/hrm/pit/childrenEdu/getCondition', 'GET', params);
			break;
	}
}

export const getDialogForm = (cPage, params = {}) => {
	switch (cPage) {
		case 'childEducation':
			return WeaTools.callApi('/api/hrm/pit/childrenEdu/getForm', 'GET', params);
			break;
	}
}

export const saveDialogForm = (cPage, params = {}) => {
	switch (cPage) {
		case 'childEducation':
			return WeaTools.callApi('/api/hrm/pit/childrenEdu/saveForm', 'POST', params);
			break;
	}
}