feat(web/route): 支持电脑端鼠标平移画布 & 优化动态SVG宽度
1. 修复电脑端画布无法拖拽滑动问题: - 新增 onPanStart/onPanMove/onPanEnd 逻辑 - 绑定鼠标事件到 .visual-line-container,实现按住左键平移 scrollLeft 2. 修复长线路无法完全滚动的问题: - 将固定 100% 的宽度替换为动态宽度计算:Math.max(100, 50 + stations.length * 120 + 50) + px - 确保原生 overflow-x: auto 能正确感知超出容器的内部站点 3. 更新静态资源版本号避免缓存
This commit is contained in:
@@ -223,8 +223,13 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 可视化线路编辑-->
|
<!-- 可视化线路编辑-->
|
||||||
<div class="visual-line-container">
|
<div class="visual-line-container" ref="visualLineContainer"
|
||||||
<svg width="100%" height="200"
|
:class="{ 'is-panning': isPanning }"
|
||||||
|
@mousedown="onPanStart"
|
||||||
|
@mousemove="onPanMove"
|
||||||
|
@mouseup="onPanEnd"
|
||||||
|
@mouseleave="onPanEnd">
|
||||||
|
<svg :style="{ minWidth: '100%', width: Math.max(100, 50 + selectedLine.stations.length * 120 + 50) + 'px' }" height="200"
|
||||||
v-if="selectedLine.stations && selectedLine.stations.length > 0">
|
v-if="selectedLine.stations && selectedLine.stations.length > 0">
|
||||||
<!--站点连接线-->
|
<!--站点连接线-->
|
||||||
<line x1="50" y1="100" :x2="50 + (selectedLine.stations.length - 1) * 120" y2="100"
|
<line x1="50" y1="100" :x2="50 + (selectedLine.stations.length - 1) * 120" y2="100"
|
||||||
@@ -602,7 +607,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<script src="/custom-dialog.js?v=11"></script>
|
<script src="/custom-dialog.js?v=11"></script>
|
||||||
<script src="/public-status.js?v=14"></script>
|
<script src="/public-status.js?v=14"></script>
|
||||||
<script src="ticket-route.js?v=5"></script>
|
<script src="ticket-route.js?v=6"></script>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
const isDomain = location.hostname.includes('fse-media.group');
|
const isDomain = location.hostname.includes('fse-media.group');
|
||||||
|
|||||||
@@ -497,6 +497,33 @@ createApp({
|
|||||||
await saveDragResult();
|
await saveDragResult();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* 画布平移*/
|
||||||
|
const visualLineContainer = ref(null);
|
||||||
|
const isPanning = ref(false);
|
||||||
|
const panStartX = ref(0);
|
||||||
|
const panScrollLeft = ref(0);
|
||||||
|
|
||||||
|
const onPanStart = (e) => {
|
||||||
|
if (e.button !== 0) return;
|
||||||
|
if (e.target.closest && e.target.closest('.station-node')) return;
|
||||||
|
isPanning.value = true;
|
||||||
|
panStartX.value = e.clientX;
|
||||||
|
if (visualLineContainer.value) {
|
||||||
|
panScrollLeft.value = visualLineContainer.value.scrollLeft;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onPanMove = (e) => {
|
||||||
|
if (!isPanning.value || !visualLineContainer.value) return;
|
||||||
|
e.preventDefault();
|
||||||
|
const dx = e.clientX - panStartX.value;
|
||||||
|
visualLineContainer.value.scrollLeft = panScrollLeft.value - dx;
|
||||||
|
};
|
||||||
|
|
||||||
|
const onPanEnd = () => {
|
||||||
|
isPanning.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
/* 订单管理 */
|
/* 订单管理 */
|
||||||
const fetchOrders = async () => {
|
const fetchOrders = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -1032,6 +1059,7 @@ createApp({
|
|||||||
handleStationClick, isStationSelected,
|
handleStationClick, isStationSelected,
|
||||||
onStationDragStart, onStationDragOver, onStationDrop, draggingStationIndex,
|
onStationDragStart, onStationDragOver, onStationDrop, draggingStationIndex,
|
||||||
onStationTouchStart,
|
onStationTouchStart,
|
||||||
|
visualLineContainer, isPanning, onPanStart, onPanMove, onPanEnd,
|
||||||
showStationModal, stationForm, stationFormOriginalCode, transferTargets, saveStationSettings, closeStationModal,
|
showStationModal, stationForm, stationFormOriginalCode, transferTargets, saveStationSettings, closeStationModal,
|
||||||
showLineModal, lineForm, openLineModal, saveLineSettings, closeLineModal,
|
showLineModal, lineForm, openLineModal, saveLineSettings, closeLineModal,
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user