Merge branch 'bugfix/custom-table' into feature/spectrum-analysis
This commit is contained in:
		
						commit
						b0499f0748
					
				|  | @ -50,6 +50,10 @@ export default { | |||
|     canSelect: { | ||||
|       type: Boolean, | ||||
|       default: true | ||||
|     }, | ||||
|     multiple: { | ||||
|       type: Boolean, | ||||
|       default: false | ||||
|     } | ||||
|   }, | ||||
|   data() { | ||||
|  | @ -60,17 +64,24 @@ export default { | |||
|   methods: { | ||||
|     // 实现单击选中/反选功能 | ||||
|     customRow(record) { | ||||
|       const key = record[this.rowKey] | ||||
|       return { | ||||
|         class: this.innerSelectedRowKeys.includes(record[this.rowKey]) ? 'ant-table-row-selected' : '', | ||||
|         class: this.innerSelectedRowKeys.includes(key) ? 'ant-table-row-selected' : '', | ||||
|         on: { | ||||
|           click: () => { | ||||
|             if(!this.canSelect) { | ||||
|               return | ||||
|             } | ||||
|             if (this.innerSelectedRowKeys.includes(record[this.rowKey])) { | ||||
|               this.innerSelectedRowKeys = [] | ||||
|             if (this.innerSelectedRowKeys.includes(key)) { | ||||
|                const findIndex = this.innerSelectedRowKeys.findIndex(k => k == key) | ||||
|                this.innerSelectedRowKeys.splice(findIndex, 1) | ||||
|             } else { | ||||
|               this.innerSelectedRowKeys = [record[this.rowKey]] | ||||
|               if(this.multiple) { | ||||
|                 this.innerSelectedRowKeys.push(key) | ||||
|               } | ||||
|               else { | ||||
|                 this.innerSelectedRowKeys = [key] | ||||
|               } | ||||
|             } | ||||
|             this.$emit('update:selectedRowKeys', this.innerSelectedRowKeys) | ||||
|           } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user