Преглед на файлове

修改现货合同审核

huangbin преди 4 години
родител
ревизия
2f655b2d8a

+ 8 - 8
src/services/proto/hedgeplan/index.ts

@@ -1,10 +1,10 @@
 // 套保计划
-import {buildProtoReq50, parseProtoRsp50} from "@/services/socket/protobuf/buildReq";
 import APP from "@/services";
-import {Callback} from "@/utils/websocket";
-import {ErmcpHedgePlanReq, HedgePlanOperateReq} from "@/services/proto/hedgeplan/interface";
-import {getSelectedAccountId, getUserId} from "@/services/bus/account";
-import {v4 as uuidv4} from "uuid";
+import { getSelectedAccountId, getUserId } from "@/services/bus/account";
+import { ErmcpHedgePlanReq } from "@/services/proto/hedgeplan/interface";
+import { buildProtoReq50, parseProtoRsp50 } from "@/services/socket/protobuf/buildReq";
+import { Callback } from "@/utils/websocket";
+import { v4 as uuidv4 } from "uuid";
 
 /**
  * 套保计划操作请求
@@ -18,7 +18,7 @@ export const hedgePlanReq = (param: ErmcpHedgePlanReq): Promise<any> => {
         const params = {
             protobufName: 'ErmcpHedgePlanReq',
             funCodeName: 'ErmcpHedgePlanReq',
-            reqParams:  param,
+            reqParams: param,
             msgHeadParams: {
                 AccountID: getSelectedAccountId(),
                 MarketID: 18,
@@ -44,7 +44,7 @@ export const hedgePlanReq = (param: ErmcpHedgePlanReq): Promise<any> => {
  * 老的计划操作接口 我只负责删除 操作类型-1:保存草稿2:提交申请3:删除4审核通过5审核拒绝
  * @param param
  */
-export const oldHedgePlanReq = (param: HedgePlanOperateReq): Promise<any> => {
+export const oldHedgePlanReq = (param: any): Promise<any> => {
     param.OperateSrc = 2; // 操作来源-1:管理端2:终端
     param.ClientTicket = uuidv4(); // 流水号
     param.UserID = getUserId()
@@ -53,7 +53,7 @@ export const oldHedgePlanReq = (param: HedgePlanOperateReq): Promise<any> => {
         const params = {
             protobufName: 'HedgePlanOperateReq',
             funCodeName: 'HedgePlanOperateReq',
-            reqParams:  param,
+            reqParams: param,
             msgHeadParams: {
                 AccountID: getSelectedAccountId(),
                 MarketID: 18,

+ 24 - 24
src/services/proto/spotcontract/interface.ts

@@ -1,6 +1,6 @@
 // 现货合同操作请求 0 29 167
 export interface GldErmcpSpotContractOperateReq {
-    SpotContractID: number // uint64 现货合同ID(602+Unix秒时间戳(10位)+xxxxxx)
+    SpotContractID: string // uint64 现货合同ID(602+Unix秒时间戳(10位)+xxxxxx)
     OperateType: number // uint32 操作类型-1:保存草稿2:提交申请3:审核通过4:审核拒绝5:撤回6:正常完结7:异常终止
     Remark: string // string 操作备注
     Info?: GldSpotContractInfo // GldSpotContractInfo 现货合同信息
@@ -26,28 +26,28 @@ export interface GldErmcpSpotContractOperateRsp {
 
 // 现货合同信息 0 29 166
 export interface GldSpotContractInfo {
-    TradeDate: string // string 交易日(yyyyMMdd)
-    ContractNo: string // string 现货合同编号
-    ContractType: number// int32 现货合同类型-1:采购-1:销售
-    UserID: number // uint64 机构ID
-    BuyUserID: number // uint64 采购方ID
-    SellUserID: number // uint64 客户ID
-    SignDate: string // string 签订日期
+    TradeDate?: string // string 交易日(yyyyMMdd)
+    ContractNo?: string // string 现货合同编号
+    ContractType?: number// int32 现货合同类型-1:采购-1:销售
+    UserID?: number // uint64 机构ID
+    BuyUserID?: number // uint64 采购方ID
+    SellUserID?: number // uint64 客户ID
+    SignDate?: string // string 签订日期
     ContractAttachment?: Uint8Array // bytes 合同附件
     ContractMargin?: number // double 合同保证金
-    DeliveryGoodsID: number  // uint64 现货品种ID
-    WrStandardID: number  // uint64 现货商品ID
-    ProductType: number  // uint32 产品类型-1:标准仓单2:等标3:非标
-    ConvertFactor: number  // double 标仓系数
-    SpotGoodsDesc: string // string 商品型号
-    PriceType: number // uint32 定价类型-1:一口价2:点价3:暂定价
-    Qty: number // double 数量
-    Price: number// double 价格暂定价[1:一口价、3:暂定价]
-    Amount: number // double 金额[1:一口价、3:暂定价]
-    DeliveryStartDate: string// string 交收期(开始)
-    DeliveryEndDate: string // string 交收期(结束)
-    GoodsID: number // uint64 点价合约ID-0:为现货,其它为期货商品合约ID[2:点价3:暂定价]
-    PriceMove: number// double 升贴水[2:点价3:暂定价]
+    DeliveryGoodsID?: number  // uint64 现货品种ID
+    WrStandardID?: number  // uint64 现货商品ID
+    ProductType?: number  // uint32 产品类型-1:标准仓单2:等标3:非标
+    ConvertFactor?: number  // double 标仓系数
+    SpotGoodsDesc?: string // string 商品型号
+    PriceType?: number // uint32 定价类型-1:一口价2:点价3:暂定价
+    Qty?: number // double 数量
+    Price?: number// double 价格暂定价[1:一口价、3:暂定价]
+    Amount?: number // double 金额[1:一口价、3:暂定价]
+    DeliveryStartDate?: string// string 交收期(开始)
+    DeliveryEndDate?: string // string 交收期(结束)
+    GoodsID?: number // uint64 点价合约ID-0:为现货,其它为期货商品合约ID[2:点价3:暂定价]
+    PriceMove?: number// double 升贴水[2:点价3:暂定价]
     StartDate?: string // string 点价开始日期[2:点价3:暂定价]
     EndDate?: string // string 点价结束日期[2:点价3:暂定价]
     PointDesc?: string // string 点价备注[2:点价3:暂定价]
@@ -56,17 +56,17 @@ export interface GldSpotContractInfo {
     TradeUserID?: number // uint64 交易员ID
     PricedQty?: number // double 已定价量
     PricedAmount?: number // double 已定价金额
-    SpotGoodsBrandID: number // uint64 现货品牌ID
+    SpotGoodsBrandID?: number // uint64 现货品牌ID
     Remark?: string // string 合同备注
     SaleUserID?: number // uint64 业务员ID
     AccountID?: number // uint64 期货账户ID
     BizType?: number // uint32 业务类型 - 1:套保 2:套利
-    CurrencyID: number // 结算币种ID
+    CurrencyID?: number // 结算币种ID
 }
 
 //现货合同操作请求  (一部分操作用这个借口)
 export interface SpotContractOperateReq {
-    SpotContractID: number; // 现货合同id
+    SpotContractID: string; // 现货合同id
     OperateType: number; // uint32 操作类型-1:保存草稿2:提交申请3:审核通过4:审核拒绝5:撤回6:正常完结7:异常终止
     Remark: string; // string 操作备注
     Info?: SpotContractInfo; // SpotContractInfo 现货合同信息

+ 1 - 0
src/services/socket/protobuf/buildReq.ts

@@ -70,6 +70,7 @@ function buildSoleProtoReq(protobufName: string, reqParams: type.ReqParams) {
     ReqKeys.forEach((e) => {
         ReqKeysMap.set(e.toLowerCase(), e);
     });
+    // 此处需要待优化,proto嵌套的时候存在问题
     const paramKeys = Object.keys(reqParams);
     for (let i = 0; i < paramKeys.length; i++) {
         const item = paramKeys[i];

+ 13 - 1
src/services/socket/protobuf/index.ts

@@ -2,7 +2,7 @@
 import Protobuf from 'protobufjs';
 class ProtobufCtr {
     protoBufer: any;
-    constructor() {}
+    constructor() { }
     /**
      * 加载proto文件
      * @param {*} proto 导入的proto
@@ -28,6 +28,18 @@ class ProtobufCtr {
         if (this.protoBufer) {
             const RootProto = this.protoBufer.build(protoName);
             const instenceProto = new RootProto();
+            const set = new WeakSet()
+            // 处理 proto 嵌套问题
+            RootProto.$type.children.forEach((el: any) => {
+                const { resolvedType, name } = el;
+                if (resolvedType && typeof resolvedType === 'object') {
+                    if (!set.has(resolvedType)) {
+                        // 防止 proto 错误,导致一直在递归 
+                        set.add(resolvedType)
+                        instenceProto[name] = this.generateProtoInstence(resolvedType.name)
+                    }
+                }
+            });
             return instenceProto;
         }
         console.error('没有找到protoBufer相关数据');

+ 7 - 8
src/views/business/plan/components/setup.ts

@@ -1,10 +1,10 @@
-import {ref} from "vue";
-import {hedgePlanReq} from "@/services/proto/hedgeplan";
-import {ErmcpHedgePlanReq} from "@/services/proto/hedgeplan/interface";
-import {message} from "ant-design-vue";
-import {getRequestResultInfo} from "@/common/methods/request";
-import {hedgePlanSign} from "@/views/business/plan/setup";
+import { getRequestResultInfo } from "@/common/methods/request";
+import { hedgePlanReq } from "@/services/proto/hedgeplan";
+import { ErmcpHedgePlanReq } from "@/services/proto/hedgeplan/interface";
+import { hedgePlanSign } from "@/views/business/plan/setup";
+import { message } from "ant-design-vue";
 import Long from "long";
+import { ref } from "vue";
 
 /**
  * 套保计划状态管理
@@ -25,7 +25,6 @@ export function PlanStatus() {
             OperateType: type
         }
         const sign = getRequestResultInfo(hedgePlanSign, type)  // 接口请求后的返回提示 这里统一进行管理
-        debugger
         return hedgePlanReq(params)
             .then(res => {
                 message.success(sign[0])
@@ -37,6 +36,6 @@ export function PlanStatus() {
             })
     }
 
-    return {loading, changeStatus}
+    return { loading, changeStatus }
 }
 

+ 4 - 6
src/views/information/spot-contract/components/add/setup.ts

@@ -7,16 +7,14 @@ import { QueryDeliveryGoods, QueryDeliveryGoodsDetail } from '@/services/go/ermc
 import { Ermcp3Brand, Ermcp3Wrstandard, ErmcpDeliveryGoodsRsp } from '@/services/go/ermcp/goodsInfo/interface';
 import {
     GldErmcpSpotContractOperateReq,
-    GldSpotContractInfo,
-    SpotContractOperateReq
+    GldSpotContractInfo
 } from "@/services/proto/spotcontract/interface";
 import { orderContractControl } from "@/views/information/spot-contract/components/setup";
 import { message } from 'ant-design-vue';
 import { RuleObject } from 'ant-design-vue/lib/form/interface';
 import moment, { Moment } from 'moment';
-import {reactive, Ref, ref, UnwrapRef} from 'vue';
+import { reactive, Ref, ref, UnwrapRef } from 'vue';
 import { FormState } from "./interface";
-import Long from "long";
 
 export function handleFromState() {
     const formState: UnwrapRef<FormState> = reactive({
@@ -106,8 +104,8 @@ export function addContractReq() {
             // TradeUserID: form.TradeUserID, //           交易员ID
             // SaleUserID: form.SaleUserID,//             业务员id
         }
-        const params : GldErmcpSpotContractOperateReq = {
-            SpotContractID: 0,
+        const params: GldErmcpSpotContractOperateReq = {
+            SpotContractID: '0',
             OperateType: 1,
             Remark: '',
             Info: info,

+ 27 - 27
src/views/information/spot-contract/components/check/index.vue

@@ -224,16 +224,17 @@
 </template>
 
 <script lang="ts">
-import { defineComponent, PropType, reactive, ref } from 'vue';
+import { defineComponent, PropType, ref, toRaw } from 'vue';
 import { closeModal } from '@/common/setup/modal/index';
 import { getBizTypeName, getContractStatusName, getContractTypeName, getPriceTypeName } from '@/views/information/spot-contract/setup';
 import { Ermcp3ContractRsp } from '@/services/go/ermcp/spot-contract/interface';
 import { formatTime, formatValue, initData } from '@/common/methods';
-import { orderContractControl, orderContractOperateControl} from '@/views/information/spot-contract/components/setup';
+import { orderContractControl, orderContractOperateControl } from '@/views/information/spot-contract/components/setup';
 import { Modal } from 'ant-design-vue';
-import { handleAccountManager, handleForm } from './setup';
-import {GldErmcpSpotContractOperateReq, SpotContractOperateReq} from "@/services/proto/spotcontract/interface";
-import Long from "long";
+import { handleForm } from './setup';
+import { handleAccountManager } from '../setup';
+import { GldErmcpSpotContractOperateReq, SpotContractOperateReq } from '@/services/proto/spotcontract/interface';
+import Long from 'long';
 
 export default defineComponent({
     name: 'spot-contract-detail',
@@ -252,26 +253,26 @@ export default defineComponent({
         const loading = ref<boolean>(false);
         // 表单
         const { rules, formState, formRef } = handleForm();
-
-        const maskClosableFlag = ref<boolean>(false);
         function submit() {
             Modal.confirm({
                 title: '是否确认审核通过',
                 okText: '确认审核通过',
                 cancelText: '取消',
                 onOk() {
-                    const reqs: GldErmcpSpotContractOperateReq = {
-                        SpotContractID: Long.fromString(props.selectedRow.spotcontractid),
-                        OperateType: 4,
-                        Remark: '',
-                    }
-                    // 审核通过
-                    orderContractControl(reqs, loading)
-                        .then((res) => {
+                    formRef.value.validate().then(() => {
+                        const param = toRaw(formState);
+                        const reqs: GldErmcpSpotContractOperateReq = {
+                            SpotContractID: props.selectedRow.spotcontractid,
+                            OperateType: 4,
+                            Remark: param.Remark,
+                            Info: param,
+                        };
+                        // 审核通过
+                        orderContractControl(reqs, loading).then(() => {
                             cancel();
                             context.emit('refresh');
-                        })
-                        .catch((err) => {});
+                        });
+                    });
                 },
                 onCancel() {
                     console.log('Cancel');
@@ -284,18 +285,17 @@ export default defineComponent({
                 okText: '确认审核拒绝',
                 cancelText: '取消',
                 onOk() {
+                    const param = toRaw(formState);
                     const reqs: SpotContractOperateReq = {
-                        SpotContractID: Long.fromString(props.selectedRow.spotcontractid),
+                        SpotContractID: props.selectedRow.spotcontractid,
                         OperateType: 4,
-                        Remark: '',
-                    }
+                        Remark: param.Remark,
+                    };
                     // 审核拒绝
-                    orderContractOperateControl(reqs, loading)
-                        .then((res) => {
-                            cancel();
-                            context.emit('refresh');
-                        })
-                        .catch((err) => {});
+                    orderContractOperateControl(reqs, loading).then(() => {
+                        cancel();
+                        context.emit('refresh');
+                    });
                 },
                 onCancel() {
                     console.log('Cancel');
@@ -310,7 +310,7 @@ export default defineComponent({
             visible,
             cancel,
             submit,
-            maskClosableFlag,
+            maskClosableFlag: false,
             getContractTypeName,
             getBizTypeName,
             formatValue,

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

@@ -7,4 +7,5 @@ export interface FormState {
     MerUserID: number | undefined// uint64 跟单员ID
     TradeUserID: number | undefined// uint64 交易员ID
     SaleUserID: number | undefined // uint64 业务员ID
+    Remark: string
 }

+ 4 - 69
src/views/information/spot-contract/components/check/setup.ts

@@ -1,72 +1,7 @@
-import { validateCommon } from '@/common/setup/validate'
-import { QueryAccMgrLoginUser } from '@/services/go/ermcp/account'
-import { ErmcpLoginUser } from '@/services/go/ermcp/account/interface'
-import { message } from 'ant-design-vue'
-import { RuleObject } from 'ant-design-vue/lib/form/interface'
-import { reactive, ref, UnwrapRef } from 'vue'
-import { FormState, Value } from './interface'
-
-export function handleAccountManager() {
-    // 交易用户
-    const traderList = ref<Value[]>([])
-    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({ id: roleid, name: rolename })
-                    }
-                }
-            })
-        }).catch(err => message.error(err))
-    }
-    // 处理 跟单员 /  业务员 列表
-    function handleList(el: ErmcpLoginUser, type: string, set: Set<number>): Value | null {
-        const { loginstatus, userid, accountname, logincode, roletype } = el;
-        let result = null
-        if (loginstatus === 1) {// 登录账户状态 - 1:正常 
-            if (roletype.includes(type)) {  // 过滤角色类型
-                if (!set.has(userid)) { // 去重
-                    set.add(userid)
-                    result = { id: userid, name: `${accountname}-${logincode}` }
-                }
-            }
-        }
-        return result
-    }
-    // 业务员
-    const businesserList = ref<Value[]>([])
-    // 跟单员
-    const merchandiserList = ref<Value[]>([])
-    function getBusinesserList() {
-        QueryAccMgrLoginUser(1).then(res => {
-            const bSet = new Set<number>([]);
-            const mSet = new Set<number>([]);
-            const list: ErmcpLoginUser[] = []
-            res.forEach(e => {
-                // eslint-disable-next-line prefer-spread
-                list.push.apply(list, e.userlist)
-            })
-            list.forEach(el => {
-                // 业务员
-                const b = handleList(el, '22', bSet)
-                if (b) {
-                    businesserList.value.push(b)
-                }
-                // 跟单员
-                const m = handleList(el, '23', mSet)
-                if (m) {
-                    merchandiserList.value.push(m)
-                }
-            })
-        }).catch(err => message.error(err))
-    }
-    return { traderList, businesserList, merchandiserList, getRoleList, getBusinesserList }
-}
+import { validateCommon } from '@/common/setup/validate';
+import { RuleObject } from 'ant-design-vue/lib/form/interface';
+import { reactive, ref, UnwrapRef } from 'vue';
+import { FormState } from './interface';
 
 // 表单
 export function handleForm() {

+ 74 - 1
src/views/information/spot-contract/components/setup.ts

@@ -1,12 +1,16 @@
 import { commonResultInfo, getRequestResultInfo } from "@/common/methods/request";
+import { QueryAccMgrLoginUser } from "@/services/go/ermcp/account";
+import { ErmcpLoginUser } from "@/services/go/ermcp/account/interface";
 import { orderContract, spotContractStatus } from "@/services/proto/spotcontract";
 import {
     GldErmcpSpotContractOperateReq,
     SpotContractOperateReq
 } from "@/services/proto/spotcontract/interface";
 import { ContractStateSign, GldContractStateSign } from "@/views/information/spot-contract/setup";
+import { message } from "ant-design-vue";
 import Long from 'long';
-import { Ref } from "vue";
+import { ref, Ref } from "vue";
+import { Value } from "./check/interface";
 
 /**
  * 合同操作相关 针对操作类型 1: 保存草稿  2: 提交申请 3: 删除成功 4:审核通过
@@ -36,6 +40,10 @@ export function orderContractControl(reqs: GldErmcpSpotContractOperateReq, loadi
  * @returns 
  */
 export function orderContractOperateControl(reqs: SpotContractOperateReq, loading: Ref<boolean>): Promise<string> {
+    //处理 合同id
+    if (reqs.SpotContractID) {
+        reqs.SpotContractID = Long.fromString(reqs.SpotContractID)
+    }
     // loading 效果
     loading.value = true
     // 获取提示信息
@@ -46,3 +54,68 @@ export function orderContractOperateControl(reqs: SpotContractOperateReq, loadin
     return commonResultInfo(result, sign, loading)
 }
 
+/**
+ * 处理 /账号列表: 交易用户 业务员 跟单员
+ * @returns 
+ */
+export function handleAccountManager() {
+    // 交易用户
+    const traderList = ref<Value[]>([])
+    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({ id: roleid, name: rolename })
+                    }
+                }
+            })
+        }).catch(err => message.error(err))
+    }
+    // 处理 跟单员 /  业务员 列表
+    function handleList(el: ErmcpLoginUser, type: string, set: Set<number>): Value | null {
+        const { loginstatus, userid, accountname, logincode, roletype } = el;
+        let result = null
+        if (loginstatus === 1) {// 登录账户状态 - 1:正常 
+            if (roletype.includes(type)) {  // 过滤角色类型
+                if (!set.has(userid)) { // 去重
+                    set.add(userid)
+                    result = { id: userid, name: `${accountname}-${logincode}` }
+                }
+            }
+        }
+        return result
+    }
+    // 业务员
+    const businesserList = ref<Value[]>([])
+    // 跟单员
+    const merchandiserList = ref<Value[]>([])
+    function getBusinesserList() {
+        QueryAccMgrLoginUser(1).then(res => {
+            const bSet = new Set<number>([]);
+            const mSet = new Set<number>([]);
+            const list: ErmcpLoginUser[] = []
+            res.forEach(e => {
+                // eslint-disable-next-line prefer-spread
+                list.push.apply(list, e.userlist)
+            })
+            list.forEach(el => {
+                // 业务员
+                const b = handleList(el, '22', bSet)
+                if (b) {
+                    businesserList.value.push(b)
+                }
+                // 跟单员
+                const m = handleList(el, '23', mSet)
+                if (m) {
+                    merchandiserList.value.push(m)
+                }
+            })
+        }).catch(err => message.error(err))
+    }
+    return { traderList, businesserList, merchandiserList, getRoleList, getBusinesserList }
+}