adtec-core-package 0.2.10 → 0.2.12

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.2.10",
3
+ "version": "0.2.12",
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
- "pinia-plugin-store": "^2.2.9",
19
- "crypto-js": "^4.2.0",
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-router": "^4.5.0",
29
- "uuid": "^11.0.3",
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",
@@ -11,7 +11,6 @@
11
11
  </div>
12
12
  </div>
13
13
  </el-flex>
14
-
15
14
  <el-flex
16
15
  width="240px"
17
16
  justify="flex-end"
@@ -22,20 +21,19 @@
22
21
  <el-button type="primary" @click="search" :class="getRouteName + '_search'">查询</el-button>
23
22
  <el-button type="text" @click="retract" v-show="is_retract">
24
23
  <el-icon
25
- ><ArrowDown v-show="retractval === '展开'" /><ArrowUp
26
- v-show="retractval === '收起'" /></el-icon
24
+ ><ArrowDown v-show="retractval === '展开'" /><ArrowUp
25
+ v-show="retractval === '收起'" /></el-icon
27
26
  >{{ retractval }}</el-button
28
27
  >
29
28
  </el-flex>
30
29
  </el-flex>
31
30
  </template>
32
31
  <script setup lang="ts">
33
- import { computed, inject, nextTick, onMounted, ref, watch } from 'vue'
32
+ import { computed, inject, nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
34
33
  import { useWindowSize } from '@vueuse/core'
35
34
  import { useRouter } from 'vue-router'
36
- import ElFlex from '../ElFlex/ElFlex.vue'
37
35
  import { ArrowDown, ArrowUp } from '@element-plus/icons-vue'
38
-
36
+ import ElFlex from '../ElFlex/ElFlex.vue'
39
37
  const router = useRouter()
40
38
  const getRouteName = computed(() => {
41
39
  return router.currentRoute.value.name as string
@@ -47,30 +45,42 @@ const is_retract = ref(false)
47
45
  const ref_div = ref()
48
46
  const windowContent = useWindowSize()
49
47
  const collapsed = inject<boolean>('collapsed')
48
+ const collapsedSearch=ref<boolean|undefined>(false)
50
49
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
51
50
  //@ts-expect-error
52
51
  watch(collapsed, () => {
52
+ collapsedSearch.value = collapsed
53
+ calculation()
54
+ })
55
+ watch(collapsedSearch, () => {
53
56
  calculation()
54
57
  })
55
58
  watch(windowContent.width, () => {
56
59
  calculation()
57
60
  })
58
61
  const calculation = () => {
59
- setTimeout(() => {
60
- if (!(ref_div.value.offsetHeight > 95)) {
61
- if (ref_div.value.offsetHeight !== 0) {
62
- is_retract.value = false
63
- height.value = ref_div.value.offsetHeight + 15 + 'px'
64
- retractval.value = '收起'
65
- } else {
66
- calculation()
62
+ nextTick(()=>{
63
+ setTimeout(() => {
64
+ if(ref_div.value.children.length>0) {
65
+ if (!(ref_div.value.children[0].offsetHeight > 95)) {
66
+ if (ref_div.value.children[0].offsetHeight !== 0) {
67
+ is_retract.value = false
68
+ height.value = ref_div.value.children[0].offsetHeight + 15 + 'px'
69
+ retractval.value = '收起'
70
+ } else {
71
+ calculation()
72
+ }
73
+ }else if(ref_div.value.children[0].offsetHeight<=95){
74
+ is_retract.value = false
75
+ }
76
+ else {
77
+ is_retract.value = true
78
+ height.value = '95px'
79
+ retractval.value = '展开'
80
+ }
67
81
  }
68
- } else {
69
- is_retract.value = true
70
- height.value = '95px'
71
- retractval.value = '展开'
72
- }
73
- }, 100)
82
+ }, 200)
83
+ })
74
84
  }
75
85
  watch(windowContent.height, () => {
76
86
  calculation()
@@ -100,6 +110,11 @@ const emit = defineEmits<{
100
110
  (event: 'search'): void
101
111
  }>()
102
112
  onMounted(() => {
113
+ collapsedSearch.value = collapsed
114
+ //@ts-ignore
115
+ window.$wujie?.bus.$on("collapsedChangeBus", (val:boolean) => {
116
+ collapsedSearch.value=val
117
+ });
103
118
  nextTick(() => {
104
119
  if (!(ref_content.value.children[0].scrollHeight > 95)) {
105
120
  is_retract.value = false
@@ -112,7 +127,10 @@ onMounted(() => {
112
127
  }
113
128
  })
114
129
  })
115
-
130
+ onUnmounted(()=>{
131
+ //@ts-ignore
132
+ window.$wujie?.bus.$off("collapsedChangeBus")
133
+ })
116
134
  // onKeyStroke(['d', 'D', 'ArrowRight'], () => {
117
135
  // translateX.value += 10
118
136
  // }, { dedupe: true })
@@ -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, ref, watch, type PropType } from 'vue'
17
+ import { useEcharts, type EChartsCoreOption } 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,11 +4,12 @@ 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: string[]) {
7
+ export default function useDictHooks(dictTypes?: string[]) {
8
8
  const dictStores = dictStore()
9
9
  const { dictMap, dictDefaultValueMap } = storeToRefs(dictStores)
10
10
  const getDict = async (dictTypes: string[]) => {
11
11
  try {
12
+ if (!dictTypes || !dictTypes.length) return
12
13
  // 判断是否存在缓存数据,如果存在则不请求接口
13
14
  const dictKeySet = new Set(Object.keys(dictStores.dictMap))
14
15
  const uncachedDictTypes = dictTypes.filter((dictType) => !dictKeySet.has(dictType))
@@ -62,9 +63,9 @@ export default function useDictHooks(dictTypes: string[]) {
62
63
  const getDictData = (value: string, dictType: string) => {
63
64
  return dictStores.dictDataMap.get(dictType)?.get(value)
64
65
  }
65
-
66
- getDict(dictTypes).then(() => {})
67
-
66
+ if (dictTypes && dictTypes.length) {
67
+ getDict(dictTypes).then(() => {})
68
+ }
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 { onBeforeUnmount, onDeactivated, onMounted, shallowRef, unref } from 'vue'
8
+ import type{Ref}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 }
@@ -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]
@@ -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,userSelect
30
+ ElAutoToolTip,
31
+ userSelect,
32
+ baseEcharts,
30
33
  },
31
34
  directives: {
32
35
  keydown: vKeydown,
@@ -0,0 +1,80 @@
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
+ TitleComponent,
13
+ TooltipComponent,
14
+ GridComponent,
15
+ PolarComponent,
16
+ AriaComponent,
17
+ ParallelComponent,
18
+ LegendComponent,
19
+ RadarComponent,
20
+ ToolboxComponent,
21
+ DatasetComponent, // 数据集组件
22
+ DataZoomComponent,
23
+ VisualMapComponent,
24
+ TimelineComponent,
25
+ CalendarComponent,
26
+ GraphicComponent,
27
+ TransformComponent, // 数据转换器组件(filter, sort)
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 {
38
+ BarChart,
39
+ LineChart,
40
+ PieChart,
41
+ MapChart,
42
+ RadarChart,
43
+ PictorialBarChart,
44
+ } from 'echarts/charts'
45
+
46
+ // 注册必须的组件
47
+ echarts.use([
48
+ // 内置组件
49
+ TitleComponent,
50
+ TooltipComponent,
51
+ GridComponent,
52
+ PolarComponent,
53
+ AriaComponent,
54
+ ParallelComponent,
55
+ LegendComponent,
56
+ RadarComponent,
57
+ ToolboxComponent,
58
+ DatasetComponent,
59
+ DataZoomComponent,
60
+ VisualMapComponent,
61
+ TimelineComponent,
62
+ CalendarComponent,
63
+ GraphicComponent,
64
+ TransformComponent,
65
+ // 渲染器
66
+ CanvasRenderer,
67
+ SVGRenderer,
68
+ // 特性
69
+ LabelLayout,
70
+ UniversalTransition,
71
+ // 图表
72
+ BarChart,
73
+ LineChart,
74
+ PieChart,
75
+ MapChart,
76
+ RadarChart,
77
+ PictorialBarChart,
78
+ ])
79
+
80
+ export default echarts