adtec-core-package 0.3.1 → 0.3.3

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.3.1",
3
+ "version": "0.3.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -45,14 +45,16 @@ const is_retract = ref(false)
45
45
  const ref_div = ref()
46
46
  const windowContent = useWindowSize()
47
47
  const collapsed = inject<boolean>('collapsed')
48
- const collapsedSearch=ref<boolean|undefined>(false)
48
+ const collapsedSearch=ref<boolean>(false)
49
49
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
50
50
  //@ts-expect-error
51
51
  watch(collapsed, () => {
52
- collapsedSearch.value = collapsed
53
- calculation()
52
+ //@ts-ignore
53
+ collapsedSearch.value = collapsed.value
54
+ // calculation()
54
55
  })
55
56
  watch(collapsedSearch, () => {
57
+ console.log("collapsedSearch")
56
58
  calculation()
57
59
  })
58
60
  watch(windowContent.width, () => {
@@ -110,7 +112,9 @@ const emit = defineEmits<{
110
112
  (event: 'search'): void
111
113
  }>()
112
114
  onMounted(() => {
113
- collapsedSearch.value = collapsed
115
+ //ts-ignore
116
+ //@ts-expect-error
117
+ collapsedSearch.value = collapsed.value
114
118
  //@ts-ignore
115
119
  window.$wujie?.bus.$on("collapsedChangeBus", (val:boolean) => {
116
120
  collapsedSearch.value=val
@@ -1,36 +1,40 @@
1
+ import { storeToRefs } from 'pinia'
1
2
  import { ElMessage } from 'element-plus'
2
3
  import SysDictCacheApi from '../api/SysDictCacheApi'
3
4
  import type { ISysDictDataCacheVo } from '../interface/ISysDictDataCacheVo'
4
- import { type dictDataMapVoType, dictStore } from '../stores/dictStore'
5
+ import { dictStore } from '../stores/dictStore'
5
6
 
6
- export default function useDictHooks(dictTypes: string[]) {
7
+ export default function useDictHooks(dictTypes?: string[]) {
7
8
  const dictStores = dictStore()
8
-
9
+ const { dictMap, dictDefaultValueMap } = storeToRefs(dictStores)
9
10
  const getDict = async (dictTypes: string[]) => {
10
11
  try {
11
- //判断是否存在缓存数据,如果存在则不请求接口
12
+ if (!dictTypes || !dictTypes.length) return
13
+ // 判断是否存在缓存数据,如果存在则不请求接口
12
14
  const dictKeySet = new Set(Object.keys(dictStores.dictMap))
13
15
  const uncachedDictTypes = dictTypes.filter((dictType) => !dictKeySet.has(dictType))
14
- if (uncachedDictTypes.length) {
15
- const data = await SysDictCacheApi.batchGetSysDictDataCacheVo(dictTypes)
16
- dictStores.dictMap = { ...dictStores.dictMap, ...data }
17
- // 获取默认值
18
- Object.keys(data).forEach((item: string) => {
19
- findDefaultValue(data[item], item)
20
- const dataMap: dictDataMapVoType = {}
21
- packageDictDataMap(dataMap, data[item])
22
- dictStores.dictDataMap[item] = dataMap
23
- })
24
- }
16
+ if (!uncachedDictTypes.length) return
17
+ const data = await SysDictCacheApi.batchGetSysDictDataCacheVo(uncachedDictTypes)
18
+ dictStores.dictMap = { ...dictStores.dictMap, ...data }
19
+ // 获取默认值
20
+ Object.keys(data).forEach((item: string) => {
21
+ findDefaultValue(data[item], item)
22
+ const dataMap = new Map<string, ISysDictDataCacheVo>()
23
+ packageDictDataMap(dataMap, data[item])
24
+ dictStores.dictDataMap.set(item, dataMap)
25
+ })
25
26
  } catch (error: any) {
26
27
  ElMessage.error(error.msg || error.message)
27
28
  }
28
29
  }
29
30
 
30
- const packageDictDataMap = async (map: dictDataMapVoType, list?: ISysDictDataCacheVo[]) => {
31
+ const packageDictDataMap = async (
32
+ map: Map<string, ISysDictDataCacheVo>,
33
+ list?: ISysDictDataCacheVo[],
34
+ ) => {
31
35
  if (list && list.length) {
32
36
  list.forEach((item: ISysDictDataCacheVo) => {
33
- map[item.value] = { ...item, ...{ children: undefined } }
37
+ map.set(item.value, { ...item, ...{ children: undefined } })
34
38
  packageDictDataMap(map, item.children)
35
39
  })
36
40
  }
@@ -38,9 +42,7 @@ export default function useDictHooks(dictTypes: string[]) {
38
42
 
39
43
  const findDefaultValue = async (list: ISysDictDataCacheVo[], type: string) => {
40
44
  const find = getDefaultValue(list)
41
- if (find) {
42
- dictStores.dictDefaultValueMap[type] = find
43
- }
45
+ find && dictStores.dictDefaultValueMap.set(type, find)
44
46
  }
45
47
 
46
48
  const getDefaultValue = (list?: ISysDictDataCacheVo[]): ISysDictDataCacheVo | undefined => {
@@ -55,21 +57,18 @@ export default function useDictHooks(dictTypes: string[]) {
55
57
  }
56
58
 
57
59
  const getDictName = (value?: string, dictType?: string) => {
58
- if (dictStores.dictDataMap[dictType!]) {
59
- return dictStores.dictDataMap[dictType!][value!]?.label || value
60
- }
61
- return value
60
+ return dictStores.dictDataMap.get(dictType!)?.get(value!)?.label || value
62
61
  }
63
62
 
64
63
  const getDictData = (value: string, dictType: string) => {
65
- return dictStores.dictDataMap[dictType!][value!]
64
+ return dictStores.dictDataMap.get(dictType)?.get(value)
65
+ }
66
+ if (dictTypes && dictTypes.length) {
67
+ getDict(dictTypes).then(() => {})
66
68
  }
67
-
68
- getDict(dictTypes).then(() => {})
69
-
70
69
  return {
71
- dictMap: dictStores.dictMap,
72
- dictDefaultValueMap: dictStores.dictDefaultValueMap,
70
+ dictMap,
71
+ dictDefaultValueMap,
73
72
  getDict,
74
73
  getDictName,
75
74
  getDictData,
@@ -1,5 +1,4 @@
1
1
  import { type Ref, ref } from 'vue'
2
- import { cloneDeep } from 'lodash-es'
3
2
 
4
3
  /**
5
4
  * 创建人 胡啸东
@@ -9,10 +8,10 @@ import { cloneDeep } from 'lodash-es'
9
8
  */
10
9
 
11
10
  export function useResetRefHooks<T>(value: T): [Ref<T>, () => void] {
12
- const initValue = cloneDeep(value)
11
+ const initValue = JSON.parse(JSON.stringify(value))
13
12
  const state = ref(value)
14
13
  const reset = () => {
15
- state.value = cloneDeep(initValue)
14
+ state.value = JSON.parse(JSON.stringify(initValue))
16
15
  }
17
16
  //@ts-ignore
18
17
  return [state, reset]
@@ -7,18 +7,11 @@ export interface dictMapType {
7
7
  [key: string]: ISysDictDataCacheVo[]
8
8
  }
9
9
 
10
- export interface dictDataMapVoType {
11
- [key: string]: ISysDictDataCacheVo
12
- }
13
-
14
- export interface dictDataMapType {
15
- [key: string]: { [key: string]: ISysDictDataCacheVo }
16
- }
17
-
18
10
  export const dictStore = defineStore('dictStore', () => {
19
11
  const dictMap = ref<dictMapType>({})
20
- const dictDataMap = ref<dictDataMapType>({})
21
- const dictDefaultValueMap = ref<dictDataMapVoType>({})
12
+ const dictDataMap = ref<Map<string, Map<string, ISysDictDataCacheVo>>>(new Map())
13
+ const dictDefaultValueMap = ref<Map<string, ISysDictDataCacheVo>>(new Map())
14
+
22
15
  return {
23
16
  dictMap,
24
17
  dictDataMap,