Commit d1a7021f by 龚桂斌

合并分支 'tht-project' 到 'master'

修改bug

查看合并请求 !22
parents d54af864 c2fd3503
...@@ -233,6 +233,7 @@ ...@@ -233,6 +233,7 @@
if (this.getUrlSearch("factory_code")) { if (this.getUrlSearch("factory_code")) {
this.factoryCode = this.getUrlSearch("factory_code"); //截取url后面的参数 this.factoryCode = this.getUrlSearch("factory_code"); //截取url后面的参数
} }
// this.factoryCode = "66c6bd8c-fd58-11ef-9692-00163e04c506"
this.initCurrentTimeFn() this.initCurrentTimeFn()
}, },
computed: { computed: {
...@@ -529,12 +530,12 @@ ...@@ -529,12 +530,12 @@
this.allEquipmentData.forEach(function (equip) { this.allEquipmentData.forEach(function (equip) {
codeToSeqMap[equip.code] = equip.sequence; codeToSeqMap[equip.code] = equip.sequence;
}); });
// 获取当前车间下的设备 code 列表 // 获取当前车间下的设备 code 列表
var validCodes = this.allEquipmentData var validCodes = this.allEquipmentData.filter(function (e) {
.filter(function (e) { return !this.selectedWorkshop || e.plant_name === this.selectedWorkshop; }.bind(this)) return !this.selectedWorkshop || e.plant_name === this.selectedWorkshop;
.map(function (e) { return e.code; }); }.bind(this)).map(function (e) {
return e.code;
});
// 过滤掉不属于当前车间的设备 // 过滤掉不属于当前车间的设备
var filteredDevices = deviceStateData.filter(function (d) { var filteredDevices = deviceStateData.filter(function (d) {
return !this.selectedWorkshop || validCodes.includes(d.code); return !this.selectedWorkshop || validCodes.includes(d.code);
...@@ -545,7 +546,7 @@ ...@@ -545,7 +546,7 @@
}); });
// 将API返回的数据转换为页面所需的格式 // 将API返回的数据转换为页面所需的格式
this.deviceList = filteredDevices.map(function (device) { var deviceList = filteredDevices.map(function (device, index) {
// 根据API返回的状态确定前端显示的状态 // 根据API返回的状态确定前端显示的状态
var status = "off"; var status = "off";
if (device.state === "green") { if (device.state === "green") {
...@@ -581,10 +582,10 @@ ...@@ -581,10 +582,10 @@
var deviceName = device.name || device.code // 默认使用API返回的名称或编码 var deviceName = device.name || device.code // 默认使用API返回的名称或编码
// 在所有设备列表中查找匹配的设备 // 在所有设备列表中查找匹配的设备
if (this.allEquipmentData && this.allEquipmentData.length > 0) { if (this.allEquipmentData && this.allEquipmentData.length > 0) {
var matchedDevice = this.allEquipmentData.find(function (equip) { return equip.code === device.code; }); var matchedDevice = this.allEquipmentData.find(function (equip) { return equip.code === device.code; })
// 如果找到匹配的设备,使用其名称 // 如果找到匹配的设备,使用其名称
if (matchedDevice && matchedDevice.name) { if (matchedDevice && matchedDevice.name) {
deviceName = device.name ? matchedDevice.name : device.code deviceName = matchedDevice?.name || device.code
} else { } else {
return false return false
} }
...@@ -603,7 +604,9 @@ ...@@ -603,7 +604,9 @@
} }
}.bind(this)).sort(function (a, b) { }.bind(this)).sort(function (a, b) {
return (codeToSeqMap[a.code] || Number.MAX_SAFE_INTEGER) - (codeToSeqMap[b.code] || Number.MAX_SAFE_INTEGER); return (codeToSeqMap[a.code] || Number.MAX_SAFE_INTEGER) - (codeToSeqMap[b.code] || Number.MAX_SAFE_INTEGER);
}); })
// 过滤没有信息项的数据
this.deviceList = deviceList.filter(item => item.id)
}, },
formatTime: function (seconds) { formatTime: function (seconds) {
......
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