fix: 客户侧栏换仓改回中间弹窗
All checks were successful
Build and Deploy Front / deploy (push) Successful in 4m0s

去掉侧栏 Popover,点击寄件仓仍打开 WarehouseAddressPeekModal。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zzh 2026-11-15 21:58:58 +08:00
parent 49ca5072c4
commit d9307c239d
4 changed files with 37 additions and 500 deletions

1
src/components.d.ts vendored
View File

@ -79,6 +79,5 @@ declare module 'vue' {
UserEditDrawer: typeof import('./components/UserEditDrawer/index.vue')['default']
UserProfileFields: typeof import('./components/UserProfileFields/index.vue')['default']
WarehouseAddressPeekModal: typeof import('./components/customer-side-rail/WarehouseAddressPeekModal.vue')['default']
WarehouseSwitcherPopover: typeof import('./components/customer-side-rail/WarehouseSwitcherPopover.vue')['default']
}
}

View File

@ -1,422 +0,0 @@
<script setup lang="ts">
import { computed, ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { IconCheck, IconCopy, IconHome, IconSearch } from '@arco-design/web-vue/es/icon'
import type { WarehouseDto } from '@/api/system/warehouse'
import { useWarehousePeek } from './useWarehousePeek'
const props = defineProps<{
/** 与 trigger 的 popup-visible 同步;打开时拉列表 */
active: boolean
}>()
const emit = defineEmits<{
close: []
openFull: []
}>()
const { t } = useI18n()
const {
loading,
customerCode,
currentId,
currentItem,
orderedList,
displayRecipient,
displayAddress,
copyItem,
copyField,
selectWarehouse,
loadList,
} = useWarehousePeek()
const filterKeyword = ref('')
const SEARCH_THRESHOLD = 6
const showSearch = computed(() => orderedList.value.length >= SEARCH_THRESHOLD)
const filteredList = computed(() => {
const q = filterKeyword.value.trim().toLowerCase()
if (!q) return orderedList.value
return orderedList.value.filter((row) =>
String(row.warehouseName || '')
.toLowerCase()
.includes(q),
)
})
watch(
() => props.active,
(open) => {
if (open) {
filterKeyword.value = ''
void loadList()
}
},
)
function onSelect(item: WarehouseDto) {
const switched = selectWarehouse(item)
if (switched || Number(item.id) === currentId.value) {
emit('close')
}
}
function onOpenFull() {
emit('close')
emit('openFull')
}
function onListKeydown(e: KeyboardEvent, item: WarehouseDto, index: number) {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault()
onSelect(item)
return
}
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
e.preventDefault()
const delta = e.key === 'ArrowDown' ? 1 : -1
const next = index + delta
if (next < 0 || next >= filteredList.value.length) return
const el = document.getElementById(`csr-wh-opt-${filteredList.value[next]?.id}`)
el?.focus()
}
}
</script>
<template>
<div class="wh-switcher" role="dialog" :aria-label="t('nav.warehousePeek.switchTitle')">
<header class="wh-switcher__head">
<div class="wh-switcher__title">
<span>{{ t('nav.warehousePeek.switchTitle') }}</span>
<span v-if="customerCode" class="wh-switcher__code">{{ customerCode }}</span>
</div>
<p class="wh-switcher__tip">{{ t('nav.warehousePeek.tip') }}</p>
</header>
<div v-if="showSearch" class="wh-switcher__search">
<icon-search class="wh-switcher__search-icon" />
<input
v-model="filterKeyword"
type="search"
class="wh-switcher__search-input"
:placeholder="t('nav.warehousePeek.searchPlaceholder')"
autocomplete="off"
/>
</div>
<a-spin :loading="loading" class="wh-switcher__spin">
<div
v-if="!filteredList.length && !loading"
class="wh-switcher__empty"
>
{{ t('nav.warehousePeek.empty') }}
</div>
<ul class="wh-switcher__list" role="listbox" :aria-label="t('nav.warehousePeek.switchTitle')">
<li
v-for="(item, index) in filteredList"
:id="`csr-wh-opt-${item.id}`"
:key="String(item.id)"
role="option"
tabindex="0"
class="wh-switcher__option"
:class="{ 'is-current': Number(item.id) === currentId }"
:aria-selected="Number(item.id) === currentId"
@click="onSelect(item)"
@keydown="onListKeydown($event, item, index)"
>
<icon-home class="wh-switcher__option-icon" />
<span class="wh-switcher__option-name">{{ item.warehouseName || '-' }}</span>
<icon-check
v-if="Number(item.id) === currentId"
class="wh-switcher__option-check"
/>
</li>
</ul>
<section v-if="currentItem" class="wh-switcher__summary" @click.stop>
<div class="wh-switcher__summary-head">
<span>{{ t('nav.warehousePeek.addressSummary') }}</span>
<button
type="button"
class="wh-switcher__copy-all"
@click="copyItem(currentItem)"
>
<icon-copy />
{{ t('nav.warehousePeek.copyAll') }}
</button>
</div>
<div class="wh-switcher__row">
<span class="wh-switcher__label">{{ t('system.warehouseAddress.fields.recipient') }}</span>
<span class="wh-switcher__value" :title="displayRecipient(currentItem)">
{{ displayRecipient(currentItem) }}
</span>
<button type="button" class="wh-switcher__copy" @click="copyField(displayRecipient(currentItem))">
<icon-copy />
</button>
</div>
<div class="wh-switcher__row">
<span class="wh-switcher__label">{{ t('system.warehouseAddress.fields.contactPhone') }}</span>
<span class="wh-switcher__value" :title="currentItem.contactPhone || '-'">
{{ currentItem.contactPhone || '-' }}
</span>
<button type="button" class="wh-switcher__copy" @click="copyField(currentItem.contactPhone || '')">
<icon-copy />
</button>
</div>
<div class="wh-switcher__row">
<span class="wh-switcher__label">{{ t('system.warehouseAddress.fields.shippingAddress') }}</span>
<span class="wh-switcher__value" :title="displayAddress(currentItem)">
{{ displayAddress(currentItem) }}
</span>
<button type="button" class="wh-switcher__copy" @click="copyField(displayAddress(currentItem))">
<icon-copy />
</button>
</div>
</section>
</a-spin>
<footer class="wh-switcher__foot">
<button type="button" class="wh-switcher__full" @click="onOpenFull">
{{ t('nav.warehousePeek.viewFull') }}
</button>
</footer>
</div>
</template>
<style scoped lang="less">
.wh-switcher {
width: min(320px, 86vw);
max-height: min(70vh, 520px);
display: flex;
flex-direction: column;
padding: 10px 0 8px;
color: var(--color-text-1);
&__head {
padding: 0 12px 8px;
}
&__title {
display: flex;
align-items: center;
gap: 8px;
font-size: 13px;
font-weight: 650;
}
&__code {
padding: 1px 6px;
border-radius: 4px;
background: color-mix(in srgb, var(--app-primary-color, #1d7281) 10%, #fff);
color: var(--app-primary-color, #1d7281);
font-size: 11px;
font-weight: 700;
font-variant-numeric: tabular-nums;
}
&__tip {
margin: 4px 0 0;
color: var(--color-text-3);
font-size: 11px;
line-height: 1.4;
}
&__search {
position: relative;
margin: 0 12px 8px;
}
&__search-icon {
position: absolute;
left: 10px;
top: 50%;
transform: translateY(-50%);
color: var(--color-text-4);
font-size: 13px;
pointer-events: none;
}
&__search-input {
width: 100%;
height: 32px;
padding: 0 10px 0 30px;
border: 1px solid var(--color-border-2, #e5e6eb);
border-radius: 6px;
background: #fff;
color: var(--color-text-1);
font-size: 13px;
outline: none;
&:focus {
border-color: color-mix(in srgb, var(--app-primary-color, #1d7281) 45%, transparent);
}
}
&__spin {
display: block;
flex: 1;
min-height: 0;
overflow: auto;
padding: 0 6px;
}
&__empty {
padding: 24px 12px;
text-align: center;
color: var(--color-text-3);
font-size: 13px;
}
&__list {
margin: 0;
padding: 0;
list-style: none;
}
&__option {
display: flex;
align-items: center;
gap: 8px;
min-height: 36px;
padding: 6px 10px;
border-radius: 6px;
cursor: pointer;
outline: none;
transition: background-color 0.14s ease;
&:hover,
&:focus-visible {
background: color-mix(in srgb, var(--app-primary-color, #1d7281) 8%, #fff);
}
&.is-current {
background: color-mix(in srgb, var(--app-primary-color, #1d7281) 10%, #fff);
}
}
&__option-icon {
flex-shrink: 0;
color: var(--app-primary-color, #1d7281);
font-size: 14px;
}
&__option-name {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 13px;
font-weight: 550;
}
&__option-check {
flex-shrink: 0;
color: var(--app-primary-color, #1d7281);
font-size: 14px;
}
&__summary {
margin: 8px 6px 0;
padding: 8px 10px;
border-radius: 8px;
border: 1px solid var(--color-border-2, #e5e6eb);
background: color-mix(in srgb, var(--app-primary-color, #1d7281) 4%, #fff);
}
&__summary-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
margin-bottom: 6px;
color: var(--color-text-2);
font-size: 12px;
font-weight: 600;
}
&__copy-all {
display: inline-flex;
align-items: center;
gap: 4px;
height: 24px;
padding: 0 8px;
border: none;
border-radius: 4px;
background: color-mix(in srgb, var(--app-primary-color, #1d7281) 10%, #fff);
color: var(--app-primary-color, #1d7281);
font-size: 11px;
font-weight: 600;
cursor: pointer;
&:hover {
background: color-mix(in srgb, var(--app-primary-color, #1d7281) 16%, #fff);
}
}
&__row {
display: grid;
grid-template-columns: 52px minmax(0, 1fr) 22px;
align-items: start;
gap: 4px;
padding: 4px 0;
}
&__label {
color: var(--color-text-3);
font-size: 11px;
line-height: 1.45;
}
&__value {
min-width: 0;
color: var(--color-text-1);
font-size: 12px;
line-height: 1.45;
word-break: break-word;
}
&__copy {
display: inline-flex;
align-items: center;
justify-content: center;
width: 22px;
height: 22px;
border: none;
border-radius: 4px;
background: transparent;
color: var(--color-text-4);
cursor: pointer;
font-size: 12px;
&:hover {
color: var(--app-primary-color, #1d7281);
background: color-mix(in srgb, var(--app-primary-color, #1d7281) 8%, #fff);
}
}
&__foot {
padding: 8px 12px 0;
border-top: 1px solid var(--color-border-2, rgba(0, 0, 0, 0.06));
margin-top: 8px;
}
&__full {
width: 100%;
height: 32px;
border: none;
border-radius: 6px;
background: transparent;
color: var(--app-primary-color, #1d7281);
font-size: 12px;
font-weight: 600;
cursor: pointer;
&:hover {
background: color-mix(in srgb, var(--app-primary-color, #1d7281) 8%, #fff);
}
}
}
</style>

View File

@ -85,51 +85,22 @@
<!-- 底栏:当前仓(一级)→ 头像/消息/打印/收起(二级) -->
<div class="customer-side-rail__dock">
<a-trigger
v-model:popup-visible="warehouseSwitcherVisible"
trigger="click"
position="tr"
:popup-translate="[0, -8]"
unmount-on-close
content-class="csr-warehouse-switcher-popup"
<button
type="button"
class="customer-side-rail__warehouse-chip"
:class="{ 'is-compact': compactLayout }"
:title="warehouseDockTitle"
:aria-label="warehouseDockTitle"
@click="openWarehouseAddressPeek"
>
<a-tooltip
:content="warehouseDockTitle"
position="right"
:disabled="!compactLayout || warehouseSwitcherVisible"
>
<button
type="button"
class="customer-side-rail__warehouse-chip"
:class="{
'is-compact': compactLayout,
'is-open': warehouseSwitcherVisible,
}"
:aria-label="warehouseDockTitle"
aria-haspopup="listbox"
:aria-expanded="warehouseSwitcherVisible"
>
<icon-home class="customer-side-rail__warehouse-chip-icon" />
<span v-if="!compactLayout" class="customer-side-rail__warehouse-chip-body">
<span class="customer-side-rail__warehouse-chip-label">
{{ t('nav.warehousePeek.shipLabel') }}
</span>
<span class="customer-side-rail__warehouse-chip-name">{{ warehouseDockName }}</span>
</span>
<icon-down
v-if="!compactLayout"
class="customer-side-rail__warehouse-chip-chevron"
/>
</button>
</a-tooltip>
<template #content>
<WarehouseSwitcherPopover
:active="warehouseSwitcherVisible"
@close="warehouseSwitcherVisible = false"
@open-full="openWarehouseAddressPeek"
/>
</template>
</a-trigger>
<icon-home class="customer-side-rail__warehouse-chip-icon" />
<span v-if="!compactLayout" class="customer-side-rail__warehouse-chip-body">
<span class="customer-side-rail__warehouse-chip-label">
{{ t('nav.warehousePeek.shipLabel') }}
</span>
<span class="customer-side-rail__warehouse-chip-name">{{ warehouseDockName }}</span>
</span>
</button>
<div
class="customer-side-rail__toolbar"
@ -210,7 +181,6 @@ import { Message } from '@arco-design/web-vue'
import {
IconDoubleLeft,
IconDoubleRight,
IconDown,
IconHome,
IconPrinter,
IconRefresh,
@ -253,7 +223,6 @@ import { openPortalSideDrawer } from '@/views/user/portal-drawer/usePortalSideDr
import RightTopMessage from '@/components/top-nav/RightTopMessage.vue'
import RightTopUser from '@/components/top-nav/RightTopUser.vue'
import WarehouseAddressPeekModal from '@/components/customer-side-rail/WarehouseAddressPeekModal.vue'
import WarehouseSwitcherPopover from '@/components/customer-side-rail/WarehouseSwitcherPopover.vue'
const { t, te, locale } = useI18n()
const route = useRoute()
@ -361,7 +330,6 @@ function handleCustomerBalanceChanged() {
}
const warehousePeekVisible = ref(false)
const warehouseSwitcherVisible = ref(false)
const warehouseDockName = computed(
() =>
@ -374,14 +342,9 @@ const warehouseDockTitle = computed(() =>
)
function openWarehouseAddressPeek() {
warehouseSwitcherVisible.value = false
warehousePeekVisible.value = true
}
watch(compactLayout, () => {
warehouseSwitcherVisible.value = false
})
async function ensureWarehouseOptions() {
try {
const { items } = await getWarehouseList({ page: 1, pageSize: 100 })
@ -931,15 +894,6 @@ onUnmounted(() => {
border-color: color-mix(in srgb, var(--app-primary-color, #1d7281) 28%, transparent);
}
&.is-open {
border-color: color-mix(in srgb, var(--app-primary-color, #1d7281) 40%, transparent);
box-shadow: 0 0 0 2px color-mix(in srgb, var(--app-primary-color, #1d7281) 12%, transparent);
.customer-side-rail__warehouse-chip-chevron {
transform: rotate(180deg);
}
}
&.is-compact {
width: 40px;
height: 40px;
@ -980,13 +934,6 @@ onUnmounted(() => {
color: var(--color-text-1);
}
&__warehouse-chip-chevron {
flex-shrink: 0;
font-size: 12px;
color: var(--color-text-3);
transition: transform 0.16s ease;
}
/* 二级:头像 + 消息 + 打印 + 收起 */
&__toolbar {
display: flex;
@ -1243,10 +1190,4 @@ onUnmounted(() => {
}
}
:global(.csr-warehouse-switcher-popup) {
padding: 0 !important;
border-radius: 10px !important;
overflow: hidden;
box-shadow: 0 8px 28px rgba(15, 23, 42, 0.12) !important;
}
</style>

View File

@ -140,6 +140,20 @@ export function useWarehousePeek() {
return true
}
function applyStoreOptionsFallback() {
const opts = warehouseStore.options || []
if (!opts.length) {
list.value = []
return
}
list.value = opts.map((o) =>
normalize({
id: o.value,
warehouseName: o.label,
}),
)
}
async function loadList() {
loading.value = true
try {
@ -147,10 +161,15 @@ export function useWarehousePeek() {
getWarehouseList({ page: 1, pageSize: 100 }),
loadCustomerCode(),
])
list.value = (res.items ?? []).map(normalize).sort(compareWarehouseSort)
syncWarehouseOptions(list.value)
const rows = (res.items ?? []).map(normalize).sort(compareWarehouseSort)
if (rows.length) {
list.value = rows
syncWarehouseOptions(list.value)
} else {
applyStoreOptionsFallback()
}
} catch {
list.value = []
applyStoreOptionsFallback()
} finally {
loading.value = false
}