import request from '/@/utils/request';
import { AxiosPromise } from 'axios';
import type { ClassListParams, ClassItem, ListOrdersParams, UploadOrdersToLisParams } from './type';

export function Add(params: object) {
	return request({
		url: '/lis/class/info/add',
		method: 'post',
		data: params,
	});
}
export function update(params: object) {
	return request({
		url: '/lis/class/info/update',
		method: 'post',
		data: params,
	});
}
export function deleteId(params: string) {
	return request({
		url: '/lis/class/info/delete',
		method: 'post',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		data: params,
	});
}

/**
 * 获取分类列表
 * @param params 
 * @returns 
 */
export function list(params: ClassListParams) :AxiosPromise<ClassItem[]> {
    return request({
      url: '/lis/class/info/list',
      method: 'post',
      data: params
    })
}


/**
 * 获取门诊采样数据
 * @param params 
 * @returns 
 */
export function listOrdersApi(params: ListOrdersParams) {
	return request({
		url: '/lis/barcode/info/listOrders',
		method: 'post',
		params
	})
}

/**
 * 打印条码
 * @param data 
 * @returns 
 */
export function printBarcodeApi(data: { orders: any[], printerName: string; }) {
	return request({
		url: '/lis/barcode/info/printBarcode',
		method: 'post',
		data
	})
}

/**
 * 取消采样
 * @param barcode 
 * @returns 
 */
export function cancelBarcodeApi(barcode: string) {
	return request({
		url: '/lis/barcode/info/cancelBarcode',
		method: 'post',
		headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		params: { barcode }
	})
}

/**
 * 获取lis条码打印机列表
 * @param clientCode 
 * @returns 
 */
export function getAvailableDevicesByDeviceTypeApi(clientCode: string) {
	return request({
		url: '/comm/service/device/info/getAvailableDevicesByDeviceType',
		method: 'post',
		headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		params: { 
			clientCode,
			deviceType: 'LIS条码标签打印机'
		}
	})
}


/**
 * 手动上传申请至LIS
 * @param params 
 * @returns 
 */
export function uploadOrdersToLisApi(params: UploadOrdersToLisParams) {
	return request({
		url: '/lis/barcode/info/uploadOrdersToLis',
		method: 'post',
		headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		params
	})
}