setup.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /**
  2. * 登记相关
  3. *
  4. * 采购 - 待点价 - 点价登记
  5. * 采购 - 履约交收 - (交收登记, 款项登记, 发票登记, 入库登记)
  6. *
  7. */
  8. import {
  9. ErmcpContractOperateApplyReq,
  10. FundsReq,
  11. InvoiceReq,
  12. SettlementReq,
  13. SomePriceReq
  14. } from "@/services/proto/contract/interface";
  15. import {operationContractReq} from "@/services/proto/contract";
  16. import Long from "long";
  17. import {commonResultInfo, getRequestResultInfo} from "@/common/methods/request";
  18. import {purchaseStateSign} from "@/views/business/purchase/setup";
  19. import {hedgePlanReq} from "@/services/proto/hedgeplan";
  20. import {Ref} from "vue";
  21. import {objectToUint8Array} from "@/utils/objHandle";
  22. import {ermcpInOutStockApplyReq} from "@/services/proto/warehouse";
  23. import {ERMCPAreaInOutStockApplyReq} from "@/services/proto/warehouse/interface";
  24. /**
  25. * 这里负责 点价登记, 交收登记, 款项登记, 发票登记, 入库登记
  26. */
  27. /**
  28. * 点价登记
  29. * @param spotcontractid 合同id
  30. * @param req 点价价格以及数量
  31. */
  32. export function somePriceReq(spotcontractid: string, req: SomePriceReq, loading: Ref<boolean>): Promise<string> {
  33. return operationContractRsp(1,
  34. operationContractReqBuilder(req, spotcontractid, 1),
  35. loading)
  36. }
  37. /**
  38. * 交收登记
  39. */
  40. export function settlementReq(spotcontractid: string, req: SettlementReq, loading: Ref<boolean>): Promise<string> {
  41. return operationContractRsp(2,
  42. operationContractReqBuilder(req, spotcontractid, 2),
  43. loading)
  44. }
  45. /**
  46. * 款项登记
  47. */
  48. export function fundsReq(spotcontractid: string, req: FundsReq, loading: Ref<boolean>,Remark:String): Promise<string> {
  49. return operationContractRsp(3,
  50. operationContractReqBuilder(req, spotcontractid, 3),
  51. loading)
  52. }
  53. /**
  54. * 发票登记
  55. */
  56. export function invoiceReq(spotcontractid: string, req: InvoiceReq, loading: Ref<boolean>): Promise<string> {
  57. return operationContractRsp(4,
  58. operationContractReqBuilder(req, spotcontractid, 4),
  59. loading)
  60. }
  61. /**
  62. * 入库登记
  63. */
  64. export function storageReq(req: ERMCPAreaInOutStockApplyReq, loading: Ref<boolean>): Promise<string>{
  65. const sign = getRequestResultInfo(purchaseStateSign, 5) // 接口请求后的返回提示 这里统一进行管理
  66. const result = ermcpInOutStockApplyReq(req)
  67. return commonResultInfo(result, sign, loading)
  68. }
  69. /**
  70. * 请求报文组装
  71. * @param req 特定的请求包结构
  72. * @param id 操作的合同id
  73. * @param type 操作类型
  74. */
  75. export function operationContractReqBuilder(req: Object, id: string, type: number,Remark?:String): ErmcpContractOperateApplyReq {
  76. return {
  77. OperateType: 1, // uint32 操作类型-1:登记2:确认3:拒绝4:撤销
  78. Remark:'',
  79. Info: {
  80. OperateApplyType: type, // uint32 操作申请类型-1:点价2:结算3:款项4:发票
  81. RelatedID: Long.fromString(id), // uint64 现货合同ID(602+Unix秒时间戳(10位)+xxxxxx)
  82. DetailJson: objectToUint8Array(req), // bytes 明细JSON {}
  83. },
  84. } as ErmcpContractOperateApplyReq
  85. }
  86. /**
  87. * 登记返回处理
  88. * @param type 登记类型
  89. * @param req 请求数据
  90. * @param loading
  91. */
  92. export function operationContractRsp(type: number, req: ErmcpContractOperateApplyReq, loading: Ref<boolean>): Promise<string> {
  93. const sign = getRequestResultInfo(purchaseStateSign, type) // 接口请求后的返回提示 这里统一进行管理
  94. const result = operationContractReq(req)
  95. return commonResultInfo(result, sign, loading)
  96. }