| | |
| | | width="50" |
| | | align="center" |
| | | > |
| | | <template slot-scope="{ row }"> |
| | | <el-checkbox :disabled="!isRowSelectable(row)" :value=isSelected(row) @change="handleSelectChange(row, $event)"></el-checkbox> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="编号" type="index" width="50"> |
| | | </el-table-column> |
| | |
| | | }, |
| | | detailsVisible: false, |
| | | selectedRows: [], |
| | | selectNums: [], |
| | | backupSelectedNums: [], |
| | | }; |
| | | }, |
| | | components: { |
| | |
| | | ][idx - 1]; |
| | | export_json_to_excel(tHeader, excelData, fileName); |
| | | }, |
| | | isRowSelectable(row, index) { |
| | | isRowSelectable(row) { |
| | | return row.alarmLevel != 1; |
| | | }, |
| | | toggleRowSelection(row, selected) { |
| | | if (selected) { |
| | | this.selectedRows.push(row); |
| | | } else { |
| | | this.selectedRows = this.selectedRows.filter(r => r !== row); |
| | | } |
| | | updateSelectionState() { |
| | | // console.log('updateSelectionState ?', '============='); |
| | | this.$nextTick(() => { |
| | | // console.log('updateSelectionState', JSON.stringify(this.backupSelectedNums), '============='); |
| | | |
| | | this.backupSelectedNums.forEach(num => { |
| | | const row = this.table1.datas.find(item => item.num === num); |
| | | if (row) this.$refs.unconfirmTable.toggleRowSelection(row, true); |
| | | }); |
| | | }); |
| | | |
| | | }, |
| | | |
| | | isSelected(row) { |
| | | return this.backupSelectedNums.includes(row.num); |
| | | }, |
| | | handleSelectChange(row, checked) { |
| | | // console.log('handleSelectChange?', '============='); |
| | | |
| | | if (row.alarmLevel == 1) return; // 禁用行直接返回 |
| | | const index = this.selectNums.indexOf(row.num); |
| | | if (checked && index === -1) { |
| | | this.selectNums.push(row.num); |
| | | } else if (!checked && index > -1) { |
| | | this.selectNums.splice(index, 1); |
| | | } |
| | | |
| | | }, |
| | | handleSelect(data) { |
| | | // console.log('handleSelect', data, '============='); |
| | | this.selectedRows = data; |
| | | // console.log('handleSelect ?', data, '============='); |
| | | let nums = []; |
| | | let selectedRows = []; |
| | | // console.log('handleSelect ', data, '============='); |
| | | for (let i = 0, len = data.length; i < len; i++) { |
| | | if (data[i].alarmLevel != 1) { |
| | | nums.push(data[i].num); |
| | | selectedRows.push(data[i]); |
| | | } else { |
| | | this.$refs.unconfirmTable.toggleRowSelection(data[i], false); |
| | | } |
| | | } |
| | | // console.log('nums', nums, 'selectedRows', selectedRows, '============='); |
| | | |
| | | this.selectNums = nums; |
| | | // this.backupSelectedNums = nums; |
| | | // this.selectedRows = data.filter(row => row.alarmLevel != 1); |
| | | this.selectedRows = selectedRows; |
| | | |
| | | |
| | | }, |
| | | // 批量确认 |
| | |
| | | if (isExportFile) { |
| | | this.exportFile(list, 1); |
| | | } else { |
| | | // console.log('update tabledata', JSON.stringify(this.selectNums), '============='); |
| | | |
| | | this.backupSelectedNums = [...this.selectNums]; |
| | | this.table1.datas = list; |
| | | // this.updateSelectionState(); |
| | | this.updateSelectionState(); |
| | | } |
| | | } else { |
| | | this.total1 = 0; |