| | |
| | | return `${year}-${month}-${day}`; // 返回格式化后的字符串 |
| | | }, |
| | | selectionChange(e) { |
| | | // 只保留最后选中的那一条 |
| | | if (e.detail && e.detail.index !== undefined) { |
| | | this.selectedIndexs = [e.detail.index]; |
| | | // 只允许选中一条 |
| | | if (Array.isArray(e.detail) && e.detail.length > 0) { |
| | | // 只保留最后一条 |
| | | const last = e.detail[e.detail.length - 1]; |
| | | this.selectedIndexs = [this.tableData.indexOf(last)]; |
| | | |
| | | // 取消其他已选 |
| | | // 只选中最后一条 |
| | | this.$nextTick(() => { |
| | | // 获取表格ref |
| | | const table = this.$refs.table; |
| | | if (table && table.clearSelection) { |
| | | if (table && table.clearSelection && table.toggleRowSelection) { |
| | | table.clearSelection(); |
| | | // 重新选中当前 |
| | | table.toggleRowSelection(this.tableData[e.detail.index], true); |
| | | table.toggleRowSelection(last, true); |
| | | } |
| | | }); |
| | | } else { |
| | | this.selectedIndexs = []; |
| | | } |
| | | }, |
| | | |