更新自定义群体拖拽时的处理逻辑

v1.2.0
于肖磊 2025-02-26 17:56:52 +08:00
parent 0a59b5e682
commit e43c2cc77d
4 changed files with 51 additions and 8 deletions

View File

@ -20,7 +20,7 @@
</el-tooltip>
</div>
</el-form-item>
<template v-if="form.tabs_top_up == '1' && !is_not_general_safe_distance">
<template v-if="form.tabs_top_up == '1' && is_not_general_safe_distance">
<el-form-item label="安全距离">
<div class="flex-row align-c gap-10">
<el-switch v-model="form.is_general_safe_distance" active-value="1" inactive-value="0" />
@ -356,7 +356,7 @@ const tabs_theme_change = (val: string | number | boolean | undefined): void =>
//
const is_not_general_safe_distance = computed(() => common_store.is_immersion_model && !common_store.is_general_safe_distance);
watchEffect(() => {
if (is_not_general_safe_distance.value) {
if (!is_not_general_safe_distance.value) {
form.value.is_general_safe_distance = '0';
}
});

View File

@ -724,6 +724,8 @@ const area_box_point = ref({ x: 0, y: 0 });
const dbl_drag_event = (item: hotListData, index: number) => {
hot_list_index.value = index;
};
// followerMap
type FollowerMap = { [key: string]: any };
//
const start_drag_area_box = (index: number, event: MouseEvent) => {
hot_list_index.value = index;
@ -771,12 +773,31 @@ const start_drag_area_box = (index: number, event: MouseEvent) => {
//
const move_x = new_coordinate.x - clone_drag_start.x;
const move_y = new_coordinate.y - clone_drag_start.y;
// ID
const followerIds = new Set(diy_data.value.filter(item => item.is_hot !== '1' && item.com_data?.data_follow?.id !== '').map(item => item.com_data?.data_follow?.id));
// followerMap
const followerMap: FollowerMap = {};
//
diy_data.value.forEach(item => {
if (item.com_data?.data_follow?.id !== '') {
followerMap[item.com_data.data_follow.id] = item;
}
});
// ,
diy_data.value.forEach(item => {
if (item.is_hot == '1') { //
let { record_x, record_y } = cloneDeep(item.location);
let { record_x, record_y } = item.location || {};
item.location.x = Math.max(0, record_x + move_x);
item.location.y = Math.max(0, record_y + move_y);
// 使
if (followerIds.has(item.id)) {
const followerItem = followerMap[item.id];
if (followerItem && followerItem.location) {
const location_2 = followerItem.location || {};
const { record_x: record_x_2 = 0, record_y: record_y_2 = 0 } = location_2;
followerItem.location = { ...location_2, x: Math.max(0, record_x_2 + move_x), y: Math.max(0, record_y_2 + move_y)};
}
}
}
});
hot_list.data[hot_list_index.value].drag_start.x = new_coordinate.x;
@ -788,13 +809,31 @@ const start_drag_area_box = (index: number, event: MouseEvent) => {
document.onmouseup = () => {
is_draggable.value = true;
drag_box_bool.value = false;
// ID
const followerIds = new Set(diy_data.value.filter(item => item.is_hot !== '1' && item.com_data?.data_follow?.id !== '').map(item => item.com_data?.data_follow?.id));
const followerMap: FollowerMap = {};
//
diy_data.value.forEach(item => {
if (item.com_data?.data_follow?.id !== '') {
followerMap[item.com_data.data_follow.id] = item;
}
});
// xy
diy_data.value.forEach(item => {
if (item.is_hot == '1') {
const { x, y } = cloneDeep(item.location);
const { x, y } = item.location;
item.location.record_x = x;
item.location.record_y = y;
item.location.staging_y = y;
// 使
if (followerIds.has(item.id)) {
const followerItem = followerMap[item.id];
if (followerItem && followerItem.location) {
const location_2 = followerItem.location || {};
const { x: record_x = 0, y: record_y = 0 } = location_2;
followerItem.location = { ...location_2, record_x: record_x, record_y: record_y, staging_y: record_y };
}
}
}
});
if (hot_list?.data.length > 0) {
@ -1096,11 +1135,15 @@ const handleKeyUp = (e: KeyboardEvent) => {
// x 0
if (isWithinBounds(item.location.x + x, item.com_data.com_width, 390) && (id === '' || (id != '' && type == 'top'))) {
item.location.x += x;
} else if (id != '' && type == 'left' && x !== 0) {
ElMessage.info('当前组件已经左跟随其他组件x轴不允许修改');
}
// Y0
if (isWithinBounds(item.location.y + y, item.com_data.com_height, center_height.value) && (id === '' || (id != '' && type == 'left'))) {
item.location.y += y;
item.location.staging_y += y;
} else if (id != '' && type == 'top' && y !== 0) {
ElMessage.info('当前组件已经上跟随其他组件y轴不允许修改');
}
operation_end(get_history_name(item));
}

View File

@ -20,7 +20,7 @@
</el-tooltip>
</div>
</el-form-item>
<template v-if="form.tabs_top_up == '1' && !is_not_general_safe_distance">
<template v-if="form.tabs_top_up == '1' && is_not_general_safe_distance">
<el-form-item label="安全距离">
<div class="flex-row align-c gap-10">
<el-switch v-model="form.is_general_safe_distance" active-value="1" inactive-value="0" />
@ -347,7 +347,7 @@ const tabs_theme_change = (val: string | number | boolean | undefined): void =>
//
const is_not_general_safe_distance = computed(() => common_store.is_immersion_model && !common_store.is_general_safe_distance);
watchEffect(() => {
if (is_not_general_safe_distance.value) {
if (!is_not_general_safe_distance.value) {
form.value.is_general_safe_distance = '0';
}
});

View File

@ -20,7 +20,7 @@
</el-tooltip>
</div>
</el-form-item>
<template v-if="form.tabs_top_up == '1' && !is_not_general_safe_distance">
<template v-if="form.tabs_top_up == '1' && is_not_general_safe_distance">
<el-form-item label="安全距离">
<div class="flex-row align-c gap-10">
<el-switch v-model="form.is_general_safe_distance" active-value="1" inactive-value="0" />
@ -329,7 +329,7 @@ const change_shop_type = () => {
//
const is_not_general_safe_distance = computed(() => common_store.is_immersion_model && !common_store.is_general_safe_distance);
watchEffect(() => {
if (is_not_general_safe_distance.value) {
if (!is_not_general_safe_distance.value) {
form.value.is_general_safe_distance = '0';
}
});