li.shaoyi 7 meses atrás
pai
commit
6c825aa47c

+ 1 - 1
src/packages/pc/App.vue

@@ -38,7 +38,7 @@ const locale = computed(() => {
       return th
     case Language.Traditional:
       return zhTW
-    case Language.VI:
+    case Language.Vietnamese:
       return vi
     default:
       return zhCn

+ 30 - 3
src/packages/pc/router/dynamicRouter.ts

@@ -8,13 +8,16 @@ export default new (class {
     /** 防止动态路由无限加载 */
     isReady = false;
 
+    /** 已注册的路由 */
+    private registeredRouteNames: string[] = [];
+
     /**
      * 添加404页面
      */
     private addNotFound() {
         router.addRoute({
             path: '/:pathMatch(.*)*',
-            name: 'Error',
+            name: 'NotFound',
             component: Page,
             meta: {
                 title: '系统错误'
@@ -22,7 +25,7 @@ export default new (class {
             children: [
                 {
                     path: '',
-                    name: 'ErrorIndex',
+                    name: 'NotFoundIndex',
                     component: () => import('../views/error/404.vue'),
                     meta: {
                         title: '404'
@@ -33,6 +36,15 @@ export default new (class {
     }
 
     /**
+     * 移除404页面
+     */
+    private removeNotFound() {
+        if (router.hasRoute('NotFound')) {
+            router.removeRoute('NotFound');
+        }
+    }
+
+    /**
      * 动态添加路由
      * @param routes 
      * @param parentName 
@@ -67,6 +79,10 @@ export default new (class {
 
                 parentName ? router.addRoute(parentName, route) : router.addRoute(route);
 
+                if (item.parentCode === '') {
+                    this.registeredRouteNames.push(item.resourceCode); // 添加一级路由到注册列表
+                }
+
                 if (item.children && item.children.length) {
                     this.addRoutes(item.children, item.resourceCode);
                 }
@@ -75,11 +91,22 @@ export default new (class {
     }
 
     /**
+     * 移除所有已注册的路由
+     */
+    unregisterRoutes() {
+        this.removeNotFound();
+        this.registeredRouteNames.forEach((name) => {
+            router.removeRoute(name);
+        })
+        this.registeredRouteNames = [];
+    }
+
+    /**
      * 注册路由
      * @returns 
      */
     registerRoutes() {
-        const routerStore = useRouterStore()
+        const routerStore = useRouterStore();
         this.addNotFound();
         this.addRoutes(routerStore.userRoutes);
         this.isReady = true;

+ 172 - 0
src/packages/pc/views/account/fundacct/components/edit/index.vue

@@ -0,0 +1,172 @@
+<!-- 账号管理-资金账户管理-编辑 -->
+<template>
+    <app-drawer title="编辑" width="900" v-model:show="show" :refresh="refresh" :loading="loading">
+        <el-form ref="formRef" class="el-form--horizontal" label-width="180px" :model="formData" :show-message="false">
+            <el-form-item label="资金账户">
+                <span>{{ record.accountId }}</span>
+            </el-form-item>
+            <el-form-item label="账户类型" v-if="record.isMain === 1">
+                <span>{{ mainaccounttypeEnum.getEnumTypeName(record.isMain) }}</span>
+            </el-form-item>
+            <template v-else>
+                <el-form-item label="所属母账户">
+                    <span>{{ record.parentAccountId }}</span>
+                </el-form-item>
+            </template>
+            <template v-if="data && data.selfFlag === 1">
+                <template v-if="!data.cannotEdit">
+                    <el-form-item class="el-form-item--row" label="市场权限">
+                        <el-table ref="tableRef" :data="formData.dtype" @selection-change="handleSelectionChange"
+                            border>
+                            <el-table-column type="selection" width="55" />
+                            <el-table-column prop="marketName" label="市场" />
+                            <el-table-column prop="tradeMode" label="买大厅权限"
+                                v-if="multipleSelection.some((e) => e.tradeProperty === 4 || e.tradeMode === 79)">
+                                <template #default="{ row }">
+                                    <span v-if="row.tradeMode === 79">买大厅权限:可挂</span>
+                                    <template v-else-if="row.tradeMode === 17 && row.tradeProperty === 4">
+                                        <el-select v-model="row.dtype">
+                                            <template v-for="(value, key) in data.marketbstype" :key="key">
+                                                <el-option :label="value" :value="Number(key)" />
+                                            </template>
+                                        </el-select>
+                                    </template>
+                                    <template v-else>
+                                        {{ handleNoneValue() }}
+                                    </template>
+                                </template>
+                            </el-table-column>
+                            <el-table-column prop="tradeMode" label="卖大厅权限"
+                                v-if="multipleSelection.some((e) => e.tradeProperty === 4 || [77, 78].includes(e.tradeMode))">
+                                <template #default="{ row }">
+                                    <span v-if="[77, 78].includes(row.tradeMode)">卖大厅权限:可挂</span>
+                                    <template v-else-if="row.tradeProperty === 4">
+                                        <el-select v-model="row.spotRightType">
+                                            <template v-for="(value, key) in data.marketbstype" :key="key">
+                                                <el-option :label="value" :value="Number(key)" />
+                                            </template>
+                                        </el-select>
+                                    </template>
+                                    <template v-else>
+                                        {{ handleNoneValue() }}
+                                    </template>
+                                </template>
+                            </el-table-column>
+                        </el-table>
+                    </el-form-item>
+                </template>
+                <el-form-item class="el-form-item--row" label="授权登录账户(交易员)">
+                    <!-- <el-checkbox-group v-model="formData.loginIds">
+                        <template v-for="value in data.loginaccount" :key="value">
+                            <el-checkbox :label="value" :value="value" />
+                        </template>
+                    </el-checkbox-group> -->
+                    {{ handleNoneValue(data.loginaccount.join(',')) }}
+                </el-form-item>
+                <el-form-item class="el-form-item--row" label="默认授权登录账户">
+                    {{ handleNoneValue(data.defaultloginaccount.join(',')) }}
+                </el-form-item>
+            </template>
+        </el-form>
+        <template #footer>
+            <el-button @click="onCancel(false)">{{ t('operation.close') }}</el-button>
+            <el-button type="primary" @click="onSubmit">{{ t('operation.submit') }}</el-button>
+        </template>
+    </app-drawer>
+</template>
+
+<script lang="ts" setup>
+import { ref, reactive, PropType, toRaw, nextTick } from 'vue'
+import { ElMessage, FormInstance, TableInstance } from 'element-plus'
+import { handleNoneValue } from '@/filters'
+import { useEnum } from '@/hooks/enum'
+import { useRequest } from '@/hooks/request'
+import { updateTaAccountInit, updateTaAccount, queryTaAccountDetail } from '@/services/api/account'
+import { i18n } from '@/stores'
+import AppDrawer from '@pc/components/base/drawer/index.vue'
+
+const props = defineProps({
+    record: {
+        type: Object as PropType<Model.TaAccountRsp>,
+        required: true
+    }
+})
+
+const mainaccounttypeEnum = useEnum('mainaccounttype') // 账户类型
+
+const t = i18n.global.t
+const tableRef = ref<TableInstance>()
+const formRef = ref<FormInstance>()
+const show = ref(true)
+const refresh = ref(false)
+const multipleSelection = ref<Model.UpdateTaAccountReq['dtype']>([]) // 已选中的市场数据
+
+const formData = reactive<Partial<Model.UpdateTaAccountReq>>({
+    dtype: [],
+    loginIds: []
+})
+
+const { data } = useRequest(updateTaAccountInit, {
+    params: {
+        accountId: props.record.accountId
+    },
+    onSuccess: (res) => {
+        formData.dtype = Object.values(res.data.clildmarkets)
+        // 初始化已选中的市场
+        nextTick(() => {
+            formData.dtype?.forEach((e) => {
+                if (e.checked) {
+                    tableRef.value?.toggleRowSelection(e)
+                }
+            })
+        })
+    }
+})
+
+const { loading } = useRequest(queryTaAccountDetail, {
+    params: {
+        accountId: props.record.accountId
+    },
+    onSuccess: (res) => {
+        const data = res.data
+        formData.accountId = data.accountId
+        formData.loginIds = data.loginIds
+        formData.relatedaccountstatus = data.relatedAccountStatus
+        formData.relateduserid = data.relatedUserId
+        formData.userid = data.userId
+    },
+    onError: (err) => {
+        ElMessage.error(err)
+    }
+})
+
+const handleSelectionChange = (selection: Model.UpdateTaAccountReq['dtype']) => {
+    multipleSelection.value = selection
+}
+
+const onCancel = (isRefresh = false) => {
+    show.value = false
+    refresh.value = isRefresh
+}
+
+const onSubmit = () => {
+    formRef.value?.validate((valid) => {
+        if (valid) {
+            loading.value = true
+            const rawData = toRaw(formData)
+            rawData.dtype = multipleSelection.value
+
+            updateTaAccount({
+                data: rawData
+            }).then(() => {
+                ElMessage.success(t('common.tips3'))
+                onCancel(true)
+            }).catch((err) => {
+                ElMessage.error(t('common.tips4') + err)
+            }).finally(() => {
+                loading.value = false
+            })
+        }
+    })
+}
+</script>

+ 1 - 1
src/packages/pc/views/account/fundacct/components/password/index.vue

@@ -2,7 +2,7 @@
 <template>
     <app-drawer :title="t('account.fundacct.password.title')" width="480" v-model:show="show" :refresh="refresh"
         :loading="loading">
-        <el-form ref="formRef" class="el-form--vertical" label-width="140px" :model="formData" :rules="formRules">
+        <el-form ref="formRef" class="el-form--vertical" label-width="100px" :model="formData" :rules="formRules">
             <el-form-item :label="t('account.fundacct.password.accountId')">
                 {{ record.accountId }}
             </el-form-item>

+ 6 - 3
src/packages/pc/views/auth/login/index.vue

@@ -34,14 +34,14 @@ import { ElMessage, FormInstance, FormRules } from 'element-plus'
 import { useRequest } from '@/hooks/request'
 import { verifyCode } from '@/services/api/user'
 import { useLogin } from '@/business/login'
-import { useRouterStore, i18n } from '@/stores'
+import { i18n } from '@/stores'
 import service from '@/services'
+import dynamicRouter from '../../../router/dynamicRouter'
 import SignLayout from '../components/layout/index.vue'
 
 const { formData, userLogin } = useLogin()
 const route = useRoute()
 const router = useRouter()
-const menuStore = useRouterStore()
 const formRef = shallowRef<FormInstance>()
 const loading = shallowRef(false)
 //const remember = shallowRef(false) // 记住账号
@@ -72,7 +72,10 @@ const formSubmit = () => {
       try {
         loading.value = true
         await userLogin()
-        await menuStore.getUserRoutes()
+        
+        // 路由跳转前需移除 NotFound 路由,否则可能因为动态路由还未加载,路由不存在而被匹配到 NotFound 页面
+        dynamicRouter.unregisterRoutes()
+
         const redirect = route.query.redirect
         if (redirect) {
           router.replace(redirect.toString())

+ 13 - 0
src/services/api/account/index.ts

@@ -1,5 +1,8 @@
 import httpClient from '@/services/http'
 import { CommonFetchOptions } from '@/services/http/types'
+import { useUserStore } from '@/stores'
+
+const userStore = useUserStore()
 
 /**
  * 资金账户管理查询
@@ -16,6 +19,16 @@ export function queryTaAccountDetail(options: CommonFetchOptions<{ request: Mode
 }
 
 /**
+ * 资金账户管理-->资金账户信息修改--> 初始化
+ */
+export function updateTaAccountInit(options: CommonFetchOptions<{ request: Model.UpdateTaAccountInitReq; response: Model.UpdateTaAccountInitRsp; }>) {
+    if (options.data) {
+        options.data.orgztypes = userStore.userInfo.orgztypes
+    }
+    return httpClient.commonRequest('/taAccount/updateTaAccountInit', 'get', options)
+}
+
+/**
  * 资金账户管理-->资金账户信息修改
  */
 export function updateTaAccount(options: CommonFetchOptions<{ request: Partial<Model.UpdateTaAccountReq>; }>) {

+ 7 - 1
src/stores/modules/menu.ts

@@ -66,6 +66,11 @@ export const useRouterStore = defineStore(() => {
         return filterMenus(children)
     }
 
+    // 清除用户路由信息
+    const clearUserRoutes = () => {
+        userRoutes.value = []
+    }
+
     return {
         loading,
         userRoutes,
@@ -73,6 +78,7 @@ export const useRouterStore = defineStore(() => {
         getUserRoutes,
         getChildrenRoutes,
         getUserMenus,
-        getChildrenMenus
+        getChildrenMenus,
+        clearUserRoutes
     }
 })

+ 35 - 0
src/types/model/account.d.ts

@@ -381,6 +381,41 @@ declare namespace Model {
         relationOrderId: string; // 关联单号
     }
 
+    /** 资金账户管理-->资金账户信息修改--> 初始化 请求 */
+    interface UpdateTaAccountInitReq {
+        accountId: number;
+        orgztypes?: string;
+    }
+
+    /** 资金账户管理-->资金账户信息修改--> 初始化 响应 */
+    interface UpdateTaAccountInitRsp {
+        cannotEdit: number;
+        clildmarkets: {
+            [key: number]: {
+                checked: number;
+                dtype: number;
+                fdType: number;
+                fspotRightType: number;
+                marketId: number;
+                marketName: string;
+                spotRightType: number; // code:marketbstype
+                tradeMode: number;
+                tradeProperty: number;
+            }
+        };
+        defaultloginaccount: number[];
+        isshowrelationuser: string;
+        loginaccount: number[];
+        marketbstype: {
+            [key: number]: string;
+        };
+        markets: [];
+        oldLogin: string;
+        relatedU: {};
+        selfFlag: number;
+        taa: {};
+    }
+
     /** 账号管理-->交易账号管理-->获取列表 请求 */
     interface TradingAccReq {
         loginid?: number; // 登录账号