diff --git a/src/views/planning-production/production-monitoring/tray-registration/index.vue b/src/views/planning-production/production-monitoring/tray-registration/index.vue index d5233287..ffd6eb03 100644 --- a/src/views/planning-production/production-monitoring/tray-registration/index.vue +++ b/src/views/planning-production/production-monitoring/tray-registration/index.vue @@ -342,6 +342,20 @@ export default { const payload = res && res.data ? res.data : (res || {}) return payload.data || payload }, + normalizeBatteryCheckResult (res) { + if (res && res.code !== undefined) { + return { + code: Number(res.code), + message: res.msg || res.errmsg, + data: res.data || {} + } + } + return { + code: 0, + message: '', + data: res || {} + } + }, formatLabel (item) { return `${item.tray_format} / ${item.battery_format} / ${item.battery_count}` }, @@ -454,10 +468,9 @@ export default { action: 'check_elements_code', battery_id: batteryId }) - const payload = res && res.data ? res.data : (res || {}) - const data = payload.data || {} - if (payload.code !== undefined && Number(payload.code) !== 0) { - this.$message.error(payload.msg || payload.errmsg || this.$t(this.key('format_error'))) + const { code, message, data } = this.normalizeBatteryCheckResult(res) + if (code !== 0) { + this.$message.error(message || this.$t(this.key('format_error'))) this.removeBattery(channel) return }