import http from '@/http/api.js'

// ==================== 自助取号机接口 ====================

/**
 * 主题取号列表
 * @param {*} params
 * @returns
 */
export const getThemeList = params => {
	return http.request({
		url: 'api/blade-subject/subject/list',
		method: 'GET',
		params: {
			...params
		},
	});
};

/**
 * 事项列表
 * @param {*} params
 * @returns
 */
export const getBusinessList = params => {
	return http.request({
		url: 'api/blade-item/list',
		method: 'GET',
		params: {
			...params
		},
	});
};

/**
 * 历史取号列表
 * @param {*} params
 * @returns
 */
export const getHistoryList = params => {
	return http.request({
		url: 'api/blade-queuerecord/queueRecord/history',
		method: 'GET',
		params: {
			...params
		},
	});
};

/**
 * 取号
 * @param {*} data { applicantName, applicantIdCard, itemId, windowId }
 * @returns
 */
export const takeNumber = data => {
	return http.request({
		url: 'api/blade-queuerecord/queueRecord/take-number',
		method: 'POST',
		data
	});
};

/**
 * 事项详情
 * @param {*} params { id }
 * @returns
 */
export const getItemDetail = params => {
	return http.request({
		url: 'api/blade-item/detail',
		method: 'GET',
		params
	});
};

// ==================== 叫号机窗口端接口 ====================

/**
 * 获取可选窗口列表
 * @param {*} params { status, serviceStatus, current, size }
 * @returns
 */
export const getWindowList = params => {
	return http.request({
		url: '/api/blade-windows/list',
		method: 'GET',
		params: {
			status: 1,
			serviceStatus: 1,
			current: 1,
			size: 100,
			...params
		}
	});
};

/**
 * 选择窗口
 * @param {*} data { windowId }
 * @returns
 */
export const selectWindow = data => {
	return http.request({
		url: '/api/blade-windows/select-window',
		method: 'POST',
		data
	});
};

/**
 * 窗口工作台（获取当前叫号和等候人数）
 * @param {*} params { windowId }
 * @returns
 */
export const getWindowWorkbench = params => {
	return http.request({
		url: '/api/blade-queuerecord/queueRecord/window-workbench',
		method: 'GET',
		params
	});
};

/**
 * 呼叫下一位
 * @param {*} data { windowId }
 * @returns
 */
export const callNext = data => {
	return http.request({
		url: '/api/blade-queuerecord/queueRecord/call-next',
		method: 'POST',
		data
	});
};

/**
 * 重呼
 * @param {*} data { recordId, windowId }
 * @returns
 */
export const recall = data => {
	return http.request({
		url: '/api/blade-queuerecord/queueRecord/recall',
		method: 'POST',
		data
	});
};

/**
 * 开始办理
 * @param {*} data { recordId, windowId }
 * @returns
 */
export const startHandle = data => {
	return http.request({
		url: '/api/blade-queuerecord/queueRecord/start-handle',
		method: 'POST',
		data
	});
};

/**
 * 完成办理
 * @param {*} data { recordId, windowId }
 * @returns
 */
export const finishHandle = data => {
	return http.request({
		url: '/api/blade-queuerecord/queueRecord/finish',
		method: 'POST',
		data
	});
};

/**
 * 过号
 * @param {*} data { recordId, windowId }
 * @returns
 */
export const passRecord = data => {
	return http.request({
		url: '/api/blade-queuerecord/queueRecord/pass',
		method: 'POST',
		data
	});
};

/**
 * 转移窗口
 * @param {*} data { recordId, windowId, targetWindowId }
 * @returns
 */
export const transferRecord = data => {
	return http.request({
		url: '/api/blade-queuerecord/queueRecord/transfer',
		method: 'POST',
		data
	});
};

/**
 * 挂起窗口
 * @param {*} data { windowId, reason }
 * @returns
 */
export const suspendWindow = data => {
	return http.request({
		url: '/api/blade-windows/suspend',
		method: 'POST',
		data
	});
};

/**
 * 恢复窗口
 * @param {*} data { windowId }
 * @returns
 */
export const resumeWindow = data => {
	return http.request({
		url: '/api/blade-windows/resume',
		method: 'POST',
		data
	});
};

/**
 * 窗口统计
 * @param {*} params { windowId, date }
 * @returns
 */
export const getWindowStat = params => {
	return http.request({
		url: '/api/blade-queuerecord/queueRecord/window-stat',
		method: 'GET',
		params
	});
};