web-component-gallery 2.3.17 → 2.3.19

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.
@@ -13,19 +13,21 @@
13
13
  <div class="TransferTable__Content">
14
14
  <div class="TransferTable__Left">
15
15
  <Table
16
+ ref="tableA"
16
17
  v-bind="{
17
18
  datas: listDatasA,
18
19
  columns,
19
20
  paginationParams: listPaginationA,
20
21
  rowSelection: {
21
22
  selectedRowKeys: selectedKeys,
22
- onChange: selectedRecords,
23
+ onChange: (selectedKey, selectedRecord) => selectedRecords(selectedKey, selectedRecord, rowKeyA),
23
24
  getCheckboxProps: record => ({
24
25
  props: {
25
26
  disabled: isRecordDisabled(record)
26
27
  }
27
28
  })
28
- }
29
+ },
30
+ ...tablePropsA
29
31
  }"
30
32
  @pageSizeChange="(pagination) => (listPaginationA = pagination, onListPageAHandler())"
31
33
  >
@@ -35,7 +37,7 @@
35
37
  v-for="(op, i) in operateSetting"
36
38
  :key="i"
37
39
  type="link"
38
- :disabled="shouldDisableButton(op, customProps)"
40
+ :disabled="shouldDisableButton(op, rowKeyA)"
39
41
  @click="handleTableAction(op.code, customProps)"
40
42
  >
41
43
  {{ op.title }}
@@ -46,21 +48,23 @@
46
48
 
47
49
  <div class="TransferTable__Right">
48
50
  <Table
51
+ ref="tableB"
49
52
  v-bind="{
50
53
  datas: listDatasB,
51
54
  columns: resetColumnsB,
52
55
  paginationParams: listPaginationB,
53
56
  rowSelection: {
54
57
  selectedRowKeys: selectedKeys,
55
- onChange: selectedRecords,
58
+ onChange: (selectedKey, selectedRecord) => selectedRecords(selectedKey, selectedRecord, rowKeyB),
56
59
  getCheckboxProps: record => ({
57
60
  props: {
58
61
  disabled: isRecordDisabled(record)
59
62
  }
60
63
  })
61
- }
64
+ },
65
+ ...tablePropsB
62
66
  }"
63
- @pageSizeChange="(pagination) => (listPaginationB = pagination, onListPageBHandler())"
67
+ @pageSizeChange="onListPageBHandler"
64
68
  >
65
69
  <span class="Table__Name" slot="ATableTitle">已选{{title}}列表</span>
66
70
  <template #action="{customProps, index}">
@@ -68,7 +72,7 @@
68
72
  v-for="(op, i) in operateSetting"
69
73
  :key="i"
70
74
  type="link"
71
- :disabled="shouldDisableButton(op, customProps)"
75
+ :disabled="shouldDisableButton(op, rowKeyB)"
72
76
  @click="handleTableAction(op.code, customProps)"
73
77
  >
74
78
  {{ op.title }}
@@ -109,6 +113,16 @@ export default {
109
113
  columns: Array,
110
114
  // B列表项配置(如不传,则默认与A列表项一致)
111
115
  columnsB: Array,
116
+ // A表额外属性配置
117
+ tablePropsA: {
118
+ type: Object,
119
+ default: () => ({})
120
+ },
121
+ // B表额外属性配置
122
+ tablePropsB: {
123
+ type: Object,
124
+ default: () => ({})
125
+ },
112
126
  // 支持传递额外参数
113
127
  extraParams: {
114
128
  type: Object,
@@ -165,6 +179,14 @@ export default {
165
179
  // B表格项配置
166
180
  resetColumnsB() {
167
181
  return this.columnsB || this.columns
182
+ },
183
+ // A表 rowKey
184
+ rowKeyA() {
185
+ return this.$refs.tableA.rowKey
186
+ },
187
+ // B表 rowKey
188
+ rowKeyB() {
189
+ return this.$refs.tableB.rowKey
168
190
  }
169
191
  },
170
192
  watch: {
@@ -183,7 +205,7 @@ export default {
183
205
  method: 'modalOpen',
184
206
  params: record
185
207
  })
186
- },
208
+ },
187
209
  handleReset() {
188
210
  this.searchForm = {}
189
211
  this.handleSearch()
@@ -216,42 +238,42 @@ export default {
216
238
  },
217
239
 
218
240
  // 获取右侧表格数据(从已选记录中分页)
219
- onListPageBHandler() {
241
+ onListPageBHandler(paginationB) {
220
242
  try {
221
243
  const chunks = chunkArray(this.selectedRecordsB, this.listPaginationB.size)
222
244
  this.listPaginationB = {
223
245
  ...this.listPaginationB,
224
- current: chunks.length,
246
+ ...(paginationB || { current: chunks.length }),
225
247
  total: this.selectedRecordsB.length
226
248
  }
227
249
  this.listDatasB = chunks[this.listPaginationB.current - 1] || []
228
250
 
229
251
  // 同步选中状态
230
- this.selectedKeys = this.selectedRecordsB.map(r => r.id)
252
+ this.selectedKeys = this.selectedRecordsB.map(r => r[this.rowKeyB])
231
253
  } catch(err) {
232
254
  console.error('更新已选列表失败:', err)
233
255
  }
234
256
  },
235
257
 
236
258
  // 取消 / 选择当前行
237
- selectedRecords(selectedKey, selectedRecord) {
238
- const currentIds = new Set(this.selectedRecordsB.map(r => r.id))
259
+ selectedRecords(selectedKey, selectedRecord, rowKey) {
260
+ const currentIds = new Set(this.selectedRecordsB.map(r => r[this.rowKeyB]))
239
261
  const newIds = new Set(selectedKey)
240
262
 
241
263
  this.selectedRecordsB = newIds.size > currentIds.size
242
- ? [...this.selectedRecordsB, ...selectedRecord.filter(r =>
243
- newIds.has(r.id) && !currentIds.has(r.id)
244
- )]
245
- : this.selectedRecordsB.filter(r => newIds.has(r.id))
264
+ ? [...this.selectedRecordsB, ...selectedRecord.map(r => {
265
+ if (newIds.has(r[rowKey]) && !currentIds.has(r[rowKey])) return { ...r, [this.rowKeyB]: r[rowKey] }
266
+ }).filter(Boolean)]
267
+ : this.selectedRecordsB.filter(r => newIds.has(r[this.rowKeyB]))
246
268
  },
247
269
 
248
270
  // 检查记录是否已被保存(需要禁用)
249
- isRecordDisabled(record) {
250
- return this.savedRecordIds.includes(record.id)
271
+ isRecordDisabled(rowKey) {
272
+ return this.savedRecordIds.includes(rowKey)
251
273
  },
252
274
 
253
275
  // 判断按钮是否应该禁用
254
- shouldDisableButton(operation, record) {
276
+ shouldDisableButton(operation, rowKey) {
255
277
  // 如果没有设置 savedRecordIds,则不禁用任何按钮
256
278
  if (!this.savedRecordIds || this.savedRecordIds.length === 0) {
257
279
  return false
@@ -263,7 +285,7 @@ export default {
263
285
  }
264
286
 
265
287
  // 默认情况下,已保存的记录相关操作按钮会被禁用
266
- return this.isRecordDisabled(record)
288
+ return this.isRecordDisabled(rowKey)
267
289
  }
268
290
  }
269
291
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-component-gallery",
3
- "version": "2.3.17",
3
+ "version": "2.3.19",
4
4
  "description": "基础vue、antdvue、less实现的私有组件库",
5
5
  "main": "dist/index.umd.js",
6
6
  "files": [