adtec-core-package 0.2.11 → 0.2.13
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 +12 -10
- package/src/components/Search/ElSearch.vue +8 -4
- package/src/components/baseEcharts/index.vue +48 -0
- package/src/hooks/useDictHooks.ts +12 -11
- package/src/hooks/useEcharts.ts +58 -0
- package/src/hooks/useResetRefHooks.ts +1 -0
- package/src/mixin/globalMixin.ts +4 -1
- package/src/plugins/echartsConfig.ts +73 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adtec-core-package",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.13",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -13,27 +13,29 @@
|
|
|
13
13
|
"format": "prettier --write src/"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@onlyoffice/document-editor-vue": "1.4.0",
|
|
17
16
|
"@element-plus/icons-vue": "^2.3.1",
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"jsencrypt": "^3.3.2",
|
|
17
|
+
"@onlyoffice/document-editor-vue": "1.4.0",
|
|
18
|
+
"@types/echarts": "^5.0.0",
|
|
21
19
|
"axios": "^1.7.7",
|
|
20
|
+
"crypto-js": "^4.2.0",
|
|
21
|
+
"echarts": "^5.6.0",
|
|
22
22
|
"element-plus": "^2.8.7",
|
|
23
|
+
"jsencrypt": "^3.3.2",
|
|
23
24
|
"pinia": "^2.3.0",
|
|
25
|
+
"pinia-plugin-store": "^2.2.9",
|
|
24
26
|
"scss": "^0.2.4",
|
|
25
27
|
"scss-loader": "^0.0.1",
|
|
28
|
+
"socket.io-client": "^2.3.1",
|
|
29
|
+
"uuid": "^11.0.3",
|
|
26
30
|
"vue": "^3.5.13",
|
|
27
31
|
"vue-focus-lock": "^3.0.0",
|
|
28
|
-
"vue-
|
|
29
|
-
"
|
|
30
|
-
"socket.io-client": "^2.3.1",
|
|
31
|
-
"vue-img-viewr": "2.0.11"
|
|
32
|
+
"vue-img-viewr": "2.0.11",
|
|
33
|
+
"vue-router": "^4.5.0"
|
|
32
34
|
},
|
|
33
35
|
"devDependencies": {
|
|
34
36
|
"@tsconfig/node22": "^22.0.0",
|
|
35
|
-
"@types/node": "^22.10.2",
|
|
36
37
|
"@types/crypto-js": "^4.2.2",
|
|
38
|
+
"@types/node": "^22.10.2",
|
|
37
39
|
"@vitejs/plugin-vue": "^5.2.1",
|
|
38
40
|
"@vitejs/plugin-vue-jsx": "^4.1.1",
|
|
39
41
|
"@vue/eslint-config-prettier": "^10.1.0",
|
|
@@ -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
|
|
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
|
-
|
|
53
|
-
|
|
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
|
-
|
|
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
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<!--创建人 胡啸东-->
|
|
2
|
+
<!--说明: index-->
|
|
3
|
+
<!--创建时间: 2024/11/4 下午4:52-->
|
|
4
|
+
<!--修改时间: 2024/11/4 下午4:52-->
|
|
5
|
+
<template>
|
|
6
|
+
<div
|
|
7
|
+
ref="echartsRef"
|
|
8
|
+
:style="{
|
|
9
|
+
width: width,
|
|
10
|
+
height: height,
|
|
11
|
+
}"
|
|
12
|
+
/>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script lang="ts" setup>
|
|
16
|
+
import { onMounted, type PropType, ref, watch } from 'vue'
|
|
17
|
+
import { type EChartsCoreOption, useEcharts } from '../../hooks/useEcharts.ts' // 引入hooks
|
|
18
|
+
const props = defineProps({
|
|
19
|
+
options: { type: Object as PropType<EChartsCoreOption>, required: true },
|
|
20
|
+
height: { type: String, default: '100%' },
|
|
21
|
+
width: { type: String, default: '100%' },
|
|
22
|
+
themeColors: { type: Array as PropType<string[]>, default: () => [] },
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const echartsRef = ref()
|
|
26
|
+
|
|
27
|
+
const { setOptions, initCharts } = useEcharts(echartsRef, props.options)
|
|
28
|
+
|
|
29
|
+
watch(
|
|
30
|
+
() => props.options,
|
|
31
|
+
(nVal) => {
|
|
32
|
+
let targetOptions: EChartsCoreOption = {}
|
|
33
|
+
if (props.themeColors && props.themeColors.length > 0) {
|
|
34
|
+
targetOptions = { ...nVal }
|
|
35
|
+
targetOptions.color = props.themeColors
|
|
36
|
+
} else {
|
|
37
|
+
targetOptions = { ...nVal }
|
|
38
|
+
}
|
|
39
|
+
setOptions(targetOptions)
|
|
40
|
+
},
|
|
41
|
+
{ deep: true },
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
onMounted(() => {
|
|
45
|
+
initCharts()
|
|
46
|
+
})
|
|
47
|
+
defineExpose({ setOptions, initCharts })
|
|
48
|
+
</script>
|
|
@@ -4,23 +4,24 @@ import SysDictCacheApi from '../api/SysDictCacheApi'
|
|
|
4
4
|
import type { ISysDictDataCacheVo } from '../interface/ISysDictDataCacheVo'
|
|
5
5
|
import { dictStore } from '../stores/dictStore'
|
|
6
6
|
|
|
7
|
-
export default function useDictHooks(dictTypes
|
|
7
|
+
export default function useDictHooks(dictTypes?: string[]) {
|
|
8
8
|
const dictStores = dictStore()
|
|
9
|
-
const { dictMap, dictDefaultValueMap } = storeToRefs(dictStores)
|
|
9
|
+
const { dictMap, dictDefaultValueMap,dictDataMap } = storeToRefs(dictStores)
|
|
10
10
|
const getDict = async (dictTypes: string[]) => {
|
|
11
11
|
try {
|
|
12
|
+
if (!dictTypes || !dictTypes.length) return
|
|
12
13
|
// 判断是否存在缓存数据,如果存在则不请求接口
|
|
13
|
-
const dictKeySet = new Set(Object.keys(
|
|
14
|
+
const dictKeySet = new Set(Object.keys(dictMap.value))
|
|
14
15
|
const uncachedDictTypes = dictTypes.filter((dictType) => !dictKeySet.has(dictType))
|
|
15
16
|
if (!uncachedDictTypes.length) return
|
|
16
17
|
const data = await SysDictCacheApi.batchGetSysDictDataCacheVo(uncachedDictTypes)
|
|
17
|
-
|
|
18
|
+
dictMap.value = { ...dictMap.value, ...data }
|
|
18
19
|
// 获取默认值
|
|
19
20
|
Object.keys(data).forEach((item: string) => {
|
|
20
21
|
findDefaultValue(data[item], item)
|
|
21
22
|
const dataMap = new Map<string, ISysDictDataCacheVo>()
|
|
22
23
|
packageDictDataMap(dataMap, data[item])
|
|
23
|
-
|
|
24
|
+
dictDataMap.value.set(item, dataMap)
|
|
24
25
|
})
|
|
25
26
|
} catch (error: any) {
|
|
26
27
|
ElMessage.error(error.msg || error.message)
|
|
@@ -41,7 +42,7 @@ export default function useDictHooks(dictTypes: string[]) {
|
|
|
41
42
|
|
|
42
43
|
const findDefaultValue = async (list: ISysDictDataCacheVo[], type: string) => {
|
|
43
44
|
const find = getDefaultValue(list)
|
|
44
|
-
find &&
|
|
45
|
+
find && dictDefaultValueMap.value.set(type, find)
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
const getDefaultValue = (list?: ISysDictDataCacheVo[]): ISysDictDataCacheVo | undefined => {
|
|
@@ -56,15 +57,15 @@ export default function useDictHooks(dictTypes: string[]) {
|
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
const getDictName = (value?: string, dictType?: string) => {
|
|
59
|
-
return
|
|
60
|
+
return dictDataMap.value.get(dictType!)?.get(value!)?.label || value
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
const getDictData = (value: string, dictType: string) => {
|
|
63
|
-
return
|
|
64
|
+
return dictDataMap.value.get(dictType)?.get(value)
|
|
65
|
+
}
|
|
66
|
+
if (dictTypes && dictTypes.length) {
|
|
67
|
+
getDict(dictTypes).then(() => {})
|
|
64
68
|
}
|
|
65
|
-
|
|
66
|
-
getDict(dictTypes).then(() => {})
|
|
67
|
-
|
|
68
69
|
return {
|
|
69
70
|
dictMap,
|
|
70
71
|
dictDefaultValueMap,
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 创建人 胡啸东
|
|
3
|
+
* 说明: useEcharts
|
|
4
|
+
* 创建时间: 2024/11/4 下午4:51
|
|
5
|
+
* 修改时间: 2024/11/4 下午4:51
|
|
6
|
+
*/
|
|
7
|
+
import type { Ref } from 'vue'
|
|
8
|
+
import { onBeforeUnmount, onDeactivated, onMounted, shallowRef, unref } from 'vue'
|
|
9
|
+
import echarts from '../plugins/echartsConfig.ts'
|
|
10
|
+
|
|
11
|
+
export type EChartsCoreOption = echarts.EChartsCoreOption
|
|
12
|
+
|
|
13
|
+
const useEcharts = (elRef: Ref<HTMLDivElement>, options: EChartsCoreOption) => {
|
|
14
|
+
const charts = shallowRef<echarts.ECharts>()
|
|
15
|
+
|
|
16
|
+
const setOptions = (options: EChartsCoreOption) => {
|
|
17
|
+
charts.value && charts.value.setOption(options)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// 初始化
|
|
21
|
+
const initCharts = (themeColor?: Array<string>) => {
|
|
22
|
+
const el = unref(elRef)
|
|
23
|
+
if (!el || !unref(el)) {
|
|
24
|
+
return
|
|
25
|
+
}
|
|
26
|
+
charts.value = echarts.init(el)
|
|
27
|
+
if (themeColor) {
|
|
28
|
+
options.color = themeColor
|
|
29
|
+
}
|
|
30
|
+
setOptions(options)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// 重新窗口变化时,重新计算
|
|
34
|
+
const resize = () => {
|
|
35
|
+
charts.value && charts.value.resize()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
onMounted(() => {
|
|
39
|
+
window.addEventListener('resize', resize)
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
// 页面keepAlive时,不监听页面
|
|
43
|
+
onDeactivated(() => {
|
|
44
|
+
window.removeEventListener('resize', resize)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
onBeforeUnmount(() => {
|
|
48
|
+
window.removeEventListener('resize', resize)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
initCharts,
|
|
53
|
+
setOptions,
|
|
54
|
+
resize,
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { useEcharts }
|
package/src/mixin/globalMixin.ts
CHANGED
|
@@ -15,6 +15,7 @@ import ElTableColumnEdit from '../components/Table/ElTableColumnEdit.vue'
|
|
|
15
15
|
import vKeydown from '../directives/vKeydown'
|
|
16
16
|
import ElAutoToolTip from '../components/autoToolTip/ElAutoToolTip.vue'
|
|
17
17
|
import userSelect from '../components/business/userSelect.vue'
|
|
18
|
+
import baseEcharts from '../components/baseEcharts/index.vue'
|
|
18
19
|
//@ts-ignore
|
|
19
20
|
export const globalMixin = {
|
|
20
21
|
components: {
|
|
@@ -26,7 +27,9 @@ export const globalMixin = {
|
|
|
26
27
|
ElIconBtn,
|
|
27
28
|
ElIconSearch,
|
|
28
29
|
ElTableColumnEdit,
|
|
29
|
-
ElAutoToolTip,
|
|
30
|
+
ElAutoToolTip,
|
|
31
|
+
userSelect,
|
|
32
|
+
baseEcharts,
|
|
30
33
|
},
|
|
31
34
|
directives: {
|
|
32
35
|
keydown: vKeydown,
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 创建人 胡啸东
|
|
3
|
+
* 说明: echartsConfig
|
|
4
|
+
* 创建时间: 2024/11/4 下午4:50
|
|
5
|
+
* 修改时间: 2024/11/4 下午4:50
|
|
6
|
+
*/
|
|
7
|
+
// 引入 echarts 核心模块,核心模块提供了 echarts 使用必须要的接口。
|
|
8
|
+
import * as echarts from 'echarts/core'
|
|
9
|
+
//
|
|
10
|
+
// 引入内置组件,组件后缀都为Component
|
|
11
|
+
import {
|
|
12
|
+
AriaComponent,
|
|
13
|
+
CalendarComponent,
|
|
14
|
+
DatasetComponent,
|
|
15
|
+
DataZoomComponent,
|
|
16
|
+
GraphicComponent,
|
|
17
|
+
GridComponent,
|
|
18
|
+
LegendComponent,
|
|
19
|
+
ParallelComponent,
|
|
20
|
+
PolarComponent,
|
|
21
|
+
RadarComponent,
|
|
22
|
+
TimelineComponent,
|
|
23
|
+
TitleComponent,
|
|
24
|
+
ToolboxComponent,
|
|
25
|
+
TooltipComponent,
|
|
26
|
+
TransformComponent,
|
|
27
|
+
VisualMapComponent
|
|
28
|
+
} from 'echarts/components'
|
|
29
|
+
|
|
30
|
+
// 引入渲染器:echarst默认使用canvas渲染,引入 CanvasRenderer 或者 SVGRenderer 是必须的一步
|
|
31
|
+
import { CanvasRenderer, SVGRenderer } from 'echarts/renderers'
|
|
32
|
+
|
|
33
|
+
// 标签自动布局、全局过渡动画等特性
|
|
34
|
+
import { LabelLayout, UniversalTransition } from 'echarts/features'
|
|
35
|
+
|
|
36
|
+
// 引入图表类型,后缀都为Chart
|
|
37
|
+
import { BarChart, LineChart, MapChart, PictorialBarChart, PieChart, RadarChart } from 'echarts/charts'
|
|
38
|
+
|
|
39
|
+
// 注册必须的组件
|
|
40
|
+
echarts.use([
|
|
41
|
+
// 内置组件
|
|
42
|
+
TitleComponent,
|
|
43
|
+
TooltipComponent,
|
|
44
|
+
GridComponent,
|
|
45
|
+
PolarComponent,
|
|
46
|
+
AriaComponent,
|
|
47
|
+
ParallelComponent,
|
|
48
|
+
LegendComponent,
|
|
49
|
+
RadarComponent,
|
|
50
|
+
ToolboxComponent,
|
|
51
|
+
DatasetComponent,
|
|
52
|
+
DataZoomComponent,
|
|
53
|
+
VisualMapComponent,
|
|
54
|
+
TimelineComponent,
|
|
55
|
+
CalendarComponent,
|
|
56
|
+
GraphicComponent,
|
|
57
|
+
TransformComponent,
|
|
58
|
+
// 渲染器
|
|
59
|
+
CanvasRenderer,
|
|
60
|
+
SVGRenderer,
|
|
61
|
+
// 特性
|
|
62
|
+
LabelLayout,
|
|
63
|
+
UniversalTransition,
|
|
64
|
+
// 图表
|
|
65
|
+
BarChart,
|
|
66
|
+
LineChart,
|
|
67
|
+
PieChart,
|
|
68
|
+
MapChart,
|
|
69
|
+
RadarChart,
|
|
70
|
+
PictorialBarChart,
|
|
71
|
+
])
|
|
72
|
+
|
|
73
|
+
export default echarts
|