Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/views/information/spot-contract/components/add/index.vue
#	src/views/information/spot-contract/components/add/setup.ts
xkwg 4 anni fa
parent
commit
8c0706ecd0

+ 49 - 51
src/views/information/spot-contract/components/add/index.vue

@@ -337,23 +337,26 @@
         <legend>其他信息</legend>
         <a-row :gutter="24">
           <a-col :span="12">
-            <a-form-item label="保证金">
+            <a-form-item label="保证金"
+                         name="ContractMargin">
               <a-input class="dialogInput suffixGrey"
                        placeholder="请输入保证金"
+                       v-model:value="formState.ContractMargin"
                        style="width: 200px"
                        :suffix="payCurrencyUnit" />
             </a-form-item>
           </a-col>
           <a-col :span="12">
-            <a-form-item label="业务员">
+            <a-form-item label="业务员"
+                         name="SaleUserID">
               <a-select class="inlineFormSelect"
+                        v-model:value="formState.SaleUserID"
                         style="width: 200px"
                         placeholder="请选择业务员">
-                <a-select-option value="1">
-                  客户一
-                </a-select-option>
-                <a-select-option value="2">
-                  客户二
+                <a-select-option v-for="item in businesserList"
+                                 :key="item.id"
+                                 :value="item.id">
+                  {{item.name}}
                 </a-select-option>
               </a-select>
             </a-form-item>
@@ -361,29 +364,31 @@
         </a-row>
         <a-row :gutter="24">
           <a-col :span="12">
-            <a-form-item label="跟单员">
+            <a-form-item label="跟单员"
+                         name="MerUserID">
               <a-select class="inlineFormSelect"
+                        v-model:value="formState.MerUserID"
                         style="width: 200px"
                         placeholder="请选择跟单员">
-                <a-select-option value="1">
-                  客户一
-                </a-select-option>
-                <a-select-option value="2">
-                  客户二
+                <a-select-option v-for="item in merchandiserList"
+                                 :key="item.id"
+                                 :value="item.id">
+                  {{item.name}}
                 </a-select-option>
               </a-select>
             </a-form-item>
           </a-col>
           <a-col :span="12">
-            <a-form-item label="期货账户">
+            <a-form-item label="交易用户"
+                         name="TradeUserID">
               <a-select class="inlineFormSelect"
                         style="width: 200px"
+                        v-model:value="formState.TradeUserID"
                         placeholder="请选择期货账户">
-                <a-select-option value="1">
-                  客户一
-                </a-select-option>
-                <a-select-option value="2">
-                  客户二
+                <a-select-option v-for="item in traderList"
+                                 :key="item.id"
+                                 :value="item.id">
+                  {{item.name}}
                 </a-select-option>
               </a-select>
             </a-form-item>
@@ -404,17 +409,19 @@
 </template>
 
 <script lang="ts">
-import {defineComponent, PropType, ref, toRaw} from 'vue';
+import { defineComponent, PropType, ref, toRaw } from 'vue';
 import { closeModal } from '@/common/setup/modal/index';
 import { initData } from '@/common/methods';
-import { handleFromState, handleContract, handlevalidate, handleDeliveryGoods, handleAmout, handlePrice, handleDate, addContractReq } from './setup';
+import { handleFromState, handleContract, handleDeliveryGoods, handleAmout, handlePrice, handleDate, addContractReq } from './setup';
 import { getUserName, getUsrId } from '@/services/bus/user';
 import { getGoodsList } from '@/services/bus/goods';
 import { Goods } from '@/services/go/ermcp/goodsInfo/interface';
 import { ValidateErrorEntity } from 'ant-design-vue/lib/form/interface';
 import { FormState } from './interface';
 import { formatTime } from '@/common/methods/format';
-import {Ermcp3ContractRsp} from "@/services/go/ermcp/spot-contract/interface";
+import { Ermcp3ContractRsp } from '@/services/go/ermcp/spot-contract/interface';
+import { handleAccountManager } from '../setup';
+import { Moment } from 'moment';
 
 export default defineComponent({
     name: 'add-spot-contract',
@@ -425,36 +432,17 @@ export default defineComponent({
             default: {},
         },
     },
-    setup(props,context) {
+    setup(props, context) {
         const { visible, cancel } = closeModal('spot_contract_btn_add');
         const { sendReq } = addContractReq();
         const loading = ref<boolean>(false);
 
         // 表单
         const formRef = ref();
-        const { formState, businessType } = handleFromState();
+        const { formState, businessType, rules } = handleFromState();
         // 合同类型
         const { contractType, isSell, contractChange, customList, queryCustomList } = handleContract();
-        // 自定义表单验证方法
-        const { v_ContractType, v_BizType, v_BuyUser, v_SellUser, v_DeliveryGoods, v_WrStandard, v_SpotGoodsBrand, v_PriceType, v_Currency, v_Goods } = handlevalidate(formState);
-        const rules = {
-            ContractNo: [{ required: true, message: '请输入合同编号', trigger: 'blur' }],
-            ContractType: [{ required: true, validator: v_ContractType, trigger: 'change' }],
-            // BizType: [{ required: true, validator: v_BizType, trigger: 'change' }],
-            BuyUserID: [{ required: true, validator: v_BuyUser, trigger: 'change' }],
-            SellUserID: [{ required: true, validator: v_SellUser, trigger: 'change' }],
-            DeliveryGoodsID: [{ required: true, validator: v_DeliveryGoods, trigger: 'change' }],
-            WrStandardID: [{ required: true, validator: v_WrStandard, trigger: 'blur' }],
-            SpotGoodsBrandID: [{ required: true, validator: v_SpotGoodsBrand, trigger: 'blur' }],
-            GoodsID: [{ required: true, validator: v_Goods, trigger: 'blur' }],
-            // ConvertFactor: [{ required: true, message: '请选择品类', trigger: 'blur' }],
-            SpotGoodsDesc: [{ required: true, message: '请输入商品规格', trigger: 'blur' }],
-            PriceType: [{ required: true, validator: v_PriceType, trigger: 'blur' }],
-            CurrencyID: [{ required: true, validator: v_Currency, trigger: 'blur' }],
-            Qty: [{ required: true, message: '请输入数量', trigger: 'blur' }],
-            Price: [{ required: true, message: '请输入价格', trigger: 'blur' }],
-            PriceMove: [{ required: true, message: '请输入升贴水', trigger: 'blur' }],
-        };
+
         //  处理现货商品
         const { deliveryGoodsList, gblist, gmlist, numberUnit, WrStandardChange, getDeliveryGoods, deliveryGoodsChange } = handleDeliveryGoods(formState);
         // 价格信息
@@ -463,21 +451,26 @@ export default defineComponent({
         const { deliveryDate, priceDate, disabledDate } = handleDate();
         // 处理金额
         const { getAmout } = handleAmout(formState);
+        // 账号列表: 交易用户 业务员 跟单员
+        const { traderList, businesserList, merchandiserList, getRoleList, getBusinesserList } = handleAccountManager();
         // 现货商品列表
         const goodsList = ref<Goods[]>([]);
-        function submit(OperateType: number) {
+
+        function submit(OperateType: 1 | 2) {
             formRef.value
                 .validate()
                 .then(() => {
                     const param = toRaw(formState);
                     const id = getUsrId();
                     isSell.value ? (param.SellUserID = id) : (param.BuyUserID = id);
-
+                    const fn = (value: Moment) => {
+                        return formatTime(value, 'd') + ' ' + '00:00:00';
+                    };
                     // 交收期
                     const dDate = deliveryDate.value;
                     if (dDate.length) {
-                        const DeliveryStartDate = formatTime(dDate[0], 'd') + '00:00:00';
-                        const DeliveryEndDate = formatTime(dDate[1], 'd') + '00:00:00';
+                        const DeliveryStartDate = fn(dDate[0]);
+                        const DeliveryEndDate = fn(dDate[1]);
                         Object.assign(param, { DeliveryStartDate, DeliveryEndDate });
                     }
 
@@ -485,13 +478,13 @@ export default defineComponent({
                     const pDate = priceDate.value;
                     if (pDate.length && param.PriceType !== 1) {
                         // 点价日期[2:点价3:暂定价]
-                        const StartDate = formatTime(dDate[0], 'd') + '00:00:00';
-                        const EndDate = formatTime(dDate[1], 'd') + '00:00:00';
+                        const StartDate = fn(pDate[0]);
+                        const EndDate = fn(pDate[1]);
                         Object.assign(param, { StartDate, EndDate });
                     }
                     console.log('values', formState);
 
-                    sendReq(param, OperateType, loading)
+                    sendReq(param, loading, OperateType)
                         .then((res) => {
                             context.emit('refresh');
                             cancel();
@@ -506,6 +499,8 @@ export default defineComponent({
             queryCustomList();
             getDeliveryGoods();
             goodsList.value = getGoodsList();
+            getRoleList();
+            getBusinesserList();
         });
         return {
             visible,
@@ -537,6 +532,9 @@ export default defineComponent({
             disabledDate,
             goodsList,
             getAmout,
+            traderList,
+            businesserList,
+            merchandiserList,
         };
     },
 });

+ 1 - 1
src/views/information/spot-contract/components/add/interface.ts

@@ -26,7 +26,7 @@ export interface FormState {
     // PointDesc: string // string 点价备注[2:点价3:暂定价]
     // DeliveryDesc: string  // string 交收方式
     MerUserID: number | undefined // uint64 跟单员ID
-    TradeUserID: number // uint64 交易员ID
+    TradeUserID: number | undefined// uint64 交易员ID
     // PricedQty: number // double 已定价量
     // PricedAmount: number // double 已定价金额
     SpotGoodsBrandID: number | undefined // uint64 现货品牌ID

+ 79 - 69
src/views/information/spot-contract/components/add/setup.ts

@@ -45,14 +45,83 @@ export function handleFromState() {
         PriceMove: null,// double 升贴水[2:点价3:暂定价]
         StartDate: '', //                       点价开始时间
         EndDate: '', //                           点价结束时间
-        TradeUserID: 0, //           交易员ID
+        TradeUserID: undefined, //           交易员ID
     })
     // 业务类型
     const businessType = [
         { key: 1, value: '套保' },
         { key: 2, value: '套利' },
     ];
-    return { formState, businessType }
+    // 验证合同类型
+    async function v_ContractType(rule: RuleObject, value: number) {
+        return validateCommon(value, '请选择合同类型')
+    }
+
+    // 验证业务类型
+    // async function v_BizType(rule: RuleObject, value: number) {
+    //     return validateCommon(value, '请选择业务类型')
+    // }
+
+    // 验证业务类型
+    async function v_BuyUser(rule: RuleObject, value: number) {
+        return validateCommon(value, '请选择采购方')
+    }
+
+    // 验证业务类型
+    async function v_SellUser(rule: RuleObject, value: number) {
+        return validateCommon(value, '请选择销售方')
+    }
+
+    // 验证现货品种
+    async function v_DeliveryGoods(rule: RuleObject, value: number) {
+        return validateCommon(value, '请选择现货品种')
+    }
+
+    // 验证品类
+    async function v_WrStandard(rule: RuleObject, value: number) {
+        const errorInfo = formState.DeliveryGoodsID ? '请选择品类' : '请先选择现货品种'
+        return validateCommon(value, errorInfo)
+    }
+
+    // 验证品牌
+    async function v_SpotGoodsBrand(rule: RuleObject, value: number) {
+        const errorInfo = formState.DeliveryGoodsID ? '请选择品牌' : '请先选择现货品种'
+        return validateCommon(value, errorInfo)
+    }
+
+    // 验证定价类型
+    async function v_PriceType(rule: RuleObject, value: number) {
+        return validateCommon(value, '请选择定价类型')
+    }
+
+    // 验证结算币种
+    async function v_Currency(rule: RuleObject, value: number) {
+        return validateCommon(value, '请选择结算币种')
+    }
+
+    // 验证点价合约
+    async function v_Goods(rule: RuleObject, value: number) {
+        return validateCommon(value, '请选择点价合约')
+    }
+    const rules = {
+        ContractNo: [{ required: true, message: '请输入合同编号', trigger: 'blur' }],
+        ContractType: [{ required: true, validator: v_ContractType, trigger: 'change' }],
+        // BizType: [{ required: true, validator: v_BizType, trigger: 'change' }],
+        BuyUserID: [{ required: true, validator: v_BuyUser, trigger: 'change' }],
+        SellUserID: [{ required: true, validator: v_SellUser, trigger: 'change' }],
+        DeliveryGoodsID: [{ required: true, validator: v_DeliveryGoods, trigger: 'change' }],
+        WrStandardID: [{ required: true, validator: v_WrStandard, trigger: 'blur' }],
+        SpotGoodsBrandID: [{ required: true, validator: v_SpotGoodsBrand, trigger: 'blur' }],
+        GoodsID: [{ required: true, validator: v_Goods, trigger: 'blur' }],
+        // ConvertFactor: [{ required: true, message: '请选择品类', trigger: 'blur' }],
+        SpotGoodsDesc: [{ required: true, message: '请输入商品规格', trigger: 'blur' }],
+        PriceType: [{ required: true, validator: v_PriceType, trigger: 'blur' }],
+        CurrencyID: [{ required: true, validator: v_Currency, trigger: 'blur' }],
+        Qty: [{ required: true, message: '请输入数量', trigger: 'blur' }],
+        Price: [{ required: true, message: '请输入价格', trigger: 'blur' }],
+        PriceMove: [{ required: true, message: '请输入升贴水', trigger: 'blur' }],
+    };
+    return { formState, businessType, rules }
 }
 
 /**
@@ -63,7 +132,7 @@ export function addContractReq() {
      * @param form 表单信息
      *  @Param type  1: 保存草稿  2: 提交申请
      */
-    function sendReq(form: FormState, type: number, loading: Ref<boolean>): Promise<string> {
+    function sendReq(form: FormState, loading: Ref<boolean>, OperateType: 1 | 2): Promise<string> {
         loading.value = true
         const info: GldSpotContractInfo = {
             UserID: APP.get('userAccount').memberuserid,//  机构ID
@@ -88,7 +157,7 @@ export function addContractReq() {
             BizType: form.BizType, //                       业务类型 - 1:套保 2:套利
             Remark: form.Remark,  //       合同备注
             // ContractAttachment: ,  // 合同附件
-            ContractMargin: form.ContractMargin as number, //         合同保证金
+            ContractMargin: form.ContractMargin ? Number(form.ContractMargin) : 0, //         合同保证金
 
             Amount: [1, 3].includes(form.PriceType) ? Number(form.Price) * Number(form.Qty) : 0, //    金额
             PriceMove: Number(form.PriceMove as number), //  升贴水
@@ -100,16 +169,18 @@ export function addContractReq() {
 
             GoodsID: form.GoodsID as number, //               点价合约ID-0:为现货,其它为期货商品合约ID[2:点价3:暂定价]
 
-            // MerUserID: form.MerUserID, //             跟单员ID
-            // TradeUserID: form.TradeUserID, //           交易员ID
-            // SaleUserID: form.SaleUserID,//             业务员id
+            MerUserID: form.MerUserID || 0, //             跟单员ID
+            TradeUserID: form.TradeUserID || 0, //           交易员ID
+            SaleUserID: form.SaleUserID || 0,//             业务员id
         }
         const params: GldErmcpSpotContractOperateReq = {
             SpotContractID: '0',
-            OperateType: type,
+            OperateType,
             Remark: '',
             Info: info,
         }
+        console.log('prams', params);
+
         return orderContractControl(params, loading)
             .then(res => {
                 return Promise.resolve(res);
@@ -155,67 +226,6 @@ export function handleContract() {
     return { contractType, isSell, contractChange, customList, queryCustomList }
 }
 
-/**
- * 自定义表单验证方法
- */
-export function handlevalidate(formState: UnwrapRef<FormState>) {
-    // 验证合同类型
-    async function v_ContractType(rule: RuleObject, value: number) {
-        return validateCommon(value, '请选择合同类型')
-    }
-
-    // 验证业务类型
-    async function v_BizType(rule: RuleObject, value: number) {
-        return validateCommon(value, '请选择业务类型')
-    }
-
-    // 验证业务类型
-    async function v_BuyUser(rule: RuleObject, value: number) {
-        return validateCommon(value, '请选择采购方')
-    }
-
-    // 验证业务类型
-    async function v_SellUser(rule: RuleObject, value: number) {
-        return validateCommon(value, '请选择销售方')
-    }
-
-    // 验证现货品种
-    async function v_DeliveryGoods(rule: RuleObject, value: number) {
-        return validateCommon(value, '请选择现货品种')
-    }
-
-    // 验证品类
-    async function v_WrStandard(rule: RuleObject, value: number) {
-        const errorInfo = formState.DeliveryGoodsID ? '请选择品类' : '请先选择现货品种'
-        return validateCommon(value, errorInfo)
-    }
-
-    // 验证品牌
-    async function v_SpotGoodsBrand(rule: RuleObject, value: number) {
-        const errorInfo = formState.DeliveryGoodsID ? '请选择品牌' : '请先选择现货品种'
-        return validateCommon(value, errorInfo)
-    }
-
-    // 验证定价类型
-    async function v_PriceType(rule: RuleObject, value: number) {
-        return validateCommon(value, '请选择定价类型')
-    }
-
-    // 验证结算币种
-    async function v_Currency(rule: RuleObject, value: number) {
-        return validateCommon(value, '请选择结算币种')
-    }
-
-    // 验证点价合约
-    async function v_Goods(rule: RuleObject, value: number) {
-        return validateCommon(value, '请选择点价合约')
-    }
-
-    return {
-        v_ContractType, v_BizType, v_BuyUser, v_SellUser, v_DeliveryGoods, v_WrStandard,
-        v_SpotGoodsBrand, v_PriceType, v_Currency, v_Goods
-    }
-}
 
 /**
  * 处理现货商品