- 新增 TaskProgressFloatWidget;TaskProgressDialog 增加 minimizable 与 minimize 事件,运行中可「收起后台」,浮窗继续轮询并支持点击还原窗口, 运单页「更新揽收状态」已接入 - UpperTable 新增 #pagination-info 插槽(支持「已选 N 项」等精简文案), 运单号列对齐方式透传给 WaybillCodeActions - 盘点、入库、出库、收货、波次、订单明细、库存详情、仓库与店铺等 20+ 处 日志/明细列表由 el-table 迁移至 UpperTable,统一分页、行选择、 虚拟滚动、状态文本样式与列插槽 - 拆包录像列表、出库单详情表单、运单称重弹窗等按 task-panel 结构统一; 运单轨迹浮层支持拖动并复用 task-panel 标题与关闭样式 - 补充相关样式,修正内嵌表格高度与分页区布局,避免卡片阴影与高度塌陷
250 lines
6.3 KiB
Vue
250 lines
6.3 KiB
Vue
<!--
|
||
WaybillTraceFloat — 运单轨迹悬浮窗(可拖动、无遮罩、层级最高)
|
||
|
||
· 全局单例:由 WaybillTraceWindow 在 App.vue 中挂载一次,列表通过 openTraceWindow() 复用
|
||
· Teleport 到 body,z-index 高于 el-dialog / el-dropdown / loading
|
||
· 无遮罩层,背景页面仍可操作(不挡背后的操作)
|
||
· 按住标题栏拖动,位置自动限制在可视区域内
|
||
-->
|
||
<template>
|
||
<Teleport to="body">
|
||
<transition name="waybill-float">
|
||
<section
|
||
v-if="modelValue"
|
||
ref="panelRef"
|
||
class="waybill-trace-float"
|
||
:style="panelStyle"
|
||
role="dialog"
|
||
aria-label="运单轨迹"
|
||
>
|
||
<header class="task-panel__head wb-float-header" @pointerdown="startDrag">
|
||
<div class="task-panel__titles wb-float-titles">
|
||
<h2>运单轨迹</h2>
|
||
<p :title="waybillCode || ''">{{ waybillCode || '—' }}</p>
|
||
</div>
|
||
<button
|
||
type="button"
|
||
class="task-panel__close wb-float-close"
|
||
aria-label="关闭"
|
||
title="关闭"
|
||
@pointerdown.stop
|
||
@click="close"
|
||
>
|
||
<svg viewBox="0 0 12 12" fill="none">
|
||
<path d="M1 1L11 11M11 1L1 11" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" />
|
||
</svg>
|
||
</button>
|
||
</header>
|
||
<div class="wb-float-body">
|
||
<WaybillTraceList :waybill-code="waybillCode" :api-method="apiMethod" />
|
||
</div>
|
||
</section>
|
||
</transition>
|
||
</Teleport>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||
import WaybillTraceList from './WaybillTraceList.vue'
|
||
import { WAYBILL_FLOAT_Z_INDEX } from './z-index'
|
||
|
||
defineOptions({ name: 'WaybillTraceFloat' })
|
||
|
||
const props = defineProps<{
|
||
modelValue: boolean
|
||
waybillCode?: string | null
|
||
apiMethod?: (params: { waybillCode: string }) => Promise<any>
|
||
}>()
|
||
|
||
const emit = defineEmits<{
|
||
(e: 'update:modelValue', value: boolean): void
|
||
}>()
|
||
|
||
/** 面板尺寸:与样式保持一致,用于拖动边界计算 */
|
||
const PANEL_WIDTH = 360
|
||
const PANEL_HEIGHT = 420
|
||
const VIEWPORT_GAP = 12
|
||
|
||
const panelRef = ref<HTMLElement | null>(null)
|
||
const position = ref({ x: 0, y: 0 })
|
||
|
||
const panelStyle = computed(() => ({
|
||
left: `${position.value.x}px`,
|
||
top: `${position.value.y}px`,
|
||
width: `${PANEL_WIDTH}px`,
|
||
height: `${PANEL_HEIGHT}px`,
|
||
zIndex: WAYBILL_FLOAT_Z_INDEX
|
||
}))
|
||
|
||
function clampPosition(x: number, y: number) {
|
||
const maxX = Math.max(VIEWPORT_GAP, window.innerWidth - PANEL_WIDTH - VIEWPORT_GAP)
|
||
const maxY = Math.max(VIEWPORT_GAP, window.innerHeight - PANEL_HEIGHT - VIEWPORT_GAP)
|
||
return {
|
||
x: Math.min(Math.max(x, VIEWPORT_GAP), maxX),
|
||
y: Math.min(Math.max(y, VIEWPORT_GAP), maxY)
|
||
}
|
||
}
|
||
|
||
/** 首次打开定位到右侧偏上,避免遮挡列表左侧的操作区 */
|
||
function resetPosition() {
|
||
const initialX = window.innerWidth - PANEL_WIDTH - VIEWPORT_GAP * 2
|
||
position.value = clampPosition(initialX, 96)
|
||
}
|
||
|
||
let dragging = false
|
||
|
||
function startDrag(event: PointerEvent) {
|
||
if (event.button !== 0) return
|
||
dragging = true
|
||
const startX = event.clientX
|
||
const startY = event.clientY
|
||
const origin = { ...position.value }
|
||
|
||
const handleMove = (moveEvent: PointerEvent) => {
|
||
if (!dragging) return
|
||
moveEvent.preventDefault()
|
||
position.value = clampPosition(
|
||
origin.x + moveEvent.clientX - startX,
|
||
origin.y + moveEvent.clientY - startY
|
||
)
|
||
}
|
||
|
||
const handleUp = () => {
|
||
dragging = false
|
||
window.removeEventListener('pointermove', handleMove)
|
||
window.removeEventListener('pointerup', handleUp)
|
||
window.removeEventListener('pointercancel', handleUp)
|
||
}
|
||
|
||
window.addEventListener('pointermove', handleMove)
|
||
window.addEventListener('pointerup', handleUp)
|
||
window.addEventListener('pointercancel', handleUp)
|
||
}
|
||
|
||
function handleResize() {
|
||
if (!props.modelValue) return
|
||
position.value = clampPosition(position.value.x, position.value.y)
|
||
}
|
||
|
||
function close() {
|
||
emit('update:modelValue', false)
|
||
}
|
||
|
||
watch(
|
||
() => props.modelValue,
|
||
(visible) => {
|
||
if (visible) resetPosition()
|
||
},
|
||
{ immediate: true }
|
||
)
|
||
|
||
/** Esc 关闭(避免遮挡且免去精准点关闭按钮) */
|
||
function handleKeydown(event: KeyboardEvent) {
|
||
if (event.key === 'Escape' && props.modelValue) close()
|
||
}
|
||
|
||
onMounted(() => {
|
||
window.addEventListener('resize', handleResize)
|
||
window.addEventListener('keydown', handleKeydown)
|
||
})
|
||
|
||
onBeforeUnmount(() => {
|
||
window.removeEventListener('resize', handleResize)
|
||
window.removeEventListener('keydown', handleKeydown)
|
||
})
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.waybill-trace-float {
|
||
position: fixed;
|
||
/* 层级:二维码弹窗(5000) > 本悬浮窗(4000) > el-dialog/el-dropdown(2000+);
|
||
具体数值见 ./z-index.ts,避免被盖住或盖住二维码 */
|
||
display: flex;
|
||
flex-direction: column;
|
||
background: #fff;
|
||
color: #303133;
|
||
border: 1px solid #ebeef5;
|
||
border-radius: 8px;
|
||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
|
||
overflow: hidden;
|
||
}
|
||
|
||
/* 标题区:对齐项目表单弹窗(task-panel__head)—— 标题 + 副标题 + 右上角 SVG 关闭 */
|
||
.wb-float-header {
|
||
display: flex;
|
||
align-items: flex-start;
|
||
gap: 12px;
|
||
padding: 14px 16px 10px;
|
||
border-bottom: 1px solid #ebeef5;
|
||
flex: 0 0 auto;
|
||
cursor: move;
|
||
user-select: none;
|
||
touch-action: none;
|
||
}
|
||
|
||
.wb-float-titles {
|
||
flex: 1;
|
||
min-width: 0;
|
||
|
||
h2 {
|
||
margin: 0;
|
||
font-size: 16px;
|
||
line-height: 22px;
|
||
font-weight: 500;
|
||
color: #303133;
|
||
}
|
||
|
||
p {
|
||
margin: 4px 0 0;
|
||
font-size: 12px;
|
||
line-height: 18px;
|
||
color: #909399;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
}
|
||
|
||
.wb-float-close {
|
||
width: 24px;
|
||
height: 24px;
|
||
flex: none;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
border: none;
|
||
border-radius: 4px;
|
||
background: transparent;
|
||
color: #909399;
|
||
cursor: pointer;
|
||
transition: color 0.2s;
|
||
|
||
svg {
|
||
width: 12px;
|
||
height: 12px;
|
||
}
|
||
|
||
&:hover {
|
||
color: #409eff;
|
||
}
|
||
}
|
||
|
||
.wb-float-body {
|
||
flex: 1;
|
||
min-height: 0;
|
||
padding: 10px 16px 12px;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.waybill-float-enter-active,
|
||
.waybill-float-leave-active {
|
||
transition: opacity 0.15s ease, transform 0.15s ease;
|
||
}
|
||
|
||
.waybill-float-enter-from,
|
||
.waybill-float-leave-to {
|
||
opacity: 0;
|
||
transform: translateY(-6px);
|
||
}
|
||
</style>
|