master
lion 1 month ago
parent 55cc1b33b6
commit 3f4266ffce

@ -43,46 +43,34 @@
draggable="false" draggable="false"
alt="overview" alt="overview"
/> />
<!-- 货架点位 --> <!-- 货架点位 + 弹窗使用 Popover追加到 body 避免裁切 -->
<div v-for="shelf in shelves" :key="shelf.id" class="shelf-point" :style="{ <el-popover
left: `${shelf.area_x}%`, v-for="shelf in shelves"
top: `${shelf.area_y}%` :key="shelf.id"
}" @click="handleShelfClick(shelf)" /> placement="top"
</div> trigger="manual"
:append-to-body="true"
<!-- 物资信息浮窗 --> v-model="shelf._show"
<div v-if="showMaterialInfo" class="material-info-popup" :style="{ >
left: calculatePopupLeft(selectedShelf.area_x), <div style="min-width:320px;max-width:560px;">
top: calculatePopupTop(selectedShelf.area_y), <div class="popup-header" style="text-align:left;display:flex;align-items:center;justify-content:space-between;margin-bottom:6px;">
transform: calculatePopupTransform(selectedShelf.area_x) <span style="font-weight:600;">{{ shelf.huojiamingcheng }}</span>
}"> <el-button type="text" icon="el-icon-close" @click="shelf._show=false" />
<div class="popup-header" style="text-align: left;">
<el-button type="text" icon="el-icon-close" @click="showMaterialInfo = false" />
<span>{{ selectedShelf.huojiamingcheng }}</span>
</div> </div>
<xy-table style="width: 100%" :height="300" :list="materialList" :is-page="false" <xy-table style="width:100%" :height="300" :list="materialList" :is-page="false" :table-item="materialTable">
:table-item="materialTable"> <template v-slot:btns><div /></template>
<template v-slot:btns>
<div />
</template>
</xy-table> </xy-table>
<!-- <el-table :data="materialList" size="small" style="width: 100%" :max-height="300"> </div>
<el-table-column prop="name" label="物资名称"></el-table-column> <div
<el-table-column prop="quantity" label="数量"></el-table-column> slot="reference"
<el-table-column prop="unit" label="单位"></el-table-column> class="shelf-point"
<el-table-column prop="status" label="状态"> :style="{ left: `${shelf.area_x}%`, top: `${shelf.area_y}%` }"
<template slot-scope="scope"> @click="openShelfPopover(shelf)"
<el-tag :type="scope.row.status === '正常' ? 'success' : 'warning'"> />
{{ scope.row.status }} </el-popover>
</el-tag>
</template>
</el-table-column>
</el-table> -->
</div> </div>
</div> </div>
<!-- 无概览图时显示提示 -->
<div v-else class="no-preview"> <div v-else class="no-preview">
<el-empty description="该仓库还没有概览图"> <el-empty description="该仓库还没有概览图">
<!-- <el-button type="primary" @click="handleAddImage"></el-button> --> <!-- <el-button type="primary" @click="handleAddImage"></el-button> -->
@ -90,7 +78,6 @@
</div> </div>
</div> </div>
</div> </div>
<!-- 未选择仓库时显示提示 -->
<div v-else class="no-selection"> <div v-else class="no-selection">
<el-empty description="请选择一个仓库" /> <el-empty description="请选择一个仓库" />
</div> </div>
@ -479,12 +466,15 @@
this.resetView() this.resetView()
}, },
// // 使 Popover
async handleShelfClick(shelf) { async openShelfPopover(shelf) {
//
this.shelves.forEach(s => this.$set(s, '_show', false))
this.selectedShelf = shelf this.selectedShelf = shelf
// await this.fetchMaterialInfo(shelf.id);
await this.fetchMaterialInfo(shelf.id) await this.fetchMaterialInfo(shelf.id)
this.showMaterialInfo = true this.$nextTick(() => {
this.$set(shelf, '_show', true)
})
}, },
// //
@ -532,8 +522,6 @@
leftPx = margin leftPx = margin
transform = 'translateX(0)' transform = 'translateX(0)'
} }
// position absolute
leftPx = leftPx - containerRect.left
return { left: `${leftPx}px`, transform } return { left: `${leftPx}px`, transform }
}, },
calculatePopupLeft(x) { calculatePopupLeft(x) {
@ -543,6 +531,48 @@
return this.getPopupMetrics(x).transform return this.getPopupMetrics(x).transform
}, },
// overflow
getFixedPopupStyle(shelf) {
if (!shelf) return {}
const container = this.$el.querySelector('.preview-image')
const rect = container ? container.getBoundingClientRect() : {left: 0, top: 0, width: window.innerWidth, height: window.innerHeight}
const margin = 10
const popupWidth = Math.min(560, window.innerWidth * 0.8)
const popupHeight = 300
const xPercent = parseFloat(shelf.area_x)
const yPercent = parseFloat(shelf.area_y)
const anchorX = rect.left + (xPercent / 100) * rect.width
const anchorY = rect.top + (yPercent / 100) * rect.height
// XgetPopupMetrics
let leftPx = anchorX
let transformX = 'translateX(-50%)'
if (anchorX + popupWidth / 2 > window.innerWidth - margin) {
leftPx = window.innerWidth - margin
transformX = 'translateX(-100%)'
} else if (anchorX - popupWidth / 2 < margin) {
leftPx = margin
transformX = 'translateX(0)'
}
// Y
let topPx = anchorY + 20
let transformY = ''
if (anchorY + 20 + popupHeight > window.innerHeight - margin) {
topPx = anchorY - (popupHeight + 20)
}
if (topPx < margin) topPx = margin
return {
position: 'fixed',
left: `${leftPx}px`,
top: `${topPx}px`,
transform: `${transformX} ${transformY}`.trim(),
maxWidth: '80vw',
zIndex: 10000
}
},
// //
handleResize() { handleResize() {
// //

Loading…
Cancel
Save