Commit f8b6d9cd by nningxx

add 设备sort

parent b0a240ed
......@@ -526,17 +526,24 @@
if (!deviceStateData || !Array.isArray(deviceStateData)) {
return;
}
const codeToSeqMap = {};
this.allEquipmentData.forEach(equip => {
codeToSeqMap[equip.code] = equip.sequence;
});
// 获取当前车间下的设备 code 列表
const validCodes = this.allEquipmentData
.filter(e => !this.selectedWorkshop || e.plant_name === this.selectedWorkshop)
.map(e => e.code);
// 过滤掉不属于当前车间的设备
const filteredDevices = deviceStateData.filter(d =>
!this.selectedWorkshop || validCodes.includes(d.code)
);
).map(device => ({
...device,
seq: codeToSeqMap[device.code] || Number.MAX_SAFE_INTEGER // 如果找不到 seq,默认排最后
}));
// 将API返回的数据转换为页面所需的格式
this.deviceList = filteredDevices.map((device) => {
......@@ -553,7 +560,9 @@
}
// 计算持续时间的显示格式
let durationText = "0"
if (device.duration_hours !== undefined) { durationText = this.formatTime(Number(device.duration_hours * 3600)) }
if (device.duration_hours !== undefined) {
durationText = this.formatTime(Number(device.duration_hours * 3600))
}
let run_seconds = "0"
if (device.run_seconds !== undefined) run_seconds = this.formatTime(Number(device.run_seconds))
......@@ -594,7 +603,8 @@
yellow_seconds: yellow_seconds,
red_seconds: red_seconds
}
});
}).sort((a, b) => (codeToSeqMap[a.code] || Number.MAX_SAFE_INTEGER)
- (codeToSeqMap[b.code] || Number.MAX_SAFE_INTEGER));
},
formatTime(seconds) {
......
......@@ -8,6 +8,9 @@
<xpath expr="//field[@name='workshop_id']" position="after">
<field name="data_acquisition_code"/>
</xpath>
<xpath expr="//field[@name='work_center_id']" position="after">
<field name="sequence"/>
</xpath>
</field>
</record>
<record id="view_roke_mes_equipment_tree_tht" model="ir.ui.view">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment