@longhongguo/form-create-ant-design-vue 3.3.27 → 3.3.28
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": "@longhongguo/form-create-ant-design-vue",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.28",
|
|
4
4
|
"description": "AntDesignVue版本低代码表单|FormCreate 是一个可以通过 JSON 生成具有动态渲染、数据收集、验证和提交功能的低代码表单生成组件。支持6个UI框架,适配移动端,并且支持生成任何 Vue 组件。内置20种常用表单组件和自定义组件,再复杂的表单都可以轻松搞定。",
|
|
5
5
|
"main": "./dist/form-create.min.js",
|
|
6
6
|
"module": "./dist/form-create.esm.js",
|
|
@@ -70,6 +70,10 @@ export default {
|
|
|
70
70
|
type: Boolean,
|
|
71
71
|
default: false
|
|
72
72
|
},
|
|
73
|
+
selectField: {
|
|
74
|
+
type: String,
|
|
75
|
+
default: 'checked'
|
|
76
|
+
},
|
|
73
77
|
showOperationColumn: {
|
|
74
78
|
type: Boolean,
|
|
75
79
|
default: true
|
|
@@ -197,14 +201,16 @@ export default {
|
|
|
197
201
|
return
|
|
198
202
|
}
|
|
199
203
|
this.oldValue = str
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
this.
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
204
|
+
|
|
205
|
+
// 从数据中读取选中状态,初始化 selectedRows
|
|
206
|
+
if (this.showSelectColumn) {
|
|
207
|
+
this.selectedRows.clear()
|
|
208
|
+
this.modelValue.forEach((data, idx) => {
|
|
209
|
+
if (data && data[this.selectField] === true) {
|
|
210
|
+
this.selectedRows.add(idx)
|
|
211
|
+
}
|
|
212
|
+
})
|
|
213
|
+
}
|
|
208
214
|
|
|
209
215
|
this.trs = this.trs.splice(0, this.modelValue.length)
|
|
210
216
|
if (!this.modelValue.length) {
|
|
@@ -265,9 +271,10 @@ export default {
|
|
|
265
271
|
) {
|
|
266
272
|
return
|
|
267
273
|
}
|
|
268
|
-
//
|
|
274
|
+
// 删除数据行
|
|
275
|
+
this.trs.splice(idx, 1)
|
|
276
|
+
// 更新 selectedRows,删除当前索引,后续索引前移
|
|
269
277
|
this.selectedRows.delete(idx)
|
|
270
|
-
// 更新后续行的索引
|
|
271
278
|
const newSelectedRows = new Set()
|
|
272
279
|
this.selectedRows.forEach(selectedIdx => {
|
|
273
280
|
if (selectedIdx < idx) {
|
|
@@ -278,7 +285,6 @@ export default {
|
|
|
278
285
|
})
|
|
279
286
|
this.selectedRows = newSelectedRows
|
|
280
287
|
|
|
281
|
-
this.trs.splice(idx, 1)
|
|
282
288
|
this.updateValue()
|
|
283
289
|
if (this.trs.length) {
|
|
284
290
|
this.trs.forEach((tr) => this.updateRaw(tr))
|
|
@@ -319,7 +325,9 @@ export default {
|
|
|
319
325
|
// 更新选择列
|
|
320
326
|
if (this.showSelectColumn && tr.children[colOffset]) {
|
|
321
327
|
const selectCell = tr.children[colOffset]
|
|
322
|
-
|
|
328
|
+
// 从数据对象中读取选中状态
|
|
329
|
+
const rowData = this.modelValue[idx]
|
|
330
|
+
const isSelected = rowData && rowData[this.selectField] === true
|
|
323
331
|
if (selectCell.children && selectCell.children[0]) {
|
|
324
332
|
const checkbox = selectCell.children[0]
|
|
325
333
|
checkbox.props.checked = isSelected
|
|
@@ -355,10 +363,18 @@ export default {
|
|
|
355
363
|
}
|
|
356
364
|
},
|
|
357
365
|
toggleRowSelect(idx, checked) {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
366
|
+
// 更新数据对象中的选中状态
|
|
367
|
+
const rowData = this.modelValue[idx]
|
|
368
|
+
if (rowData) {
|
|
369
|
+
if (checked) {
|
|
370
|
+
this.selectedRows.add(idx)
|
|
371
|
+
rowData[this.selectField] = true
|
|
372
|
+
} else {
|
|
373
|
+
this.selectedRows.delete(idx)
|
|
374
|
+
rowData[this.selectField] = false
|
|
375
|
+
}
|
|
376
|
+
// 触发数据更新
|
|
377
|
+
this.updateValue()
|
|
362
378
|
}
|
|
363
379
|
// 更新全选状态
|
|
364
380
|
this.updateSelectAllState()
|
|
@@ -366,17 +382,20 @@ export default {
|
|
|
366
382
|
this.$emit('select-change', Array.from(this.selectedRows))
|
|
367
383
|
},
|
|
368
384
|
toggleSelectAll(checked) {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
if (
|
|
385
|
+
// 更新所有数据对象中的选中状态
|
|
386
|
+
this.modelValue.forEach((rowData, idx) => {
|
|
387
|
+
if (rowData) {
|
|
388
|
+
if (checked) {
|
|
373
389
|
this.selectedRows.add(idx)
|
|
390
|
+
rowData[this.selectField] = true
|
|
391
|
+
} else {
|
|
392
|
+
this.selectedRows.delete(idx)
|
|
393
|
+
rowData[this.selectField] = false
|
|
374
394
|
}
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
}
|
|
395
|
+
}
|
|
396
|
+
})
|
|
397
|
+
// 触发数据更新
|
|
398
|
+
this.updateValue()
|
|
380
399
|
// 更新所有行的选择状态
|
|
381
400
|
this.trs.forEach((tr) => {
|
|
382
401
|
if (!tr._isEmpty) {
|
|
@@ -389,16 +408,18 @@ export default {
|
|
|
389
408
|
updateSelectAllState() {
|
|
390
409
|
if (!this.showSelectColumn) return
|
|
391
410
|
|
|
392
|
-
const validRows = this.
|
|
411
|
+
const validRows = this.modelValue.filter((rowData, idx) => {
|
|
412
|
+
const tr = this.trs[idx]
|
|
413
|
+
return tr && !tr._isEmpty
|
|
414
|
+
})
|
|
393
415
|
if (validRows.length === 0) return
|
|
394
416
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
return this.
|
|
417
|
+
// 从数据对象中读取选中状态
|
|
418
|
+
const allSelected = validRows.every((rowData) => {
|
|
419
|
+
return rowData && rowData[this.selectField] === true
|
|
398
420
|
})
|
|
399
|
-
const someSelected = validRows.some((
|
|
400
|
-
|
|
401
|
-
return this.selectedRows.has(actualIdx)
|
|
421
|
+
const someSelected = validRows.some((rowData) => {
|
|
422
|
+
return rowData && rowData[this.selectField] === true
|
|
402
423
|
})
|
|
403
424
|
|
|
404
425
|
// 更新表头的全选checkbox(通过 DOM 操作)
|
|
@@ -449,6 +470,9 @@ export default {
|
|
|
449
470
|
native: true,
|
|
450
471
|
class: '_fc-tf-head-select',
|
|
451
472
|
style: {
|
|
473
|
+
width: '40px',
|
|
474
|
+
minWidth: '40px',
|
|
475
|
+
maxWidth: '40px',
|
|
452
476
|
textAlign: 'center',
|
|
453
477
|
...(this.headerBackgroundColor
|
|
454
478
|
? {
|
|
@@ -475,6 +499,9 @@ export default {
|
|
|
475
499
|
class: '_fc-tf-select',
|
|
476
500
|
native: true,
|
|
477
501
|
style: {
|
|
502
|
+
width: '40px',
|
|
503
|
+
minWidth: '40px',
|
|
504
|
+
maxWidth: '40px',
|
|
478
505
|
textAlign: 'center'
|
|
479
506
|
},
|
|
480
507
|
children: [
|