adtec-core-package 0.7.3 → 0.7.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adtec-core-package",
3
- "version": "0.7.3",
3
+ "version": "0.7.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,5 +1,7 @@
1
1
  import request from '../utils/request'
2
2
  import type { IOrgDeptInfo } from '../interface/IOrgDeptInfo'
3
+ import type { IMdmOrgQuery } from '@/interface/IMdmOrgQuery.ts'
4
+ import type { IMdmOrg } from '@/interface/IMdmOrg.ts'
3
5
 
4
6
  /**
5
7
  * Create by丁盼
@@ -14,4 +16,11 @@ export default {
14
16
  getMdmOrgDeptTree(): Promise<IOrgDeptInfo[]> {
15
17
  return request.post('/api/base/mdmDept/getMdmOrgDeptTree', {})
16
18
  },
19
+
20
+ /**
21
+ * 获取组织列表
22
+ */
23
+ getMdmOrgList(query: IMdmOrgQuery) {
24
+ return request.post<IMdmOrg[]>('/api/base/mdmDept/getMdmOrgList', query)
25
+ },
17
26
  }
@@ -20,7 +20,10 @@ export default {
20
20
  /**
21
21
  * 批量获取字典数据
22
22
  */
23
- batchGetSysDictDataCacheVo(dictTypes: string[]): Promise<dictMapType> {
24
- return request.post<dictMapType>(basePath + 'batchGetSysDictDataCacheVo', dictTypes)
25
- },
23
+ batchGetSysDictDataCacheVo(dictTypes: string[], orgId?: string): Promise<dictMapType> {
24
+ return request.post<dictMapType>(
25
+ basePath + 'batchGetSysDictDataCacheVo?orgId=' + (orgId ? orgId : ''),
26
+ dictTypes
27
+ )
28
+ }
26
29
  }
@@ -3,19 +3,26 @@ import SysDictCacheApi from '../api/SysDictCacheApi'
3
3
  import type { ISysDictDataCacheVo } from '../interface/ISysDictDataCacheVo'
4
4
  import { type dictDataMapVoType, dictStore } from '../stores/dictStore'
5
5
  import { storeToRefs } from 'pinia'
6
+ import { userInfoStore } from '../stores/userInfoStore.ts'
6
7
 
7
- export default function useDictHooks(dictTypes?: string[]) {
8
+ const userInfo = userInfoStore()
9
+ export default function useDictHooks(dictTypes?: string[], orgId?: string) {
8
10
  const dictStores = dictStore()
11
+ const { clearDictCache } = dictStores
9
12
  const { dictMap, dictDefaultValueMap, dictDataMap } = storeToRefs(dictStores)
10
-
11
- const getDict = async (dictTypes?: string[]) => {
13
+ const getDict = async (dictTypes?: string[], orgId?: string) => {
12
14
  try {
13
15
  if (!dictTypes || !dictTypes.length) return
14
16
  //判断是否存在缓存数据,如果存在则不请求接口
15
17
  const dictKeySet = new Set(Object.keys(dictMap.value))
16
- const uncachedDictTypes = dictTypes.filter((dictType) => !dictKeySet.has(dictType))
18
+ let uncachedDictTypes = dictTypes.filter((dictType) => !dictKeySet.has(dictType))
19
+ if (orgId) {
20
+ uncachedDictTypes = uncachedDictTypes.concat(dictTypes.filter((dictType) => !dictKeySet.has(`${orgId}:${dictType}`)))
21
+ } else {
22
+ uncachedDictTypes = uncachedDictTypes.concat(dictTypes.filter((dictType) => !dictKeySet.has(`${userInfo.getUserInfo.orgId}:${dictType}`)))
23
+ }
17
24
  if (!uncachedDictTypes.length) return
18
- const data = await SysDictCacheApi.batchGetSysDictDataCacheVo(dictTypes)
25
+ const data = await SysDictCacheApi.batchGetSysDictDataCacheVo(uncachedDictTypes, orgId)
19
26
  dictMap.value = { ...dictMap.value, ...data }
20
27
  // 获取默认值
21
28
  const promises = Object.keys(data).map(async (item: string) => {
@@ -41,7 +48,7 @@ export default function useDictHooks(dictTypes?: string[]) {
41
48
  const packageDictDataMap = async (
42
49
  map: dictDataMapVoType,
43
50
  defaultList: ISysDictDataCacheVo[],
44
- list?: ISysDictDataCacheVo[],
51
+ list?: ISysDictDataCacheVo[]
45
52
  ) => {
46
53
  if (list && list.length) {
47
54
  const promises = list.map(async (item: ISysDictDataCacheVo) => {
@@ -57,23 +64,33 @@ export default function useDictHooks(dictTypes?: string[]) {
57
64
  }
58
65
  }
59
66
 
60
- const getDictName = (value?: string, dictType?: string) => {
61
- if (dictDataMap.value[dictType!]) {
62
- return dictDataMap.value[dictType!][value!]?.label || value
63
- }
67
+ const getDictName = (value?: string, dictType?: string, orgId?: string) => {
68
+ //此处需要支持多租户
69
+ let key = orgId ? `${orgId}:${dictType}` : dictType
70
+ if (dictDataMap.value[key!]) return dictDataMap.value[key!][value!]?.label || value
71
+ key = `${userInfo.getUserInfo.orgId}:${dictType}`
72
+ if (dictDataMap.value[key!]) return dictDataMap.value[key!][value!]?.label || value
64
73
  return value
65
74
  }
66
75
 
67
- const getDictData = (value: string, dictType: string) => {
68
- return dictDataMap.value[dictType!][value!]
76
+ const getDictData = (value: string, dictType: string, orgId?: string) => {
77
+ //此处需要支持多租户
78
+ let key = orgId ? `${orgId}:${dictType}` : dictType
79
+ if (dictDataMap.value[key!][value!]) return dictDataMap.value[key!][value!]
80
+ key = `${userInfo.getUserInfo.orgId}:${dictType}`
81
+ return dictDataMap.value[key!][value!]
69
82
  }
70
- getDict(dictTypes).then(() => {})
71
-
83
+ const clearDict = (dictType?: string[], orgId?: string, all?: Boolean) => {
84
+ clearDictCache(dictType, userInfo.getUserInfo.orgId, orgId, all)
85
+ }
86
+ getDict(dictTypes, orgId).then(() => {
87
+ })
72
88
  return {
73
89
  dictMap,
74
90
  dictDefaultValueMap,
75
91
  getDict,
76
92
  getDictName,
77
93
  getDictData,
94
+ clearDict
78
95
  }
79
96
  }
@@ -79,4 +79,6 @@ export interface IMdmDept extends IpageDataQuery {
79
79
  updateByName?: string
80
80
 
81
81
  level?: string
82
+
83
+ orgId?: string
82
84
  }
@@ -1,10 +1,12 @@
1
+ import type { BaseEntity } from '@/interface/BaseEntity.ts'
2
+
1
3
  /**
2
4
  * 创建人 胡啸东
3
5
  * 说明: IMdmEmployee
4
6
  * 创建时间: 2024/11/28 下午2:29
5
7
  * 修改时间: 2024/11/28 下午2:29
6
8
  */
7
- export interface IMdmEmployee {
9
+ export interface IMdmEmployee extends BaseEntity{
8
10
  /**
9
11
  * 主键id
10
12
  */
@@ -124,19 +126,4 @@ export interface IMdmEmployee {
124
126
  orgName?: string
125
127
  deptName?: string
126
128
  postName?: string
127
-
128
- // 是否删除,1=是,0=否。
129
- isDelete?: string
130
-
131
- // 创建者
132
- createBy?: string
133
-
134
- // 创建时间
135
- createTime?: string
136
-
137
- // 更新者
138
- updateBy?: string
139
-
140
- // 更新时间
141
- updateTime?: string
142
129
  }
@@ -0,0 +1,29 @@
1
+ import type { BaseEntity } from '@/interface/BaseEntity.ts'
2
+
3
+ /**
4
+ * 创建人 胡啸东
5
+ * 说明: Iss
6
+ * 创建时间: 2024/11/21 下午3:16
7
+ * 修改时间: 2024/11/21 下午3:16
8
+ */
9
+ export interface IMdmOrg extends BaseEntity{
10
+ // 组织ID
11
+ id?: string
12
+
13
+ // 组织编码
14
+ code?: string
15
+
16
+ // 组织名称
17
+ name?: string
18
+
19
+ // 简称
20
+ shortName?: string
21
+
22
+ // 备注
23
+ remark?: string
24
+
25
+ // 是否有效,存布尔字典“SysBool”的值:1=是,0=否。
26
+ isValid?: string
27
+ //是否系统组织
28
+ isSysOrg?: string
29
+ }
@@ -1,4 +1,4 @@
1
- import type { IpageDataQuery } from 'adtec-core-package/src/interface/PageData'
1
+ import type { IpageDataQuery } from './PageData.ts'
2
2
 
3
3
  /**
4
4
  * 创建人 胡啸东
@@ -1,7 +1,6 @@
1
1
  import { defineStore } from 'pinia'
2
2
  import { ref } from 'vue'
3
3
  import type { ISysDictDataCacheVo } from '../interface/ISysDictDataCacheVo'
4
-
5
4
  // 定义包含map的整体类型
6
5
  export interface dictMapType {
7
6
  [key: string]: ISysDictDataCacheVo[]
@@ -20,15 +19,33 @@ export const dictStore = defineStore('dictStore', () => {
20
19
  const dictDataMap = ref<dictDataMapType>({})
21
20
  const dictDefaultValueMap = ref<dictMapType>({})
22
21
 
23
- const clearDict = () => {
24
- dictMap.value = {}
25
- dictDataMap.value = {}
26
- dictDefaultValueMap.value = {}
22
+ const clearDictCache = (dictType?: string[],userOrgId?: string, orgId?: string, all?: Boolean) => {
23
+ if (dictType) {
24
+ dictType.forEach((item) => {
25
+ if (orgId) {
26
+ const key = `${orgId}:${item}`
27
+ delete dictMap.value[key]
28
+ delete dictDataMap.value[key]
29
+ delete dictDefaultValueMap.value[key]
30
+ } else {
31
+ delete dictMap.value[item]
32
+ delete dictDataMap.value[item]
33
+ delete dictDefaultValueMap.value[item]
34
+ delete dictMap.value[`${userOrgId}:${item}`]
35
+ delete dictDataMap.value[`${userOrgId}:${item}`]
36
+ delete dictDefaultValueMap.value[`${userOrgId}:${item}`]
37
+ }
38
+ })
39
+ } else if (all) {
40
+ dictMap.value = {}
41
+ dictDataMap.value = {}
42
+ dictDefaultValueMap.value = {}
43
+ }
27
44
  }
28
45
  return {
29
46
  dictMap,
30
47
  dictDataMap,
31
48
  dictDefaultValueMap,
32
- clearDict,
49
+ clearDictCache,
33
50
  }
34
51
  })