jianghu-ui 1.0.4 → 1.0.5

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": "jianghu-ui",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "JianghuJS UI Component Library with Storybook, Vue 2, and Vuetify 2",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -844,6 +844,10 @@ export default {
844
844
  dense: {
845
845
  type: Boolean,
846
846
  default: false
847
+ },
848
+ context: {
849
+ type: Object,
850
+ default: null
847
851
  }
848
852
  },
849
853
  data() {
@@ -1267,7 +1271,7 @@ export default {
1267
1271
  },
1268
1272
  getColumnRawValue(header, item, value) {
1269
1273
  if (header && typeof header.valueGetter === 'function') {
1270
- return header.valueGetter(item, header);
1274
+ return header.valueGetter.call(this.context, item, header);
1271
1275
  }
1272
1276
  if (value !== undefined) return value;
1273
1277
  const key = header?.value;
@@ -1276,7 +1280,7 @@ export default {
1276
1280
  },
1277
1281
  applyValueFormatter(header, rawValue, item, index = 0) {
1278
1282
  if (header && typeof header.valueFormatter === 'function') {
1279
- const formatted = header.valueFormatter(rawValue, item, header, index);
1283
+ const formatted = header.valueFormatter.call(this.context, rawValue, item, header, index);
1280
1284
  if (formatted !== undefined && formatted !== null) {
1281
1285
  return formatted;
1282
1286
  }
@@ -1537,7 +1541,7 @@ export default {
1537
1541
  if (!this.actionColumn || !this.actionColumn.buttons) return [];
1538
1542
  return this.actionColumn.buttons.filter(btn => {
1539
1543
  if (typeof btn.visible === 'function') {
1540
- return btn.visible(row);
1544
+ return btn.visible.call(this.context, row);
1541
1545
  }
1542
1546
  return btn.visible !== false;
1543
1547
  });
@@ -1549,7 +1553,7 @@ export default {
1549
1553
  if (!confirmed) return;
1550
1554
  }
1551
1555
  if (btn.onClick) {
1552
- await btn.onClick(row);
1556
+ await btn.onClick.call(this.context, row);
1553
1557
  }
1554
1558
  },
1555
1559
  // 复制到剪贴板
@@ -1587,7 +1591,7 @@ export default {
1587
1591
  this.$emit('selection-change', payload);
1588
1592
  this.$emit('input', selectedItems);
1589
1593
  if (this.rowSelection && typeof this.rowSelection.onChange === 'function') {
1590
- this.rowSelection.onChange(payload.selectedRowKeys, selectedItems);
1594
+ this.rowSelection.onChange.call(this.context, payload.selectedRowKeys, selectedItems);
1591
1595
  }
1592
1596
  },
1593
1597
  // 页码改变
@@ -1650,7 +1654,7 @@ export default {
1650
1654
  const value = queryData[key];
1651
1655
  const meta = this.filterFieldMetaMap[key];
1652
1656
  if (meta && typeof meta.transform === 'function') {
1653
- const result = meta.transform(value, queryData);
1657
+ const result = meta.transform.call(this.context, value, queryData);
1654
1658
  if (result && typeof result === 'object' && !Array.isArray(result)) {
1655
1659
  Object.assign(filters, result);
1656
1660
  return;
@@ -1874,7 +1878,7 @@ export default {
1874
1878
  const snapshot = this.getColumnStateSnapshot();
1875
1879
  this.$emit('columns-state-change', snapshot);
1876
1880
  if (this.columnsState && typeof this.columnsState.onChange === 'function') {
1877
- this.columnsState.onChange(snapshot);
1881
+ this.columnsState.onChange.call(this.context, snapshot);
1878
1882
  }
1879
1883
  this.persistColumnState(snapshot);
1880
1884
  },