Compare commits

..

4 Commits

Author SHA1 Message Date
liufumingren
0601dca37d fix(express-interface):面单余量不属于表单内容,移除 2026-10-27 00:27:27 +08:00
liufumingren
e2e1aeaa95 feat(express-interface): pick 产品编码 from the express product type list
- read product_types from index.getShopExpressList and keep it keyed by both
  wp_code and sys_express_code, mirroring the existing site option mapping
- render 产品编码 as a filterable select labelled "名称(编码)" and keep storing
  the code; hide the field entirely when the express returns no product_types
- clear a stale product_type when the express / platform / shop changes

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-27 00:21:21 +08:00
liufumingren
9aa6e4ca0d fix(login): surface business failures and localize the login panel art
- request interceptor: treat flag=failure / success=false as a business error
  even when code is 0 (the gateway returns code 0 for login failures), so the
  backend message is shown instead of being swallowed
- tag already-notified errors so callers do not toast twice
- user store: throw a readable error when the login response has no token
  (previously crashed on null.token and the login page silently ignored it)
- login page: show an error message for errors the interceptor did not report
- replace the remote gw.alipayobjects.com decoration with a local svg

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-27 00:20:48 +08:00
liufumingren
e9c73ecd79 feat(nav): collapse top menu into a local-only "More" menu and fix navbar icons
- top menu: compute available width via flex layout (fixed logo / right-menu),
  collapse the overflow into a "更多" sub menu with one item per line and
  right-side flyout for nested menus
- align menu item heights (remove el-sub-menu 2px border causing 3px offset),
  rotate the "更多" caret when opened
- add local svg icons: fullscreen / exit-fullscreen / time / message / email
  (were referenced but never added, so the toolbar icons rendered empty)
- navbar icons follow the light text color instead of inheriting dark gray
- replace the empty chat button image with the ChatDotRound icon
- drop the external IM redirect in AiChat: the panel now stays in-app
- localize the avatar fallback (was wpimg.wallstcn.com)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-27 00:20:15 +08:00
16 changed files with 392 additions and 82 deletions

View File

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
<rect width="64" height="64" fill="#d8dee9"/>
<circle cx="32" cy="24" r="11" fill="#f5f7fa"/>
<path d="M32 38c-10 0-18 6-18 14v12h36V52c0-8-8-14-18-14z" fill="#f5f7fa"/>
</svg>

After

Width:  |  Height:  |  Size: 267 B

View File

@ -0,0 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400" width="400" height="400">
<g fill="none" stroke="#ffffff" stroke-width="1.5">
<circle cx="80" cy="70" r="55"/>
<circle cx="320" cy="120" r="90"/>
<circle cx="180" cy="300" r="120"/>
<circle cx="360" cy="330" r="60"/>
<path d="M0 210c70 0 70-70 140-70s70 70 140 70 70-70 120-70"/>
<path d="M0 262c70 0 70-70 140-70s70 70 140 70 70-70 120-70"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 445 B

4
src/icons/svg/email.svg Normal file
View File

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path fill-rule="evenodd" d="M3 4h18a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1zm1 2v12h16V6H4z"/>
<path d="M4.6 6.4 12 11.6l7.4-5.2 1.2 1.7-8.6 6-8.6-6z"/>
</svg>

After

Width:  |  Height:  |  Size: 249 B

View File

@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M9 9h4v2h-2v2H9V9z"/>
<path d="M15 9v4h-2v-2h-2V9h4z"/>
<path d="M9 11v4H5v-2h2v-2h2z"/>
<path d="M15 11h4v2h-2v2h-2v-4z"/>
</svg>

After

Width:  |  Height:  |  Size: 209 B

View File

@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M3 3h7v2H5v5H3V3z"/>
<path d="M14 3h7v7h-2V5h-5V3z"/>
<path d="M3 14h2v5h5v2H3v-7z"/>
<path d="M19 14h2v7h-7v-2h5v-5z"/>
</svg>

After

Width:  |  Height:  |  Size: 206 B

View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M4 3h16a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-9l-5 4v-4H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"/>
</svg>

After

Width:  |  Height:  |  Size: 164 B

4
src/icons/svg/time.svg Normal file
View File

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path fill-rule="evenodd" d="M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20zm0 2a8 8 0 1 0 0 16 8 8 0 0 0 0-16z"/>
<path d="M11 5h2v7.1l3.9 2.3-1 1.7L11 13.3V5z"/>
</svg>

After

Width:  |  Height:  |  Size: 229 B

View File

@ -9,6 +9,7 @@ export default {
"validity": "Validity",
"days": "Days",
"refresh": "Refresh",
"More": "More",
"Close": "Close",
"Close Other": "Close Other",
"Close All": "Close All"

View File

@ -9,6 +9,7 @@ export default {
"validity": "有效期",
"days": "天",
"refresh": "刷新",
"More": "更多",
"Close": "关闭",
"Close Other": "关闭其他",
"Close All": "全部关闭"

View File

@ -109,14 +109,12 @@ import { ref, nextTick, onMounted, watch } from 'vue'
import { useAiStore, AI_IDENTITIES } from '@/stores/modules/ai'
import { Plus, Clock, Close, UserFilled, Service, Position, ChatDotRound, Delete, ArrowDown } from '@element-plus/icons-vue'
import type { ElScrollbar } from 'element-plus'
import { loginToIm } from '@/api/index'
import dayjs from 'dayjs'
const aiStore = useAiStore()
const inputMessage = ref('')
const scrollbarRef = ref<InstanceType<typeof ElScrollbar>>()
const showHistory = ref(false)
const IM_LOGIN_URL = 'https://192.168.11.56:9096/'
const getIconComponent = (iconName: string) => {
const icons: Record<string, any> = { Service }
@ -185,18 +183,6 @@ const sendMessage = () => {
}, 1000)
}
const openImPage = async () => {
try {
const res = await loginToIm()
const imCode = res?.data?.code
if (!imCode) return
const openUrl = `${IM_LOGIN_URL}?token=${encodeURIComponent(imCode)}`
window.open(openUrl, '_blank')
} catch (error) {
console.error('Failed to login to IM:', error)
}
}
watch(() => aiStore.messages.length, () => {
if (!showHistory.value) {
scrollToBottom()
@ -205,19 +191,7 @@ watch(() => aiStore.messages.length, () => {
onMounted(() => {
scrollToBottom()
if (aiStore.isVisible) {
openImPage()
}
})
watch(
() => aiStore.isVisible,
isVisible => {
if (isVisible) {
openImPage()
}
}
)
</script>
<style lang="scss" scoped>

View File

@ -47,7 +47,7 @@
<el-dropdown class="avatar-container right-menu-item" trigger="click">
<div class="avatar-wrapper">
<span class="user-name">{{ user.employees_name || user.username }}</span>
<img :src="avatar || 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif'" class="user-avatar">
<img :src="avatar || defaultAvatar" class="user-avatar">
<svg-icon icon-class="eye" style="font-size: 10px; margin-left: 5px;" />
</div>
<template #dropdown>
@ -81,8 +81,8 @@
<!-- <div class="view-change" @click="toggleLayout">
<svg-icon :icon-class="layoutMode === 'sidebar' ? 'tree' : 'table'" style="font-size: 20px; color: white;" />
</div> -->
<div class="ai-btn" @click="toggleAi">
<img class="ai-img" />
<div class="ai-btn" title="AI 助手" @click="toggleAi">
<el-icon class="ai-icon"><ChatDotRound /></el-icon>
</div>
</div>
</div>
@ -91,6 +91,7 @@
<script setup lang="ts">
import { computed, onMounted, onUnmounted, ref } from 'vue'
import { ChatDotRound } from '@element-plus/icons-vue'
import { useAppStore } from '@/stores/modules/app'
import { useUserStore } from '@/stores/modules/user'
import { useSettingsStore } from '@/stores/modules/settings'
@ -104,6 +105,7 @@ import dayjs from 'dayjs'
import { useFullscreen } from '@vueuse/core'
import { tMenu } from '@/lang/index'
import { afterSaleWorkCount, afterSaleWorkList } from '@/api/aftersale/index'
import defaultAvatar from '@/assets/images/avatar-default.svg'
const { isFullscreen, toggle } = useFullscreen()
@ -243,11 +245,13 @@ onUnmounted(() => {
height: 45px;
overflow: hidden;
position: relative;
display: flex;
align-items: center;
background-color: #0C90FF;
//box-shadow: 0 1px 4px rgba(0, 21, 41, .08);
.logo {
float: left;
flex: 0 0 120px;
margin-left: 25px;
margin-right: 10px;
width: 120px;
@ -269,16 +273,18 @@ onUnmounted(() => {
}
.breadcrumb-container {
float: left;
flex: 0 0 auto;
height: 45px;
display: flex;
align-items: center;
}
.top-menu-wrapper {
float: left;
flex: 1 1 auto;
min-width: 0;
height: 45px;
margin-left: 10px;
overflow: hidden;
:deep(.top-menu-container) {
background-color: transparent !important;
@ -294,7 +300,8 @@ onUnmounted(() => {
}
.right-menu {
float: right;
flex: 0 0 auto;
margin-left: auto;
height: 45px;
display: flex;
align-items: center;
@ -314,6 +321,11 @@ onUnmounted(() => {
cursor: pointer;
transition: background .3s;
/* 顶栏为深色背景,图标统一跟随浅色文字,避免沿用侧边栏的深灰导致看不清 */
:deep(svg.svg-icon) {
color: aliceblue;
}
.day-text,
.validity-text {
color: aliceblue;
@ -416,8 +428,7 @@ onUnmounted(() => {
}
.view-change,
.ai-btn ,
.ai-img {
.ai-btn {
width: 32px;
height: 32px;
border-radius: 50%;
@ -428,6 +439,19 @@ onUnmounted(() => {
cursor: pointer;
}
.ai-btn {
transition: background-color .3s;
&:hover {
background-color: #66b1ff;
}
.ai-icon {
color: #fff;
font-size: 18px;
}
}
</style>

View File

@ -1,5 +1,5 @@
<template>
<div class="top-menu-container">
<div ref="containerRef" class="top-menu-container">
<el-menu
:default-active="activeMenu"
mode="horizontal"
@ -9,31 +9,76 @@
:ellipsis="false"
class="top-menu"
>
<sidebar-item
v-for="route in permission_routes"
:key="route.path"
:item="route"
:base-path="route.path"
<sidebar-item
v-for="menuRoute in visibleRoutes"
:key="menuRoute.path"
:item="menuRoute"
:base-path="menuRoute.path"
:is-horizontal="true"
/>
<el-sub-menu v-if="overflowRoutes.length" index="__top_menu_more__" class="top-menu-more">
<template #title>
<span class="more-title">{{ moreText }}</span>
<el-icon class="more-arrow"><ArrowDown /></el-icon>
</template>
<sidebar-item
v-for="menuRoute in overflowRoutes"
:key="menuRoute.path"
:item="menuRoute"
:base-path="menuRoute.path"
:is-horizontal="true"
:is-nest="true"
/>
</el-sub-menu>
</el-menu>
<!-- 隐藏测量层:用同一套菜单组件量取自然宽度,用于计算需要收纳的菜单数量 -->
<div ref="measureRef" class="top-menu-measure" aria-hidden="true">
<el-menu mode="horizontal" :ellipsis="false" class="top-menu">
<sidebar-item
v-for="menuRoute in routes"
:key="menuRoute.path"
:item="menuRoute"
:base-path="menuRoute.path"
:is-horizontal="true"
/>
<el-sub-menu index="__top_menu_more_measure__" class="top-menu-more">
<template #title>
<span class="more-title">{{ moreText }}</span>
<el-icon class="more-arrow"><ArrowDown /></el-icon>
</template>
</el-sub-menu>
</el-menu>
</div>
</div>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
import { useRoute } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'
import { useI18n } from 'vue-i18n'
import { ArrowDown } from '@element-plus/icons-vue'
import { usePermissionStore } from '@/stores/modules/permission'
import SidebarItem from './Sidebar/SidebarItem.vue'
import variables from '@/styles/variables.module.scss'
const route = useRoute()
const permissionStore = usePermissionStore()
const { t, locale } = useI18n()
const permission_routes = computed(() => {
// Filter out hidden routes
return permissionStore.routes.filter((route: any) => !(route as any).hidden)
})
const containerRef = ref<HTMLElement>()
const measureRef = ref<HTMLElement>()
/** 一级菜单:过滤 hidden,保证与测量层渲染出的节点一一对应 */
const routes = computed(() =>
permissionStore.routes.filter(item => {
const { hidden, meta } = item as RouteRecordRaw & { hidden?: boolean }
return !hidden && !(meta as { hidden?: boolean } | undefined)?.hidden
})
)
const moreText = computed(() => t('common.More'))
const activeMenu = computed(() => {
const { meta, path } = route
@ -42,39 +87,125 @@ const activeMenu = computed(() => {
}
return path
})
/** 展示的一级菜单数量:先全量渲染,测量完成后收敛,避免首帧空白 */
const visibleCount = ref(Number.MAX_SAFE_INTEGER)
/** 各一级菜单的右边界(相对菜单左边界),用于累计已占用宽度 */
const itemRightEdges = ref<number[]>([])
/** 「更多」及其左侧间距占用的宽度 */
const moreBlockWidth = ref(0)
const visibleRoutes = computed(() => routes.value.slice(0, visibleCount.value))
const overflowRoutes = computed(() => routes.value.slice(visibleCount.value))
const recalcVisibleCount = () => {
const container = containerRef.value
const edges = itemRightEdges.value
if (!container) return
if (!edges.length) {
visibleCount.value = routes.value.length
return
}
const available = container.clientWidth
if ((edges[edges.length - 1] ?? 0) <= available) {
visibleCount.value = routes.value.length
return
}
// 放不下:预留「更多」的宽度后,取能完整展示的最长前缀
const limit = available - moreBlockWidth.value
let count = 0
for (const edge of edges) {
if (edge > limit) break
count += 1
}
visibleCount.value = count
}
/** 借助隐藏测量层量取一级菜单实际宽度,并重算收纳数量 */
const measureItems = () => {
const menuEl = measureRef.value?.querySelector('.top-menu') as HTMLElement | null
if (!menuEl) return
const children = Array.from(menuEl.children) as HTMLElement[]
if (!children.length) {
itemRightEdges.value = []
moreBlockWidth.value = 0
recalcVisibleCount()
return
}
// 最后一个子节点固定是「更多」触发器,其余为一级菜单
const moreEl = children[children.length - 1]
if (!moreEl) return
const itemEls = children.slice(0, -1)
const menuRect = menuEl.getBoundingClientRect()
const itemRects = itemEls.map(el => el.getBoundingClientRect())
itemRightEdges.value = itemRects.map(rect => rect.right - menuRect.left)
const moreRect = moreEl.getBoundingClientRect()
const lastRect = itemRects[itemRects.length - 1]
// 间距取「最后一个菜单项 → 更多」的真实间距,避免与外边距重复计算
const gap = lastRect ? Math.max(moreRect.left - lastRect.right, 0) : 0
moreBlockWidth.value = gap + moreRect.width
recalcVisibleCount()
}
const refresh = async () => {
await nextTick()
measureItems()
}
let resizeObserver: ResizeObserver | null = null
onMounted(() => {
refresh()
if (typeof ResizeObserver !== 'undefined') {
resizeObserver = new ResizeObserver(() => recalcVisibleCount())
if (containerRef.value) resizeObserver.observe(containerRef.value)
}
// 字体加载完成后文字宽度会变化,需要重新测量
document.fonts?.ready.then(() => measureItems()).catch(() => {})
})
onUnmounted(() => {
resizeObserver?.disconnect()
resizeObserver = null
})
watch(routes, refresh)
// 切换语言后菜单文本宽度会变化,需要重新测量
watch(locale, refresh)
</script>
<style lang="scss" scoped>
.top-menu-container {
position: relative;
width: 100%;
height: 45px;
background-color: v-bind('variables.menuBg');
border-bottom: 1px solid #d8dce5;
.top-menu {
border-bottom: none;
height: 45px;
display: flex;
align-items: center;
justify-content: flex-start;
padding-left: 20px;
/* Prevent menu items from wrapping and allow horizontal scroll when overflow */
/* 保持单行,超出的部分由「更多」收纳后隐藏,不再出现横向滚动 */
flex-wrap: nowrap;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
white-space: nowrap;
/* Let the menu grow to its content so inner scroll works */
min-width: max-content;
overflow: hidden;
padding-left: 20px;
:deep(.el-menu-item), :deep(.el-sub-menu__title) {
height: 40px !important;
line-height: 40px !important;
margin: 0px 4px;
border-radius: 4px;
/* 统一去掉下边框,避免下拉项与普通菜单项出现 2px 的高差 */
border-bottom: none !important;
font-size: 14px;
padding: 0 8px !important;
display: inline-flex;
white-space: nowrap;
&:hover {
background-color: rgba(0, 0, 0, 0.05) !important;
}
@ -84,5 +215,69 @@ const activeMenu = computed(() => {
display: none !important;
}
}
/* 一级菜单的外层 div 不参与压缩,保证实际渲染宽度与测量结果一致 */
:deep(.top-menu > div) {
flex: 0 0 auto;
display: flex;
align-items: center;
/* 链接层也用 flex,去掉 inline-flex 菜单项带来的行盒下沉(约 3px) */
> a {
display: flex;
align-items: center;
}
}
/* 下拉型一级菜单(如「商品管理」)同样按 flex 排布,避免比普通菜单项高 3px */
:deep(.top-menu > div > li.el-sub-menu) {
display: flex;
align-items: center;
}
.top-menu-more {
flex: 0 0 auto;
:deep(.el-sub-menu__title) {
display: inline-flex;
align-items: center;
gap: 4px;
}
.more-title {
white-space: nowrap;
line-height: 1;
}
.more-arrow {
width: 12px;
height: 12px;
margin: 0;
font-size: 12px;
line-height: 1;
transition: transform .2s ease;
}
&.is-opened .more-arrow {
transform: rotate(180deg);
}
}
/* 测量层:不参与布局与交互,仅用于量取菜单宽度 */
.top-menu-measure {
position: absolute;
top: 0;
left: 0;
height: 0;
overflow: hidden;
visibility: hidden;
pointer-events: none;
.top-menu {
width: max-content;
min-width: max-content;
overflow: visible;
}
}
}
</style>
</style>

View File

@ -42,9 +42,15 @@ export const useUserStore = defineStore('user', {
password,
device: appStore.device
})
const data = resp.data
this.token = data.token
setToken(data.token)
const data = resp.data as { token?: string } | null
// 兜底:业务层未返回 token 时视为登录失败,避免后续在 null 上取属性导致报错被静默吞掉
if (!data?.token) {
const { message } = resp as unknown as { message?: string }
throw new Error(message || '登录失败,请稍后重试')
}
const token = data.token
this.token = token
setToken(token)
// 打印组件连接在路由守卫 getInfo 成功后统一触发一次(此时才可按“用户+仓库”配置决定尝试哪些组件)
return true
},

View File

@ -41,6 +41,24 @@ type ServiceRequestConfig = {
listTimeout?: number | false
}
/**
* 业务失败判定:网关失败时可能返回 code=0,但会同时给出 flag=failure(/failed/fail/error) 或 success=false。
* 仅凭 code 判断会把这类响应误认为成功(例如登录密码错误时页面无任何提示)。
*/
function isBusinessFailure(res: unknown): boolean {
if (!res || typeof res !== 'object') return false
const { success, flag } = res as { success?: unknown; flag?: unknown }
if (success === false || flag === false) return true
return typeof flag === 'string' && ['failure', 'failed', 'fail', 'error'].includes(flag.toLowerCase())
}
/** 统一构造业务错误,并标记是否已由拦截器提示过,避免调用方重复弹窗 */
function createBusinessError(message: string, notified: boolean) {
const err = new Error(message) as Error & { notified?: boolean }
err.notified = notified
return err
}
/** 取出网关接口名(`/system` 网关通过 `params.method` 指定,如 waybill.warehouse.list) */
function getGatewayMethod(config: { params?: unknown }): string | undefined {
const params = config.params as { method?: unknown } | undefined
@ -169,25 +187,25 @@ service.interceptors.response.use(
// 静默请求:业务码/网络失败不弹全局提示(调用方自行回退默认值)
const silentError = Boolean((response.config as unknown as ServiceRequestConfig | undefined)?.silentError)
// 检查业务状态码
if (!SUCCESS_CODES.includes(res.code)) {
// 检查业务状态码(同时识别 flag/success 显式失败标记,见 isBusinessFailure)
if (isBusinessFailure(res) || !SUCCESS_CODES.includes(res?.code)) {
// 优先使用后端返回的 message,如果没有则从映射表获取,最后使用默认值
const errorMessage = res.message || (ERROR_CODE_MAP as Record<number | string, string>)[res.code] || '请求失败'
const errorMessage = res?.message || (ERROR_CODE_MAP as Record<number | string, string>)[res?.code] || '请求失败'
// Token 失效处理
if ([401, 50008, 50012, 50014].includes(res.code)) {
if ([401, 50008, 50012, 50014].includes(res?.code)) {
handleTokenExpired()
return Promise.reject(new Error(errorMessage))
return Promise.reject(createBusinessError(errorMessage, true))
}
// 权限不足处理
if ([403, 40005, 40006].includes(res.code)) {
if ([403, 40005, 40006].includes(res?.code)) {
if (!silentError) ElMessage.warning('没有操作权限')
return Promise.reject(new Error(errorMessage))
return Promise.reject(createBusinessError(errorMessage, !silentError))
}
if (!silentError) ElMessage.error(errorMessage)
return Promise.reject(new Error(errorMessage))
return Promise.reject(createBusinessError(errorMessage, !silentError))
} else {
// 请求成功,返回数据
return res
@ -238,6 +256,7 @@ service.interceptors.response.use(
if ((error.config as unknown as ServiceRequestConfig | undefined)?.silentError !== true) {
ElMessage.error(message)
error.notified = true
}
return Promise.reject(error)
}

View File

@ -347,8 +347,10 @@ const handleLogin = () => {
try {
await userStore.login(loginForm)
router.push({ path: redirect.value || '/', query: otherQuery.value })
} catch {
// handled by interceptor
} catch (err) {
// 拦截器已提示过的错误不再重复弹窗,未提示的(如缺少 token 的兜底异常)在此提示
const { notified, message } = (err ?? {}) as { notified?: boolean; message?: string }
if (!notified) ElMessage.error(message || t('login.loginFailed'))
} finally {
loading.value = false
}
@ -598,7 +600,7 @@ onUnmounted(() => {
height: 100%;
top: 0;
left: 0;
background: url('https://gw.alipayobjects.com/zos/rmsportal/TVirbqOXmUycLUXfInid.svg') no-repeat center;
background: url('../../assets/images/login-panel-pattern.svg') no-repeat center;
background-size: cover;
opacity: 0.1;
}

View File

@ -436,19 +436,21 @@
<el-input v-model="formData.viewer" placeholder="可选,最长 50 字符" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-col v-if="dialogProductTypeOptions.length" :span="12">
<el-form-item label="产品编码">
<el-input v-model="formData.product_type" placeholder="请输入产品编码" />
</el-form-item>
</el-col>
<el-col :span="12" v-if="formData.can_use_count !== undefined">
<el-form-item label="可用单量">
<el-input :model-value="String(formData.can_use_count)" disabled />
</el-form-item>
</el-col>
<el-col :span="12" v-if="dialogMode === 'edit'">
<el-form-item label="可用面单数量">
<el-input :model-value="String(formData.quantity ?? 0)" disabled />
<el-select
v-model="formData.product_type"
filterable
clearable
placeholder="请选择产品编码"
>
<el-option
v-for="item in dialogProductTypeOptions"
:key="item.code"
:label="item.label"
:value="item.code"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
@ -573,6 +575,7 @@ import {
resolveExpressInterfaceAddress
} from './express-interface-config'
type ProductTypeOption = { code: string; name: string; label: string }
type ExpressOption = { code: string; name: string; label?: string; sysExpressCode?: string; providerid?: string }
type PlatformOption = { code: string; name: string; label?: string }
type ShopOption = { value: number | string; label: string }
@ -770,6 +773,8 @@ const activeTemplateExpressCode = computed(() =>
)
const serviceValueMap = ref<Record<string, any>>({})
const shopExpressSitesMap = ref<Record<string, SiteOption[]>>({})
/** 已签约快递 → 产品编码列表(product_types),来源 index.getShopExpressList */
const shopExpressProductTypesMap = ref<Record<string, ProductTypeOption[]>>({})
const selectedSiteKey = ref<string>('')
const selectedAddressKey = ref<string>('')
const SERVICE_EMPTY_ENUM_TOKEN = '__SERVICE_EMPTY_ENUM__'
@ -885,6 +890,21 @@ const dialogSiteOptions = computed<SiteOption[]>(() => {
)
})
/** 当前已选快递的产品编码下拉项;快递未返回 product_types(或为空)时为空数组,对应「产品编码」不展示 */
const dialogProductTypeOptions = computed<ProductTypeOption[]>(() => {
const selectedSignedCode = String(formData.sys_express_code || '').trim()
const selectedSignedExpress = dialogExpressOptions.value.find(
(item) => String(item.sysExpressCode || item.code || '').trim() === selectedSignedCode
)
const selectedSysCode = String(selectedSignedExpress?.sysExpressCode || formData.express_code || '').trim()
if (!selectedSignedCode && !selectedSysCode) return []
return (
shopExpressProductTypesMap.value[selectedSignedCode] ||
shopExpressProductTypesMap.value[selectedSysCode] ||
[]
)
})
const selectedSite = computed<SiteOption | null>(() => {
if (!selectedSiteKey.value) return null
return dialogSiteOptions.value.find((item) => item.key === selectedSiteKey.value) || null
@ -1429,11 +1449,13 @@ async function loadShopExpressOptions(shopId: string | number) {
const res: any = await getShopExpressList({ shop_id: shopId, shopId: shopId })
if (!isSuccess(res)) {
dialogExpressOptions.value = []
shopExpressProductTypesMap.value = {}
ElMessage.error(res?.message || '获取店铺快递列表失败')
return
}
const list = Array.isArray(res?.data?.list) ? res.data.list : []
const siteMap: Record<string, SiteOption[]> = {}
const productTypeMap: Record<string, ProductTypeOption[]> = {}
dialogExpressOptions.value = list
.map((item: any) => {
const code = item?.wp_code || item?.express_code || item?.code
@ -1441,7 +1463,25 @@ async function loadShopExpressOptions(shopId: string | number) {
const providerid = String(item?.providerid || item?.provider_id || item?.providerId || '').trim()
const name = item?.wp_name || item?.express_name || item?.name
const label = item?.label || name
const productTypes: ProductTypeOption[] = []
if (code) {
// 产品编码:快递返回 product_types 时按 code/name 归一化,供「产品编码」下拉使用
const productTypeUniq = new Map<string, ProductTypeOption>()
;(Array.isArray(item?.product_types) ? item.product_types : []).forEach((productType: Record<string, unknown>) => {
const productCode = String(productType?.code ?? '').trim()
if (!productCode || productTypeUniq.has(productCode)) return
const productName = String(productType?.name ?? '').trim()
productTypeUniq.set(productCode, {
code: productCode,
name: productName || productCode,
label: productName && productName !== productCode ? `${productName}(${productCode})` : productCode
})
})
productTypes.push(...productTypeUniq.values())
productTypeMap[code] = productTypes
if (sysExpressCode && sysExpressCode !== code) {
productTypeMap[sysExpressCode] = productTypes
}
const accounts = Array.isArray(item?.accounts) ? item.accounts : []
const mappedSites = accounts.map((acc: any, idx: number) => {
const shipAddresses = Array.isArray(acc?.ship_addresses) ? acc.ship_addresses : []
@ -1570,9 +1610,11 @@ async function loadShopExpressOptions(shopId: string | number) {
)
formData.providerid = String(selectedBySignedCode?.providerid || '').trim()
shopExpressSitesMap.value = siteMap
shopExpressProductTypesMap.value = productTypeMap
} catch {
dialogExpressOptions.value = []
shopExpressSitesMap.value = {}
shopExpressProductTypesMap.value = {}
ElMessage.error('获取店铺快递列表失败')
} finally {
shopExpressLoading.value = false
@ -1770,6 +1812,8 @@ async function handleExpressCodeChange() {
selectedSiteKey.value = ''
selectedAddressKey.value = ''
formData.site_code = ''
// 产品编码随快递变化,切换快递后旧编码不再适用
formData.product_type = ''
formData.providerid = String(selectedSignedExpress?.providerid || '').trim()
formData.shipperno = ''
customExpressOptions.value = []
@ -1817,6 +1861,7 @@ async function handlePlatformCodeChange(value: string | number | undefined) {
formData.site_code = ''
formData.shipperno = ''
formData.sys_express_code = ''
formData.product_type = ''
formData.template_url = ''
formData.template_id = null
templateSelectValue.value = ''
@ -1830,6 +1875,7 @@ async function handlePlatformCodeChange(value: string | number | undefined) {
formData.ext_data = undefined
dialogExpressOptions.value = []
shopExpressSitesMap.value = {}
shopExpressProductTypesMap.value = {}
await loadShopOptions(platformCode)
}
@ -1845,6 +1891,7 @@ async function handleShopChange(value: string | number | undefined) {
formData.ext_data = undefined
formData.shipperno = ''
formData.sys_express_code = ''
formData.product_type = ''
formData.template_url = ''
formData.template_id = null
templateSelectValue.value = ''
@ -1853,6 +1900,7 @@ async function handleShopChange(value: string | number | undefined) {
templateOptions.value = []
dialogExpressOptions.value = []
shopExpressSitesMap.value = {}
shopExpressProductTypesMap.value = {}
selectedSiteKey.value = ''
selectedAddressKey.value = ''
formData.site_code = ''
@ -1902,6 +1950,7 @@ async function openCreate() {
formData.shop_id = undefined
dialogExpressOptions.value = []
shopExpressSitesMap.value = {}
shopExpressProductTypesMap.value = {}
selectedSiteKey.value = ''
selectedAddressKey.value = ''
shopOptions.value = []
@ -1921,6 +1970,7 @@ async function openEdit(row: ExpressInterfaceRecord) {
serviceValueMap.value = {}
dialogExpressOptions.value = []
shopExpressSitesMap.value = {}
shopExpressProductTypesMap.value = {}
selectedSiteKey.value = ''
selectedAddressKey.value = ''
templateOptions.value = []