setup.ts 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import { getAreaUserId } from "@/services/bus/user";
  2. import {
  3. GldErmcpSpotContractOperateReq,
  4. GldSpotContractInfo
  5. } from "@/services/proto/spotcontract/interface";
  6. import { orderContractControl } from "@/views/information/spot-contract/components/setup";
  7. import moment from 'moment';
  8. import { Ref } from 'vue';
  9. import { FormState } from "../interface";
  10. /**
  11. * 新增现货合同 表单提交
  12. */
  13. export function addContractReq() {
  14. /**
  15. * @param form 表单信息
  16. * @Param type 1: 保存草稿 2: 提交申请
  17. */
  18. function sendReq(form: FormState, loading: Ref<boolean>, OperateType: 1 | 2): Promise<string> {
  19. loading.value = true
  20. const info: GldSpotContractInfo = {
  21. UserID: getAreaUserId(),// 机构ID
  22. ProductType: 1, // 产品类型 产品类型-1:标准仓单2:等标3:非标
  23. ContractNo: form.ContractNo, // 现货合同编号
  24. ContractType: form.ContractType, // 现货合同类型-1:采购-1:销售
  25. BuyUserID: form.BuyUserID, // 采购方ID
  26. SellUserID: form.SellUserID,// 客户ID
  27. DeliveryGoodsID: form.DeliveryGoodsID as number,// 现货品种ID
  28. WrStandardID: form.WrStandardID as number,// 品类ID
  29. SpotGoodsBrandID: form.SpotGoodsBrandID as number,// 品牌ID
  30. ConvertFactor: form.ConvertFactor as number, // 标仓系数
  31. SpotGoodsDesc: form.SpotGoodsDesc, // 商品规格
  32. PriceType: form.PriceType,// 定价类型
  33. CurrencyID: form.CurrencyID as number,// 结算币种
  34. Qty: Number(form.Qty), // 数量
  35. Price: Number(form.Price), // 价格
  36. TradeDate: moment().format("YYYYMMDD"),// 交易日
  37. SignDate: moment().format("YYYY-MM-DD HH:mm:ss"), // 签订日期
  38. // 以上必填
  39. // 以下选填
  40. BizType: form.BizType, // 业务类型 - 1:套保 2:套利
  41. Remark: form.Remark, // 合同备注
  42. // ContractAttachment: , // 合同附件
  43. ContractMargin: form.ContractMargin ? Number(form.ContractMargin) : 0, // 合同保证金
  44. Amount: [1, 3].includes(form.PriceType) ? Number(form.Price) * Number(form.Qty) : 0, // 金额
  45. PriceMove: Number(form.PriceMove as number), // 升贴水
  46. StartDate: form.StartDate, // 点价开始时间
  47. EndDate: form.EndDate, // 点价结束时间
  48. DeliveryStartDate: form.DeliveryStartDate,// 交收期开始
  49. DeliveryEndDate: form.DeliveryEndDate, // 交收期结束
  50. GoodsID: form.GoodsID as number, // 点价合约ID-0:为现货,其它为期货商品合约ID[2:点价3:暂定价]
  51. MerUserID: form.MerUserID || 0, // 跟单员ID
  52. TradeUserID: form.TradeUserID || 0, // 交易员ID
  53. SaleUserID: form.SaleUserID || 0,// 业务员id
  54. }
  55. const params: GldErmcpSpotContractOperateReq = {
  56. SpotContractID: '0',
  57. OperateType,
  58. Remark: '',
  59. Info: info,
  60. }
  61. return orderContractControl(params, loading)
  62. .then(res => {
  63. return Promise.resolve(res);
  64. })
  65. .catch(err => {
  66. return Promise.reject(err);
  67. })
  68. }
  69. return { sendReq }
  70. }