| | |
| | | onMounted(async () => { |
| | | signalR.off('PublicAlarm'); |
| | | signalR.on('PublicAlarm', (data: any) => { |
| | | console.log(data) |
| | | var listAlarm = tableData.value.filter(t => t.id == data.id); |
| | | if (listAlarm.length == 0) { |
| | | tableData.value.unshift(data) |
| | | console.log(data); |
| | | |
| | | // 更新 tableData |
| | | const index = tableData.value.findIndex(t => t.id == data.id); |
| | | |
| | | if (index === -1) { |
| | | // 如果不存在,添加新数据 |
| | | tableData.value.unshift(data); |
| | | tableParams.value.total = tableData.value.length; |
| | | } else { |
| | | if (data.status == 1) { |
| | | // 如果状态为 1,更新数据 |
| | | tableData.value.splice(index, 1, data); |
| | | } else { |
| | | // 如果状态不是 1,报警消除 |
| | | tableData.value.splice(index, 1); |
| | | } |
| | | } |
| | | |
| | | // 更新输送线数据 |
| | | updateCellData(cellsDataOne, data); |
| | | updateCellData(cellsDataTwo, data); |
| | | updateCellData(cellsDataThree, data); |
| | | }); |
| | | }); |
| | | // 更新输送线数据的通用函数 |
| | | function updateCellData(cellsData: any[], data: any) { |
| | | const foundCell = cellsData.find(cell => cell.Code === data.stationNum); |
| | | if (foundCell) { |
| | | if (data.status == 1) { |
| | | foundCell.IsUse = 4; |
| | | } |
| | | else { |
| | | //如果已经存在就更新数据 |
| | | const index = tableData.value.findIndex(t => t.id == data.id); |
| | | tableData.value.splice(index, 1, data); |
| | | foundCell.IsUse = 0; |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | //堆垛机数据 |
| | | const cellsDataLine = [ |
| | | { Id: 1, Code: '001', LineCode: '', EndLocat: '', IsShow: 1, IsUse: 0, BoxHeight: 10 }, |
| | |
| | | tableData.value = res.data.result; |
| | | tableParams.value.total = tableData.value.length; |
| | | |
| | | //处理一楼输送线数据 |
| | | tableData.value.forEach((item) => { |
| | | const foundCell = cellsDataOne.find(cell => cell.Code === item.stationNum); |
| | | if (foundCell) { |
| | | foundCell.IsUse = 4; |
| | | } |
| | | }); |
| | | //加载输送线数据 |
| | | cellsData.value =cellsDataOne; |
| | | |
| | | //处理二楼输送线数据 |
| | | tableData.value.forEach((item) => { |
| | | const foundCell = cellsDataTwo.find(cell => cell.Code === item.stationNum); |
| | | if (foundCell) { |
| | | foundCell.IsUse = 4; |
| | | } |
| | | }); |
| | | |
| | | //处理三楼输送线数据 |
| | | tableData.value.forEach((item) => { |
| | | const foundCell = cellsDataThree.find(cell => cell.Code === item.stationNum); |
| | | if (foundCell) { |
| | | foundCell.IsUse = 4; |
| | | } |
| | | }); |
| | | // 更新输送线数据 |
| | | updateCells(cellsDataOne); |
| | | updateCells(cellsDataTwo); |
| | | updateCells(cellsDataThree); |
| | | |
| | | console.log(tableParams.value.total); |
| | | loading.value = false; |
| | | }; |
| | | |
| | | // 更新输送线数据的通用函数 |
| | | function updateCells(cellsData: any[]) { |
| | | tableData.value.forEach((item) => { |
| | | updateCellData(cellsData, item); |
| | | }); |
| | | } |
| | | handleQuery(); |
| | | |
| | | //复位报警 |
| | |
| | | gap: 0px; |
| | | /* Gap between cells */ |
| | | |
| | | margin-top: -20px;; |
| | | margin-top: -20px; |
| | | ; |
| | | } |
| | | |
| | | .grid-item { |
| | |
| | | .active2>div { |
| | | display: none; |
| | | } |
| | | |
| | | .active3 { |
| | | background-color: #fff; |
| | | border:1px solid red; |
| | | } |
| | | |
| | | .active3>div { |
| | | display: none; |
| | | } |
| | | |
| | | .active4 { |
| | | background-color: red; |
| | | } |