import { AddReq,EditReq, DelReq,UserPageQuery } from '@fast-crud/fast-crud';
import { request } from '/@/utils/service';

export const apiPrefix = '/api/system/inventory/check-records/list/';
export function GetList(query: UserPageQuery) {
	return request({
		url: apiPrefix,
		method: 'get',
		params: query,
	});
}
// export function GetObj(id: InfoReq) {
// 	return request({
// 		url: apiPrefix + id,
// 		method: 'get',
// 	});
// }

export function AddObj(obj: AddReq) {
	return request({
		url: apiPrefix,
		method: 'post',
		data: obj,
	});
}

export function UpdateObj(obj: EditReq) {
	return request({
		url: apiPrefix + obj.id + '/',
		method: 'put',
		data: obj,
	});
}

export function DelObj(id: DelReq) {
	return request({
		url: apiPrefix + id + '/',
		method: 'delete',
		data: { id },
	});
}

export function GetPermission() {
    return request({
        url: apiPrefix,
        method: 'get',
    });
}


export function StartScan(obj: object) {
	return request({
		url: '/api/system/device/scan/start/',
		method: 'post',
		data: obj,
	});
}


// 获取盘点记录详情
export function GetDetail(id: number) {
    return request({
        url: `/api/system/inventory/check-records/${id}/`,
        method: 'get',
    });
}

export function ScanDevice(obj: object) {
	return request({
		url: '/api/system/device/scan/',
		method: 'post',
		data: obj,
	});
}

// 批量扫描设备
export function ScanDeviceBatch(obj: { check_no: string; device_codes: string[] }) {
	return request({
		url: '/api/system/device/scan/batch/',
		method: 'post',
		data: obj,
	});
}


export function CompleteScan(obj: object) {
	return request({
		url: '/api/system/device/scan/complete/',
		method: 'post',
		data: obj,
	});
}
export function CancelScan(id: number) {
	return request({
		url: `/api/system/inventory/check-records/${id}/cancel/`,
		method: 'post',
		// data: obj,
	});
}


