create-jnrs-vue 1.2.21 → 1.2.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/jnrs-vue/.env.development +1 -1
- package/jnrs-vue/README.md +1 -1
- package/jnrs-vue/package.json +3 -3
- package/jnrs-vue/src/api/common/index.ts +2 -2
- package/jnrs-vue/src/api/demos/index.ts +73 -32
- package/jnrs-vue/src/api/request.ts +10 -11
- package/jnrs-vue/src/api/system/index.ts +27 -26
- package/jnrs-vue/src/components/common/CardTable.vue +3 -3
- package/jnrs-vue/src/components/common/DictTag.vue +1 -1
- package/jnrs-vue/src/components/common/ImageView.vue +4 -4
- package/jnrs-vue/src/components/common/PdfView.vue +4 -4
- package/jnrs-vue/src/components/select/SelectManager.vue +2 -2
- package/jnrs-vue/src/composables/useCrud.ts +29 -10
- package/jnrs-vue/src/layout/RouterTabs.vue +6 -6
- package/jnrs-vue/src/layout/SideMenuItem.vue +2 -2
- package/jnrs-vue/src/layout/TopHeader.vue +2 -1
- package/jnrs-vue/src/layout/index.vue +2 -1
- package/jnrs-vue/src/locales/en.ts +1 -1
- package/jnrs-vue/src/main.ts +2 -7
- package/jnrs-vue/src/router/index.ts +5 -4
- package/jnrs-vue/src/stores/index.ts +8 -0
- package/jnrs-vue/src/stores/system/auth.ts +67 -0
- package/jnrs-vue/src/types/index.ts +2 -81
- package/jnrs-vue/src/types/system.d.ts +115 -0
- package/jnrs-vue/src/types/system.js +1 -0
- package/jnrs-vue/src/types/system.ts +124 -0
- package/jnrs-vue/src/types/webSocket.ts +4 -4
- package/jnrs-vue/src/utils/dict.ts +59 -0
- package/jnrs-vue/src/utils/file.ts +1 -1
- package/jnrs-vue/src/utils/index.ts +4 -0
- package/jnrs-vue/src/utils/packages.ts +6 -65
- package/jnrs-vue/src/utils/permissions.ts +1 -1
- package/jnrs-vue/src/views/demos/crud/index.vue +29 -17
- package/jnrs-vue/src/views/demos/simpleTable/index.vue +2 -2
- package/jnrs-vue/src/views/demos/unitTest/RequestPage.vue +30 -7
- package/jnrs-vue/src/views/demos/unitTest/index.vue +2 -2
- package/jnrs-vue/src/views/home/index.vue +1 -1
- package/jnrs-vue/src/views/login/index.vue +2 -2
- package/jnrs-vue/src/views/system/dict/index.vue +4 -4
- package/jnrs-vue/src/views/system/mine/baseInfo.vue +2 -2
- package/jnrs-vue/src/views/system/mine/securitySettings.vue +1 -1
- package/jnrs-vue/src/views/visual/index.vue +3 -4
- package/jnrs-vue/vite.config.ts +2 -2
- package/jnrs-vue/viteMockServe/fail.ts +3 -3
- package/jnrs-vue/viteMockServe/file.ts +1 -1
- package/jnrs-vue/viteMockServe/index.ts +7 -16
- package/jnrs-vue/viteMockServe/json/loginRes_user.json +1 -1
- package/jnrs-vue/viteMockServe/success.ts +5 -5
- package/package.json +1 -1
- package/jnrs-vue/src/api/user/index.ts +0 -12
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { useSystemStore } from '@jnrs/vue-core/pinia'
|
|
3
|
-
import type {
|
|
3
|
+
import type { IMenuItem } from '@jnrs/vue-core'
|
|
4
4
|
|
|
5
5
|
defineProps<{
|
|
6
|
-
listItem:
|
|
6
|
+
listItem: IMenuItem
|
|
7
7
|
}>()
|
|
8
8
|
|
|
9
9
|
const { menuCollapse } = useSystemStore()
|
|
@@ -4,7 +4,8 @@ import { storeToRefs } from 'pinia'
|
|
|
4
4
|
import { ElLoading, ElMessageBox } from 'element-plus'
|
|
5
5
|
import { handleRouter } from '@jnrs/vue-core/router'
|
|
6
6
|
import { GlobalSetting } from '@jnrs/vue-core/components'
|
|
7
|
-
import { useSystemStore,
|
|
7
|
+
import { useSystemStore, useMenuStore } from '@jnrs/vue-core/pinia'
|
|
8
|
+
import { useAuthStore } from '@/stores'
|
|
8
9
|
import { useI18n } from '@/locales'
|
|
9
10
|
import { LogoutApi } from '@/api/system'
|
|
10
11
|
import ImageView from '@/components/common/ImageView.vue'
|
|
@@ -3,7 +3,8 @@ import { ref, watch, toRefs } from 'vue'
|
|
|
3
3
|
import SideMenu from './SideMenu.vue'
|
|
4
4
|
import TopHeader from './TopHeader.vue'
|
|
5
5
|
import RouterTabs from './RouterTabs.vue'
|
|
6
|
-
import {
|
|
6
|
+
import { useSystemStore } from '@jnrs/vue-core/pinia'
|
|
7
|
+
import { useAuthStore } from '@/stores'
|
|
7
8
|
|
|
8
9
|
const watermarkFont = ref({
|
|
9
10
|
color: 'rgba(0, 0, 0, 0)',
|
package/jnrs-vue/src/main.ts
CHANGED
|
@@ -4,13 +4,12 @@ import '@jnrs/shared/styles/theme.scss'
|
|
|
4
4
|
import '@/assets/styles/index.scss'
|
|
5
5
|
|
|
6
6
|
import { createApp } from 'vue'
|
|
7
|
-
import { createPinia } from 'pinia'
|
|
8
|
-
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
|
|
9
|
-
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
|
10
7
|
import App from './App.vue'
|
|
8
|
+
import pinia from '@/stores'
|
|
11
9
|
import { router } from './router'
|
|
12
10
|
import { i18n } from './locales'
|
|
13
11
|
import { permissions } from './directives/permissions'
|
|
12
|
+
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
|
14
13
|
|
|
15
14
|
const app = createApp(App)
|
|
16
15
|
|
|
@@ -21,10 +20,6 @@ for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
|
|
21
20
|
app.component(key, component)
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
// pinia 相关
|
|
25
|
-
const pinia = createPinia()
|
|
26
|
-
pinia.use(piniaPluginPersistedstate)
|
|
27
|
-
|
|
28
23
|
app.use(pinia)
|
|
29
24
|
app.use(router)
|
|
30
25
|
app.use(i18n)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { FileModules, RouteLocationNormalizedGeneric } from '@jnrs/vue-core/router'
|
|
2
|
-
import type {
|
|
2
|
+
import type { IMenuItem } from '@jnrs/vue-core'
|
|
3
3
|
import { LAYOUT_NAME, GLOBAL_COMPONENT, routes } from './routes'
|
|
4
4
|
import { createVueRouter } from '@jnrs/vue-core/router'
|
|
5
|
-
import {
|
|
5
|
+
import { useMenuStore } from '@jnrs/vue-core/pinia'
|
|
6
|
+
import { useAuthStore } from '@/stores'
|
|
6
7
|
import { MenuApi } from '@/api/system'
|
|
7
8
|
import { hasMenuViewPermission } from '@/utils/permissions'
|
|
8
9
|
|
|
@@ -12,7 +13,7 @@ const fileModules = import.meta.glob('/src/views/**/*.vue') as FileModules
|
|
|
12
13
|
* 递归过滤菜单树,仅保留当前用户有权限访问的节点
|
|
13
14
|
* TODO 如果是后端返回的数据就没必要判断了,后端会判断
|
|
14
15
|
*/
|
|
15
|
-
function filterMenuByPermission(menus:
|
|
16
|
+
function filterMenuByPermission(menus: IMenuItem[]): IMenuItem[] {
|
|
16
17
|
return menus
|
|
17
18
|
.map((item) => {
|
|
18
19
|
const children = item.children ? filterMenuByPermission(item.children) : []
|
|
@@ -27,7 +28,7 @@ function filterMenuByPermission(menus: MenuItem[]): MenuItem[] {
|
|
|
27
28
|
}
|
|
28
29
|
return null
|
|
29
30
|
})
|
|
30
|
-
.filter(Boolean) as
|
|
31
|
+
.filter(Boolean) as IMenuItem[]
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
const router = createVueRouter({
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ref } from 'vue'
|
|
2
|
+
import { defineStore } from 'pinia'
|
|
3
|
+
import type { IDict, IUser, IRole } from '@/types'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* useAuthStore 权限仓库
|
|
7
|
+
* @returns hasAuthenticated 是否已身份验证
|
|
8
|
+
* @returns token 身份验证凭证
|
|
9
|
+
* @returns userInfo 用户信息
|
|
10
|
+
* @returns dict 字典
|
|
11
|
+
* @returns role 角色权限
|
|
12
|
+
* @methods asyncSetAuth 设置权限信息
|
|
13
|
+
* @methods clearAuth 清除权限信息
|
|
14
|
+
*/
|
|
15
|
+
export const useAuthStore = defineStore(
|
|
16
|
+
'jnrs-vue:auth',
|
|
17
|
+
() => {
|
|
18
|
+
const hasAuthenticated = ref(false)
|
|
19
|
+
const token = ref<string | null>(null)
|
|
20
|
+
const userInfo = ref<IUser | null>(null)
|
|
21
|
+
const dict = ref<IDict>({})
|
|
22
|
+
const role = ref<IRole[]>([])
|
|
23
|
+
|
|
24
|
+
const setToken = (d: string) => {
|
|
25
|
+
token.value = d
|
|
26
|
+
hasAuthenticated.value = true
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const setUserInfo = (d: IUser) => {
|
|
30
|
+
userInfo.value = d
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const setDict = (d: IDict) => {
|
|
34
|
+
dict.value = d
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const setRole = (d: IRole[]) => {
|
|
38
|
+
role.value = d
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const clearAuth = () => {
|
|
42
|
+
token.value = null
|
|
43
|
+
userInfo.value = null
|
|
44
|
+
dict.value = {}
|
|
45
|
+
role.value = []
|
|
46
|
+
hasAuthenticated.value = false
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
hasAuthenticated,
|
|
51
|
+
token,
|
|
52
|
+
userInfo,
|
|
53
|
+
dict,
|
|
54
|
+
role,
|
|
55
|
+
setUserInfo,
|
|
56
|
+
setToken,
|
|
57
|
+
setDict,
|
|
58
|
+
setRole,
|
|
59
|
+
clearAuth
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
persist: {
|
|
64
|
+
pick: ['hasAuthenticated', 'token', 'userInfo', 'dict']
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
)
|
|
@@ -1,81 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*/
|
|
4
|
-
export interface Attachment {
|
|
5
|
-
/**
|
|
6
|
-
* 数据 id
|
|
7
|
-
*/
|
|
8
|
-
id: number
|
|
9
|
-
/**
|
|
10
|
-
* 文件 id
|
|
11
|
-
*/
|
|
12
|
-
documentId: number
|
|
13
|
-
/**
|
|
14
|
-
* 文件名
|
|
15
|
-
*/
|
|
16
|
-
fileName: string
|
|
17
|
-
/**
|
|
18
|
-
* 文件名唯一标识(用于文件获取 API)
|
|
19
|
-
*/
|
|
20
|
-
uniqueFileName: string
|
|
21
|
-
/**
|
|
22
|
-
* MIME 类型
|
|
23
|
-
*/
|
|
24
|
-
fileType: string
|
|
25
|
-
/**
|
|
26
|
-
* 文件大小 单位:字节(Bytes)
|
|
27
|
-
*/
|
|
28
|
-
fileSize: number
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 文件容器(用于图片或附件)
|
|
33
|
-
*/
|
|
34
|
-
export interface Document {
|
|
35
|
-
id: number
|
|
36
|
-
description: string | null
|
|
37
|
-
attachments: Attachment[]
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* 图片 & 附件数据
|
|
42
|
-
*/
|
|
43
|
-
export interface FileContainer {
|
|
44
|
-
/**
|
|
45
|
-
* 图片
|
|
46
|
-
*/
|
|
47
|
-
imageDocument?: Document
|
|
48
|
-
/**
|
|
49
|
-
* 附件
|
|
50
|
-
*/
|
|
51
|
-
attachmentDocument?: Document
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* 分页
|
|
56
|
-
*/
|
|
57
|
-
export interface Pagination {
|
|
58
|
-
/**
|
|
59
|
-
* 当前页码
|
|
60
|
-
*/
|
|
61
|
-
pageNo: number
|
|
62
|
-
/**
|
|
63
|
-
* 每页大小
|
|
64
|
-
*/
|
|
65
|
-
pageSize: number
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* 分页列表数据
|
|
70
|
-
*/
|
|
71
|
-
// eslint-disable-next-line
|
|
72
|
-
export interface PageTableData<T = Record<string, any>> extends Pagination {
|
|
73
|
-
/**
|
|
74
|
-
* 数据列表
|
|
75
|
-
*/
|
|
76
|
-
list: T[]
|
|
77
|
-
/**
|
|
78
|
-
* 数据总数
|
|
79
|
-
*/
|
|
80
|
-
count: number
|
|
81
|
-
}
|
|
1
|
+
export * from './system'
|
|
2
|
+
export * from './webSocket'
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 文件信息
|
|
3
|
+
*/
|
|
4
|
+
export interface IAttachment {
|
|
5
|
+
/**
|
|
6
|
+
* 数据 id
|
|
7
|
+
*/
|
|
8
|
+
id: number;
|
|
9
|
+
/**
|
|
10
|
+
* 文件 id
|
|
11
|
+
*/
|
|
12
|
+
documentId: number;
|
|
13
|
+
/**
|
|
14
|
+
* 文件名
|
|
15
|
+
*/
|
|
16
|
+
fileName: string;
|
|
17
|
+
/**
|
|
18
|
+
* 文件名唯一标识(用于文件获取 API)
|
|
19
|
+
*/
|
|
20
|
+
uniqueFileName: string;
|
|
21
|
+
/**
|
|
22
|
+
* MIME 类型
|
|
23
|
+
*/
|
|
24
|
+
fileType: string;
|
|
25
|
+
/**
|
|
26
|
+
* 文件大小 单位:字节(Bytes)
|
|
27
|
+
*/
|
|
28
|
+
fileSize: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 文件容器(用于图片或附件)
|
|
32
|
+
*/
|
|
33
|
+
export interface IDocument {
|
|
34
|
+
id: number;
|
|
35
|
+
description: string | null;
|
|
36
|
+
attachments: IAttachment[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 图片 & 附件数据
|
|
40
|
+
*/
|
|
41
|
+
export interface IFile {
|
|
42
|
+
/**
|
|
43
|
+
* 图片
|
|
44
|
+
*/
|
|
45
|
+
imageDocument?: IDocument;
|
|
46
|
+
/**
|
|
47
|
+
* 附件
|
|
48
|
+
*/
|
|
49
|
+
attachmentDocument?: IDocument;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 分页
|
|
53
|
+
*/
|
|
54
|
+
export interface IPagination {
|
|
55
|
+
/**
|
|
56
|
+
* 当前页码
|
|
57
|
+
*/
|
|
58
|
+
pageNo: number;
|
|
59
|
+
/**
|
|
60
|
+
* 每页大小
|
|
61
|
+
*/
|
|
62
|
+
pageSize: number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 分页列表数据
|
|
66
|
+
*/
|
|
67
|
+
export interface IPageTableData<T = Record<string, any>> extends IPagination {
|
|
68
|
+
/**
|
|
69
|
+
* 数据列表
|
|
70
|
+
*/
|
|
71
|
+
list: T[];
|
|
72
|
+
/**
|
|
73
|
+
* 数据总数
|
|
74
|
+
*/
|
|
75
|
+
count: number;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 用户信息
|
|
79
|
+
*/
|
|
80
|
+
export interface IUser {
|
|
81
|
+
id: number;
|
|
82
|
+
name: string;
|
|
83
|
+
role: number;
|
|
84
|
+
permissions?: string[];
|
|
85
|
+
jobTitle?: number;
|
|
86
|
+
workNo?: string;
|
|
87
|
+
workgroup?: string;
|
|
88
|
+
avatarFileName?: string;
|
|
89
|
+
[key: string]: unknown;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 字典
|
|
93
|
+
*/
|
|
94
|
+
export interface IDictItem {
|
|
95
|
+
label: string;
|
|
96
|
+
value: string | number;
|
|
97
|
+
sequence: number;
|
|
98
|
+
displayColor?: string;
|
|
99
|
+
[key: string]: unknown;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* 字典键值对
|
|
103
|
+
*/
|
|
104
|
+
export interface IDict {
|
|
105
|
+
[key: string]: IDictItem[];
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 角色
|
|
109
|
+
*/
|
|
110
|
+
export interface IRole {
|
|
111
|
+
label: string;
|
|
112
|
+
value: string | number;
|
|
113
|
+
permissions?: string[];
|
|
114
|
+
[key: string]: unknown;
|
|
115
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 文件信息
|
|
3
|
+
*/
|
|
4
|
+
export interface IAttachment {
|
|
5
|
+
/**
|
|
6
|
+
* 数据 id
|
|
7
|
+
*/
|
|
8
|
+
id: number
|
|
9
|
+
/**
|
|
10
|
+
* 文件 id
|
|
11
|
+
*/
|
|
12
|
+
documentId: number
|
|
13
|
+
/**
|
|
14
|
+
* 文件名
|
|
15
|
+
*/
|
|
16
|
+
fileName: string
|
|
17
|
+
/**
|
|
18
|
+
* 文件名唯一标识(用于文件获取 API)
|
|
19
|
+
*/
|
|
20
|
+
uniqueFileName: string
|
|
21
|
+
/**
|
|
22
|
+
* MIME 类型
|
|
23
|
+
*/
|
|
24
|
+
fileType: string
|
|
25
|
+
/**
|
|
26
|
+
* 文件大小 单位:字节(Bytes)
|
|
27
|
+
*/
|
|
28
|
+
fileSize: number
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 文件容器(用于图片或附件)
|
|
33
|
+
*/
|
|
34
|
+
export interface IDocument {
|
|
35
|
+
id: number
|
|
36
|
+
description: string | null
|
|
37
|
+
attachments: IAttachment[]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 图片 & 附件数据
|
|
42
|
+
*/
|
|
43
|
+
export interface IFile {
|
|
44
|
+
/**
|
|
45
|
+
* 图片
|
|
46
|
+
*/
|
|
47
|
+
imageDocument?: IDocument
|
|
48
|
+
/**
|
|
49
|
+
* 附件
|
|
50
|
+
*/
|
|
51
|
+
attachmentDocument?: IDocument
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 分页
|
|
56
|
+
*/
|
|
57
|
+
export interface IPagination {
|
|
58
|
+
/**
|
|
59
|
+
* 当前页码
|
|
60
|
+
*/
|
|
61
|
+
pageNo: number
|
|
62
|
+
/**
|
|
63
|
+
* 每页大小
|
|
64
|
+
*/
|
|
65
|
+
pageSize: number
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 分页列表数据
|
|
70
|
+
*/
|
|
71
|
+
// eslint-disable-next-line
|
|
72
|
+
export interface IPageTableData<T = Record<string, any>> extends IPagination {
|
|
73
|
+
/**
|
|
74
|
+
* 数据列表
|
|
75
|
+
*/
|
|
76
|
+
list: T[]
|
|
77
|
+
/**
|
|
78
|
+
* 数据总数
|
|
79
|
+
*/
|
|
80
|
+
count: number
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 用户信息
|
|
85
|
+
*/
|
|
86
|
+
export interface IUser {
|
|
87
|
+
id: number
|
|
88
|
+
name: string
|
|
89
|
+
role: number
|
|
90
|
+
permissions?: string[]
|
|
91
|
+
jobTitle?: number
|
|
92
|
+
workNo?: string
|
|
93
|
+
workgroup?: string
|
|
94
|
+
avatarFileName?: string
|
|
95
|
+
[key: string]: unknown
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 字典
|
|
100
|
+
*/
|
|
101
|
+
export interface IDictItem {
|
|
102
|
+
label: string
|
|
103
|
+
value: string | number
|
|
104
|
+
sequence: number
|
|
105
|
+
displayColor?: string
|
|
106
|
+
[key: string]: unknown
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 字典键值对
|
|
111
|
+
*/
|
|
112
|
+
export interface IDict {
|
|
113
|
+
[key: string]: IDictItem[]
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* 角色
|
|
118
|
+
*/
|
|
119
|
+
export interface IRole {
|
|
120
|
+
label: string
|
|
121
|
+
value: string | number
|
|
122
|
+
permissions?: string[]
|
|
123
|
+
[key: string]: unknown
|
|
124
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface IMsgIdMessage {
|
|
2
2
|
msgId: string
|
|
3
3
|
d: unknown
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
export interface
|
|
6
|
+
export interface ITypeDataMessage {
|
|
7
7
|
type: string | number
|
|
8
8
|
data: unknown
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
// 类型守卫函数 MsgId 结构
|
|
12
|
-
export function isMsgIdMessage(msg: unknown): msg is
|
|
12
|
+
export function isMsgIdMessage(msg: unknown): msg is IMsgIdMessage {
|
|
13
13
|
return typeof msg === 'object' && msg !== null && 'msgId' in msg && 'd' in msg
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
// 类型守卫函数 Type 结构
|
|
17
|
-
export function isTypeDataMessage(msg: unknown): msg is
|
|
17
|
+
export function isTypeDataMessage(msg: unknown): msg is ITypeDataMessage {
|
|
18
18
|
return typeof msg === 'object' && msg !== null && 'type' in msg && 'data' in msg
|
|
19
19
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @Author : TanRui
|
|
3
|
+
* @WeChat : Tan578853789
|
|
4
|
+
* @File : dict.ts
|
|
5
|
+
* @Date : 2025/12/04
|
|
6
|
+
* @Desc. : 字典类函数
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { IDictItem } from '@/types'
|
|
10
|
+
import { useAuthStore } from '@/stores'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 根据字典名称获取字典数据
|
|
14
|
+
* @param name 字典名称
|
|
15
|
+
* @returns 某字典名称所对应的字典列表数据
|
|
16
|
+
*/
|
|
17
|
+
export const getDictList = (name: string): IDictItem[] => {
|
|
18
|
+
const { dict } = useAuthStore()
|
|
19
|
+
if (!name || !Object.hasOwn(dict, name)) return []
|
|
20
|
+
return dict[name]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 根据字典名称和字典值获取字典标签
|
|
25
|
+
* @param name 字典名称
|
|
26
|
+
* @param value 字典值
|
|
27
|
+
* @returns 某字典名称所对应的字典标签
|
|
28
|
+
*/
|
|
29
|
+
export const getDictLabel = (name: string, value: string | number): string => {
|
|
30
|
+
if (!name) return ''
|
|
31
|
+
const { dict } = useAuthStore()
|
|
32
|
+
if (!Object.hasOwn(dict, name)) return String(value)
|
|
33
|
+
return dict[name].find((d) => String(d.value) === String(value))?.label || String(value)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 根据字典名称和字典标签获取字典值
|
|
38
|
+
* @param name 字典名称
|
|
39
|
+
* @param label 字典标签
|
|
40
|
+
* @returns 某字典名称所对应的字典值
|
|
41
|
+
*/
|
|
42
|
+
export const getDictValue = (name: string, label: string): string | number | undefined => {
|
|
43
|
+
if (!name) return ''
|
|
44
|
+
const { dict } = useAuthStore()
|
|
45
|
+
if (!Object.hasOwn(dict, name)) return undefined
|
|
46
|
+
return dict[name].find((d) => String(d.label) === String(label))?.value || undefined
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 根据字典名称和字典值获取字典颜色
|
|
51
|
+
* @param name 字典名称
|
|
52
|
+
* @param value 字典值
|
|
53
|
+
* @returns 某字典名称所对应的字典颜色
|
|
54
|
+
*/
|
|
55
|
+
export const getDictColor = (name: string, value: string | number): string => {
|
|
56
|
+
const { dict } = useAuthStore()
|
|
57
|
+
if (!name || !Object.hasOwn(dict, name)) return ''
|
|
58
|
+
return dict[name].find((d) => String(d.value) === String(value))?.displayColor || ''
|
|
59
|
+
}
|
|
@@ -25,7 +25,7 @@ export const getFileUrl = async (uniqueFileName: string) => {
|
|
|
25
25
|
* @param fieldName - 要提取的对象字段名(默认 'id')
|
|
26
26
|
* @returns 提取出的 string | number 值,或 undefined
|
|
27
27
|
*/
|
|
28
|
-
export function extractFieldId(value: unknown, fieldName: string = 'id')
|
|
28
|
+
export function extractFieldId(value: unknown, fieldName: string = 'id') {
|
|
29
29
|
// 1. 排除 null 和 undefined
|
|
30
30
|
if (value == null) return undefined
|
|
31
31
|
|
|
@@ -7,86 +7,27 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { ElMessage, ElLoading } from 'element-plus'
|
|
10
|
-
import {
|
|
11
|
-
getDictList as _getDictList,
|
|
12
|
-
getDictLabel as _getDictLabel,
|
|
13
|
-
getDictValue as _getDictValue,
|
|
14
|
-
getDictColor as _getDictColor,
|
|
15
|
-
downloadByBlob as _downloadByBlob
|
|
16
|
-
} from '@jnrs/shared'
|
|
17
|
-
import { useAuthStore } from '@jnrs/vue-core/pinia'
|
|
18
|
-
import { objectToFormData as _objectToFormData } from '@jnrs/shared'
|
|
10
|
+
import { objectToFormData as _objectToFormData, downloadByBlob as _downloadByBlob } from '@jnrs/shared'
|
|
19
11
|
import { FileApi } from '@/api/common'
|
|
20
12
|
|
|
21
|
-
/**
|
|
22
|
-
* 根据字典名称获取字典数据
|
|
23
|
-
* @param name 字典名称
|
|
24
|
-
* @returns 某字典名称所对应的字典列表数据
|
|
25
|
-
*/
|
|
26
|
-
export const getDictList = (name: string) => {
|
|
27
|
-
const { dict } = useAuthStore()
|
|
28
|
-
if (dict) {
|
|
29
|
-
return _getDictList(name, dict)
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* 根据字典名称和字典值获取字典标签
|
|
35
|
-
* @param name 字典名称
|
|
36
|
-
* @param value 字典值
|
|
37
|
-
* @returns 某字典名称所对应的字典标签
|
|
38
|
-
*/
|
|
39
|
-
export const getDictLabel = (name: string, value: string | number) => {
|
|
40
|
-
const { dict } = useAuthStore()
|
|
41
|
-
if (dict) {
|
|
42
|
-
return _getDictLabel(name, value, dict)
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* 根据字典名称和字典标签获取字典值
|
|
48
|
-
* @param name 字典名称
|
|
49
|
-
* @param label 字典标签
|
|
50
|
-
* @returns 某字典名称所对应的字典值
|
|
51
|
-
*/
|
|
52
|
-
export const getDictValue = (name: string, label: string) => {
|
|
53
|
-
const { dict } = useAuthStore()
|
|
54
|
-
if (dict) {
|
|
55
|
-
return _getDictValue(name, label, dict)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* 根据字典名称和字典值获取字典颜色
|
|
61
|
-
* @param name 字典名称
|
|
62
|
-
* @param value 字典值
|
|
63
|
-
* @returns 某字典名称所对应的字典颜色
|
|
64
|
-
*/
|
|
65
|
-
export const getDictColor = (name: string, value: string | number) => {
|
|
66
|
-
const { dict } = useAuthStore()
|
|
67
|
-
if (dict) {
|
|
68
|
-
return _getDictColor(name, value, dict)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
13
|
/**
|
|
73
14
|
* 将对象转为 FormData
|
|
74
15
|
* @param obj 对象
|
|
75
16
|
* @returns FormData
|
|
76
17
|
*/
|
|
77
|
-
export const objectToFormData = (obj:
|
|
18
|
+
export const objectToFormData = (obj: object): FormData => {
|
|
78
19
|
// 根据后端返回结果处理的映射关系
|
|
79
20
|
const mapConfig = {
|
|
80
21
|
// 图片
|
|
81
|
-
newImageFiles: { finallyKey: '
|
|
22
|
+
newImageFiles: { finallyKey: 'originImageNames', valueKey: 'uniqueFileName' },
|
|
82
23
|
// 通用附件
|
|
83
|
-
newAttachmentFile: { finallyKey: '
|
|
24
|
+
newAttachmentFile: { finallyKey: 'originAttachmentName', valueKey: 'uniqueFileName' },
|
|
84
25
|
// 程序文件
|
|
85
|
-
newProgramFile: { finallyKey: '
|
|
26
|
+
newProgramFile: { finallyKey: 'originProgramName', valueKey: 'uniqueFileName' },
|
|
86
27
|
// 数据库
|
|
87
28
|
databaseFile: { finallyKey: 'databaseFile', valueKey: 'uniqueFileName' }
|
|
88
29
|
}
|
|
89
|
-
return _objectToFormData(obj, mapConfig)
|
|
30
|
+
return _objectToFormData(obj as Record<string, unknown>, mapConfig)
|
|
90
31
|
}
|
|
91
32
|
|
|
92
33
|
/**
|