lambo-design-bi 0.0.183 → 0.0.185

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.
@@ -1,12 +1,14 @@
1
1
  <template>
2
2
  <LamboNumberInfoBi :title="title" :sub-title="subTitle" :num="num" :sub-num1="subNum1" :trend1="trend1"
3
- :is-drill="isDrill" @on-drill="onDrill" :sub-num2="subNum2" :trend2="trend2" :polar1="polar1" :polar2="polar2" :eva-level="evaLevel">
3
+ :widget="widget" :is-drill="isDrill" @on-drill="onDrill" :sub-num2="subNum2" :trend2="trend2" :polar1="polar1"
4
+ :polar2="polar2" :eva-level="evaLevel" :tab-clickable="tabClickable" @on-tab-click="onTabClick">
4
5
  </LamboNumberInfoBi>
5
6
  </template>
6
7
  <script>
7
8
  import { getListMapData } from "../api/data"
8
9
  import LamboNumberInfoBi from "../../../pub/number-info/index"
9
- import { pageDrill } from '../util/router-util';
10
+ import { pageDrill } from '../util/router-util'
11
+ import { EVENT_TYPES, EventBus } from '../util/event-bus'
10
12
 
11
13
  export default {
12
14
  name: "BiNumIndex",
@@ -41,8 +43,10 @@ export default {
41
43
  drillK2: null,
42
44
  drillV2: null,
43
45
  drillK3: null,
44
- dirllV3: null,
45
- evaLevel: null
46
+ drillV3: null,
47
+ evaLevel: null,
48
+ tabClickable: false,
49
+ defaultTabActive: false
46
50
  }
47
51
  },
48
52
  methods: {
@@ -54,6 +58,12 @@ export default {
54
58
  if (this.toPageId && this.toRouteName) {
55
59
  this.isDrill = true
56
60
  }
61
+ if (this.widget.options["tabClickable"] === '1') {
62
+ this.tabClickable = true
63
+ }
64
+ if (this.widget.options["defaultTabActive"] === '1') {
65
+ this.defaultTabActive = true
66
+ }
57
67
  },
58
68
  doSearch() {
59
69
  if (!this.apiId) {
@@ -126,7 +136,25 @@ export default {
126
136
  console.error('num 跳转失败:', error.msg)
127
137
  this.$message.error(error.msg)
128
138
  }
129
- }
139
+ },
140
+ onTabClick() {
141
+ console.log("num onTabClick 卡片点击触发父组件事件,当前实例:", this.widget.id + "_" + this.widget.name)
142
+ this.emitNumIdxTabClicked()
143
+ },
144
+ emitNumIdxTabClicked() {
145
+ if (this.tabClickable) {
146
+ // 发布卡片激活事件
147
+ EventBus.$emit(EVENT_TYPES.NUM_IDX_ACTIVATED, {
148
+ rootId: this.widget.rootId,
149
+ widgetId: this.widget.id,
150
+ widgetName: this.widget.name,
151
+ options: this.widget.options,
152
+ idxBizCode: this.widget.options.idxBizCode || null,
153
+ instance: this
154
+ })
155
+ }
156
+ },
157
+
130
158
  },
131
159
  created() {
132
160
  console.log("num-idx widget:", this.widget)
@@ -143,7 +171,10 @@ export default {
143
171
  this.doSearch()
144
172
  },
145
173
  deep: true
146
- },
174
+ }
175
+ },
176
+ beforeDestroy() {
177
+
147
178
  }
148
179
  }
149
180
  </script>
@@ -26,6 +26,7 @@ import { getPageConfig } from '../api/config'
26
26
  import { deepCopy } from "@lambo-design/shared/utils/assist"
27
27
  import { getWidgetName } from '../util/widget-map'
28
28
  import { setRouteCfg2Search, getInitSearchRes, getSearchFormRes } from './util/common'
29
+ import { EventBus, EVENT_TYPES } from '../util/event-bus'
29
30
 
30
31
  export default {
31
32
  name: 'BiIndexPageTm',
@@ -101,12 +102,19 @@ export default {
101
102
  }
102
103
  this.params = deepCopy(formParams)
103
104
  console.log("index-page-tm doSearch 2 this.params:", this.params)
105
+ },
106
+ handleNumIdxActivated(eventData) {
107
+ console.log('BiPage handleNumIdxActivated eventData:', eventData)
108
+ // 处理数值指标激活事件的逻辑
109
+ this.$set(this.params, 'idxBizCode', eventData["idxBizCode"]);
104
110
  }
105
111
  },
106
112
  created() {
107
113
  this.getConfig()
108
114
  },
109
115
  mounted() {
116
+ // 监听卡片激活事件
117
+ EventBus.$on(EVENT_TYPES.NUM_IDX_ACTIVATED, this.handleNumIdxActivated)
110
118
 
111
119
  },
112
120
  computed: {
@@ -122,6 +130,10 @@ export default {
122
130
  )
123
131
  return filteredWidgets.length > 0
124
132
  }
133
+ },
134
+ beforeDestroy() {
135
+ // 组件销毁前移除事件监听
136
+ EventBus.$off(EVENT_TYPES.NUM_IDX_ACTIVATED, this.handleOtherCardActivated)
125
137
  }
126
138
  }
127
139
  </script>
@@ -0,0 +1,10 @@
1
+ import Vue from 'vue'
2
+
3
+ // 创建全局事件总线
4
+ export const EventBus = new Vue()
5
+
6
+ // 定义事件类型常量
7
+ export const EVENT_TYPES = {
8
+ NUM_IDX_ACTIVATED: 'num-idx-activated',
9
+ NUM_IDX_DEACTIVATED: 'num-idx-deactivated'
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambo-design-bi",
3
- "version": "0.0.183",
3
+ "version": "0.0.185",
4
4
  "description": "Vue2 BI 数据可视化组件库",
5
5
  "main": "index.js",
6
6
  "author": "finch",
@@ -94,7 +94,9 @@ function getLevelOption() {
94
94
  * 40 金字塔图
95
95
  * 41 矩形树图
96
96
  * 42 桑基图
97
- * 43 仪表盘进度条) <br/>
97
+ * 43 仪表盘进度条)
98
+ * 2A:单个柱状图以及多条折线,
99
+ * 2B:单个柱状图以及左右 <br/>
98
100
  * dataX:x轴数据 <br/>
99
101
  * dataY:y轴数据 <br/>
100
102
  * dataDim:组数据 (例如柱状图、折线图多组数据) <br/>
@@ -350,6 +352,7 @@ export function getECharts(type, dataX, dataY, dataDim) {
350
352
  }
351
353
  else if (type === '20' || type === '21' || type === '22' || type === '23' || type === '24' || type === '25' || type === '26') {
352
354
  if (type === '20') {
355
+ const dynamicColors = dataDim.map((_, index) => colors[index % colors.length]);
353
356
  opt = {
354
357
  backgroundColor: '#fff',
355
358
  tooltip: {
@@ -358,6 +361,7 @@ export function getECharts(type, dataX, dataY, dataDim) {
358
361
  type: 'shadow'
359
362
  }
360
363
  },
364
+ color: dynamicColors,
361
365
  grid: {
362
366
  top: '5px', left: '0px', right: '10px', bottom: '0px', containLabel: true
363
367
  },
@@ -429,22 +433,22 @@ export function getECharts(type, dataX, dataY, dataDim) {
429
433
  normal: {
430
434
  color: function (params) {
431
435
  let colorArr =
432
- params.value > 0 ? ['#2d8cf0', 'rgb(150,204,251)'] : ['rgb(150,204,251)', '#2d8cf0'];
436
+ params.value > 0 ? ['#2d8cf0', 'rgb(150,204,251)'] : ['rgb(150,204,251)', '#2d8cf0'];
433
437
  return new echarts.graphic.LinearGradient(
434
- 0,
435
- 0,
436
- 0,
437
- 1,
438
- [{
439
- offset: 0,
440
- color: colorArr[0],
441
- },
442
- {
443
- offset: 1,
444
- color: colorArr[1],
445
- },
446
- ],
447
- false
438
+ 0,
439
+ 0,
440
+ 0,
441
+ 1,
442
+ [{
443
+ offset: 0,
444
+ color: colorArr[0],
445
+ },
446
+ {
447
+ offset: 1,
448
+ color: colorArr[1],
449
+ },
450
+ ],
451
+ false
448
452
  );
449
453
  },
450
454
  barBorderRadius: [1],
@@ -457,6 +461,15 @@ export function getECharts(type, dataX, dataY, dataDim) {
457
461
  fontSize: 10,
458
462
  },
459
463
  data: dataY[0],
464
+ markPoint: {
465
+ data: [
466
+ { type: 'max', name: 'Max' },
467
+ { type: 'min', name: 'Min' }
468
+ ]
469
+ },
470
+ markLine: {
471
+ data: [{ type: 'average', name: 'Avg' }]
472
+ }
460
473
  },
461
474
  ]
462
475
  }
@@ -1179,7 +1192,7 @@ export function getECharts(type, dataX, dataY, dataDim) {
1179
1192
 
1180
1193
  // 将 dataY 转换为带索引的排序数组
1181
1194
  let sortedIndices = dataY[0].map((_, index) => index)
1182
- .sort((a, b) => dataY[0][b] - dataY[0][a]); // 根据 dataX 的值降序排列
1195
+ .sort((a, b) => dataY[0][b] - dataY[0][a]); // 根据 dataX 的值降序排列
1183
1196
 
1184
1197
  for (let i = 0; i < sortedIndices.length; i++) {
1185
1198
  const index = sortedIndices[i];
@@ -1263,7 +1276,7 @@ export function getECharts(type, dataX, dataY, dataDim) {
1263
1276
  let radius = ['40%', '60%']; // 控制饼块粗细的半径范围
1264
1277
  let prevAngle = 0; // 初始角度
1265
1278
  let sortedIndices = dataY[0].map((_, index) => index)
1266
- .sort((a, b) => dataY[0][b] - dataY[0][a]); // 根据dataY的值进行降序排序并获取索引
1279
+ .sort((a, b) => dataY[0][b] - dataY[0][a]); // 根据dataY的值进行降序排序并获取索引
1267
1280
 
1268
1281
  for (let i = 0; i < sortedIndices.length; i++) {
1269
1282
  const index = sortedIndices[i];
@@ -1749,37 +1762,37 @@ export function getECharts(type, dataX, dataY, dataDim) {
1749
1762
  value: dataY[0][index] * dataX.length,
1750
1763
  name: name
1751
1764
  },
1752
- {
1753
- value: sum - dataY[0][index],
1754
- name: name,
1755
- itemStyle: {
1756
- normal: {
1757
- color: "rgba(0,0,0,0)"
1758
- }
1759
- },
1760
- label: {
1761
- normal: {
1762
- show: false,
1765
+ {
1766
+ value: sum - dataY[0][index],
1767
+ name: name,
1768
+ itemStyle: {
1769
+ normal: {
1770
+ color: "rgba(0,0,0,0)"
1771
+ }
1763
1772
  },
1764
- emphasis: {
1765
- show: false
1766
- }
1767
- },
1768
- labelLine: {
1769
- normal: {
1770
- show: false
1773
+ label: {
1774
+ normal: {
1775
+ show: false,
1776
+ },
1777
+ emphasis: {
1778
+ show: false
1779
+ }
1771
1780
  },
1772
- emphasis: {
1773
- show: false
1774
- }
1775
- },
1776
- tooltip: {
1777
- show: false,
1778
- formatter: function () {
1779
- return '';
1781
+ labelLine: {
1782
+ normal: {
1783
+ show: false
1784
+ },
1785
+ emphasis: {
1786
+ show: false
1787
+ }
1788
+ },
1789
+ tooltip: {
1790
+ show: false,
1791
+ formatter: function () {
1792
+ return '';
1793
+ }
1780
1794
  }
1781
1795
  }
1782
- }
1783
1796
  ]
1784
1797
  });
1785
1798
  if (showBackground === true) {
@@ -1894,37 +1907,37 @@ export function getECharts(type, dataX, dataY, dataDim) {
1894
1907
  value: dataY[0][index],
1895
1908
  name: name
1896
1909
  },
1897
- {
1898
- value: sum,
1899
- name: name,
1900
- itemStyle: {
1901
- normal: {
1902
- color: "rgba(0,0,0,0)"
1903
- }
1904
- },
1905
- label: {
1906
- normal: {
1907
- show: false,
1910
+ {
1911
+ value: sum,
1912
+ name: name,
1913
+ itemStyle: {
1914
+ normal: {
1915
+ color: "rgba(0,0,0,0)"
1916
+ }
1908
1917
  },
1909
- emphasis: {
1910
- show: false
1911
- }
1912
- },
1913
- labelLine: {
1914
- normal: {
1915
- show: false
1918
+ label: {
1919
+ normal: {
1920
+ show: false,
1921
+ },
1922
+ emphasis: {
1923
+ show: false
1924
+ }
1916
1925
  },
1917
- emphasis: {
1918
- show: false
1919
- }
1920
- },
1921
- tooltip: {
1922
- show: false,
1923
- formatter: function () {
1924
- return '';
1926
+ labelLine: {
1927
+ normal: {
1928
+ show: false
1929
+ },
1930
+ emphasis: {
1931
+ show: false
1932
+ }
1933
+ },
1934
+ tooltip: {
1935
+ show: false,
1936
+ formatter: function () {
1937
+ return '';
1938
+ }
1925
1939
  }
1926
1940
  }
1927
- }
1928
1941
  ]
1929
1942
  });
1930
1943
  if (showBackground == true) {
@@ -1949,37 +1962,37 @@ export function getECharts(type, dataX, dataY, dataDim) {
1949
1962
  color: "#E3F0FF"
1950
1963
  },
1951
1964
  },
1952
- {
1953
- value: 5,
1954
- name: name,
1955
- itemStyle: {
1956
- normal: {
1957
- color: "rgba(0,0,0,0)"
1958
- }
1959
- },
1960
- label: {
1961
- normal: {
1962
- show: false,
1965
+ {
1966
+ value: 5,
1967
+ name: name,
1968
+ itemStyle: {
1969
+ normal: {
1970
+ color: "rgba(0,0,0,0)"
1971
+ }
1963
1972
  },
1964
- emphasis: {
1965
- show: false
1966
- }
1967
- },
1968
- labelLine: {
1969
- normal: {
1970
- show: false
1973
+ label: {
1974
+ normal: {
1975
+ show: false,
1976
+ },
1977
+ emphasis: {
1978
+ show: false
1979
+ }
1971
1980
  },
1972
- emphasis: {
1973
- show: false
1974
- }
1975
- },
1976
- tooltip: {
1977
- show: false,
1978
- formatter: function () {
1979
- return '';
1981
+ labelLine: {
1982
+ normal: {
1983
+ show: false
1984
+ },
1985
+ emphasis: {
1986
+ show: false
1987
+ }
1988
+ },
1989
+ tooltip: {
1990
+ show: false,
1991
+ formatter: function () {
1992
+ return '';
1993
+ }
1980
1994
  }
1981
1995
  }
1982
- }
1983
1996
  ]
1984
1997
  });
1985
1998
  }
@@ -2310,6 +2323,262 @@ export function getECharts(type, dataX, dataY, dataDim) {
2310
2323
  };
2311
2324
  }
2312
2325
  }
2326
+ else if (type ==='2A'){
2327
+ let series = [];
2328
+ if (dataY.length > 0) {
2329
+ series.push({
2330
+ name: dataDim[0],
2331
+ type: 'bar',
2332
+ barWidth: '30px',
2333
+ itemStyle: {
2334
+ normal: {
2335
+ color: function (params) {
2336
+ const baseColor = colors[0];
2337
+ const lightColor = hexToRgba(baseColor, 0.6);
2338
+ const colorArr = params.value > 0 ? [baseColor, lightColor] : [lightColor, baseColor];
2339
+ return new echarts.graphic.LinearGradient(0, 0, 0, 1, [
2340
+ { offset: 0, color: colorArr[0] },
2341
+ { offset: 1, color: colorArr[1] }
2342
+ ]);
2343
+ },
2344
+ barBorderRadius: [1]
2345
+ }
2346
+ },
2347
+ tooltip: { valueFormatter: value => value },
2348
+ data: dataY.map(item => item[0])
2349
+ });
2350
+ }
2351
+ for (let i = 1; i < 2; i++) {
2352
+ series.push({
2353
+ name: dataDim[i],
2354
+ type: 'line',
2355
+ smooth: true,
2356
+ showAllSymbol: true,
2357
+ symbol: 'circle',
2358
+ showSymbol: true,
2359
+ symbolSize: 5,
2360
+ lineStyle: {
2361
+ color: colors[i % colors.length],
2362
+ width: 3
2363
+ },
2364
+ label: { show: false },
2365
+ itemStyle: {
2366
+ color: colors[i % colors.length],
2367
+ borderColor: hexToRgba(colors[i % colors.length], 0.6),
2368
+ borderWidth: 3
2369
+ },
2370
+ tooltip: { valueFormatter: value => value },
2371
+ data: dataY.map(item => item[1])
2372
+ });
2373
+ }
2374
+ const dynamicColors = dataDim.map((_, index) => colors[index % colors.length]);
2375
+ opt = {
2376
+ tooltip: {
2377
+ trigger: 'axis',
2378
+ axisPointer: {
2379
+ type: 'shadow',
2380
+ lineStyle: { color: '#57617B' }
2381
+ }
2382
+ },
2383
+ legend: {
2384
+ data: dataDim,
2385
+ top: 0,
2386
+ itemWidth: 10,
2387
+ itemHeight: 6,
2388
+ selectedMode: true,
2389
+ textStyle: {
2390
+ fontSize: '10px',
2391
+ fontFamily: 'Microsoft YaHei',
2392
+ fontWeight: '400',
2393
+ color: '#666'
2394
+ },
2395
+ },
2396
+ color: dynamicColors,
2397
+ grid: {
2398
+ top: '5px', left: '0px', right: '10px', bottom: '0px', containLabel: true
2399
+ },
2400
+ xAxis: [
2401
+ {
2402
+ type: 'category',
2403
+ data: dataX,
2404
+ axisLine: {
2405
+ show: true,
2406
+ lineStyle: {
2407
+ color: '#333333'
2408
+ }
2409
+ },
2410
+ axisTick: {
2411
+ show: false
2412
+ }
2413
+ }
2414
+ ],
2415
+ yAxis: [
2416
+ {
2417
+ type: 'value',
2418
+ axisLabel: { formatter: '{value}' },
2419
+ axisLine: {
2420
+ show: false
2421
+ },
2422
+ axisTick: {
2423
+ show: false
2424
+ },
2425
+ splitLine: {
2426
+ show: true,
2427
+ lineStyle: {
2428
+ color: '#f0f0f0'
2429
+ }
2430
+ }
2431
+ }
2432
+ ],
2433
+ series: series
2434
+ };
2435
+ }
2436
+ else if (type ==='2B'){
2437
+ let series = [];
2438
+ if (dataY.length > 0) {
2439
+ series.push({
2440
+ name: dataDim[0],
2441
+ type: 'pictorialBar',
2442
+ barWidth: '30px',
2443
+ symbol: 'rect',
2444
+ symbolSize: ['100%', 4],
2445
+ symbolRepeat: true,
2446
+ symbolMargin: 0.3,
2447
+ symbolBoundingData: Math.max(...dataY.map(item => item[0])),
2448
+ itemStyle: {
2449
+ color: colors[0]
2450
+ },
2451
+ tooltip: { valueFormatter: value => value },
2452
+ data: dataY.map(item => item[0])
2453
+ });
2454
+ }
2455
+ if (dataY.length > 1) {
2456
+ series.push({
2457
+ name: dataDim[1],
2458
+ type: 'line',
2459
+ yAxisIndex: 1,
2460
+ smooth: true,
2461
+ showAllSymbol: true,
2462
+ symbol: 'circle',
2463
+ showSymbol: true,
2464
+ symbolSize: 5,
2465
+ lineStyle: {
2466
+ color: colors[1],
2467
+ width: 3
2468
+ },
2469
+ label: { show: false },
2470
+ itemStyle: {
2471
+ color: colors[1],
2472
+ borderColor: hexToRgba(colors[1], 0.6),
2473
+ borderWidth: 3
2474
+ },
2475
+ tooltip: { valueFormatter: value => value },
2476
+ data: dataY.map(item => item[1])
2477
+ });
2478
+ }
2479
+
2480
+ for (let i = 2; i < 3; i++) {
2481
+ series.push({
2482
+ name: dataDim[i],
2483
+ type: 'line',
2484
+ yAxisIndex: 0,
2485
+ smooth: true,
2486
+ showAllSymbol: true,
2487
+ symbol: 'circle',
2488
+ showSymbol: true,
2489
+ symbolSize: 5,
2490
+ lineStyle: {
2491
+ color: colors[i % colors.length],
2492
+ width: 3
2493
+ },
2494
+ label: { show: false },
2495
+ itemStyle: {
2496
+ color: colors[i % colors.length],
2497
+ borderColor: hexToRgba(colors[i % colors.length], 0.6),
2498
+ borderWidth: 3
2499
+ },
2500
+ tooltip: { valueFormatter: value => value },
2501
+ data: dataY.map(item => item[2])
2502
+ });
2503
+ }
2504
+ const dynamicColors = dataDim.map((_, index) => colors[index % colors.length]);
2505
+
2506
+ opt = {
2507
+ tooltip: {
2508
+ trigger: 'axis',
2509
+ axisPointer: {
2510
+ type: 'shadow',
2511
+ lineStyle: { color: '#57617B' }
2512
+ }
2513
+ },
2514
+ legend: {
2515
+ data: dataDim,
2516
+ top: 0,
2517
+ itemWidth: 10,
2518
+ itemHeight: 6,
2519
+ selectedMode: true,
2520
+ textStyle: {
2521
+ fontSize: '10px',
2522
+ fontFamily: 'Microsoft YaHei',
2523
+ fontWeight: '400',
2524
+ color: '#666'
2525
+ },
2526
+ },
2527
+ color: dynamicColors,
2528
+ grid: {
2529
+ top: '5px', left: '0px', right: '10px', bottom: '0px', containLabel: true
2530
+ },
2531
+ xAxis: [
2532
+ {
2533
+ type: 'category',
2534
+ data: dataX,
2535
+ axisLine: {
2536
+ show: true,
2537
+ lineStyle: {
2538
+ color: '#333333'
2539
+ }
2540
+ },
2541
+ axisTick: {
2542
+ show: false
2543
+ }
2544
+ }
2545
+ ],
2546
+ yAxis: [
2547
+ {
2548
+ type: 'value',
2549
+ name: '',
2550
+ axisLabel: { formatter: '{value}' },
2551
+ axisLine: {
2552
+ show: false
2553
+ },
2554
+ axisTick: {
2555
+ show: false
2556
+ },
2557
+ splitLine: {
2558
+ show: true,
2559
+ lineStyle: {
2560
+ color: '#f0f0f0'
2561
+ }
2562
+ }
2563
+ },
2564
+ {
2565
+ type: 'value',
2566
+ name: '',
2567
+ axisLabel: { formatter: '{value}' },
2568
+ axisLine: {
2569
+ show: false
2570
+ },
2571
+ axisTick: {
2572
+ show: false
2573
+ },
2574
+ splitLine: {
2575
+ show: false
2576
+ }
2577
+ }
2578
+ ],
2579
+ series: series
2580
+ };
2581
+ }
2313
2582
  return opt
2314
2583
  }
2315
2584
 
@@ -1,5 +1,6 @@
1
1
  <template>
2
- <div class="ivu-number-info">
2
+ <div class="ivu-number-info" :class="{ 'card-active': isActive, 'card-tabClickable': tabClickable }"
3
+ @click="handleTabClick">
3
4
  <div class="ivu-number-info-title-lambo title-div" :class="{ 'isDrill': isDrill }" v-if="title" @click="drill">
4
5
  <slot name="title">{{ title }}</slot>
5
6
  <div class="cd-right-top">
@@ -55,12 +56,14 @@
55
56
  </slot>
56
57
  </span>
57
58
  </div>
59
+ <div class="card-bottom-line" :class="{ 'active': isActive }"></div>
58
60
  </div>
59
61
  </template>
60
62
  <script>
61
63
  import { oneOf } from 'view-ui-plus/src/utils/assist'
62
64
  import Trend from 'view-ui-plus/src/components/trend'
63
65
  import 'view-ui-plus/dist/styles/viewuiplus.css'
66
+ import { EVENT_TYPES, EventBus } from '../../bi/widget/util/event-bus'
64
67
 
65
68
  export default {
66
69
  name: 'LamboNumberInfoBi',
@@ -117,7 +120,19 @@ export default {
117
120
  evaLevel: {
118
121
  type: String,
119
122
  default: ''
120
- }
123
+ },
124
+ tabClickable: {
125
+ type: Boolean,
126
+ default: true
127
+ },
128
+ defaultTabActive: {
129
+ type: Boolean,
130
+ default: false
131
+ },
132
+ widget: {
133
+ type: Object,
134
+ default: () => ({})
135
+ },
121
136
  },
122
137
  computed: {
123
138
  valueStyle() {
@@ -126,13 +141,61 @@ export default {
126
141
  };
127
142
  }
128
143
  },
144
+ data() {
145
+ return {
146
+ isActive: false
147
+ }
148
+ },
129
149
  methods: {
130
150
  drill() {
131
151
  if (this.isDrill) {
132
152
  console.log("number-info 点击了下钻按钮")
133
153
  this.$emit('on-drill', {})
134
154
  }
155
+ },
156
+ handleTabClick() {
157
+ if (this.tabClickable) {
158
+ if (!this.isActive) {
159
+ this.isActive = true
160
+ this.$emit('on-tab-click', {})
161
+ }
162
+ console.log("num-info handleTabClick 卡片被点击,当前实例:", this.widget.id + "_" + this.widget.name)
163
+ }
164
+ },
165
+ handleOtherNumIdxTabClicked(eventData) {
166
+ // 处理其他卡片激活事件:如果是同一个页面,且不是当前卡片,则取消激活
167
+ if (eventData && this.widget && this.tabClickable === true && this.isActive === true
168
+ && eventData.rootId === this.widget.rootId && eventData.widgetId !== this.widget.id) {
169
+ this.isActive = false
170
+ console.log(`num-info handleOtherCardActivated 卡片 ${this.widget.id}_${this.widget.name} 因 ${eventData.widgetId}_${eventData.widgetName} 激活而取消激活`)
171
+ }
172
+ },
173
+ eventBusOn() {
174
+ if (this.tabClickable) {
175
+ EventBus.$on(EVENT_TYPES.NUM_IDX_ACTIVATED, this.handleOtherNumIdxTabClicked)
176
+ }
177
+ },
178
+ eventBusOff() {
179
+ if (this.tabClickable) {
180
+ EventBus.$off(EVENT_TYPES.NUM_IDX_ACTIVATED, this.handleOtherNumIdxTabClicked)
181
+ }
182
+ },
183
+ initDefTabClickActiveStatus() {
184
+ if(this.tabClickable === true && this.defaultTabActive === true ){
185
+ if (!this.isActive) {
186
+ this.isActive = true
187
+ this.$emit('on-tab-click', {})
188
+ }
189
+ console.log("num-info handleCardClick 卡片初始设置为激活状态触发点击,当前实例:", this.widget.id + "_" + this.widget.name)
190
+ }
135
191
  }
192
+ },
193
+ created() {
194
+ this.eventBusOn()
195
+ this.initDefTabClickActiveStatus()
196
+ },
197
+ beforeDestroy() {
198
+ this.eventBusOff()
136
199
  }
137
200
  };
138
201
  </script>
@@ -184,4 +247,43 @@ export default {
184
247
  margin-right: -8px;
185
248
  border-top-right-radius: 6px;
186
249
  }
250
+
251
+ // 重写卡片基础样式,添加点击效果
252
+ .ivu-number-info {
253
+ cursor: default;
254
+
255
+ // 新增:可点击状态
256
+ &.card-tabClickable {
257
+ cursor: pointer;
258
+
259
+ &:hover {
260
+ transform: translateY(-2px);
261
+ }
262
+ }
263
+
264
+ // 新增:激活状态
265
+ &.card-active {
266
+ .card-bottom-line.active {
267
+ opacity: 1;
268
+ transform: scaleX(1);
269
+ }
270
+ }
271
+ }
272
+
273
+ .card-bottom-line {
274
+ width: 100%;
275
+ height: 3px;
276
+ margin-bottom: -10px;
277
+ background: linear-gradient(90deg, #1890ff, #69c0ff);
278
+ opacity: 0;
279
+ transform: scaleX(0.8);
280
+ transition: all 0.3s ease;
281
+ border-bottom-left-radius: 6px;
282
+ border-bottom-right-radius: 6px;
283
+
284
+ &.active {
285
+ opacity: 1;
286
+ transform: scaleX(1);
287
+ }
288
+ }
187
289
  </style>