@@ -259,19 +259,14 @@ export default {
259
259
props : {
260
260
list : {
261
261
...props . Array ,
262
- validator : function ( value ) {
263
- var self = this
264
- return ! tools . obj . type . isNull ( value ) && ! tools . obj . type . isUndefined ( value ) ||
265
- value . every && value . every ( e => e [ self . primaryKey ] ) ||
266
- tools . obj . type . isObject ( value ) && value [ self . primaryKey ]
267
- } ,
262
+ validator : value => ! tools . obj . type . isNull ( value ) && ! tools . obj . type . isUndefined ( value ) ,
268
263
} ,
269
264
checked : {
270
- type : [ Array , Object ] ,
265
+ type : [ String , Number , Array , Object ] ,
271
266
} ,
272
267
primaryKey : {
273
268
...props . String ,
274
- default : 'id' ,
269
+ default : null ,
275
270
} ,
276
271
} ,
277
272
data ( ) {
@@ -281,11 +276,9 @@ export default {
281
276
}
282
277
} ,
283
278
mounted ( ) {
284
- if ( this . isMultiple ) {
285
- this . checkedValues = this . checked && tools . obj . type . isArray ( this . checked ) ? this . checked : [ ]
286
- } else {
287
- this . checkedValues = this . checked && tools . obj . type . isObject ( this . checked ) ? this . checked : { }
288
- }
279
+ this . checkedValues = this . isMultiple
280
+ ? this . checked && tools . obj . type . isArray ( this . checked ) ? this . checked : [ ]
281
+ : this . checked && ( tools . obj . type . isObject ( this . checked ) || tools . obj . type . isString ( this . checked ) ) ? this . checked : null
289
282
} ,
290
283
watch : {
291
284
checked : function ( value ) {
@@ -307,8 +300,8 @@ export default {
307
300
isChecked : function ( item ) {
308
301
if ( ! this . checkedMap || this . checkedMap && this . checkedMap . length === 0 ) return false
309
302
return this . isMultiple
310
- ? this . checkedMap . includes && this . checkedMap . includes ( item [ this . primaryKey ] || item )
311
- : ( item && item [ this . primaryKey ] || item ) === this . checkedMap
303
+ ? this . checkedMap . includes && this . checkedMap . includes ( item [ this . primaryKey || 'value' ] || item )
304
+ : ( item && item [ this . primaryKey || 'value' ] || item ) === this . checkedMap
312
305
} ,
313
306
} ,
314
307
} ,
@@ -318,16 +311,16 @@ export default {
318
311
event : 'select:selected' ,
319
312
} ,
320
313
props : {
314
+ primaryKey : {
315
+ ...props . String ,
316
+ default : null ,
317
+ } ,
321
318
list : props . Array ,
322
319
selected : {
323
320
type : [ String , Number , Array , Object ] ,
324
321
default : function ( ) {
325
322
return this . isMultiple ? [ ] : "" ;
326
- }
327
- } ,
328
- primaryKey : {
329
- ...props . String ,
330
- default : 'id' ,
323
+ } ,
331
324
} ,
332
325
multiple : props . Boolean ,
333
326
} ,
@@ -349,20 +342,15 @@ export default {
349
342
} ,
350
343
selectItem : {
351
344
props : {
345
+ primaryKey : {
346
+ ...props . String ,
347
+ default : null ,
348
+ } ,
352
349
item : {
353
350
type : [ String , Number , Array , Object ] ,
354
- validator : function ( value ) {
355
- var self = this
356
- return ! tools . obj . type . isNull ( value ) && ! tools . obj . type . isUndefined ( value ) ||
357
- value . every && value . every ( e => e [ self . primaryKey ] ) ||
358
- tools . obj . type . isObject ( value ) && value [ self . primaryKey ]
359
- } ,
351
+ validator : value => ! tools . obj . type . isNull ( value ) && ! tools . obj . type . isUndefined ( value ) ,
360
352
} ,
361
353
selected : [ String , Number , Array , Object ] ,
362
- primaryKey : {
363
- ...props . String ,
364
- default : 'id' ,
365
- } ,
366
354
isMultiple : props . Boolean ,
367
355
} ,
368
356
computed : {
@@ -375,8 +363,8 @@ export default {
375
363
isSelected : function ( ) {
376
364
if ( ! this . selectedMap || this . selectedMap && this . selectedMap . length === 0 ) return false
377
365
return this . isMultiple
378
- ? this . selectedMap . includes && this . selectedMap . includes ( this . item [ this . primaryKey ] || this . item )
379
- : ( this . item && this . item [ this . primaryKey ] || this . item ) === this . selectedMap
366
+ ? this . selectedMap . includes && this . selectedMap . includes ( this . item [ this . primaryKey || 'value' ] || this . item )
367
+ : ( this . item && this . item [ this . primaryKey || 'value' ] || this . item ) === this . selectedMap
380
368
} ,
381
369
} ,
382
370
} ,
@@ -449,5 +437,6 @@ export default {
449
437
} ,
450
438
}
451
439
} , // thead
440
+
452
441
} , // grid - grid view & table
453
442
}
0 commit comments