fix(external-send): 发货同步失败给出完整原因,前端可看全文

现象:配送列表只显示「店管家发货同步失败:请先」,看不出到底缺什么。

- dgj.sendOrders:失败时拼上平台 ErrorCode、逐单错误(Data[].IsError/ErrMsg/Message),
  并在订单没有运单号时补一句「N 单在店管家还没有运单号(可能未取号/未打印面单)」
- StatusPanel:同步失败原因加 tooltip,鼠标悬停可看完整文案(原来只有 CSS 省略号)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
liufumingren 2026-11-07 08:01:42 +08:00
parent cf0d984224
commit 9cc301916e
2 changed files with 39 additions and 2 deletions

View File

@ -81,6 +81,27 @@ function buildPlatformError(message, res) {
return error;
}
/**
* 收集发货回传响应里的逐单错误(各平台结构不统一,这里按常见字段兜底)
* @param {Object} json 平台响应
* @return {string[]} 可读错误文案
*/
function describeSendErrors(json) {
const out = [];
const data = json && json.Data;
const list = Array.isArray(data) ? data : (data && Array.isArray(data.List) ? data.List : []);
for (const item of list) {
if (!item || typeof item !== 'object') continue;
const isError = item.IsError === true || Number(item.IsError) === 1;
const message = item.ErrorMsg || item.ErrMsg || item.Message || (isError ? '平台返回失败' : '');
if (!message) continue;
const code = item.LogicOrderId || item.OrderCode || item.PlatformOrderId || '';
out.push(code ? `${code}: ${message}` : message);
}
// 去重但保留顺序
return [ ...new Set(out) ].slice(0, 3);
}
/** 订单列表单页条数(平台允许 500) */
const ORDER_PAGE_SIZE = 500;
@ -2848,7 +2869,21 @@ class DgjService extends PrintPlatformService {
throw buildPlatformError(`店管家登录已失效:${(res.json && res.json.Message) || 'token is invalid'}`, res);
}
if (!res.json || res.json.Success !== true) {
const reason = (res.json && (res.json.Message || res.json.ErrorCode)) || `HTTP ${res.status}`;
const json = res.json || {};
const hints = [];
if (json.ErrorCode !== undefined && json.ErrorCode !== null && String(json.ErrorCode) !== '') {
hints.push(`ErrorCode=${json.ErrorCode}`);
}
hints.push(...describeSendErrors(json));
// 平台对「这一单还没运单号」只回一句「请先…」,补一句本地判断,避免只看到半句话
const missingWaybill = orders.filter(item => !String(item.WaybillCode || '').trim()).length;
if (missingWaybill) {
hints.push(`其中 ${missingWaybill} 单在店管家还没有运单号(可能未取号/未打印面单)`);
}
const reason = [
json.Message || `HTTP ${res.status}`,
...hints,
].filter(Boolean).join(';');
throw buildPlatformError(`店管家发货同步失败:${reason}`, res);
}
return res.json;

View File

@ -1007,7 +1007,9 @@ onBeforeUnmount(() => {
<span v-if="Number(row.external_send_times) > 0" class="muted send-times">
第 {{ row.external_send_times }} 次
</span>
<div v-if="row.external_send_error" class="send-error">{{ row.external_send_error }}</div>
<el-tooltip v-if="row.external_send_error" :content="row.external_send_error" placement="top" :show-after="200">
<div class="send-error">{{ row.external_send_error }}</div>
</el-tooltip>
</template>
</el-table-column>
<el-table-column v-if="!isException" prop="remark" label="备注 / 异常原因" min-width="140" show-overflow-tooltip />