Przeglądaj źródła

Merge branch 'master' of http://47.101.159.18:3000/Muchinfo/MTP2.0_WEB

marymelisa 4 lat temu
rodzic
commit
9d993db912

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

@@ -0,0 +1,2 @@
+import { getRequestResultInfo } from './resultInfo'
+export { getRequestResultInfo }

+ 1 - 0
src/common/methods/request/interface.ts

@@ -0,0 +1 @@
+export type ResultInfo = [string, string]

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

@@ -0,0 +1,15 @@
+import { ResultInfo } from './interface'
+/**
+ * 获取请求接口时候成功或者失败信息
+ * @param map 提示信息数据集合
+ * @param type 数据集合 的key
+ * @returns [成功信息, 失败信息]
+ */
+export function getRequestResultInfo(map: Map<number, ResultInfo>, type: number): ResultInfo {
+    if (map.has(type)) {
+        const result = map.get(type) as ResultInfo
+        return result
+    } else {
+        return ['成功', '失败']
+    }
+}

+ 6 - 10
src/views/information/custom/compoments/setup.ts

@@ -5,6 +5,9 @@ import {UserInfoCheckMangeReq} from "@/services/proto/accountinfo/interface";
 import {message} from 'ant-design-vue';
 import {ref} from "vue";
 import {BaseResponse} from "@/services/go";
+import {getRequestResultInfo} from "@/common/methods/request";
+import {GldContractStateSign} from "@/views/information/spot-contract/setup";
+import {ModifyUserInfoSign} from "@/views/information/custom/setup";
 
 /**
  *  撤销客户资料 撤销后的数据会进入草稿(未提交)
@@ -37,21 +40,14 @@ export function updateUserAccount() {
 
     // 这里调用的是修改客户申请接口
     function ModifyUserInfo(userID: number, accountStatus: number): Promise<string> {
+        const sign = getRequestResultInfo(ModifyUserInfoSign, accountStatus)  // 接口请求后的返回提示 这里统一进行管理
         return UpdateUserAccountStatus(userID, accountStatus)
             .then((res) => {
                 console.log('更新用户资料成功 accountStatus = ' + accountStatus);
-                if (accountStatus === 4) {
-                    return Promise.resolve("恢复成功")
-                } else {
-                    return Promise.resolve("停用成功")
-                }
+                return Promise.resolve(sign[0])
             })
             .catch((err) => {
-                if (accountStatus === 4) {
-                    return Promise.reject("恢复失败:" + err.message)
-                } else {
-                    return Promise.reject("停用失败:" + err.message)
-                }
+                return Promise.reject(sign[1])
             }).finally(() => {
                 loading.value = false
             })

+ 10 - 0
src/views/information/custom/setup.ts

@@ -1,4 +1,5 @@
 import {getItemEnum} from "@/services/bus/allEnum";
+import {ResultInfo} from "@/common/methods/request/interface";
 
 /**
  * 获取客户资料状态
@@ -37,3 +38,12 @@ export function getCardTypeName(type: number): string{
     const cardName = getItemEnum('certificatetype').find(e => e.enumitemname === type);
     return cardName ? cardName.enumdicname : "--"
 }
+
+/************** 接口相关提示 **************** /
+ *
+ */
+// 更新用户状态 4:正常 6:注销(停用)
+export const ModifyUserInfoSign = new Map<number, ResultInfo>([
+    [4, ['恢复成功', '恢复失败:']],
+    [6, ['停用成功', '停用失败:']],
+])

+ 1 - 3
src/views/information/spot-contract/components/cancel/index.vue

@@ -204,7 +204,6 @@ export default defineComponent({
         const {loading, orderContractState} = OrderContractControl()
         const maskClosableFlag = ref<boolean>(false);
         function submit() {
-            loading.value = true;
             Modal.confirm({
                 title: '是否确认撤销',
                 okText: '确认撤销',
@@ -213,12 +212,11 @@ export default defineComponent({
                     // 撤销合同
                     orderContractState(props.selectedRow.spotcontractid, 5)
                         .then(res => {
-                            message.success(res);
                             // 通知上层  刷新数据
                             context.emit('refresh');
                             cancel();
                         }).catch(err => {
-                        message.error(err);
+
                     });
                 },
                 onCancel() {

+ 0 - 2
src/views/information/spot-contract/components/delete/index.vue

@@ -213,12 +213,10 @@ export default defineComponent({
                     // 删除客户资料
                     orderContractState(props.selectedRow.spotcontractid, 1)
                         .then(res => {
-                            message.success(res);
                             // 通知上层  刷新数据
                             context.emit('refresh');
                             cancel();
                         }).catch(err => {
-                        message.error(err);
                     });
                 },
                 onCancel() {

+ 0 - 2
src/views/information/spot-contract/components/finish/index.vue

@@ -213,12 +213,10 @@ export default defineComponent({
                     // 完结合同
                     orderContractState(props.selectedRow.spotcontractid, 6)
                         .then(res => {
-                            message.success(res);
                             // 通知上层  刷新数据
                             context.emit('refresh');
                             cancel();
                         }).catch(err => {
-                        message.error(err);
                     });
                 },
                 onCancel() {

+ 18 - 52
src/views/information/spot-contract/components/setup.ts

@@ -1,12 +1,13 @@
+import { orderContract, spotContractStatus } from "@/services/proto/spotcontract";
 import {
     GldErmcpSpotContractOperateReq,
     GldSpotContractInfo,
     SpotContractOperateReq
 } from "@/services/proto/spotcontract/interface";
-import {orderContract, spotContractStatus} from "@/services/proto/spotcontract";
-import {ref} from "vue";
-import {getSelectedAccountId} from "@/services/bus/account";
-import * as Long from "long";
+import { ref } from "vue";
+import {getRequestResultInfo} from "@/common/methods/request";
+import {ContractStateSign, GldContractStateSign} from "@/views/information/spot-contract/setup";
+import {message} from "ant-design-vue";
 
 /**
  * 合同操作相关
@@ -27,49 +28,31 @@ export function changeOrderContract() {
             Remark: '',
             Info: info,
         }
-        let successText = "成功"
-        let errorText = "失败"
-
-        switch (type){
-            case 1:
-                successText = "保存草稿成功"
-                errorText = "保存草稿失败:"
-                break;
-            case 2:
-                successText = "提交申请成功"
-                errorText = "提交申请失败:"
-                break;
-            case 3:
-                successText = "删除成功"
-                errorText = "删除失败:"
-                break;
-            case 4:
-                successText = "审核通过"
-                errorText = "审核失败:"
-                break;
-        }
+        const sign = getRequestResultInfo(GldContractStateSign, type)  // 接口请求后的返回提示 这里统一进行管理
 
         return orderContract(reqs)
             .then(res => {
-                return Promise.resolve(successText)
+                message.success(sign[0])
+                return Promise.resolve(sign[0])
             })
             .catch(err => {
-                return Promise.reject(errorText + err)
+                message.success(sign[1])
+                return Promise.reject(sign[1] + err)
             }).finally(() => {
                 loading.value = false
             })
     }
 
-    return {loading, orderContractState}
+    return { loading, orderContractState }
 }
 
-
 /**
  * 修改合同类型
  * 4:审核拒绝 6:正常完结 5:撤销
  */
 export function OrderContractControl() {
     const loading = ref<boolean>(false);
+    loading.value = true
 
     function orderContractState(id: string, type: number): Promise<string> {
         const reqs: SpotContractOperateReq = {
@@ -77,36 +60,19 @@ export function OrderContractControl() {
             OperateType: type,
             Remark: '',
         }
-        let successText = "成功"
-        let errorText = "失败"
-
-        switch (type) {
-            case 4:
-                successText = "审核拒绝成功"
-                errorText = "审核拒绝失败:"
-                break;
-            case 5:
-                successText = "撤销成功"
-                errorText = "撤销失败:"
-                break;
-            case 6:
-                successText = "正常完结"
-                errorText = "合同完结失败:"
-                break;
-        }
-
+        const sign = getRequestResultInfo(ContractStateSign, type)  // 接口请求后的返回提示 这里统一进行管理
         return spotContractStatus(reqs)
             .then(res => {
-                return Promise.resolve(successText)
+                message.success(sign[0])
+                return Promise.resolve(sign[0])
             })
             .catch(err => {
-                return Promise.reject(errorText + err)
+                message.success(sign[1])
+                return Promise.reject(sign[1] + err)
             }).finally(() => {
                 loading.value = false
             })
     }
 
-    return {loading, orderContractState}
+    return { loading, orderContractState }
 }
-
-

+ 16 - 0
src/views/information/spot-contract/setup.ts

@@ -4,6 +4,8 @@
  * //合同状态 - number;
  //:未提交 1:待审核 2:执行中 3:正常完结 4:审核拒绝 5:异常完结 6:已撤回
  */
+import {ResultInfo} from "@/common/methods/request/interface";
+
 export function getContractStatusName(state: number): string {
     let result = "--";
     switch (state) {
@@ -86,3 +88,17 @@ export function getContractTypeName(type: number): string{
 /************** 接口相关提示 **************** /
  *
  */
+// 合同操作 操作类型 1: 保存草稿  2: 提交申请 3: 删除成功 4:审核通过
+export const GldContractStateSign = new Map<number, ResultInfo>([
+    [1, ['保存草稿成功', '保存草稿失败:']],
+    [2, ['提交申请成功', '提交申请失败:']],
+    [3, ['删除成功', '删除失败:']],
+    [4, ['审核通过', '审核失败:']],
+])
+
+// 合同操作 4:审核拒绝 6:正常完结 5:撤销
+export const ContractStateSign = new Map<number, ResultInfo>([
+    [4, ['审核拒绝成功', '审核拒绝失败:']],
+    [5, ['撤销成功', '撤销失败:']],
+    [6, ['正常完结', '合同完结失败:']],
+])