huangbin 4 anos atrás
pai
commit
d443744ae6

+ 5 - 2
src/common/methods/request/index.ts

@@ -1,2 +1,5 @@
-import { getRequestResultInfo } from './resultInfo'
-export { getRequestResultInfo }
+import { ResultInfo } from './interface'
+import { commonResultInfo, getRequestResultInfo } from './resultInfo'
+export { getRequestResultInfo, commonResultInfo }
+export type { ResultInfo }
+

+ 22 - 0
src/common/methods/request/resultInfo.ts

@@ -1,3 +1,5 @@
+import { message } from 'ant-design-vue'
+import { Ref } from 'vue'
 import { ResultInfo } from './interface'
 /**
  * 获取请求接口时候成功或者失败信息
@@ -12,4 +14,24 @@ export function getRequestResultInfo(map: Map<number, ResultInfo>, type: number)
     } else {
         return ['成功', '失败']
     }
+}
+
+/**
+ * 请求接口通用信息处理(此方法用于不关心请求结果,只关心成功或者失败状态)
+ * @param fn 处理服务接口的函数
+ * @param sign 自定义成功和失败的信息
+ * @param loading loading状态
+ */
+export function commonResultInfo(fn: Promise<any>, sign: ResultInfo, loading: Ref<boolean>): Promise<string> {
+    return fn.then(() => {
+        message.success(sign[0])
+        return Promise.resolve(sign[0])
+    })
+        .catch((err: string) => {
+            console.warn(`${fn}调用失败: err`);
+            message.error(sign[1] + err)
+            return Promise.reject(sign[1] + err)
+        }).finally(() => {
+            loading.value = false
+        })
 }

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

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

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

@@ -7,16 +7,19 @@
            :maskClosable="maskClosableFlag"
            @cancel="cancel"
            width="890px">
-     <template #footer>
-       <a-button key="submit"
+    <template #footer>
+      <a-button key="submit"
                 class="cancelBtn"
                 @click="refuse">审核拒绝</a-button>
-        <a-button key="submit"
+      <a-button key="submit"
                 type="primary"
                 :loading="loading"
                 @click="submit">审核通过</a-button>
     </template>
-    <a-form class="inlineForm">
+    <a-form class="inlineForm"
+            ref="formRef"
+            :model="formState"
+            :rules="rules">
       <fieldset class="formFieldSet">
         <legend>基本信息</legend>
         <a-row :gutter="24">
@@ -39,28 +42,28 @@
           </a-col>
           <a-col :span="12">
             <a-form-item label="采购方">
-                <span class="white">{{ formatValue(selectedRow.buyusername) }}</span>
+              <span class="white">{{ formatValue(selectedRow.buyusername) }}</span>
             </a-form-item>
           </a-col>
-      </a-row>
-      <a-row :gutter="24">
+        </a-row>
+        <a-row :gutter="24">
           <a-col :span="12">
             <a-form-item label="销售方">
-             <span class="white">{{ formatValue(selectedRow.sellusername) }}</span>
+              <span class="white">{{ formatValue(selectedRow.sellusername) }}</span>
             </a-form-item>
           </a-col>
           <a-col :span="12">
             <a-form-item label="合同附件">
-                <div class="upload">
-                    <div class="look">{{ formatValue(selectedRow.contracctstatus) }}</div>
-                </div>
+              <div class="upload">
+                <div class="look">{{ formatValue(selectedRow.contracctstatus) }}</div>
+              </div>
             </a-form-item>
           </a-col>
         </a-row>
         <a-row :gutter="24">
           <a-col :span="24">
             <a-form-item label="状态">
-             <span class="green">{{ formatValue(getContractStatusName(selectedRow.contracctstatus)) }}</span>
+              <span class="green">{{ formatValue(getContractStatusName(selectedRow.contracctstatus)) }}</span>
             </a-form-item>
           </a-col>
         </a-row>
@@ -87,11 +90,11 @@
           </a-col>
           <a-col :span="12">
             <a-form-item label="标仓系数">
-                <span class="white">{{ formatValue(selectedRow.convertfactor) }}</span>
+              <span class="white">{{ formatValue(selectedRow.convertfactor) }}</span>
             </a-form-item>
           </a-col>
-      </a-row>
-      <a-row :gutter="24">
+        </a-row>
+        <a-row :gutter="24">
           <a-col :span="24">
             <a-form-item label="商品规格">
               <span class="white">{{ formatValue(selectedRow.spotgoodsdesc) }}</span>
@@ -147,15 +150,16 @@
             </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>
@@ -163,35 +167,37 @@
         </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-select class="inlineFormSelect"
+            <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>
           </a-col>
-      </a-row>
-      <a-row :gutter="24">
+        </a-row>
+        <a-row :gutter="24">
           <a-col :span="24">
             <a-form-item label="备注">
               <span class="white">{{ formatValue(selectedRow.remark) }}</span>
@@ -203,10 +209,12 @@
         <legend>审核信息</legend>
         <a-row :gutter="24">
           <a-col :span="24">
-            <a-form-item label="审核意见">
+            <a-form-item label="审核意见"
+                         name="Remark">
               <a-input class="dialogInput"
-                      style="width: 620px"
-                      placeholder="请输入审核意见" />
+                       v-model:value="formState.Remark"
+                       style="width: 620px"
+                       placeholder="请输入审核意见" />
             </a-form-item>
           </a-col>
         </a-row>
@@ -216,18 +224,14 @@
 </template>
 
 <script lang="ts">
-import {defineComponent, PropType, ref} from 'vue';
+import { defineComponent, PropType, reactive, ref } 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} from "@/common/methods";
-import {changeOrderContract, OrderContractControl} from "@/views/information/spot-contract/components/setup";
-import {Modal} from "ant-design-vue";
+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 { changeOrderContract, OrderContractControl } from '@/views/information/spot-contract/components/setup';
+import { Modal } from 'ant-design-vue';
+import { handleAccountManager, handleForm } from './setup';
 
 export default defineComponent({
     name: 'spot-contract-detail',
@@ -240,7 +244,13 @@ export default defineComponent({
     },
     setup(props, context) {
         const { visible, cancel } = closeModal('spot_contract_btn_check');
-        const  { loading, orderContractState } = changeOrderContract()
+        // 账号列表: 交易用户 业务员 跟单员
+        const { traderList, businesserList, merchandiserList, getRoleList, getBusinesserList } = handleAccountManager();
+
+        const { loading, orderContractState } = changeOrderContract();
+        // 表单
+        const { rules, formState, formRef } = handleForm();
+
         const maskClosableFlag = ref<boolean>(false);
         function submit() {
             Modal.confirm({
@@ -250,45 +260,45 @@ export default defineComponent({
                 onOk() {
                     // 审核通过
                     orderContractState(props.selectedRow.spotcontractid, 4)
-                        .then(res => {
-                            cancel()
-                            context.emit('refresh')
-                        })
-                        .catch(err => {
-
+                        .then((res) => {
+                            cancel();
+                            context.emit('refresh');
                         })
+                        .catch((err) => {});
                 },
                 onCancel() {
                     console.log('Cancel');
                 },
             });
         }
-        function refuse(){
+        function refuse() {
             Modal.confirm({
                 title: '是否确认审核拒绝',
                 okText: '确认审核拒绝',
                 cancelText: '取消',
                 onOk() {
                     // 审核拒绝
-                    OrderContractControl().orderContractState(props.selectedRow.spotcontractid, 4)
-                        .then(res => {
-                            cancel()
-                            context.emit('refresh')
-                        })
-                        .catch(err => {
-
+                    OrderContractControl()
+                        .orderContractState(props.selectedRow.spotcontractid, 4)
+                        .then((res) => {
+                            cancel();
+                            context.emit('refresh');
                         })
+                        .catch((err) => {});
                 },
                 onCancel() {
                     console.log('Cancel');
                 },
             });
         }
+        initData(() => {
+            getRoleList();
+            getBusinesserList();
+        });
         return {
             visible,
             cancel,
             submit,
-            loading,
             maskClosableFlag,
             getContractTypeName,
             getBizTypeName,
@@ -297,6 +307,13 @@ export default defineComponent({
             formatTime,
             getPriceTypeName,
             refuse,
+            traderList,
+            businesserList,
+            merchandiserList,
+            loading,
+            formState,
+            rules,
+            formRef,
         };
     },
 });

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

@@ -0,0 +1,10 @@
+export interface Value {
+    id: number,
+    name: string,
+}
+
+export interface FormState {
+    MerUserID: number | undefined// uint64 跟单员ID
+    TradeUserID: number | undefined// uint64 交易员ID
+    SaleUserID: number | undefined // uint64 业务员ID
+}

+ 94 - 14
src/views/information/spot-contract/components/check/setup.ts

@@ -1,18 +1,98 @@
-// import {  QueryAccMgrLoginUser }  from '@/services/go/ermcp/account'
+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() {
-    // function getList(arr) {
-    //     arr.forEach(el => {
+    // 交易用户
+    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 }
+}
 
-    //     });
-    // }
-    // QueryAccMgrLoginUser(1).then(res => {
-    //     const map = new Set<number>([])
-    //     res.forEach(e => {
-
-    //     })
-    //     if (res.length) {
-
-    //     }
-    // })
+// 表单
+export function handleForm() {
+    const formRef = ref();
+    const formState: UnwrapRef<FormState> = reactive({
+        MerUserID: undefined,// uint64 跟单员ID
+        TradeUserID: undefined,// uint64 交易员ID
+        SaleUserID: undefined, // uint64 业务员ID
+        Remark: ''
+    })
+    // 验证跟单员
+    async function v_MerUser(rule: RuleObject, value: number) {
+        return validateCommon(value, '请选择跟单员')
+    }
+    // 验证交易员
+    async function v_TradeUser(rule: RuleObject, value: number) {
+        return validateCommon(value, '请选择交易员')
+    }
+    // 验证业务员
+    async function v_SaleUser(rule: RuleObject, value: number) {
+        return validateCommon(value, '请选择业务员')
+    }
+    const rules = {
+        MerUserID: [{ required: true, validator: v_MerUser, trigger: 'blur' }],
+        TradeUserID: [{ required: true, validator: v_TradeUser, trigger: 'blur' }],
+        SaleUserID: [{ required: true, validator: v_SaleUser, trigger: 'blur' }],
+    }
+    return { rules, formState, formRef }
 }

+ 38 - 67
src/views/information/spot-contract/components/setup.ts

@@ -1,85 +1,56 @@
-import { getRequestResultInfo } from "@/common/methods/request";
+import { commonResultInfo, getRequestResultInfo } from "@/common/methods/request";
 import { orderContract, spotContractStatus } from "@/services/proto/spotcontract";
 import {
     GldErmcpSpotContractOperateReq,
-    GldSpotContractInfo,
     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 } from "vue";
+
 
 /**
- * 合同操作相关
+ * 
  */
-export function changeOrderContract() {
-    const loading = ref<boolean>(false);
-
-    /**
-     * 合同操作
-     * @param id 合同id
-     * @param type 操作类型 1: 保存草稿  2: 提交申请 3: 删除成功 4:审核通过
-     * @param info 合同信息
-     */
-    function orderContractState(id: string, type: number, info?: GldSpotContractInfo): Promise<string> {
-        loading.value = true
-        const reqs: GldErmcpSpotContractOperateReq = info === undefined ? {
-            SpotContractID: Long.fromString(id),
-            OperateType: type,
-            Remark: '',
-        } : {
-            SpotContractID: Long.fromString(id),
-            OperateType: type,
-            Remark: '',
-            Info: info,
-        }
-
-        const sign = getRequestResultInfo(GldContractStateSign, type)  // 接口请求后的返回提示 这里统一进行管理
-        return orderContract(reqs)
-            .then(res => {
-                message.success(sign[0])
-                return Promise.resolve(sign[0])
-            })
-            .catch(err => {
-                message.error(sign[1] + err)
-                return Promise.reject(sign[1] + err)
-            }).finally(() => {
-                loading.value = false
-            })
+/**
+ * 合同操作相关 针对操作类型 1: 保存草稿  2: 提交申请 3: 删除成功 4:审核通过
+ * @param reqs GldErmcpSpotContractOperateReq
+ * @param loading 
+ * @returns 
+ */
+export function orderContractState1(reqs: GldErmcpSpotContractOperateReq, loading: Ref<boolean>): Promise<string> {
+    //处理 合同id
+    if (reqs.SpotContractID) {
+        reqs.SpotContractID = Long.fromString(reqs.SpotContractID)
     }
-
-    return { loading, orderContractState }
+    // loading 效果
+    loading.value = true
+    // 获取提示信息
+    const sign = getRequestResultInfo(GldContractStateSign, reqs.OperateType)  // 接口请求后的返回提示 这里统一进行管理
+    // 接口调用
+    const result = orderContract(reqs)
+    // 接口调用结果处理,提示成功或者失败信息,并关闭loading效果
+    return commonResultInfo(result, sign, loading)
 }
 
 /**
- * 修改合同类型
+ * 
  * 4:审核拒绝 6:正常完结 5:撤销
  */
-export function OrderContractControl() {
-    const loading = ref<boolean>(false);
-
-    function orderContractState(id: string, type: number): Promise<string> {
-        loading.value = true
-        const reqs: SpotContractOperateReq = {
-            SpotContractID: Long.fromString(id),
-            OperateType: type,
-            Remark: '',
-        }
-        const sign = getRequestResultInfo(ContractStateSign, type)  // 接口请求后的返回提示 这里统一进行管理
-        return spotContractStatus(reqs)
-            .then(res => {
-                message.success(sign[0])
-                return Promise.resolve(sign[0])
-            })
-            .catch(err => {
-                message.error(sign[1] + err)
-                return Promise.reject(sign[1] + err)
-            }).finally(() => {
-                loading.value = false
-            })
-    }
-
-    return { loading, orderContractState }
+/**
+ * 修改合同类型 针对操作类型 4:审核拒绝 6:正常完结 5:撤销
+ * @param reqs 
+ * @param loading 
+ * @returns 
+ */
+export function orderContractState2(reqs: SpotContractOperateReq, loading: Ref<boolean>): Promise<string> {
+    // loading 效果
+    loading.value = true
+    // 获取提示信息
+    const sign = getRequestResultInfo(ContractStateSign, reqs.OperateType)  // 接口请求后的返回提示 这里统一进行管理
+    // 接口调用
+    const result = spotContractStatus(reqs)
+    // 接口调用结果处理,提示成功或者失败信息,并关闭loading效果
+    return commonResultInfo(result, sign, loading)
 }