huangbin 4 年 前
コミット
7504401960

+ 104 - 17
src/views/business/plan/components/add/index.vue

@@ -8,21 +8,24 @@
     <template #footer>
       <a-button key="submit"
                 class="cancelBtn"
-                @click="cancel">保存草稿
+                @click="submit(1)">保存草稿
       </a-button>
       <a-button key="submit"
                 type="primary"
                 :loading="loading"
-                @click="submit">提交审核</a-button>
+                @click="submit(2)">提交审核</a-button>
     </template>
     <a-form class="inlineForm"
-            ref="formRef">
+            ref="formRef"
+            :model="formState"
+            :rules="rules">
       <a-row :gutter="24">
         <a-col :span="12">
           <a-form-item label="计划类型"
-                       name="">
+                       name="ContractType">
             <a-select class="inlineFormSelect"
                       style="width: 200px"
+                      v-model:value="formState.ContractType"
                       placeholder="请选择计划类型">
               <a-select-option v-for="item in planTye"
                                :value="item.enumitemname"
@@ -34,17 +37,20 @@
         </a-col>
         <a-col :span="12">
           <a-form-item label="计划名称"
-                       name="">
+                       name="HedgePlanNo">
             <a-input class="dialogInput"
+                     v-model:value="formState.HedgePlanNo"
                      style="width: 200px"
                      placeholder="请输入计划名称" />
           </a-form-item>
         </a-col>
         <a-col :span="12">
           <a-form-item label="现货品种"
-                       name="">
+                       name="DeliveryGoodsID">
             <a-select class="inlineFormSelect"
                       style="width: 200px"
+                      v-model:value="formState.DeliveryGoodsID"
+                      @change="chooseMG"
                       placeholder="请选择现货品种">
               <a-select-option v-for="item in DGList"
                                :value="item.data.deliverygoodsid"
@@ -55,25 +61,76 @@
           </a-form-item>
         </a-col>
         <a-col :span="12">
+          <a-form-item label="品类"
+                       name="WRStandardID">
+            <a-select class="inlineFormSelect"
+                      style="width: 200px"
+                      v-model:value="formState.WRStandardID"
+                      placeholder="请选择品类">
+              <a-select-option v-for="item in gmlist"
+                               :value="item.wrstandardid"
+                               :key="item.wrstandardid">
+                {{item.wrstandardname}}
+              </a-select-option>
+            </a-select>
+          </a-form-item>
+        </a-col>
+        <a-col :span="12">
           <a-form-item label="标仓系数"
                        name="">
-            <span class="white">1</span>
+            <a-input class="ConvertFactor"
+                     v-model:value="formState.ConvertFactor"
+                     readonly
+                     style="width: 200px"
+                     placeholder="请输入标仓系数" />
           </a-form-item>
         </a-col>
-        <a-col :span="24">
+        <a-col :span="12">
           <a-form-item label="计划量"
                        class="relative"
-                       name="">
+                       name="PlanQty">
             <a-input class="dialogInput"
                      style="width: 200px"
+                     v-model:value="formState.PlanQty"
                      placeholder="请输入计划量" />
           </a-form-item>
         </a-col>
+        <a-col :span="12">
+          <a-form-item label="交易用户"
+                       name="Tradeuserid">
+            <a-select class="inlineFormSelect"
+                      style="width: 200px"
+                      v-model:value="formState.Tradeuserid"
+                      placeholder="请选择交易用户">
+              <a-select-option v-for="item in traderList"
+                               :value="item.roleid"
+                               :key="item.roleid">
+                {{item.rolename}}
+              </a-select-option>
+            </a-select>
+          </a-form-item>
+        </a-col>
+        <a-col :span="12">
+          <a-form-item label="结算币种"
+                       name="Currencyid">
+            <a-select class="inlineFormSelect"
+                      style="width: 200px"
+                      v-model:value="formState.Currencyid"
+                      placeholder="请选择结算币种">
+              <a-select-option v-for="item in priceTyep"
+                               :key="item.enumdicid"
+                               :value="item.enumdicid">
+                {{item.enumdicname}}
+              </a-select-option>
+            </a-select>
+          </a-form-item>
+        </a-col>
         <a-col :span="24">
           <a-form-item label="备注"
                        class="relative"
-                       name="">
+                       name="Remark">
             <a-input class="dialogInput"
+                     v-model:value="formState.Remark"
                      style="width: 636px"
                      placeholder="请输入备注" />
           </a-form-item>
@@ -84,29 +141,52 @@
 </template>
 
 <script lang="ts">
-import { defineComponent, ref } from 'vue';
+import { defineComponent, ref, toRaw } from 'vue';
 import { closeModal } from '@/common/setup/modal/index';
 import { initData } from '@/common/methods/index';
-import { getSpotContractTypeEnumList } from '@/common/constants/enumsList';
+import { getPayCurrencyTypeEnumList, getSpotContractTypeEnumList } from '@/common/constants/enumsList';
 import { AllEnums } from '@/services/go/commonService/interface';
 import { getAllEnum } from '@/services/bus/allEnum';
-import { getMiddleGoodsD } from '../setup';
+import { getMiddleGoodsD, handleForm, handleTrader } from '../setup';
+import { ValidateErrorEntity } from 'ant-design-vue/lib/form/interface';
+import { FormState } from '@/views/information/spot-contract/components/interface';
+import { context } from 'ant-design-vue/lib/vc-image/src/PreviewGroup';
 
 export default defineComponent({
     name: 'add-custom',
     components: {},
-    setup() {
+    setup(props, context) {
         const { visible, cancel } = closeModal('plan_btn_add');
         const planTye = ref<AllEnums[]>(getSpotContractTypeEnumList());
         // const arr = getAllEnum().filter((e) => e.enumdicname === '销售');
         // console.log('arr', arr);
-        const { DGList, getDG } = getMiddleGoodsD();
+        // 品种、品类
+        const { DGList, getDG, gmlist, chooseMG } = getMiddleGoodsD();
+        // 交易用户
+        const { traderList, getRoleList } = handleTrader();
+        // 币种
+        const priceTyep = getPayCurrencyTypeEnumList();
+        // 表单
+        const { formRef, formState, rules } = handleForm();
         const loading = ref<boolean>(false);
-        function submit() {
-            cancel();
+        function submit(OperateType: 1 | 2) {
+            formRef.value
+                .validate()
+                .then(() => {
+                    const param = toRaw(formState);
+                    // addAction(param).then(() => {
+                    //     cancel();
+                    //     context.emit('refresh', true);
+                    // });
+                    console.log('param', param);
+                })
+                .catch((error: ValidateErrorEntity<FormState>) => {
+                    console.log('error', error);
+                });
         }
         initData(() => {
             getDG();
+            getRoleList();
         });
         return {
             visible,
@@ -115,6 +195,13 @@ export default defineComponent({
             loading,
             planTye,
             DGList,
+            gmlist,
+            chooseMG,
+            traderList,
+            priceTyep,
+            formRef,
+            formState,
+            rules,
         };
     },
 });

+ 25 - 0
src/views/business/plan/components/interface.ts

@@ -0,0 +1,25 @@
+export interface FormState {
+    // HedgePlanID: number // uint64 套保计划ID(601+Unix秒时间戳(10位)+xxxxxx)
+    HedgePlanNo: string // string 套保计划名称
+    ContractType: number | undefined// int32 计划类型-1:采购-1:销售
+    // AreaUserID?: number// uint64 机构ID
+    DeliveryGoodsID: number | undefined// uint64 现货品种ID
+    // ProductType?: number // int32 产品类型-1:标准仓单2:等标3:非标
+    // SpotGoodsDesc?: string // string 商品型号
+    PlanQty: string, // double 计划数量
+    ConvertFactor: number // double 标仓系数
+    // PlanTime?: string // string 计划时间
+    // TradeDate?: string // string 交易日(yyyyMMdd)
+    // ApplySrc?: number // int32 申请来源 - 1:管理端 2:终端
+    // ApplyId?: number // uint64 申请人
+    Remark: string // string 计划备注
+    OperateType: number // int32 操作类型-1:保存草稿2:提交申请
+    WRStandardID: number | undefined; // uint64 现货品类ID
+    // AccountID: number; // uint64 期货账户ID(默认为0,也可不传)
+    Tradeuserid: number | undefined; // uint64 交易用户ID
+    Currencyid: number | undefined; // uint64 结算币种ID
+    // Biztype: number; // uint64 业务类型 - 1:套保 2:套利 默认为 1
+    // auditid: number; // uint64 审核人
+    // auditsrc: number; // uint32 审核来源 - 1:管理端 2:终端
+    // auditremark: string; // string 审核备注
+}

+ 65 - 3
src/views/business/plan/components/setup.ts

@@ -1,11 +1,16 @@
 import { commonResultInfo, getRequestResultInfo } from "@/common/methods/request";
+import { validateCommon } from "@/common/setup/validate";
+import { QueryAccMgrLoginUser } from "@/services/go/ermcp/account";
+import { ErmcpLoginUserEx } from "@/services/go/ermcp/account/interface";
 import { QueryDeliveryGoodsDetail } from '@/services/go/ermcp/goodsInfo';
-import { ErmcpDeliveryGoodsDetailEx } from "@/services/go/ermcp/goodsInfo/interface";
+import { Ermcp3Wrstandard, ErmcpDeliveryGoodsDetailEx } from "@/services/go/ermcp/goodsInfo/interface";
 import { hedgePlanReq, oldHedgePlanReq } from "@/services/proto/hedgeplan";
 import { ErmcpHedgePlanReq, HedgePlanOperateReq } from "@/services/proto/hedgeplan/interface";
 import { deletePlanSign, hedgePlanSign } from "@/views/business/plan/setup";
 import { message } from "ant-design-vue";
-import { ref, Ref } from "vue";
+import { RuleObject } from "ant-design-vue/lib/form/interface";
+import { reactive, ref, Ref, UnwrapRef } from "vue";
+import { FormState } from "./interface";
 
 
 /**
@@ -36,7 +41,36 @@ export function cancelPlan(req: HedgePlanOperateReq, loading: Ref<boolean>): Pro
  * 表单
  */
 export function handleForm() {
+    const formRef = ref();
+    const formState: UnwrapRef<FormState> = reactive({
+        HedgePlanNo: '',// string 套保计划名称
+        ContractType: undefined,// int32 计划类型-1:采购-1:销售
+        DeliveryGoodsID: undefined,// uint64 现货品种ID
+        PlanQty: '', // double 计划数量
+        ConvertFactor: 1, // double 标仓系数
+        Remark: '', // string 计划备注
+        OperateType: 2, // int32 操作类型-1:保存草稿2:提交申请
+        WRStandardID: undefined, // uint64 现货品类ID
+        Tradeuserid: undefined, // uint64 交易用户ID
+        Currencyid: undefined, // uint64 结算币种ID
+    })
 
+    const v_ContractType = async (rule: RuleObject, value: number) => {
+        return validateCommon(value, '请选择计划类型');
+    };
+    const v_DeliveryGoodsID = async (rule: RuleObject, value: number) => {
+        return validateCommon(value, '请选择现货品种');
+    };
+    const v_Currencyid = async (rule: RuleObject, value: number) => {
+        return validateCommon(value, '请选择结算币种');
+    };
+    const rules = {
+        PlanQty: [{ required: true, message: '请输入计划数量', trigger: 'blur' }],
+        ContractType: [{ required: true, validator: v_ContractType, trigger: 'change' }],
+        DeliveryGoodsID: [{ required: true, validator: v_DeliveryGoodsID, trigger: 'change' }],
+        Currencyid: [{ required: true, validator: v_Currencyid, trigger: 'change' }],
+    }
+    return { formRef, formState, rules }
 }
 
 /**
@@ -45,6 +79,8 @@ export function handleForm() {
 export function getMiddleGoodsD() {
     // 现货品种列表
     const DGList = ref<ErmcpDeliveryGoodsDetailEx[]>([])
+    // 品类
+    const gmlist = ref<Ermcp3Wrstandard[]>([])
     // 获取品种数据
     function getDG() {
         QueryDeliveryGoodsDetail().then(res => {
@@ -53,7 +89,33 @@ export function getMiddleGoodsD() {
     }
     // 选中品种数据
     function chooseMG(id: number) {
+        const temp = DGList.value.find(e => e.data.deliverygoodsid === id)
+        gmlist.value = temp ? temp.gmlist : []
+    }
+    return { DGList, getDG, gmlist, chooseMG }
+}
 
+/**
+ * 交易用户
+ * @returns 
+ */
+export function handleTrader() {
+    // 交易用户
+    const traderList = ref<ErmcpLoginUserEx[]>([])
+    function getRoleList() {
+        QueryAccMgrLoginUser(2).then(res => {
+            const set = new Set<number>([])
+            traderList.value.length = 0;
+            res.forEach(e => {
+                const { roleid, rolename, accountstatus } = e;
+                if (accountstatus === 4) {  // 账户的状态 - 4 正常
+                    if (!set.has(roleid)) { // 去重
+                        set.add(roleid)
+                        traderList.value.push(e)
+                    }
+                }
+            })
+        }).catch(err => message.error(err))
     }
-    return { DGList, getDG }
+    return { traderList, getRoleList }
 }