feat: CustomTable增加同步选中的行功能(selectionRows)
This commit is contained in:
		
							parent
							
								
									d98f7e1dd0
								
							
						
					
					
						commit
						0fd52c80cf
					
				|  | @ -19,7 +19,6 @@ | ||||||
|   </a-table> |   </a-table> | ||||||
| </template> | </template> | ||||||
| <script> | <script> | ||||||
| import {cloneDeep} from 'lodash' |  | ||||||
| export default { | export default { | ||||||
|   props: { |   props: { | ||||||
|     list: { |     list: { | ||||||
|  | @ -47,6 +46,9 @@ export default { | ||||||
|     selectedRowKeys: { |     selectedRowKeys: { | ||||||
|       type: Array |       type: Array | ||||||
|     }, |     }, | ||||||
|  |     selectionRows: { | ||||||
|  |       type: Array | ||||||
|  |     }, | ||||||
|     canSelect: { |     canSelect: { | ||||||
|       type: Boolean, |       type: Boolean, | ||||||
|       default: true |       default: true | ||||||
|  | @ -58,7 +60,8 @@ export default { | ||||||
|   }, |   }, | ||||||
|   data() { |   data() { | ||||||
|     return { |     return { | ||||||
|         innerSelectedRowKeys: cloneDeep(this.selectedRowKeys) || [] |         innerSelectedRowKeys: [], | ||||||
|  |         innerSelectedRows: [] | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   methods: { |   methods: { | ||||||
|  | @ -83,7 +86,6 @@ export default { | ||||||
|                 this.innerSelectedRowKeys = [key] |                 this.innerSelectedRowKeys = [key] | ||||||
|               } |               } | ||||||
|             } |             } | ||||||
|             this.$emit('update:selectedRowKeys', this.innerSelectedRowKeys) |  | ||||||
|           } |           } | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|  | @ -93,8 +95,15 @@ export default { | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   watch: { |   watch: { | ||||||
|     selectedRowKeys () { |     selectedRowKeys (val) { | ||||||
|         this.innerSelectedRowKeys = cloneDeep(this.selectedRowKeys) |         this.innerSelectedRowKeys = val | ||||||
|  |     }, | ||||||
|  |     innerSelectedRowKeys () { | ||||||
|  |       this.$emit('update:selectedRowKeys', this.innerSelectedRowKeys) | ||||||
|  |       this.innerSelectedRows = this.innerSelectedRowKeys.map((key) => { | ||||||
|  |         return this.list.find(item => item[this.rowKey] === key) | ||||||
|  |       }) | ||||||
|  |       this.$emit('update:selectionRows', this.innerSelectedRows) | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   computed: { |   computed: { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user