/** * 登记相关 * * 采购 - 待点价 - 点价登记 * 采购 - 履约交收 - (交收登记, 款项登记, 发票登记, 入库登记) * */ import { commonResultInfo, getRequestResultInfo } from "@/common/methods/request"; import { operationContractReq } from "@/services/proto/contract"; import { ErmcpContractOperateApplyReq, FundsReq, InvoiceReq, SettlementReq, SomePriceReq } from "@/services/proto/contract/interface"; import { objectToUint8Array } from "@/utils/objHandle"; import { purchaseStateSign } from "@/views/business/purchase/setup"; import Long from "long"; import { Ref } from "vue"; /** * 这里负责 点价登记, 交收登记, 款项登记, 发票登记, 入库登记 */ /** * 点价登记 * @param spotcontractid 合同id * @param req 点价价格以及数量 */ export function somePriceReq(spotcontractid: string, req: SomePriceReq, loading: Ref): Promise { return operationContractRsp(1, operationContractReqBuilder(req, spotcontractid, 1), loading) } /** * 交收登记 */ export function settlementReq(spotcontractid: string, req: SettlementReq, loading: Ref): Promise { return operationContractRsp(2, operationContractReqBuilder(req, spotcontractid, 2), loading) } /** * 款项登记 */ export function fundsReq(spotcontractid: string, req: FundsReq, loading: Ref, Remark: String): Promise { return operationContractRsp(3, operationContractReqBuilder(req, spotcontractid, 3), loading) } /** * 发票登记 */ export function invoiceReq(spotcontractid: string, req: InvoiceReq, loading: Ref): Promise { return operationContractRsp(4, operationContractReqBuilder(req, spotcontractid, 4), loading) } /** * 请求报文组装 * @param req 特定的请求包结构 * @param id 操作的合同id * @param type 操作类型 */ export function operationContractReqBuilder(req: Object, id: string, type: number, Remark?: String): ErmcpContractOperateApplyReq { return { OperateType: 1, // uint32 操作类型-1:登记2:确认3:拒绝4:撤销 Remark: '', Info: { OperateApplyType: type, // uint32 操作申请类型-1:点价2:结算3:款项4:发票 RelatedID: Long.fromString(id), // uint64 现货合同ID(602+Unix秒时间戳(10位)+xxxxxx) DetailJson: objectToUint8Array(req), // bytes 明细JSON {} }, } as ErmcpContractOperateApplyReq } /** * 登记返回处理 * @param type 登记类型 * @param req 请求数据 * @param loading */ export function operationContractRsp(type: number, req: ErmcpContractOperateApplyReq, loading: Ref): Promise { const sign = getRequestResultInfo(purchaseStateSign, type) // 接口请求后的返回提示 这里统一进行管理 const result = operationContractReq(req) return commonResultInfo(result, sign, loading) }