import { getUserId } from "@/services/bus/account";
import { commonSearch_go } from "@/services/go";
import {
    Ermcp3AreaStock,
    Ermcp3AreaStockApply,
    QueryAreaStockApplyReq
} from "@/services/go/ermcp/search-inventory/interface";

/** ================================= 库存查询 ================================**/
/**
 * 查询机构库存(库存查询/当前库存) /Ermcp3/QueryAreaStock
 * @constructor
 */
export function QueryAreaStock(): Promise<Ermcp3AreaStock[]> {
    const userid = getUserId(); // 所属机构id
    return commonSearch_go('/Ermcp3/QueryAreaStock', { userid }).catch((err) => {
        throw new Error(`查询机构库存(库存管理/当前库存): ${err}`);
    });
}

/**
 * 查询库存申请(库存查询|库存审核)  /Ermcp3/QueryAreaStockApply  (管理 - 库存审核) 调用的是同一个接口
 * @param req
 * @constructor
 */
export function QueryAreaStockApply(req: QueryAreaStockApplyReq): Promise<Ermcp3AreaStockApply[]> {
    const userid = getUserId(); // 所属机构id
    Object.assign(req, { userid })
    return commonSearch_go('/Ermcp3/QueryAreaStockApply', req).catch((err) => {
        throw new Error(`查询库存申请: ${err}`);
    });
}
