فهرست منبع

fix: 层模版页面 — 同步成功提示样式错误 + 设备选择器标注门店

1. handleSyncByDevice 中 res.code 判断从 === 0 改为 === 200 || === 0,
   与 handleSyncAll 保持一致,修复成功后显示红色错误提示的 bug
2. 同步栏设备选择器 label 改为「deviceId — shopName」格式,
   DeviceOption 新增 shopName 字段,方便快速区分不同门店设备

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
skyline 2 هفته پیش
والد
کامیت
65bc79ec13
2فایلهای تغییر یافته به همراه9 افزوده شده و 7 حذف شده
  1. 2 2
      haha-admin-web/src/views/layer-template/index.vue
  2. 7 5
      haha-admin-web/src/views/layer-template/utils/hook.ts

+ 2 - 2
haha-admin-web/src/views/layer-template/index.vue

@@ -174,11 +174,11 @@ function handleSingleSync() {
           <el-option
             v-for="device in deviceOptions"
             :key="device.deviceId"
-            :label="device.label"
+            :label="device.shopName ? `${device.deviceId} — ${device.shopName}` : device.deviceId"
             :value="device.deviceId"
           >
             <div class="flex items-center justify-between w-full">
-              <span>{{ device.label }}</span>
+              <span>{{ device.shopName ? `${device.deviceId} — ${device.shopName}` : device.deviceId }}</span>
               <el-tag
                 v-if="device.isOnline !== undefined && device.isOnline !== null"
                 size="small"

+ 7 - 5
haha-admin-web/src/views/layer-template/utils/hook.ts

@@ -62,6 +62,8 @@ export interface DeviceOption {
   deviceId: string;
   /** 设备名称/编码 / Device name or code */
   label: string;
+  /** 门店名称 / Shop name */
+  shopName?: string;
   /** 在线状态 / Online status */
   isOnline?: number;
 }
@@ -194,10 +196,10 @@ export function useProduct(tableRef?: Ref) {
           .filter((device: any) => device && device.deviceId) // 过滤掉无效数据
           .map((device: any) => ({
             deviceId: String(device.deviceId || ""), // 确保转换为字符串
-            label:
-              device.name ||
-              device.deviceName ||
-              `设备 ${device.deviceId || "未知"}`,
+            label: device.shopName
+              ? `${device.deviceId} — ${device.shopName}`
+              : device.deviceId,
+            shopName: device.shopName || "",
             isOnline: device.isOnline ?? (device.status === 1), // 兼容处理
             status: device.status // 保留原始状态值
           }));
@@ -353,7 +355,7 @@ export function useProduct(tableRef?: Ref) {
       );
 
       const res = await syncLayerTemplate(deviceId);
-      if (res.code === 0) {
+      if (res.code === 200 || res.code === 0) {
         message(`已提交设备 "${deviceLabel}" 的同步请求`, { type: "success" });
         // 延迟刷新以获取最新状态
         setTimeout(() => {