Explorar el Código

refactor(photography): 将白底图上传判断改为动态获取李宁企业名单

- 移除硬编码的品牌ID列表 [44584,45488]
- 新增 isLiningCompany 计算属性从用户信息中读取 lining_company_ids
- 支持数组、JSON字符串、逗号分隔字符串等多种数据格式解析
- 增加对空值和异常格式的容错处理
panqiuyao hace 9 horas
padre
commit
736a0d9019
Se han modificado 1 ficheros con 28 adiciones y 1 borrados
  1. 28 1
      frontend/src/views/Photography/detail.vue

+ 28 - 1
frontend/src/views/Photography/detail.vue

@@ -173,7 +173,7 @@
               <svg class="arr"><use href="#i-right"/></svg>
             </div>
             <div
-              v-if="[44584,45488].includes(useUserInfoStore.userInfo.brand_company_id)"
+              v-if="isLiningCompany"
               class="trow"
               @click="handleWhiteBgUploadClick"
               v-log="{ describe: { action: '点击白底图批量上传', service: '白底图批量上传' } }"
@@ -450,6 +450,33 @@ const launchExternalTool = async (pagePath: string, successMessage: string) => {
 
 const handleWhiteBgExportClick = () => launchExternalTool('/copy_800_tool', '白底图批量导出工具已启动')
 const handleWhiteBgUploadClick = () => launchExternalTool('/upload_800_tool', '白底图批量上传工具已启动')
+
+// 李宁企业名单来自 /api/auth/user 的 lining_company_ids,命中则走白底图批量上传
+const isLiningCompany = computed(() => {
+  const info = useUserInfoStore.userInfo as any
+  const brandId = info?.brand_company_id
+  const rawIds = info?.lining_company_ids
+  if (brandId == null || rawIds == null || rawIds === '') return false
+
+  let ids: unknown[] = []
+  if (Array.isArray(rawIds)) {
+    ids = rawIds
+  } else if (typeof rawIds === 'string') {
+    const text = rawIds.trim()
+    if (!text) return false
+    if (text.startsWith('[')) {
+      try {
+        const parsed = JSON.parse(text)
+        ids = Array.isArray(parsed) ? parsed : []
+      } catch {
+        ids = text.split(',')
+      }
+    } else {
+      ids = text.split(',')
+    }
+  }
+  return ids.some((id) => String(id).trim() === String(brandId))
+})
 const handleProductAlbumClick = () => launchExternalTool('/product_list', '产品图册生成工具已启动')
 
 // 货号选择弹窗相关状态