| | |
| | | @selection-change="handleSafeHazardSelectionChange" |
| | | style="width: 100%"> |
| | | <el-table-column type="selection" |
| | | width="55" /> |
| | | width="55" |
| | | :selectable="isSelectable" /> |
| | | <el-table-column prop="code" |
| | | label="危险源编码" |
| | | width="180" |
| | |
| | | }); |
| | | }; |
| | | |
| | | const isSelectable = row => { |
| | | // 只有库存数量大于0的行才能被选择 |
| | | return Number(row.stockQty) > 0; |
| | | }; |
| | | |
| | | const handleSafeHazardSelectionChange = selection => { |
| | | // 只保留最后一个选中的项 |
| | | if (selection.length > 1) { |
| | |
| | | |
| | | // 选择变化处理 |
| | | const handleSelectionChange = selection => { |
| | | // 主表格也只保留最后一个选中的项 |
| | | if (selection.length > 1) { |
| | | const lastSelected = selection[selection.length - 1]; |
| | | selectedIds.value = [lastSelected.id]; |
| | | } else if (selection.length === 1) { |
| | | selectedIds.value = [selection[0].id]; |
| | | } else { |
| | | selectedIds.value = []; |
| | | } |
| | | selectedIds.value = selection.map(item => item.id); |
| | | }; |
| | | |
| | | // 打开表单 |