feat: 新增收集式校验错误弹窗及工位报警语音播报
新增 ErrorListDialog 组件用于统一展示结构化校验错误信息,实现报错一次收全;新增工位报警语音播报功能,通过浏览器 SpeechSynthesis 播放本工位相关报警;调整物料类别及序列号字段文案,移除「其他」类别;新增工单实际开始字段及采集方式配置;优化 AGV 及 PlcSend 页签刷新逻辑;新增看板物料追溯及工位报警接口;删除 PLC 强制写 M 位及相关测试代码;同步数据库字段注释及补丁。
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import axios from 'axios'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { getToken } from './auth'
|
||||
import { showValidationErrors } from './verror'
|
||||
|
||||
// 统一请求实例:baseURL /api,响应为 { code, message, data }
|
||||
const request = axios.create({ baseURL: '/api', timeout: 30000 })
|
||||
@@ -32,6 +33,15 @@ request.interceptors.response.use(
|
||||
const body = resp.data
|
||||
if (body && typeof body === 'object' && 'code' in body) {
|
||||
if (body.code !== 0) {
|
||||
// 收集式校验错误(code=3015,报错一次收全,2026-10-20):
|
||||
// data.errors 结构化清单 → ErrorListDialog 一次弹全,不走 ElMessage 单条
|
||||
if (body.code === 3015 && Array.isArray(body.data?.errors) && body.data.errors.length) {
|
||||
showValidationErrors(body.data.errors)
|
||||
const e = new Error(body.message || '保存失败')
|
||||
e.code = 3015
|
||||
e.errors = body.data.errors
|
||||
return Promise.reject(e)
|
||||
}
|
||||
const msg = friendlyMsg(body.message || '操作失败')
|
||||
ElMessage.error(msg)
|
||||
return Promise.reject(new Error(msg))
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { reactive } from 'vue'
|
||||
|
||||
// 收集式校验错误全局状态(报错一次收全,2026-10-20):
|
||||
// 请求拦截器识别 code=3015 后调 showValidationErrors(errors),
|
||||
// App.vue 挂载的 ErrorListDialog 读取本状态一次弹全,不再 ElMessage 单条挤牙膏。
|
||||
export const state = reactive({ show: false, errors: [] })
|
||||
|
||||
export function showValidationErrors(errors) {
|
||||
state.errors = Array.isArray(errors) ? errors : []
|
||||
state.show = state.errors.length > 0
|
||||
}
|
||||
|
||||
export function closeValidationErrors() {
|
||||
state.show = false
|
||||
}
|
||||
Reference in New Issue
Block a user