| | |
| | | let day = String(date.getDate()).padStart(2, '0'); // 获取日期并补零 |
| | | return `${year}-${month}-${day}`; // 返回格式化后的字符串 |
| | | }, |
| | | selectionChange(e) { |
| | | // 单选直接赋值 |
| | | this.selectedIndexs = [e.detail.index]; |
| | | }, |
| | | selectionChange(e) { |
| | | // 只保留最后选中的那一条 |
| | | if (e.detail && e.detail.index !== undefined) { |
| | | this.selectedIndexs = [e.detail.index]; |
| | | |
| | | // 取消其他已选 |
| | | this.$nextTick(() => { |
| | | // 获取表格ref |
| | | const table = this.$refs.table; |
| | | if (table && table.clearSelection) { |
| | | table.clearSelection(); |
| | | // 重新选中当前 |
| | | table.toggleRowSelection(this.tableData[e.detail.index], true); |
| | | } |
| | | }); |
| | | } |
| | | }, |
| | | |
| | | selectedItems() { |
| | | return this.selectedIndexs.map(i => this.tableData[i]) |