lambo-design-bi 0.0.183 → 0.0.184

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,5 +1,5 @@
1
1
  <template>
2
- <LamboNumberInfoBi :title="title" :sub-title="subTitle" :num="num" :sub-num1="subNum1" :trend1="trend1"
2
+ <LamboNumberInfoBi :title="title" :sub-title="subTitle" :num="num" :sub-num1="subNum1" :trend1="trend1" :widget="widget"
3
3
  :is-drill="isDrill" @on-drill="onDrill" :sub-num2="subNum2" :trend2="trend2" :polar1="polar1" :polar2="polar2" :eva-level="evaLevel">
4
4
  </LamboNumberInfoBi>
5
5
  </template>
@@ -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
+
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.184",
4
4
  "description": "Vue2 BI 数据可视化组件库",
5
5
  "main": "index.js",
6
6
  "author": "finch",
@@ -1,5 +1,6 @@
1
1
  <template>
2
- <div class="ivu-number-info">
2
+ <div class="ivu-number-info" :class="{ 'card-active': isActive, 'card-clickable': clickable }"
3
+ @click="handleCardClick">
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,13 +56,17 @@
55
56
  </slot>
56
57
  </span>
57
58
  </div>
59
+
60
+ <div class="card-bottom-line" :class="{ 'active': isActive }"></div>
58
61
  </div>
59
62
  </template>
60
63
  <script>
61
64
  import { oneOf } from 'view-ui-plus/src/utils/assist'
62
65
  import Trend from 'view-ui-plus/src/components/trend'
66
+ import { EVENT_TYPES, EventBus } from '../../bi/widget/util/event-bus';
63
67
  import 'view-ui-plus/dist/styles/viewuiplus.css'
64
68
 
69
+
65
70
  export default {
66
71
  name: 'LamboNumberInfoBi',
67
72
  components: { Trend },
@@ -117,7 +122,19 @@ export default {
117
122
  evaLevel: {
118
123
  type: String,
119
124
  default: ''
120
- }
125
+ },
126
+ clickable: {
127
+ type: Boolean,
128
+ default: true
129
+ },
130
+ active: {
131
+ type: Boolean,
132
+ default: false
133
+ },
134
+ widget: {
135
+ type: Object,
136
+ default: () => ({})
137
+ },
121
138
  },
122
139
  computed: {
123
140
  valueStyle() {
@@ -126,13 +143,60 @@ export default {
126
143
  };
127
144
  }
128
145
  },
146
+ data() {
147
+ return {
148
+ isActive: this.active
149
+ }
150
+ },
151
+ watch: {
152
+ active(newVal) {
153
+ this.isActive = newVal
154
+ }
155
+ },
129
156
  methods: {
130
157
  drill() {
131
158
  if (this.isDrill) {
132
159
  console.log("number-info 点击了下钻按钮")
133
160
  this.$emit('on-drill', {})
134
161
  }
162
+ },
163
+ handleCardClick() {
164
+ if (this.clickable) {
165
+ if (!this.isActive) {
166
+ this.activateCard()
167
+ }
168
+ console.log("num-info handleCardClick 卡片被点击,当前实例:", this.widget.id + "_" + this.widget.name)
169
+ }
170
+ },
171
+ // 激活卡片
172
+ activateCard() {
173
+ this.isActive = true
174
+
175
+ // 发布卡片激活事件
176
+ EventBus.$emit(EVENT_TYPES.NUM_IDX_ACTIVATED, {
177
+ widgetId: this.widget.id,
178
+ widgetName: this.widget.name,
179
+ options: this.widget.options,
180
+ instance: this
181
+ })
182
+ },
183
+ // 处理其他卡片激活事件
184
+ handleOtherCardActivated(eventData) {
185
+ // 如果是同一组且不是当前卡片,则取消激活
186
+ if (this.isActive === true && eventData.widgetId !== this.widget.id) {
187
+ this.isActive = false
188
+ console.log(`num-info handleOtherCardActivated 卡片 ${this.widget.id}_${this.widget.name} 因 ${eventData.widgetId}_${eventData.widgetName} 激活而取消激活`)
189
+ }
135
190
  }
191
+ },
192
+ mounted() {
193
+ // 监听卡片激活事件
194
+ EventBus.$on(EVENT_TYPES.NUM_IDX_ACTIVATED, this.handleOtherCardActivated)
195
+ },
196
+
197
+ beforeDestroy() {
198
+ // 组件销毁前移除事件监听
199
+ EventBus.$off(EVENT_TYPES.NUM_IDX_ACTIVATED, this.handleOtherCardActivated)
136
200
  }
137
201
  };
138
202
  </script>
@@ -184,4 +248,43 @@ export default {
184
248
  margin-right: -8px;
185
249
  border-top-right-radius: 6px;
186
250
  }
251
+
252
+ // 重写卡片基础样式,添加点击效果
253
+ .ivu-number-info {
254
+ cursor: default;
255
+
256
+ // 新增:可点击状态
257
+ &.card-clickable {
258
+ cursor: pointer;
259
+
260
+ &:hover {
261
+ transform: translateY(-2px);
262
+ }
263
+ }
264
+
265
+ // 新增:激活状态
266
+ &.card-active {
267
+ .card-bottom-line.active {
268
+ opacity: 1;
269
+ transform: scaleX(1);
270
+ }
271
+ }
272
+ }
273
+
274
+ .card-bottom-line {
275
+ width: 100%;
276
+ height: 3px;
277
+ margin-bottom: -10px;
278
+ background: linear-gradient(90deg, #1890ff, #69c0ff);
279
+ opacity: 0;
280
+ transform: scaleX(0.8);
281
+ transition: all 0.3s ease;
282
+ border-bottom-left-radius: 6px;
283
+ border-bottom-right-radius: 6px;
284
+
285
+ &.active {
286
+ opacity: 1;
287
+ transform: scaleX(1);
288
+ }
289
+ }
187
290
  </style>