Commit f8b6d9cd by nningxx

add 设备sort

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