import request from '/@/utils/request';

/**
 * 获取列表
 * @param query
 */
export const fetchList = (query?: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/page',
		method: 'get',
		params: query,
	});
};

/**
 * 班级分页
 * @param query
 */
export const classPage = (query?: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/classPage',
		method: 'get',
		params: query,
	});
};

/**
 * 返校学生分页
 * @param query
 */
export const backSchoolStuPage = (query?: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/backSchoolStuPage',
		method: 'get',
		params: query,
	});
};

/**
 * 获取列表
 * @param query
 */
export const getList = (query?: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/getList',
		method: 'get',
		params: query,
	});
};

/**
 * 初中分数线统计
 * @param query
 */
export const juniorlneStatic = (query?: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/juniorlneStatic',
		method: 'get',
		params: query,
	});
};

/**
 * 在校成绩统计
 * @param query
 */
export const inSchoolSocreStatic = (query?: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/inSchoolSocreStatic',
		method: 'get',
		params: query,
	});
};

/**
 * 按用户统计获取联系信息
 * @param query
 */
export const getContantByUserStatic = (query?: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/getContantByUserStatic',
		method: 'get',
		params: query,
	});
};

/**
 * 区域统计
 * @param query
 */
export const getAreaStatic = (query?: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/getAreaStatic',
		method: 'get',
		params: query,
	});
};

/**
 * 学校统计
 * @param query
 */
export const getSchoolStatic = (query?: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/getSchoolStatic',
		method: 'get',
		params: query,
	});
};

/**
 * 学校区域统计
 * @param query
 */
export const schoolAreaStatic = (query?: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/schoolAreaStatic',
		method: 'get',
		params: query,
	});
};

/**
 * 按部门统计获取联系信息
 * @param query
 */
export const getContantByDeptStatic = (query?: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/getContantByDeptStatic',
		method: 'get',
		params: query,
	});
};

/**
 * 获取表格统计数据列表
 * @param query
 */
export const getTabStaticDataList = (query?: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/getTabStaticDataList',
		method: 'get',
		params: query,
	});
};

/**
 * 获取学生宿舍列表
 * @param query
 */
export const fetchListStuDorm = (query?: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/fetchListStuDorm',
		method: 'get',
		params: query,
	});
};

/**
 * 新增
 * @param obj
 */
export const addObj = (obj: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/add',
		method: 'post',
		data: obj,
	});
};

/**
 * 修改班级信息
 * @param obj
 */
export const changeClassInfo = (obj: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/changeClassInfo',
		method: 'post',
		data: obj,
	});
};

/**
 * 获取专业班级
 * @param obj
 */
export const getMajorClass = (obj: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/getMajorClass',
		method: 'post',
		data: obj,
	});
};

/**
 * 单个班级
 * @param obj
 */
export const oneClass = (obj: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/oneClass',
		method: 'post',
		data: obj,
	});
};

/**
 * 单个学号
 * @param obj
 */
export const oneStuNo = (obj: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/oneStuNo',
		method: 'post',
		data: obj,
	});
};

/**
 * 学生工作
 * @param obj
 */
export const tbStuWork = (obj: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/tbStuWork',
		method: 'post',
		data: obj,
	});
};

/**
 * 发送图片
 */
export const sendImg = () => {
	return request({
		url: '/recruit/recruitplanmajor/setImg',
		method: 'get',
	});
};

/**
 * 推送城市
 * @param obj
 */
export const pushCity = (obj: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/pushCity',
		method: 'post',
		data: obj,
	});
};

/**
 * 获取详情
 * @param id
 */
export const getObj = (id: string | number) => {
	return request({
		url: `/recruit/recruitstudentsignup/${id}`,
		method: 'get',
	});
};

/**
 * 删除
 * @param id
 */
export const delObj = (id: string | number) => {
	return request({
		url: `/recruit/recruitstudentsignup/${id}`,
		method: 'delete',
	});
};

/**
 * 删除服务
 * @param id
 */
export const delFw = (id: string | number) => {
	return request({
		url: `/recruit/recruitstudentsignup/delFw/${id}`,
		method: 'delete',
	});
};

/**
 * 更新
 * @param obj
 */
export const putObj = (obj: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/edit',
		method: 'post',
		data: obj,
	});
};

/**
 * 更新返校对象
 * @param obj
 */
export const putBackObj = (obj: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/putBackObj',
		method: 'post',
		data: obj,
	});
};

/**
 * 导出压缩包
 * @param data
 */
export const exportZip = (data?: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/exportZip',
		method: 'get',
		responseType: 'blob',
		headers: { 'Content-Type': 'application/json; application/octet-stream' },
		params: data,
	});
};

/**
 * 离校
 * @param obj
 */
export const leaveSchool = (obj: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/leaveSchool',
		method: 'post',
		data: obj,
	});
};

/**
 * 导出Word
 * @param obj
 */
export const toWord = (obj: any) => {
	return request({
		url: `/recruit/recruitstudentsignup/exportRecruitStuPdf/${obj.id}`,
		method: 'get',
	});
};

/**
 * 预交退
 * @param obj
 */
export const yjOut = (obj: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/yjOut',
		method: 'post',
		data: obj,
	});
};

/**
 * 预交送
 * @param obj
 */
export const yjSend = (obj: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/yjSend',
		method: 'post',
		data: obj,
	});
};

/**
 * 确认录取通知
 * @param obj
 */
export const sureLQTZ = (obj: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/sureLQTZ',
		method: 'post',
		data: obj,
	});
};

/**
 * 设置服务
 * @param obj
 */
export const setFw = (obj: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/setFw',
		method: 'post',
		data: obj,
	});
};

export const updateInfo = (obj: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/updateInfo',
		method: 'post',
		data: obj
	})
}

/**
 * 材料审核
 * @param obj
 */
export const materialExam = (obj: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/materialExam',
		method: 'post',
		data: obj,
	});
};

//计算折算分
export const makeCorrectScore = (obj: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/makeCorrectScore',
		method: 'post',
		data: obj,
	});
};

/**
 * 转专业
 * @param obj
 */
export const changeMajor = (obj: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/majorChange',
		method: 'post',
		data: obj,
	});
};

/**
 * 退档恢复
 * @param obj
 */
export const resetSign = (obj: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/resetSign',
		method: 'post',
		data: obj,
	});
};


/**
 * 重新推送
 * @param obj
 */
export const rePush = (obj: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/rePush',
		method: 'post',
		data: obj,
	});
};

/**
 * 退回推送
 * @param obj
 */
export const backPush = (obj: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/backPush',
		method: 'post',
		data: obj,
	});
};

/**
 * 批量推送全部
 * @param obj
 */
export const batchPushAll = (obj: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/backPushAll',
		method: 'post',
		data: obj,
	});
};

/**
 * 百度地图GL
 * @param ak
 */
export const BMPGL = (ak: string) => {
	return new Promise(function (resolve, reject) {
		// @ts-ignore
		window.init = function () {
			// eslint-disable-next-line
			// resolve(BMapGL);
		};
		const script = document.createElement('script');
		script.type = 'text/javascript';
		script.src = `https://api.map.baidu.com/api?v=1.0&type=webgl&ak=${ak}&callback=init`;
		script.onerror = reject;
		document.head.appendChild(script);
	});
};

/**
 * 天地图
 * @param tk 天地图token
 */
export const loadTiandituMap = (tk: string) => {
	return new Promise(function (resolve, reject) {
		// @ts-ignore
		// 如果天地图API已经加载，直接返回
		if (window.T) {
			// @ts-ignore
			resolve(window.T);
			return;
		}
		
		// 检查是否已经有加载中的脚本
		const existingScript = document.querySelector('script[src*="api.tianditu.gov.cn"]');
		if (existingScript) {
			// 如果脚本正在加载中，等待加载完成
			existingScript.addEventListener('load', () => {
				// @ts-ignore
				resolve(window.T);
			});
			existingScript.addEventListener('error', reject);
			return;
		}
		
		// 加载天地图主库
		const script = document.createElement('script');
		script.type = 'text/javascript';
		script.src = `https://api.tianditu.gov.cn/api?v=4.0&tk=${tk}`;
		script.onload = () => {
			// @ts-ignore
			resolve(window.T);
		};
		script.onerror = reject;
		document.head.appendChild(script);
	});
};

/**
 * 宿舍申请分析
 * @param obj
 */
export const dormApplyAnalysis = (obj: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/dormApplyAnalysis',
		method: 'post',
		data: obj,
	});
};

/**
 * 面试
 * @param obj
 */
export const interview = (obj: any) => {
	return request({
		url: '/recruit/recruitstudentsignup/interview',
		method: 'post',
		data: obj,
	});
};


export const queryAllRecruitUser = () => {
	return request({
		url: '/recruit/recruitstudentsignup/queryAllRecruitUser',
		method: 'get'
	});
};
