From d1fb3008a5ff925f36178172d09af4abd6cb5b89 Mon Sep 17 00:00:00 2001 From: jlzhou <12020042@qq.com> Date: Fri, 7 Mar 2025 17:41:13 +0800 Subject: [PATCH] fix bug and WEcharts.vue --- bi-ui/src/api/request.js | 2 +- bi-ui/src/components/global/WEcharts.vue | 238 +++++++++++++++++++++++ bi-ui/src/pages/test/components.vue | 127 +++++++++--- bi-ui/src/util/index.js | 24 +++ 4 files changed, 361 insertions(+), 30 deletions(-) create mode 100644 bi-ui/src/components/global/WEcharts.vue diff --git a/bi-ui/src/api/request.js b/bi-ui/src/api/request.js index e288a5c..df84366 100644 --- a/bi-ui/src/api/request.js +++ b/bi-ui/src/api/request.js @@ -66,7 +66,7 @@ instance.interceptors.response.use(function (response) { if (response.data.code != 200) { ElMessage.error(response.data.msg || response.data.message); if(response.data.code == 401) { - let authStore = AuthStore(); + let authStore = useAuthStore(); authStore.logout(); useRouter().push({path:'/login', query: { to: encodeURIComponent(useRoute().fullPath) }}); } diff --git a/bi-ui/src/components/global/WEcharts.vue b/bi-ui/src/components/global/WEcharts.vue new file mode 100644 index 0000000..0aae861 --- /dev/null +++ b/bi-ui/src/components/global/WEcharts.vue @@ -0,0 +1,238 @@ + + + \ No newline at end of file diff --git a/bi-ui/src/pages/test/components.vue b/bi-ui/src/pages/test/components.vue index 28eded2..ac20e83 100644 --- a/bi-ui/src/pages/test/components.vue +++ b/bi-ui/src/pages/test/components.vue @@ -251,50 +251,51 @@ codeRef.setCode('new code');//设置代码 {{ ` -
- -
-
+
+ +
+
- -
-
+ +
+
- - + + - -
-
+ +
+
-
+
-
-
+
+
-
-
+
+
+
-
-
- -
-
- \{\{ am ? '暂停' : '播放' \}\}` }} + +
+
+
+ \{\{ am ? '暂停' : '播放' \}\}` }}

干扰动画效果

- + {{ am1 ? '暂停' : '播放' }}

加载动画效果

@@ -424,6 +425,66 @@ const emRef3 = proxy.$refs.emRef3; + +

图表组件

+

自适应,可使用em

+
+ +
+ + setTitles(['标题标题标题一','标题二']) + setX(['11','22','33']) + setY() + setSeries([{},{}]) +

方法

+
    +
  1. setTitles : option.legend.data = [....]
  2. +
  3. setX: option.xAxis.data = [...]
  4. +
  5. setY: option.yAxis.data = [...]
  6. +
  7. setSeries: option.series = [...]; 别名: setData
  8. +
  9. setOption: chart?.setOption;
  10. +
  11. chart: echarts的实例
  12. +
  13. el: 组件的Element引用
  14. +
+

属性

+
    +
  1. option : echarts的配置,在只允许使用Number的地方可以使用'XXXem',会根据当前字段大小自动转换为Number
  2. +
  3. useDefault: option是否合并组件里的默认配置
  4. +
  5. colors: 默认配置中的调色盘(option.color),默认: ['#e74c3c', '#f39c12', '#2ed573', '#e056fd', '#833471']
  6. +
  7. color: 默认配置中的主色,文字颜色,坐标颜色, 默认: #FFFA
  8. +
  9. excludes: 默认配置中不进行em转px操作的属性名,默认: ['fontSize']
  10. +
+

事件

+
    +
  1. resize: 组件尺寸发生变化事件,事件参数 {chart,setOption,px},px为1em的单位大小
  2. +
  3. load: 组件初始化加载完成事件,事件参数 {chart,setOption,px},px为1em的单位大小
  4. +
+ + + + + +
+ @@ -456,9 +517,17 @@ const switchValue = ref(true); const am = ref(true); const am1 = ref(true); +const resize = ({ chart, px, setOption }) => { + setOption({ legend: { itemGap: chart.getOption().series.reduce((i, item) => Math.max(i, item.name.length), 1) * px } }); +} + \ No newline at end of file diff --git a/bi-ui/src/util/index.js b/bi-ui/src/util/index.js index 0d8951c..6bddb0e 100644 --- a/bi-ui/src/util/index.js +++ b/bi-ui/src/util/index.js @@ -51,3 +51,27 @@ export function deepClone(source) { }) return targetObj } + +/** + * Merges two objects, giving the last one precedence + * @param {Object} target + * @param {(Object|Array)} source + * @returns {Object} + */ +export function objectMerge(target, source) { + if (typeof target !== 'object') { + target = {} + } + if (Array.isArray(source)) { + return source.slice() + } + Object.keys(source).forEach(property => { + const sourceProperty = source[property] + if (typeof sourceProperty === 'object') { + target[property] = objectMerge(target[property], sourceProperty) + } else { + target[property] = sourceProperty + } + }) + return target +} \ No newline at end of file