jianghu-ui 1.0.3 → 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.3",
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": {
@@ -9,7 +9,10 @@
9
9
  "build": "webpack --config webpack.config.js",
10
10
  "build:watch": "webpack --config webpack.config.js --watch",
11
11
  "serve-storybook": "npx http-server storybook-static",
12
- "deploy": "npm run build && npm run build-storybook && npx gh-pages -d storybook-static"
12
+ "deploy": "npm run build && npm run build-storybook && npx gh-pages -d storybook-static",
13
+ "release:patch": "npm version patch && npm run build && npm publish",
14
+ "release:minor": "npm version minor && npm run build && npm publish",
15
+ "release:major": "npm version major && npm run build && npm publish"
13
16
  },
14
17
  "keywords": [
15
18
  "jianghujs",
@@ -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() {
@@ -1178,6 +1182,12 @@ export default {
1178
1182
  this.$nextTick(() => this.applySelectionState());
1179
1183
  }
1180
1184
  },
1185
+ actionColumn: {
1186
+ handler() {
1187
+ this.initColumns(this.headers);
1188
+ },
1189
+ deep: true
1190
+ },
1181
1191
  columnsState: {
1182
1192
  deep: true,
1183
1193
  handler(newVal) {
@@ -1216,10 +1226,31 @@ export default {
1216
1226
  methods: {
1217
1227
  // 初始化列配置
1218
1228
  initColumns(headers) {
1229
+ const processedHeaders = [...(headers || [])];
1230
+
1231
+ if (this.actionColumn) {
1232
+ const hasActionColumn = processedHeaders.some(h => h.value === 'action');
1233
+
1234
+ if (!hasActionColumn) {
1235
+ const actionColumnConfig = {
1236
+ text: '操作', value: 'action', sortable: false, width: 120, align: 'center', class: 'fixed', cellClass: 'fixed'
1237
+ };
1238
+
1239
+ if (typeof this.actionColumn === 'object' && this.actionColumn !== null) {
1240
+ const { title, ...restOfActionColumn } = this.actionColumn;
1241
+ Object.assign(actionColumnConfig, restOfActionColumn);
1242
+ if (title) {
1243
+ actionColumnConfig.text = title;
1244
+ }
1245
+ }
1246
+ processedHeaders.push(actionColumnConfig);
1247
+ }
1248
+ }
1249
+
1219
1250
  const persistedState = this.getPersistedColumnState();
1220
1251
  const externalState = this.columnsState?.value;
1221
1252
  const defaultVisible = this.columnsState?.defaultVisible;
1222
- this.internalColumns = headers.map(h => {
1253
+ this.internalColumns = processedHeaders.map(h => {
1223
1254
  const value = h.value || h.dataIndex || h.key;
1224
1255
  const baseVisible = h.visible !== false;
1225
1256
  const visible = this.resolveColumnVisible({
@@ -1240,7 +1271,7 @@ export default {
1240
1271
  },
1241
1272
  getColumnRawValue(header, item, value) {
1242
1273
  if (header && typeof header.valueGetter === 'function') {
1243
- return header.valueGetter(item, header);
1274
+ return header.valueGetter.call(this.context, item, header);
1244
1275
  }
1245
1276
  if (value !== undefined) return value;
1246
1277
  const key = header?.value;
@@ -1249,7 +1280,7 @@ export default {
1249
1280
  },
1250
1281
  applyValueFormatter(header, rawValue, item, index = 0) {
1251
1282
  if (header && typeof header.valueFormatter === 'function') {
1252
- const formatted = header.valueFormatter(rawValue, item, header, index);
1283
+ const formatted = header.valueFormatter.call(this.context, rawValue, item, header, index);
1253
1284
  if (formatted !== undefined && formatted !== null) {
1254
1285
  return formatted;
1255
1286
  }
@@ -1510,7 +1541,7 @@ export default {
1510
1541
  if (!this.actionColumn || !this.actionColumn.buttons) return [];
1511
1542
  return this.actionColumn.buttons.filter(btn => {
1512
1543
  if (typeof btn.visible === 'function') {
1513
- return btn.visible(row);
1544
+ return btn.visible.call(this.context, row);
1514
1545
  }
1515
1546
  return btn.visible !== false;
1516
1547
  });
@@ -1522,7 +1553,7 @@ export default {
1522
1553
  if (!confirmed) return;
1523
1554
  }
1524
1555
  if (btn.onClick) {
1525
- await btn.onClick(row);
1556
+ await btn.onClick.call(this.context, row);
1526
1557
  }
1527
1558
  },
1528
1559
  // 复制到剪贴板
@@ -1560,7 +1591,7 @@ export default {
1560
1591
  this.$emit('selection-change', payload);
1561
1592
  this.$emit('input', selectedItems);
1562
1593
  if (this.rowSelection && typeof this.rowSelection.onChange === 'function') {
1563
- this.rowSelection.onChange(payload.selectedRowKeys, selectedItems);
1594
+ this.rowSelection.onChange.call(this.context, payload.selectedRowKeys, selectedItems);
1564
1595
  }
1565
1596
  },
1566
1597
  // 页码改变
@@ -1623,7 +1654,7 @@ export default {
1623
1654
  const value = queryData[key];
1624
1655
  const meta = this.filterFieldMetaMap[key];
1625
1656
  if (meta && typeof meta.transform === 'function') {
1626
- const result = meta.transform(value, queryData);
1657
+ const result = meta.transform.call(this.context, value, queryData);
1627
1658
  if (result && typeof result === 'object' && !Array.isArray(result)) {
1628
1659
  Object.assign(filters, result);
1629
1660
  return;
@@ -1847,7 +1878,7 @@ export default {
1847
1878
  const snapshot = this.getColumnStateSnapshot();
1848
1879
  this.$emit('columns-state-change', snapshot);
1849
1880
  if (this.columnsState && typeof this.columnsState.onChange === 'function') {
1850
- this.columnsState.onChange(snapshot);
1881
+ this.columnsState.onChange.call(this.context, snapshot);
1851
1882
  }
1852
1883
  this.persistColumnState(snapshot);
1853
1884
  },