浏览代码

贸易圈挂牌求购

huangbin 4 年之前
父节点
当前提交
65c0298583

+ 4 - 0
public/proto/mtp.proto

@@ -1523,6 +1523,10 @@ message HdWROrderReq {
 	optional uint32 WRStandardID = 37; // uint32 现货品种ID
 	repeated DGFactoryItems FactoryItems = 38; // DGFactoryItems 要素类型明细集合(没有仓单要素ID填写)
 	optional uint64 DelistMinQty = 39; // uint64 起摘数量
+	optional uint32 MarginFlag = 40; // uint32 挂牌是否指定保证金 0:否 1:是
+	optional uint32 MarginAlgorithm = 41; // uint32 指定保证金方式 1:比率 2:固定
+	optional double MarginValue = 42; // double 指定保证金设置值
+	optional uint32 AllFriendsFlag = 43; // uint32 是否全好友可见 0:否 1:是
 }
 // 持仓单挂牌应答 0 22 16
 message HdWROrderRsp {

+ 99 - 71
src/views/market/spot_trade/warehouse_receipt_trade/warehouse_receipt_trade_blocs/components/post-buying/index.vue

@@ -97,7 +97,7 @@
             </a-col>
             <a-col :span="24">
               <a-form-item label="履约保证金">
-                <span class="white ml8">55555</span>
+                <span class="white ml8">{{getMargin()}}</span>
               </a-form-item>
             </a-col>
             <a-col :span="24">
@@ -156,6 +156,7 @@ import { getCanUseMoney } from '@/services/bus/account';
 import { TempWrOrderQuoteDetail } from '@/views/market/spot_trade/components/post_buying/interface';
 import Friend from './friend.vue';
 import Permance from './permancePlanTmp.vue';
+import { message } from 'ant-design-vue';
 
 export default defineComponent({
     emits: ['cancel', 'update'],
@@ -181,86 +182,112 @@ export default defineComponent({
             formState.accountid = accountList[0].accountid;
         }
         //
-        const priceCheck = ref<boolean>(false);
-        const numCheck = ref<boolean>(false);
+        const priceCheck = ref<boolean>(false); // 是否可议价
+        const numCheck = ref<boolean>(false); // 是否整单
+        const friendCheck = ref<boolean>(false); // 是否不限好友
         function getSelectedAccount() {
             return accountList.find((e) => e.accountid === formState.accountid);
         }
         // 挂牌金额
         function getMoney() {
             let result = 0;
-            if (formState.FixedPrice && formState.OrderQty) {
-                result = formState.FixedPrice * formState.OrderQty;
+            const { FixedPrice, OrderQty } = formState;
+            if (FixedPrice && OrderQty) {
+                result = FixedPrice * OrderQty;
+            }
+            return result ? result.toFixed(2) : '--';
+        }
+        // 履约保证金
+        function getMargin() {
+            let result = 0;
+            const { FixedPrice, OrderQty, margin } = formState;
+            if (FixedPrice && OrderQty && margin) {
+                result = (FixedPrice * OrderQty * margin) / 100;
             }
             return result ? result.toFixed(2) : '--';
         }
-
         function submit() {
-            // const marketInfo = getMarketRunByTradeMode(17);
-            // if (marketInfo) {
-            //     validateAction<FormParam>(formRef, formState).then((res) => {
-            //         // 现在增加一种挂牌求购的情况
-            //         // 这种求购模式会生成一种仓单贸易商品
-            //         const wrGoodsInfo: WRGoodsInfo = {
-            //             GoodsID: props.selectedRow.goodsid, // uint32 配置商品ID
-            //             GoodsCode: props.selectedRow.goodscode, // string 配置商品代码
-            //             PriceFactor: 1, // double 商品价格系数
-            //             PriceMove: 0, // double 商品升贴水值
-            //             WeightRatio: 1, // double 商品重量系数
-            //         };
-            //         const param = {
-            //             AccountID: res.accountid, // 默认内部资金账号第一个
-            //             ClientSerialNo: uuidv4(), // 客户端流水号
-            //             // OperateSrc: 2,
-            //             ClientType: 4,
-            //             // MarketID: marketInfo.marketid,
-            //             LadingBillId: 0, // 提单id(wrholdlb的LadingBillId字段),卖的时候填写 uint64
-            //             // LadingBillId: 'uint642081626946446000001', // 提单id(wrholdlb的LadingBillId字段),卖的时候填写 uint64
-            //             TradeDate: moment(marketInfo.tradedate).format('YYYYMMDD'), // 交易日 string
-            //             // SubNum: '0', // 提单子单号
-            //             SubNum: 0,
-            //             // WRFactorTypeId: '2121626946446000001', // 仓单要素ID(wrholdlb的WRFactorTypeId字段),卖的时候填写 uint64
-            //             WRFactorTypeId: props.selectedRow.wrfactortypeid ? props.selectedRow.wrfactortypeid : 0, // 仓单要素ID(wrholdlb的WRFactorTypeId字段),卖的时候填写 uint64
-            //             IsSpecified: 0, // 是否指定对手 0:不指定 1:指定 uint32
-            //             // MatchUserIDs: 0, // 仓单贸易对手资金账号ID集合(指定对手时填写) uint32
-            //             OrderQty: res.OrderQty, // 委托数量(可挂部分数据量) ======
-            //             DeliveryGoodsID: props.selectedRow.deliverygoodsid, // 交割商品商品ID  // 有仓单求购
-            //             WRPriceType: isFloat() ? 2 : 1, // 价格方式 1:固定价 2:浮动价
-            //             FixedPrice: res.FixedPrice, // 固定价格
-            //             PriceFactor: 1, // 价格系数(浮动价时填写)
-            //             PriceMove: res.PriceMove, // 升贴水(浮动价时填写)
-            //             TimevalidType: 4, // 时间有效类型 1:当日有效 2:本周有效 3:指定时间有效 4:一直有效
-            //             // ValidTime: moment('2021-08-25 00:00:00').format('YYYY-MM-DD HH:mm:ss'), // 有效期限
-            //             ClientOrderTime: moment().format('YYYY-MM-DD HH:mm:ss'),
-            //             FirstRatio: 0, // 首付比例
-            //             PerformanceTemplateID: 0, // 履约计划模板ID
-            //             UserID: getUserId(),
-            //             OperatorID: getUserId(), // 操作员账号ID
-            //             BuyOrSell: 0, // 买卖方向 0买1卖
-            //             PriceDisplayMode: 1, // 浮动价显示方式 1:合并显示 2:分开显示
-            //             CanBargain: 0, // 挂牌是否可议价0:不可1:可-摘牌是否议价
-            //             Attachment1: '', // 附件1
-            //             Attachment2: '', // 附件2
-            //             Remark: '', // 备注
-            //             ApplyID: 0, // 申请ID
-            //             WRTradeGoods: isFloat() ? [wrGoodsInfo] : [],
-            //             CanPart: 1, // 是否允许部份摘牌0:不允许;1:允许
-            //             WRStandardID: props.selectedRow.wrstandardid,
-            //             HasWr: isWR(), // 无仓单挂牌  是否有无仓单
-            //             DeliveryMonth: isWR() ? '' : moment(res.DeliveryMonth).format('YYYY-MM'),
-            //             FactoryItems: props.selectedRow.wrResult != undefined ? props.selectedRow.wrResult.flatMap((it) => {
-            //                 return {
-            //                     DGFactoryItemTypeID: it.dgfactoryitemtypeid, // uint64 要素项类型ID
-            //                     DGFactoryItemID: it.dgfactoryitemid, // uint64 预约要素项类型值
-            //                     ItemTypeMode: 1, // uint32 要素项类型模式
-            //                 };
-            //             }): [], // DGFactoryItems 要素类型明细集合(没有仓单要素ID填写)
-            //         };
-            //         requestResultLoadingAndInfo(hdWROrder, param, loading, ['求购成功', '求购失败:']).then(() => {
-            //             cancel(true);
-            //         });
-            //     });
-            // }
+            if (!selectedPermance) {
+                message.error('请选择履约模板');
+                return;
+            }
+            if (!frineds) {
+                message.error('请选择朋友');
+                return;
+            }
+            const marketInfo = getMarketRunByTradeMode(17);
+            if (marketInfo) {
+                validateAction<FormParam>(formRef, formState).then((res) => {
+                    // 现在增加一种挂牌求购的情况
+                    // 这种求购模式会生成一种仓单贸易商品
+                    const wrGoodsInfo: WRGoodsInfo = {
+                        GoodsID: props.selectedRow.goodsid, // uint32 配置商品ID
+                        GoodsCode: props.selectedRow.goodscode, // string 配置商品代码
+                        PriceFactor: 1, // double 商品价格系数
+                        PriceMove: 0, // double 商品升贴水值
+                        WeightRatio: 1, // double 商品重量系数
+                    };
+                    const param = {
+                        AccountID: res.accountid, // 默认内部资金账号第一个
+                        ClientSerialNo: uuidv4(), // 客户端流水号
+                        // OperateSrc: 2,
+                        ClientType: 4,
+                        // MarketID: marketInfo.marketid,
+                        LadingBillId: 0, // 提单id(wrholdlb的LadingBillId字段),卖的时候填写 uint64
+                        // LadingBillId: 'uint642081626946446000001', // 提单id(wrholdlb的LadingBillId字段),卖的时候填写 uint64
+                        TradeDate: moment(marketInfo.tradedate).format('YYYYMMDD'), // 交易日 string
+                        // SubNum: '0', // 提单子单号
+                        SubNum: 0,
+                        // WRFactorTypeId: '2121626946446000001', // 仓单要素ID(wrholdlb的WRFactorTypeId字段),卖的时候填写 uint64
+                        WRFactorTypeId: props.selectedRow.wrfactortypeid ? props.selectedRow.wrfactortypeid : 0, // 仓单要素ID(wrholdlb的WRFactorTypeId字段),卖的时候填写 uint64
+                        IsSpecified: 1, // 是否指定对手 0:不指定 1:指定 uint32
+                        MatchUserIDs: frineds.value, // 仓单贸易对手资金账号ID集合(指定对手时填写) uint32
+                        OrderQty: res.OrderQty, // 委托数量(可挂部分数据量) ======
+                        DeliveryGoodsID: props.selectedRow.deliverygoodsid, // 交割商品商品ID  // 有仓单求购
+                        WRPriceType: 1, // 价格方式 1:固定价 2:浮动价
+                        FixedPrice: res.FixedPrice, // 固定价格
+                        PriceFactor: 1, // 价格系数(浮动价时填写)
+                        PriceMove: 0, // 升贴水(浮动价时填写)
+                        TimevalidType: 4, // 时间有效类型 1:当日有效 2:本周有效 3:指定时间有效 4:一直有效
+                        ValidTime: moment(formState.vidaliteTime).format('YYYY-MM-DD HH:mm:ss'), // 有效期限
+                        ClientOrderTime: moment().format('YYYY-MM-DD HH:mm:ss'),
+                        FirstRatio: 0, // 首付比例
+                        PerformanceTemplateID: selectedPermance.value?.autoid, // 履约计划模板ID
+                        UserID: getUserId(),
+                        OperatorID: getUserId(), // 操作员账号ID
+                        BuyOrSell: 0, // 买卖方向 0买1卖
+                        PriceDisplayMode: 1, // 浮动价显示方式 1:合并显示 2:分开显示
+                        CanBargain: 0, // 挂牌是否可议价0:不可1:可-摘牌是否议价
+                        Attachment1: '', // 附件1
+                        Attachment2: '', // 附件2
+                        Remark: '', // 备注
+                        ApplyID: 0, // 申请ID
+                        WRTradeGoods: [],
+                        CanPart: numCheck.value ? 0 : 1, // 是否允许部份摘牌0:不允许;1:允许
+                        WRStandardID: props.selectedRow.wrstandardid,
+                        HasWr: 1, // 无仓单挂牌  是否有无仓单
+                        DeliveryMonth: '',
+                        DelistMinQty: numCheck.value ? formState.delistingQty : 0, // 起摘数量
+                        MarginFlag: 1, // 挂牌是否指定保证金 0:否 1:是
+                        MarginAlgorithm: 1, // 指定保证金方式 1:比率 2:固定
+                        MarginValue: formState.margin, // 指定保证金设置值
+                        AllFriendsFlag: friendCheck.value ? 1 : 0, //是否全好友可见 0:否 1:是
+                        FactoryItems:
+                            props.selectedRow.wrResult != undefined
+                                ? props.selectedRow.wrResult.map((it) => {
+                                      return {
+                                          DGFactoryItemTypeID: it.dgfactoryitemtypeid, // uint64 要素项类型ID
+                                          DGFactoryItemID: it.dgfactoryitemid, // uint64 预约要素项类型值
+                                          ItemTypeMode: 1, // uint32 要素项类型模式
+                                      };
+                                  })
+                                : [], // DGFactoryItems 要素类型明细集合(没有仓单要素ID填写)
+                    };
+                    requestResultLoadingAndInfo(hdWROrder, param, loading, ['求购成功', '求购失败:']).then(() => {
+                        cancel(true);
+                    });
+                });
+            }
         }
         return {
             submit,
@@ -287,6 +314,7 @@ export default defineComponent({
             numCheck,
 
             getMoney,
+            getMargin,
         };
     },
 });

+ 3 - 3
src/views/market/spot_trade/warehouse_receipt_trade/warehouse_receipt_trade_blocs/components/post-buying/setup.ts

@@ -24,15 +24,15 @@ export function handleForm() {
         FixedPrice: [{ required: true, message: '请输入挂牌价格', trigger: 'blur', type: 'number', }],
         OrderQty: [
             { required: true, message: '请输入挂牌数量', trigger: 'blur', type: 'number' },
-            { min: 1, message: '挂牌挂牌数量不能小于1', }
+            { min: 1, message: '挂牌挂牌数量不能小于1', type: 'number' }
         ],
         delistingQty: [
             { required: true, message: '请输入起摘数量', trigger: 'blur', type: 'number' },
-            { min: 1, message: '起摘数量不能小于1', }
+            { min: 1, message: '起摘数量不能小于1', type: 'number' }
         ],
         margin: [
             { required: true, message: '请输入履约保证金', trigger: 'blur', type: 'number' },
-            { validator: validateMargin, trigger: 'blur' }
+            { validator: validateMargin, trigger: 'blur', type: 'number' }
         ],
         accountid: [{ required: true, message: '请输入交易账号' }],
     }