import { AxiosPromise } from 'axios';
import request from '/@/utils/request';
import type { ILastYearWeeks, IGetLatestApplyParams, IGetLatestApply, IGetListMonthSchedulesParams } from './types/HemoMedSchedule.type';

export function Add(params: string) {
	return request({
		url: '/hemo/med/schedule/add',
		method: 'post',
		data: params,
	});
}
export function update(params: string) {
	return request({
		url: '/hemo/med/schedule/update',
		method: 'post',
		data: params,
	});
}
export function save(params: string) {
	return request({
		url: '/hemo/med/schedule/save',
		method: 'post',
		data: params,
	});
}
export function deleteId(params: string) {
	return request({
		url: '/hemo/med/schedule/delete',
		method: 'post',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		data: params,
	});
}
export function list(params: object) {
    return request({
		url: '/hemo/med/schedule/list',
		method: 'post',
		headers: {
		'Content-Type': 'application/x-www-form-urlencoded'
		},
		params
    })
}
export function scheduleGetConfig(params: object) {
    return request({
		url: '/hemo/med/schedule/config/getConfig',
		method: 'post',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
		params
    })
}
/**
 * 列出今天所在周数的透析排班计划
 * @param params 客户编号
 * @returns 
 */
export function listWeekSchedules(params: string) {
    return request({
		url: '/hemo/med/schedule/listWeekSchedules',
		method: 'post',
		headers: {
		'Content-Type': 'application/x-www-form-urlencoded'
		},
		data:params
    })
}
export function getLastYearWeeks() :AxiosPromise<ILastYearWeeks[]> {
    return request({
		url: '/hemo/med/schedule/getLastYearWeeks',
		method: 'post',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
			},
    })
}

export function getCurrentWeekNumber() {
    return request({
		url: '/hemo/med/schedule/getCurrentWeekNumber',
		method: 'post',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
			}
    })
}

export function saveConfig(params: string) {
	return request({
		url: '/hemo/med/schedule/config/save',
		method: 'post',
		data: params,
	});
}
export function exportToExcel(params: string) {
	return request({
		url: '/hemo/med/schedule/exportToExcel',
		method: 'post',
		responseType: 'blob',
		params,
	});
}
export function transfer(params: object) {
	return request({
		url: '/hemo/med/schedule/transfer',
		method: 'post',
		data: params,
	});
}
export function listDeletedSchedules(params: object) {
    return request({
		url: '/hemo/med/schedule/listDeletedSchedules',
		method: 'post',
		data:params
    })
}
export function listScheduleUpdateLogs(params: object) {
    return request({
		url: '/hemo/med/schedule/listScheduleUpdateLogs',
		method: 'post',
		data:params
    })
}
export function listHemoMedScheduleChanges(params: object) {
    return request({
		url: '/hemo/schedule/change/track/record/listHemoMedScheduleChanges',
		method: 'post',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
			},
		params
    })
}
export function restoreDeletedSchedule(params: object) {
    return request({
		url: '/hemo/med/schedule/restoreDeletedSchedule',
		method: 'post',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
			},
		params
    })
}

/**
 * 导出指定周的数据到指定周
 * @param params 
 * @returns 
 */
export function scheduleExportApi(params: any) {
	return request({
		url: '/hemo/med/schedule/export',
		method: 'post',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
			},
		params
	})
}

/**
 * 获取客户排班模板导出日志
 * @param params 
 * @returns 
 */
export function getLatestApplyApi(params: IGetLatestApplyParams): AxiosPromise<IGetLatestApply> {
	return request({
		url: '/hemo/med/schedule/apply/getLatestApply',
		method: 'post',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
			},
		params
	})
}

/**
 * 按月查询排班Api
 * @param params 
 * @returns 
 */
export function getListMonthSchedulesApi(params: IGetListMonthSchedulesParams) {
	return request({
		url: '/hemo/med/schedule/listMonthSchedules',
		method: 'post',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
			},
		params
	})
}