lambo-design-bi 0.0.236 → 0.0.238

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.
@@ -127,33 +127,75 @@ export default {
127
127
  })
128
128
  }
129
129
  },
130
- buildLinkageParams(row) {
131
- if (!row || !this.linkKeys) {
132
- return {}
130
+ parseJsonConfig(value, errorMsg) {
131
+ if (typeof value !== 'string') {
132
+ return value
133
133
  }
134
- let keyMap = this.linkKeys
135
- if (typeof keyMap === 'string') {
134
+ const trimValue = value.trim()
135
+ if (!trimValue) {
136
+ return value
137
+ }
138
+ if ((trimValue.indexOf('{') === 0 && trimValue.lastIndexOf('}') === trimValue.length - 1)
139
+ || (trimValue.indexOf('[') === 0 && trimValue.lastIndexOf(']') === trimValue.length - 1)) {
136
140
  try {
137
- keyMap = JSON.parse(keyMap)
141
+ return JSON.parse(trimValue)
138
142
  } catch (e) {
139
- console.error("charts联动参数映射JSON解析异常:", this.linkKeys, e)
140
- return {}
143
+ console.error(errorMsg, value, e)
141
144
  }
142
145
  }
146
+ return value
147
+ },
148
+ getLinkWidgetIds() {
149
+ if (typeof this.linkWidgetId !== 'string') {
150
+ return []
151
+ }
152
+ return this.linkWidgetId.split(',').map(item => item.trim()).filter(item => item)
153
+ },
154
+ isLinkWidget(sourceWidgetId) {
155
+ const linkWidgetIds = this.getLinkWidgetIds()
156
+ return linkWidgetIds.indexOf(String(sourceWidgetId)) > -1
157
+ },
158
+ getLinkKeyMap(sourceWidgetId) {
159
+ const keyMap = this.parseJsonConfig(this.linkKeys, "charts联动参数映射JSON解析异常:")
160
+ if (!keyMap || typeof keyMap !== 'object' || Array.isArray(keyMap)) {
161
+ return null
162
+ }
163
+ const widgetKeyMap = keyMap[sourceWidgetId] || keyMap[String(sourceWidgetId)]
164
+ if (widgetKeyMap && typeof widgetKeyMap === 'object' && !Array.isArray(widgetKeyMap)) {
165
+ return widgetKeyMap
166
+ }
167
+ return null
168
+ },
169
+ buildLinkageParams(row, sourceWidgetId) {
170
+ if (!row || !this.linkKeys) {
171
+ return {}
172
+ }
173
+ const keyMap = this.getLinkKeyMap(sourceWidgetId)
143
174
  if (!keyMap || typeof keyMap !== 'object' || Array.isArray(keyMap)) {
175
+ console.warn("charts联动参数映射无效:", {
176
+ sourceWidgetId,
177
+ linkWidgetId: this.linkWidgetId,
178
+ linkKeys: this.linkKeys,
179
+ keyMap
180
+ })
144
181
  return {}
145
182
  }
146
183
  const params = {}
147
184
  Object.keys(keyMap).forEach(paramKey => {
148
185
  params[paramKey] = row[keyMap[paramKey]]
149
186
  })
187
+ console.log("charts联动参数:", {
188
+ sourceWidgetId,
189
+ keyMap,
190
+ params
191
+ })
150
192
  return params
151
193
  },
152
194
  handleTableRowActivated(eventData) {
153
- if (!this.linkWidgetId || !eventData || eventData.sourceWidgetId !== this.linkWidgetId) {
195
+ if (!eventData || !this.isLinkWidget(eventData.sourceWidgetId)) {
154
196
  return
155
197
  }
156
- this.linkageParams = this.buildLinkageParams(eventData.currentRow)
198
+ this.linkageParams = this.buildLinkageParams(eventData.currentRow, eventData.sourceWidgetId)
157
199
  this.doSearch()
158
200
  }
159
201
  },
@@ -2,9 +2,9 @@
2
2
  <div style="width: 100%">
3
3
  <LamboPagingTableBi ref="table" :auto-search="false" :columns="columns" :dataUrl="widget.options.url"
4
4
  :border="tableBorder" :show-table-option="true" :exportName="widget.name"
5
- :page-disable="widget.options.isPaging === '0'" :page-size="widget.options.pageSize" :export-request-limit="200"
6
- :isSingleSelectModel="true" :showSummary="widget.options.isAllSum === '1'" :summary-method="handleSummary"
7
- :highlightRow="isRowClick" @on-current-change="onCurrentChange"
5
+ :height="tableHeight" :page-disable="widget.options.isPaging === '0'" :page-size="widget.options.pageSize"
6
+ :export-request-limit="200" :isSingleSelectModel="true" :showSummary="widget.options.isAllSum === '1'"
7
+ :summary-method="handleSummary" :highlightRow="isRowClick" @on-current-change="onCurrentChange"
8
8
  @on-data-load="onDataLoad" :searchParams="tableSearchParams" :show-right-context-menu="hasRightContextMenu">
9
9
  <div slot="search"></div>
10
10
  </LamboPagingTableBi>
@@ -543,6 +543,23 @@ export default {
543
543
  isRowClick() {
544
544
  return this.widget.options.isRowClick === 1 || this.widget.options.isRowClick === '1'
545
545
  },
546
+ tableHeight() {
547
+ const tableHeight = this.widget && this.widget.options ? this.widget.options.tableHeight : ''
548
+ if (tableHeight === null || tableHeight === undefined) {
549
+ return undefined
550
+ }
551
+ const trimHeight = String(tableHeight).trim()
552
+ const heightNumber = Number(trimHeight)
553
+ if (trimHeight && !isNaN(heightNumber) && heightNumber > 0) {
554
+ if (heightNumber <= 50) {
555
+ const headerHeight = 38.4
556
+ const rowHeight = 49.1
557
+ return headerHeight + heightNumber * rowHeight
558
+ }
559
+ return heightNumber
560
+ }
561
+ return undefined
562
+ },
546
563
  columns() {
547
564
  let columns = []
548
565
  if (this.widget && Object.prototype.hasOwnProperty.call(this.widget, "options") && Object.prototype.hasOwnProperty.call(this.widget.options, "columns")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambo-design-bi",
3
- "version": "0.0.236",
3
+ "version": "0.0.238",
4
4
  "description": "Vue2 BI 数据可视化组件库",
5
5
  "main": "index.js",
6
6
  "author": "finch",