import {Ref} from "vue";
import {commonResultInfo, getRequestResultInfo} from "@/common/methods/request";
import {AreaInOutApplyAuditPassReq, AuditERMCPAreaInOutStockApplyReq} from "@/services/proto/warehouse/interface";
import {inventorySign} from "@/views/manage/inventory-review/setup";
import {inOutStockApplyReq, refuseStockApplyReq} from "@/services/proto/warehouse";

/**
 * 管理 - 库存审核 - 通过
 */
export function passStockControl(req: AreaInOutApplyAuditPassReq, loading: Ref<boolean>): Promise<string> {
    loading.value = true;
    const sign = getRequestResultInfo(inventorySign, 2)  // 接口请求后的返回提示 这里统一进行管理
    // 接口调用
    const result = inOutStockApplyReq(req)
    // 接口调用结果处理，提示成功或者失败信息，并关闭loading效果
    return commonResultInfo(result, sign, loading)
}

/**
 * 管理 - 库存审核 - 拒绝 && 撤回
 * @param req.ApplyStatus  审核状态:3-审核拒绝 5-已撤回
 */
export function refuseStockControl(req: AuditERMCPAreaInOutStockApplyReq, loading: Ref<boolean>): Promise<string> {
    loading.value = true;
    const sign = getRequestResultInfo(inventorySign, req.ApplyStatus)  // 接口请求后的返回提示 这里统一进行管理
    // 接口调用
    const result = refuseStockApplyReq(req)
    // 接口调用结果处理，提示成功或者失败信息，并关闭loading效果
    return commonResultInfo(result, sign, loading)
}