import { getUserId } from '@/services/bus/account';
import {getAreaUserId, getUserAccountType} from '@/services/bus/user';
import { commonSearch_go } from '@/services/go';
import { Ermcp3SellBuyContract, SellBuyContractReq } from '@/services/go/ermcp/purchase/interface';

/** ================================= 采购 ================================**/
/**
 * 查询采购信息(这个接口和销售是同一个接口) /Ermcp3/QuerySpotContractBS
 * @param req.querytype 查询类型 1-全部 2-待点价 3-履约结算 4-已完成 (必填)
 * @param req.usertype 用户类型 2-机构 7-企业成员
 * @param req.contractid 合同ID(SpotContractId)
 * @constructor
 */
export function QueryPurchase(req: SellBuyContractReq): Promise<Ermcp3SellBuyContract[]> {
    const param = {
        userid: getUserId(),
        areauserid: getAreaUserId(), // 所属机构id
        contracttype: 1, // 采购
        usertype: getUserAccountType()
    }
    Object.assign(param, req)
    return commonSearch_go('/Ermcp3/QuerySpotContractBS', param).catch((err) => {
        throw new Error(`查询采购信息: ${err}`);
    });
}


