import type ISingleTaskSearch from "@/interface/page/stockTask/ISingleTaskSearch.ts";
import axiosInstance from "@/api/axios.ts";
import type ISingleTaskTableData from "@/model/table/ISingleTaskTableData.ts";

export default class StockSingleTaskApi {

    // 分页查询当前任务
    static query(query: ISingleTaskSearch, pageSize: number, pageIndex: number) {
        return axiosInstance.post("/app/stockSingleTask/query", query, {
            params: {
                pageSize: pageSize,
                pageIndex: pageIndex,
            }
        });
    };
    // 分页查询历史任务
    static queryBak(query: ISingleTaskSearch, pageSize: number, pageIndex: number) {
        return axiosInstance.post("/app/stockSingleTask/queryBak", query, {
            params: {
                pageSize: pageSize,
                pageIndex: pageIndex,
            }
        });
    };
    // 下载任务数据文件
    static downloadTaskBak(query: ISingleTaskSearch) {
        return axiosInstance.post("/app/stockSingleTask/downLoadBak", query, {
            responseType: 'blob',
            timeout: 30000
        })
    };
    // 添加任务
    static addTask(data: ISingleTaskTableData) {
        return axiosInstance.post("/app/stockSingleTask/addSingleTask", data);
    };
    // 更换设备任务号
    static newPlcTaskId(taskId: string) {
        return axiosInstance.put("/app/stockSingleTask/newPlcTaskId/" + taskId);
    };
    // 更新任务状态
    static updateTaskStatus(taskId: string, taskStatus: number) {
        return axiosInstance.put("/app/stockSingleTask/updateTaskStatus", null, {
            params: {
                taskId: taskId,
                taskStatus: taskStatus
            }
        });
    };
    // 完成任务
    static completeTask(taskId: string) {
        return axiosInstance.put("/app/stockSingleTask/completeTask/" + taskId);
    };
    // 取消任务
    static cancelTask(taskId: string) {
        return axiosInstance.put("/app/stockSingleTask/cancelTask/" + taskId);
    }



}