li.shaoyi 3 rokov pred
rodič
commit
89c704a088
33 zmenil súbory, kde vykonal 217 pridanie a 200 odobranie
  1. 5 4
      src/business/common/index.ts
  2. 3 3
      src/business/customer/index.ts
  3. 2 2
      src/business/sign/index.ts
  4. 15 19
      src/filters/index.ts
  5. 12 10
      src/hooks/auth/index.ts
  6. 2 2
      src/hooks/echarts/candlestick/options.ts
  7. 2 3
      src/hooks/echarts/timeline/options.ts
  8. 3 3
      src/packages/mobile/router/index.ts
  9. 4 4
      src/packages/mobile/views/home/components/market/index.vue
  10. 15 16
      src/packages/pc/assets/themes/default/default.less
  11. 2 2
      src/packages/pc/components/modules/auth-component/index.vue
  12. 1 1
      src/packages/pc/components/modules/auth-operation/index.vue
  13. 5 5
      src/packages/pc/router/dynamicRouter.ts
  14. 8 8
      src/packages/pc/router/index.ts
  15. 13 11
      src/packages/pc/views/setting/customer/main/components/edit/index.vue
  16. 2 2
      src/packages/pc/views/system/menu/components/edit/index.vue
  17. 4 4
      src/packages/pc/views/system/menu/index.vue
  18. 3 3
      src/packages/pc/views/system/role/components/auth/index.vue
  19. 1 1
      src/packages/pc/views/system/role/index.vue
  20. 2 2
      src/services/api/account/index.ts
  21. 7 0
      src/services/api/common/index.ts
  22. 2 2
      src/services/http/index.ts
  23. 3 3
      src/services/language/index.ts
  24. 3 4
      src/services/socket/quote/index.ts
  25. 2 2
      src/services/socket/trade/index.ts
  26. 6 4
      src/stores/index.ts
  27. 3 3
      src/stores/modules/account.ts
  28. 2 2
      src/stores/modules/common.ts
  29. 2 2
      src/stores/modules/futures.ts
  30. 53 49
      src/stores/modules/storage.ts
  31. 3 3
      src/types/ermcp/account.d.ts
  32. 22 0
      src/types/ermcp/enum.d.ts
  33. 5 21
      src/types/store/globalStorage.d.ts

+ 5 - 4
src/business/common/index.ts

@@ -2,7 +2,7 @@ import { shallowRef } from 'vue'
 import { timerTask } from '@/utils/timer'
 import { queryTableDefine } from '@/services/api/common'
 import { tokenCheck } from '@/services/api/account'
-import { storageData, commonStore, futuresStore, resetStore, accountStore } from '@/stores'
+import { sessionData, commonStore, futuresStore, resetStore, accountStore } from '@/stores'
 import service from '@/services'
 import eventBus from '@/services/bus'
 import socket from '@/services/socket'
@@ -32,7 +32,7 @@ export const business = new (class {
  */
 export async function initBaseData(callback?: () => void) {
     await service.onReady(async () => {
-        if (storageData.getLoginInfo('Token')) {
+        if (sessionData.getLoginInfo('Token')) {
             // 连接交易服务
             socket.connectTrade()
             await checkToken()
@@ -58,10 +58,11 @@ export async function initBaseData(callback?: () => void) {
  * Token 效验
  */
 export function checkToken() {
+    const { LoginID, Token } = sessionData.getValue('loginInfo')
     return tokenCheck({
         data: {
-            LoginID: storageData.getLoginInfo('LoginID'),
-            Token: storageData.getLoginInfo('Token'),
+            LoginID,
+            Token,
         },
         fail: () => {
             // 失败应该退到登录页面

+ 3 - 3
src/business/customer/index.ts

@@ -2,7 +2,7 @@ import { ref } from 'vue'
 import { useDataTable } from '@/hooks/datatable'
 import { queryCustomerInfo, customerInfoOperate, userInfoOperate } from '@/services/api/customer'
 import { UserInfoType, CustomerQueryType } from '@/constants/enum/customer'
-import { storageData } from '@/stores'
+import { sessionData } from '@/stores'
 import { getTableColumns } from '../common'
 
 export function useCustomer(queryType: CustomerQueryType) {
@@ -29,7 +29,7 @@ export function useCustomer(queryType: CustomerQueryType) {
         loading.value = true
         return queryCustomerInfo({
             data: {
-                userid: storageData.getLoginInfo('UserID'),
+                userid: sessionData.getLoginInfo('UserID'),
                 querytype: queryType,
             },
             success: (res) => {
@@ -53,7 +53,7 @@ export function useCustomer(queryType: CustomerQueryType) {
 }
 
 export function useCustomerForm(selectedRow?: Ermcp.CustomerInfoRsp) {
-    const loginUserId = storageData.getLoginInfo('UserID')
+    const loginUserId = sessionData.getLoginInfo('UserID')
     const loading = ref(false)
     const formItem = ref<Proto.CustomerInfoOperateReq>({
         operatetype: 1,

+ 2 - 2
src/business/sign/index.ts

@@ -1,6 +1,6 @@
 import { ref, reactive } from 'vue'
 import { v4 } from 'uuid'
-import { storageData } from '@/stores'
+import { sessionData } from '@/stores'
 import { initBaseData } from '@/business/common'
 import { login, queryLoginId } from '@/services/api/account'
 import cryptojs from 'crypto-js'
@@ -39,7 +39,7 @@ export function useSign() {
                             LoginPWD: cryptojs.SHA256(res.data + user.LoginPWD).toString(),
                         },
                         success: (res) => {
-                            storageData.setLoginInfo(res);
+                            sessionData.setValue('loginInfo', res);
                             initBaseData(() => {
                                 loading.value = false;
                                 resolve(res);

+ 15 - 19
src/filters/index.ts

@@ -3,9 +3,9 @@
  */
 export function handlePriceColor(curValue: number, preValue: number) {
     if (!curValue || curValue === preValue) {
-        return '';
+        return ''
     } else if (curValue > preValue) {
-        return 'g-color--up';
+        return 'g-color--up'
     } else {
         return 'g-color--down'
     }
@@ -47,30 +47,26 @@ export function handleNumberValue(value: number, suffix = '') {
 export function formatDecimal(value: number, decimal = 2, round = true) {
     if (decimal <= 0) {
         if (round) {
-            return Math.round(value);
+            return Math.round(value).toString()
         }
-        return Math.trunc(value);
+        return Math.trunc(value).toString()
     } else {
         if (round) {
-            return Number(value.toFixed(decimal));
+            return value.toFixed(decimal)
         }
-
-        let num = value.toString();
-        const index = num.indexOf('.');
-
+        let num = value.toString()
+        const index = num.indexOf('.')
         if (index < 0) {
             // 小数位自动补零
             if (decimal > 0) {
-                const count = num.length;
-                num += '.';
+                const count = num.length
+                num += '.'
                 while (num.length <= count + decimal) {
-                    num += '0';
+                    num += '0'
                 }
             }
         }
-
-        const result = num.substring(0, decimal + index + 1);
-        return Number(result);
+        return num.substring(0, decimal + index + 1)
     }
 }
 
@@ -80,8 +76,8 @@ export function formatDecimal(value: number, decimal = 2, round = true) {
  * @param decimal 保留小数位 默认2 
  */
 export function formatAmount(value: number, decimal = 2) {
-    const reg = new RegExp('(\\d)(?=(\\d{3})+$)', 'ig');
-    const result = value.toFixed(decimal).toString().split('.');
-    result[0] = result[0].replace(reg, '$1,');
-    return result.join('.');
+    const reg = new RegExp('(\\d)(?=(\\d{3})+$)', 'ig')
+    const result = value.toFixed(decimal).toString().split('.')
+    result[0] = result[0].replace(reg, '$1,')
+    return result.join('.')
 }

+ 12 - 10
src/hooks/auth/index.ts

@@ -1,13 +1,13 @@
 import { defineAsyncComponent, Component } from 'vue'
 import { useRoute, useRouter } from 'vue-router'
-import { storageData } from '@/stores'
+import { sessionData } from '@/stores'
 import { AuthType } from '@/constants/enum/menu'
 import { AuthMenu } from './interface'
 
 export function useAuth(code?: string) {
     const route = useRoute()
     const router = useRouter()
-    const accountMenus = storageData.getAccountMenus()
+    const userMenus = sessionData.getValue('userMenus')
     const componentMap = new Map<string, Component>()
 
     /**
@@ -17,14 +17,14 @@ export function useAuth(code?: string) {
      */
     const getMenus = (level = 0) => {
         // 过滤层级
-        const filterLevel = (list: Ermcp.AccountMenu[], n: number): Ermcp.AccountMenu[] => {
+        const filterLevel = (list: Ermcp.UserMenu[], n: number): Ermcp.UserMenu[] => {
             if (level) {
                 return list.map((e) => ({ ...e, children: n <= 1 ? [] : filterLevel(e.children ?? [], n - 1) }))
             }
             return list
         }
         // 过滤菜单
-        const filterMenu = (list: Ermcp.AccountMenu[], parentPath = '') => {
+        const filterMenu = (list: Ermcp.UserMenu[], parentPath = '') => {
             const result: AuthMenu[] = []
             list.forEach((e) => {
                 if (e.authType === AuthType.Menu) {
@@ -40,7 +40,7 @@ export function useAuth(code?: string) {
             })
             return result
         }
-        return filterMenu(filterLevel(accountMenus, level))
+        return filterMenu(filterLevel(userMenus, level))
     }
 
     /**
@@ -71,7 +71,7 @@ export function useAuth(code?: string) {
      */
     const getChildrenAuth = () => {
         const routeName = code ?? route.name?.toString()
-        const filter = (list: Ermcp.AccountMenu[]): Ermcp.AccountMenu | undefined => {
+        const filter = (list: Ermcp.UserMenu[]): Ermcp.UserMenu | undefined => {
             if (routeName) {
                 for (const item of list) {
                     const { code, children } = item;
@@ -84,7 +84,7 @@ export function useAuth(code?: string) {
             }
             return undefined;
         }
-        return filter(accountMenus);
+        return filter(userMenus);
     }
 
     /**
@@ -99,13 +99,15 @@ export function useAuth(code?: string) {
                     if (!componentMap.get(cur.code) && cur.component) {
                         const componentString = cur.component.replace(/^\/+/, ''); // 过滤字符串前面所有 '/' 字符
                         const componentPath = componentString.replace(/\.\w+$/, ''); // 过滤后缀名,为了让 import 加入 .vue ,不然会有警告提示...
-                        const asyncComponent = defineAsyncComponent(() => import('/' + process.env.VUE_APP_ROOT + componentPath + '.vue'));
+                        const asyncComponent = defineAsyncComponent({
+                            loader: () => import('/' + process.env.VUE_APP_ROOT + componentPath + '.vue'),
+                        });
                         componentMap.set(cur.code, asyncComponent);
                     }
                     res.push(cur);
                 }
                 return res;
-            }, [] as Ermcp.AccountMenu[])
+            }, [] as Ermcp.UserMenu[])
         }
         return [];
     }
@@ -149,7 +151,7 @@ export function useAuth(code?: string) {
     return {
         route,
         router,
-        accountMenus,
+        userMenus,
         componentMap,
         getMenus,
         getChildrenMenus,

+ 2 - 2
src/hooks/echarts/candlestick/options.ts

@@ -1,11 +1,11 @@
 import { reactive, watch } from 'vue'
 import { ECOption } from '@/components/base/echarts/core'
 import { timerInterceptor } from '@/utils/timer'
-import { storageData } from '@/stores'
+import { localData } from '@/stores'
 import { EchartsDataset, EchartsOptions, Colors } from './interface'
 import moment from 'moment'
 
-const theme = storageData.getTheme();
+const theme = localData.getRef('appTheme');
 
 function getColors() {
     // 默认主题色配置

+ 2 - 3
src/hooks/echarts/timeline/options.ts

@@ -1,11 +1,10 @@
 import { reactive, watch } from 'vue'
 import { timerInterceptor } from '@/utils/timer'
-import { storageData } from '@/stores'
+import { localData } from '@/stores'
 import { echarts } from '@/components/base/echarts/core'
 import { EchartsDataset, EchartsOptions, Colors } from './interface'
 
-
-const theme = storageData.getTheme();
+const theme = localData.getRef('appTheme');
 
 function getColors() {
     // 默认主题色配置

+ 3 - 3
src/packages/mobile/router/index.ts

@@ -1,5 +1,5 @@
 import { createWebHashHistory, RouteRecordRaw } from 'vue-router'
-import { storageData } from '@/stores'
+import { sessionData } from '@/stores'
 import service from '@/services'
 import Page from '@mobile/components/layouts/page/index.vue'
 import animateRouter from './animateRouter'
@@ -65,11 +65,11 @@ const router = animateRouter.create({
 
 // 路由跳转拦截
 router.beforeEach((to, from, next) => {
-  const isLogin = storageData.getLoginInfo('Token');
+  const token = sessionData.getLoginInfo('Token');
 
   // 判断服务是否加载完成
   if (service.isReady) {
-    if (to.meta.requireAuth && !isLogin) {
+    if (to.meta.requireAuth && !token) {
       next({
         name: 'login',
         query: { redirect: to.fullPath },

+ 4 - 4
src/packages/mobile/views/home/components/market/index.vue

@@ -34,7 +34,7 @@
 <script lang="ts" setup>
 import { ref, reactive, onActivated, onDeactivated } from 'vue'
 import { Grid, GridItem, Button, ActionSheet, ActionSheetAction } from 'vant'
-import { futuresStore, storageData } from '@/stores'
+import { futuresStore, localData } from '@/stores'
 import { handlePriceColor, handleNoneValue } from '@/filters'
 import AppTable from '@mobile/components/base/table/index.vue'
 import { TableColumn } from '@mobile/components/base/table/interface'
@@ -62,15 +62,15 @@ const actions: ActionSheetAction[] = [
 const themeChange = (action: ActionSheetAction) => {
   switch (action.name) {
     case '默认': {
-      storageData.setTheme('Default')
+      localData.setTheme('Default')
       break;
     }
     case '浅色': {
-      storageData.setTheme('Light');
+      localData.setTheme('Light');
       break;
     }
     case '深色': {
-      storageData.setTheme('Dark')
+      localData.setTheme('Dark')
       break;
     }
   }

+ 15 - 16
src/packages/pc/assets/themes/default/default.less

@@ -112,22 +112,6 @@
             .el-form-item {
                 width: 50%;
 
-                &.row {
-                    width: 100%;
-
-                    .el-form-item__content {
-                        display: flex;
-
-                        >* {
-                            flex: 1;
-
-                            &:not(:first-child) {
-                                margin-left: 10px;
-                            }
-                        }
-                    }
-                }
-
                 &__label {
                     padding: 0 12px;
                 }
@@ -136,6 +120,21 @@
                     align-items  : flex-start;
                     padding-right: 80px;
                 }
+
+                &--row {
+                    width: 100%;
+                }
+
+                &--col {
+                    display: flex;
+                    width  : 100%;
+
+                    >* {
+                        &:not(:first-child) {
+                            margin-left: 10px;
+                        }
+                    }
+                }
             }
 
             .el-input {

+ 2 - 2
src/packages/pc/components/modules/auth-component/index.vue

@@ -31,12 +31,12 @@ const props = defineProps({
 
 const { componentMap, getAuthComponent } = useAuth(props.code)
 const { onChange } = useAttrs()
-const dataList = shallowRef<Ermcp.AccountMenu[]>([]) // 数据列表
+const dataList = shallowRef<Ermcp.UserMenu[]>([]) // 数据列表
 const dataIndex = shallowRef(0) // 选中的标签
 
 const componentId = computed(() => dataList.value[dataIndex.value]?.code)
 
-const onTabChange = (index: number, { code }: Ermcp.AccountMenu) => {
+const onTabChange = (index: number, { code }: Ermcp.UserMenu) => {
     if (onChange instanceof Function) {
         onChange(code)
     } else {

+ 1 - 1
src/packages/pc/components/modules/auth-operation/index.vue

@@ -82,7 +82,7 @@ const props = defineProps({
 const { componentMap, getAuthButton } = useAuth(props.code);
 const componentId = shallowRef<string>();
 const contextmenuOption = shallowRef(props.contextmenu);
-const auth = shallowRef<Ermcp.AccountMenu[]>([]);
+const auth = shallowRef<Ermcp.UserMenu[]>([]);
 
 // 数据列表
 const dataList = computed(() => {

+ 5 - 5
src/packages/pc/router/asyncRouter.ts → src/packages/pc/router/dynamicRouter.ts

@@ -1,7 +1,7 @@
 import { RouteRecordRaw } from 'vue-router'
 import { AuthType } from '@/constants/enum/menu'
 import { queryAccountMenu } from '@/services/api/account'
-import { storageData } from '@/stores'
+import { sessionData } from '@/stores'
 import router from '../router'
 
 export default new (class {
@@ -24,9 +24,9 @@ export default new (class {
      * @param routes 
      * @param parentName 
      */
-    private addRoutes(routes: Ermcp.AccountMenu[], parentName = '') {
+    private addRoutes(routes: Ermcp.UserMenu[], parentName = '') {
         routes.forEach((item) => {
-            if (item.authType === AuthType.Menu && item.component && item.url) {
+            if (item.authType === AuthType.Menu && item.component) {
                 let component;
                 switch (item.component) {
                     case 'Page': {
@@ -69,7 +69,7 @@ export default new (class {
      * @returns 
      */
     registerRoutes() {
-        const menus = storageData.getAccountMenus();
+        const menus = sessionData.getValue('userMenus');
         return new Promise((resolve, reject) => {
             this.addNotFound();
             if (menus.length) {
@@ -78,7 +78,7 @@ export default new (class {
             } else {
                 queryAccountMenu({
                     success: (res) => {
-                        storageData.setAccountMenus(res.data);
+                        sessionData.setValue('userMenus', res.data);
                         this.addRoutes(res.data);
                         resolve(true);
                     },

+ 8 - 8
src/packages/pc/router/index.ts

@@ -1,12 +1,12 @@
 import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
-import { storageData } from '@/stores'
-import asyncRouter from './asyncRouter'
+import { sessionData } from '@/stores'
+import dynamicRouter from './dynamicRouter'
 import service from '@/services'
 
 const routes: Array<RouteRecordRaw> = [
     {
         path: '/',
-        redirect: () => storageData.getLoginInfo('Token') ? '/market/futures' : '/login', // 重定向到默认页面
+        redirect: () => sessionData.getLoginInfo('Token') ? '/market/futures' : '/login', // 重定向到默认页面
     },
     {
         path: '/login',
@@ -39,8 +39,8 @@ router.beforeEach((to, from, next) => {
 
     // 判断服务是否加载完成
     if (service.isReady) {
-        if (storageData.getLoginInfo('Token')) {
-            if (asyncRouter.isReady) {
+        if (sessionData.getLoginInfo('Token')) {
+            if (dynamicRouter.isReady) {
                 if (isLoginOrRegister) {
                     next('/');
                 } else {
@@ -48,15 +48,15 @@ router.beforeEach((to, from, next) => {
                 }
             } else {
                 // 注册动态路由
-                asyncRouter.registerRoutes().then(() => {
-                    asyncRouter.isReady = true;
+                dynamicRouter.registerRoutes().then(() => {
+                    dynamicRouter.isReady = true;
                     next({ ...to, replace: true });
                 }).catch(() => {
                     // 404?
                 })
             }
         } else {
-            asyncRouter.isReady = false;
+            dynamicRouter.isReady = false;
             if (isLoginOrRegister) {
                 next();
             } else {

+ 13 - 11
src/packages/pc/views/setting/customer/main/components/edit/index.vue

@@ -66,21 +66,23 @@
             <el-form-item label="联系电话">
                 <el-input placeholder="请输入" v-model="formItem.telphone" />
             </el-form-item>
-            <el-form-item class="row" label="通讯地址">
-                <el-select v-model="formItem.provinceid"></el-select>
-                <el-select v-model="formItem.cityid"></el-select>
-                <el-select v-model="formItem.districtid"></el-select>
+            <el-form-item class="el-form-item--row" label="通讯地址">
+                <div class="el-form-item--col">
+                    <el-select v-model="formItem.provinceid"></el-select>
+                    <el-select v-model="formItem.cityid"></el-select>
+                    <el-select v-model="formItem.districtid"></el-select>
+                </div>
             </el-form-item>
-            <el-form-item class="row">
+            <el-form-item class="el-form-item--row">
                 <el-input placeholder="请输入" v-model="formItem.ipaddress" />
             </el-form-item>
-            <el-form-item class="row" label="备注">
+            <el-form-item class="el-form-item--row" label="备注">
                 <el-input placeholder="请输入" v-model="formItem.remark" />
             </el-form-item>
         </el-form>
         <template #footer>
-            <el-button @click="cancel(false)" v-loading="loading" plain>取消</el-button>
-            <el-button type="primary" v-loading="loading" @click="onSubmit">提交</el-button>
+            <el-button @click="onCancel(false)" :loading="loading" plain>取消</el-button>
+            <el-button type="primary" :loading="loading" @click="onSubmit">提交</el-button>
         </template>
     </app-drawer>
 </template>
@@ -107,7 +109,7 @@ const refresh = ref(false)
 const formRef = ref<FormInstance>()
 
 const formRules: FormRules = {
-    userinfotype: [{ required: true, type: 'number', message: '请选择证件类型' }],
+    userinfotype: [{ required: true, message: '请选择客户类型' }],
     username: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
     customername: [{ required: true, message: '请输入企业名称', trigger: 'blur' }],
     nickname: [{ required: true, message: '请输入企业简称', trigger: 'blur' }],
@@ -131,7 +133,7 @@ const formRules: FormRules = {
     ],
 }
 
-const cancel = (isRefresh = false) => {
+const onCancel = (isRefresh = false) => {
     show.value = false
     refresh.value = isRefresh
 }
@@ -141,7 +143,7 @@ const onSubmit = () => {
         if (valid) {
             updateCustomerInfo().then(() => {
                 ElMessage.success('提交成功')
-                cancel(true)
+                onCancel(true)
             }).catch((err) => {
                 ElMessage.error('提交失败:' + err)
             })

+ 2 - 2
src/packages/pc/views/system/menu/components/edit/index.vue

@@ -77,7 +77,7 @@ const components = {
 
 const props = defineProps({
     selectedRow: {
-        type: Object as PropType<Ermcp.AccountMenu>,
+        type: Object as PropType<Ermcp.UserMenu>,
         default: () => ({
             id: 0,
             authType: AuthType.Menu,
@@ -95,7 +95,7 @@ const props = defineProps({
     }
 })
 
-const { accountMenus } = useAuth()
+const { userMenus } = useAuth()
 const show = ref(true)
 const form = reactive({ ...props.selectedRow })
 

+ 4 - 4
src/packages/pc/views/system/menu/index.vue

@@ -21,12 +21,12 @@ import { useAuth } from '@/hooks/auth'
 import AppAuthOperation from '@pc/components/modules/auth-operation/index.vue'
 import AppTable from '@pc/components/base/table/index.vue'
 
-const { accountMenus } = useAuth()
-const { dataList } = useDataTable<Ermcp.AccountMenu>()
+const { userMenus } = useAuth()
+const { dataList } = useDataTable<Ermcp.UserMenu>()
 const tableRef = ref()
 const isRowExpansion = ref(false)
 
-dataList.value = accountMenus;
+dataList.value = userMenus;
 
 const columns = ref([
     {
@@ -61,7 +61,7 @@ const tableExpandAll = () => {
     const table = tableRef.value.getRef
     isRowExpansion.value = !isRowExpansion.value
 
-    const toggleRowExpansionAll = (data: Ermcp.AccountMenu[]) => {
+    const toggleRowExpansionAll = (data: Ermcp.UserMenu[]) => {
         data.forEach((item) => {
             table.toggleRowExpansion(item, isRowExpansion.value)
             if (item.children) {

+ 3 - 3
src/packages/pc/views/system/role/components/auth/index.vue

@@ -6,7 +6,7 @@
             <el-breadcrumb-item>{{ selectedRow.roleName }}</el-breadcrumb-item>
         </el-breadcrumb>
         <el-scrollbar height="300px">
-            <el-tree :data="accountMenus" :props="{ label: 'title' }" :expand-on-click-node="false" show-checkbox
+            <el-tree :data="userMenus" :props="{ label: 'title' }" :expand-on-click-node="false" show-checkbox
                 check-on-click-node default-expand-all />
         </el-scrollbar>
         <template #footer>
@@ -23,12 +23,12 @@ import AppDrawer from '@pc/components/base/drawer/index.vue'
 
 defineProps({
     selectedRow: {
-        type: Object as PropType<Ermcp.AccountRole>,
+        type: Object as PropType<Ermcp.UserRole>,
         default: () => ({})
     }
 })
 
-const { accountMenus } = useAuth()
+const { userMenus } = useAuth()
 const show = ref(true)
 </script>
 

+ 1 - 1
src/packages/pc/views/system/role/index.vue

@@ -17,7 +17,7 @@ import { queryAccountRole } from '@/services/api/account'
 import AppAuthOperation from '@pc/components/modules/auth-operation/index.vue'
 import AppTable from '@pc/components/base/table/index.vue'
 
-const { dataList } = useDataTable<Ermcp.AccountRole>()
+const { dataList } = useDataTable<Ermcp.UserRole>()
 
 const columns = ref([
     {

+ 2 - 2
src/services/api/account/index.ts

@@ -34,7 +34,7 @@ export function queryLoginData(params: HttpRequest<{ req: Ermcp.LoginQueryReq, r
 /**
  * 查询账户菜单
  */
-export function queryAccountMenu(params: HttpRequest<{ rsp: Ermcp.AccountMenu[] }>) {
+export function queryAccountMenu(params: HttpRequest<{ rsp: Ermcp.UserMenu[] }>) {
     return httpRequest('/account/menu', 'get', params);
 }
 
@@ -48,6 +48,6 @@ export function queryTaAccounts(params: HttpRequest<{ req: Ermcp.TaAccountsReq,
 /**
  * 查询账户角色
  */
-export function queryAccountRole(params: HttpRequest<{ rsp: Ermcp.AccountRole[] }>) {
+export function queryAccountRole(params: HttpRequest<{ rsp: Ermcp.UserRole[] }>) {
     return httpRequest('/account/role', 'get', params);
 }

+ 7 - 0
src/services/api/common/index.ts

@@ -13,4 +13,11 @@ export function getServerTime(params: HttpRequest<{ rsp: string }>) {
  */
 export function queryTableDefine(params: HttpRequest<{ req: Ermcp.TableDefineReq, rsp: Ermcp.TableDefineRsp[] }>) {
     return httpRequest('/Common/QueryTableDefine', 'get', params);
+}
+
+/**
+ * 查询所有枚举信息
+ */
+export function queryAllEnums(params: HttpRequest<{ req: Ermcp.EnumReq, rsp: Ermcp.EnumRsp[] }>) {
+    return httpRequest('/Common/GetAllEnums', 'get', params);
 }

+ 2 - 2
src/services/http/index.ts

@@ -2,7 +2,7 @@ import axios, { AxiosRequestConfig, Method } from 'axios'
 //import qs from 'qs'
 //import cryptojs from 'crypto-js'
 import { addPending, removePending } from './pending'
-import { storageData } from '@/stores'
+import { sessionData } from '@/stores'
 import { HttpRequest, HttpResponse, ResultCode } from './interface'
 import service from '@/services'
 
@@ -20,7 +20,7 @@ http.interceptors.request.use(
 
         //请求头签名
         const sign = {
-            token: storageData.getLoginInfo('Token'),
+            token: sessionData.getLoginInfo('Token'),
             signsecret: 'qz7qWOMXKTMT5JlDs5w4NTPwWeR3xhF1v6wqbZ9cExmP6cc3spvNAp1wJJ1SqRI5',
             timestamp: new Date().getTime(),
         };

+ 3 - 3
src/services/language/index.ts

@@ -1,13 +1,13 @@
 import axios from 'axios'
 import { createI18n } from 'vue-i18n'
 import { Language } from '@/constants/enum/language'
-import { storageData } from '@/stores'
+import { localData } from '@/stores'
 
 export default new (class {
     i18n = createI18n()
 
     constructor() {
-        const lang = storageData.getLanguage()
+        const lang = localData.getValue('lang')
         this.setLanguage(lang)
     }
 
@@ -25,6 +25,6 @@ export default new (class {
         }
 
         this.i18n.global.locale = lang
-        storageData.setLanguage(lang);
+        localData.setValue('lang', lang);
     }
 })

+ 3 - 4
src/services/socket/quote/index.ts

@@ -4,7 +4,7 @@ import { FunCode } from '@/constants/enum/funcode'
 import { QuoteRequest } from './interface'
 import { subscribeListToByteArrary } from './build/encode'
 import { parseSubscribeRsp } from './build/decode'
-import { storageData } from '@/stores'
+import { sessionData } from '@/stores'
 import socket from '../index'
 
 /**
@@ -12,9 +12,8 @@ import socket from '../index'
  * @param params 
  */
 function quoteServerMiddleware(params: QuoteRequest): Promise<Proto.QuoteRsp[]> {
-    const token = storageData.getLoginInfo('Token')
-    const loginId = storageData.getLoginInfo('LoginID')
-    const content = subscribeListToByteArrary(params.data, token, Long.fromNumber(loginId));
+    const { LoginID, Token } = sessionData.getValue('loginInfo');
+    const content = subscribeListToByteArrary(params.data, Token, Long.fromNumber(LoginID));
 
     return new Promise((resolve, reject) => {
         socket.sendQuoteServer({

+ 2 - 2
src/services/socket/trade/index.ts

@@ -1,7 +1,7 @@
 import { v4 } from 'uuid'
 import { Package50 } from '@/utils/websocket/package'
 import { FunCode } from '@/constants/enum/funcode'
-import { storageData } from '@/stores'
+import { sessionData } from '@/stores'
 import { IMessageHead } from './protobuf/proto'
 import { TradeRequest, TradeResponse } from './interface'
 import Protobuf from './protobuf'
@@ -16,7 +16,7 @@ function getProtoHeader(funCode: keyof typeof FunCode, header?: IMessageHead, ma
         FunCode: FunCode[funCode],
         UUID: v4(),
         AccessID: 0,
-        UserID: storageData.getLoginInfo('UserID'),
+        UserID: sessionData.getLoginInfo('UserID'),
         ...(header ?? {})
     }
     if (marketId) {

+ 6 - 4
src/stores/index.ts

@@ -1,18 +1,20 @@
-import storageData from './modules/storage'
+import { localData, sessionData } from './modules/storage'
 import commonStore from './modules/common'
 import accountStore from './modules/account'
 import futuresStore from './modules/futures'
 
 /**
- * 重置公共数据
+ * 重置数据
  */
 const resetStore = () => {
-    storageData.reset()
+    localData.clear()
+    sessionData.clear()
     accountStore.reset()
 }
 
 export {
-    storageData,
+    localData,
+    sessionData,
     commonStore,
     accountStore,
     futuresStore,

+ 3 - 3
src/stores/modules/account.ts

@@ -5,7 +5,7 @@ import { BuyOrSell } from '@/constants/enum/buyorsell'
 import { queryTaAccounts } from '@/services/api/account'
 import { queryErmcpTradePosition } from '@/services/api/trade'
 import subscribe from '@/services/subscribe'
-import storageData from './storage'
+import { sessionData } from './storage'
 import futuresStore from './futures'
 
 function useFormula(item: Ermcp.TradePositionRsp) {
@@ -77,7 +77,7 @@ export default new (class {
             const { calcProfitLoss } = useFormula(item)
             res.push({
                 ...item,
-                positionpl: calcProfitLoss(),
+                positionpl: Number(calcProfitLoss()),
             })
             return res
         }, [] as Ermcp.TradePositionRsp[])
@@ -93,7 +93,7 @@ export default new (class {
 
         this.pending = queryTaAccounts({
             data: {
-                loginID: storageData.getLoginInfo('LoginID')
+                loginID: sessionData.getLoginInfo('LoginID')
             },
             success: (res) => {
                 const dataList = res.data

+ 2 - 2
src/stores/modules/common.ts

@@ -1,6 +1,6 @@
 import { ref } from 'vue'
 import { queryLoginData } from '@/services/api/account'
-import storageData from './storage'
+import { sessionData } from './storage'
 
 /**
  * 公共存储类
@@ -23,7 +23,7 @@ export default new (class {
         this.loading.value = true
         return queryLoginData({
             data: {
-                loginID: storageData.getLoginInfo('LoginID')
+                loginID: sessionData.getLoginInfo('LoginID')
             },
             success: (res) => {
                 this.loginData.value = res.data

+ 2 - 2
src/stores/modules/futures.ts

@@ -1,6 +1,6 @@
 import { ref, computed } from 'vue'
 import { queryGoodsList } from '@/services/api/goods'
-import storageData from './storage'
+import { sessionData } from './storage'
 
 /**
  * 商品存储类
@@ -49,7 +49,7 @@ export default new (class {
         this.loading.value = true
         return queryGoodsList({
             data: {
-                userid: storageData.getLoginInfo('UserID')
+                userid: sessionData.getLoginInfo('UserID')
             },
             success: (res) => {
                 this.goodsList.value = res.data

+ 53 - 49
src/stores/modules/storage.ts

@@ -1,3 +1,4 @@
+import { queryAllEnums, queryTableDefine } from '@/services/api/common'
 import { AppTheme } from '@/constants/enum/theme'
 import { Language } from '@/constants/enum/language'
 import WebStorage from '@/utils/storage'
@@ -7,6 +8,7 @@ import plus from '@/utils/h5plus'
  * 初始数据
  */
 const initData: Store.GlobalStorage = {
+    appTheme: AppTheme.Default,
     lang: Language.ZhCN,
     loginInfo: {
         AccountIDs: [],
@@ -19,21 +21,17 @@ const initData: Store.GlobalStorage = {
         MemberUserID: 0,
         Token: '',
     },
-    bankSignDetail: '',
-    cusBank: '',
-    errorInfos: '',
-    allEnums: '',
-    errorCodes: [],
-    appTheme: AppTheme.Default,
-    rowNumber: '',
-    menus: [],
+    userMenus: [],
+    allEnums: [],
+    tableColumns: [],
 }
 
-export default new (class {
-    private localData = new WebStorage(localStorage, initData) // 本地存储实例
-    private sessionData = new WebStorage(sessionStorage, initData) // 会话存储实例
-
+/**
+ * 本地存储实例
+ */
+export const localData = new (class extends WebStorage<Store.GlobalStorage>{
     constructor() {
+        super(localStorage, initData)
         document.addEventListener('DOMContentLoaded', this.loadTheme, false)
     }
 
@@ -41,7 +39,7 @@ export default new (class {
      * 加载主题
      */
     private loadTheme = () => {
-        const theme = this.localData.getValue('appTheme')
+        const theme = this.getValue('appTheme')
         this.setStatusBarTheme(theme)
         document.documentElement.setAttribute('theme', theme)
         document.removeEventListener('DOMContentLoaded', this.loadTheme)
@@ -65,58 +63,64 @@ export default new (class {
     }
 
     /**
-     * 获取登录信息
+     * 设置主题
      * @param key 
-     * @returns 
      */
-    getLoginInfo = <K extends keyof Proto.LoginRsp>(key: K) => {
-        return this.localData.getValue('loginInfo')[key] || this.sessionData.getValue('loginInfo')[key]
-    }
-
-    setLoginInfo = (value: Proto.LoginRsp) => {
-        this.sessionData.setValue('loginInfo', value)
-    }
-
-    getAccountMenus = () => {
-        return this.sessionData.getValue('menus')
+    setTheme = (key: keyof typeof AppTheme) => {
+        const theme = AppTheme[key]
+        this.setStatusBarTheme(theme)
+        document.documentElement.setAttribute('theme', theme)
+        this.setValue('appTheme', theme)
     }
+})
 
-    setAccountMenus = (value: Ermcp.AccountMenu[]) => {
-        return this.sessionData.setValue('menus', value)
+/**
+ * 会话存储实例
+ */
+export const sessionData = new (class extends WebStorage<Store.GlobalStorage>{
+    constructor() {
+        super(sessionStorage, initData)
     }
 
     /**
-     * 获取当前主题
+     * 获取登录信息
+     * @param key 
      * @returns 
      */
-    getTheme = () => {
-        return this.localData.getRef('appTheme')
+    getLoginInfo = <K extends keyof Proto.LoginRsp>(key: K) => {
+        return this.getValue('loginInfo')[key]
     }
 
     /**
-     * 设置主题
-     * @param key 
+     * 获取所有枚举列表
+     * @returns 
      */
-    setTheme = (key: keyof typeof AppTheme) => {
-        const theme = AppTheme[key]
-        this.setStatusBarTheme(theme)
-        document.documentElement.setAttribute('theme', theme)
-        this.localData.setValue('appTheme', theme)
-    }
-
-    getLanguage = () => {
-        return this.localData.getValue('lang')
-    }
-
-    setLanguage = (lang: Language) => {
-        this.localData.setValue('lang', lang)
+    getAllEnumList = () => {
+        if (this.getValue('allEnums').length) {
+            return Promise.resolve()
+        }
+        return queryAllEnums({
+            success: (res) => {
+                this.setValue('allEnums', res.data)
+            }
+        })
     }
 
     /**
-     * 重置数据
+     * 获取表格列列表
+     * @returns 
      */
-    reset = () => {
-        this.localData.clear()
-        this.sessionData.clear()
+    getTableColumnList = () => {
+        if (this.getValue('tableColumns').length) {
+            return Promise.resolve()
+        }
+        return queryTableDefine({
+            data: {
+                tableType: 2
+            },
+            success: (res) => {
+                this.setValue('tableColumns', res.data)
+            }
+        })
     }
 })

+ 3 - 3
src/types/ermcp/account.d.ts

@@ -263,7 +263,7 @@ declare global {
         }
 
         /** 账号菜单 */
-        interface AccountMenu {
+        interface UserMenu {
             id: number; // 自增ID
             authType: AuthType; // 权限类型
             title: string; // 标题
@@ -277,11 +277,11 @@ declare global {
             sort: number; // 排序
             hidden: boolean; // 是否隐藏
             remark: string; // 备注
-            children?: AccountMenu[],
+            children?: UserMenu[],
         }
 
         /** 账号角色 */
-        interface AccountRole {
+        interface UserRole {
             id: number; // 自增ID
             roleName: string; // 角色名称
             createdAt: string;  // 创建时间

+ 22 - 0
src/types/ermcp/enum.d.ts

@@ -0,0 +1,22 @@
+/** 企业风管 */
+declare namespace Ermcp {
+    /** 枚举信息 请求 */
+    interface EnumReq {
+        autoid?: number; // 起始自增ID
+    }
+
+    /** 枚举信息 响应 */
+    interface EnumRsp {
+        autoid: number; // 自增ID
+        bankmappedvalue: string; // 银行服务对应值
+        enumdiccode: string; // 所属枚举代码
+        enumdicid: number; // 所属枚举ID
+        enumdicname: string; // 枚举项名称
+        enumitemname: number; // 枚举项值
+        enumitemstatus: number; // 枚举项状态 - 1.启用 2.不启用
+        enumitemvalue: string; // 通用值 - [币种通用简写]
+        param1: string; // 参数1[币种:币种小数位]
+        param2: string;  // 参数1[币种:币种显示单位]
+        remark: string; // 备注
+    }
+}

+ 5 - 21
src/types/store/globalStorage.d.ts

@@ -5,28 +5,12 @@ declare global {
     namespace Store {
         /** 本地缓存数据 */
         interface GlobalStorage {
-            lang: Language
-            loginInfo: Proto.LoginRsp; // 账号登录返回信息 token等
-            bankSignDetail: string; // 银行签约信息详情
-            cusBank: string; // 托管银行
-            errorInfos: string; // 数据库错误信息
-            allEnums: string; // 所有枚举信息
-            errorCodes: GlobalStorage.ErrorCode[];
             appTheme: AppTheme; // 应用主题色
-            rowNumber: string; // 数据库错误信息 时间戳
-            menus: Ermcp.AccountMenu[];
-        }
-
-        namespace GlobalStorage {
-            /** 错误代码 */
-            interface ErrorCode {
-                description: string;
-                errorcode: string;
-                errorid: number;
-                modulecode: string;
-                operatecode: string;
-                rownumber: string;
-            }
+            lang: Language;
+            loginInfo: Proto.LoginRsp; // 账号登录返回信息 token等
+            userMenus: Ermcp.UserMenu[];
+            allEnums: Ermcp.EnumRsp[]; // 所有枚举
+            tableColumns: Ermcp.TableDefineRsp[];
         }
     }
 }