feat:【mall】diy editor 的 hot-zone 代码优化(70%)使用 Modal 替代 el-dialog
This commit is contained in:
@@ -6,9 +6,10 @@ import type { AppLink } from '#/views/mall/promotion/components/app-link-input/d
|
|||||||
|
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
import { IconifyIcon } from '@vben/icons';
|
import { IconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
import { ElButton, ElDialog, ElImage } from 'element-plus';
|
import { ElButton, ElImage } from 'element-plus';
|
||||||
|
|
||||||
import { AppLinkSelectDialog } from '#/views/mall/promotion/components';
|
import { AppLinkSelectDialog } from '#/views/mall/promotion/components';
|
||||||
|
|
||||||
@@ -40,14 +41,19 @@ const emit = defineEmits(['update:modelValue']);
|
|||||||
|
|
||||||
const formData = ref<HotZoneItemProperty[]>([]);
|
const formData = ref<HotZoneItemProperty[]>([]);
|
||||||
|
|
||||||
const dialogVisible = ref(false); // 弹窗的是否显示
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
onClosed() {
|
||||||
|
const list = zoomOut(formData.value);
|
||||||
|
emit('update:modelValue', list);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
/** 打开弹窗 */
|
/** 打开弹窗 */
|
||||||
const open = () => {
|
function open() {
|
||||||
// 放大
|
// 放大
|
||||||
formData.value = zoomIn(props.modelValue);
|
formData.value = zoomIn(props.modelValue);
|
||||||
dialogVisible.value = true;
|
modalApi.open();
|
||||||
};
|
}
|
||||||
|
|
||||||
defineExpose({ open }); // 提供 open 方法,用于打开弹窗
|
defineExpose({ open }); // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
@@ -156,16 +162,9 @@ const setHeight = (item: HotZoneItemProperty, height: number) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 处理对话框关闭 */
|
/** 处理对话框确定 */
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
dialogVisible.value = false;
|
modalApi.close();
|
||||||
};
|
|
||||||
|
|
||||||
/** 处理对话框关闭 */
|
|
||||||
const handleClose = () => {
|
|
||||||
// 缩小
|
|
||||||
const list = zoomOut(formData.value);
|
|
||||||
emit('update:modelValue', list);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const activeHotZone = ref<HotZoneItemProperty>();
|
const activeHotZone = ref<HotZoneItemProperty>();
|
||||||
@@ -186,12 +185,7 @@ const handleAppLinkChange = (appLink: AppLink) => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ElDialog
|
<Modal title="设置热区" class="w-[780px]">
|
||||||
v-model="dialogVisible"
|
|
||||||
title="设置热区"
|
|
||||||
width="780"
|
|
||||||
@close="handleClose"
|
|
||||||
>
|
|
||||||
<div ref="container" class="w-750px relative h-full">
|
<div ref="container" class="w-750px relative h-full">
|
||||||
<ElImage
|
<ElImage
|
||||||
:src="imgUrl"
|
:src="imgUrl"
|
||||||
@@ -210,9 +204,9 @@ const handleAppLinkChange = (appLink: AppLink) => {
|
|||||||
@mousedown="handleMove(item, $event)"
|
@mousedown="handleMove(item, $event)"
|
||||||
@dblclick="handleShowAppLinkDialog(item)"
|
@dblclick="handleShowAppLinkDialog(item)"
|
||||||
>
|
>
|
||||||
<span class="pointer-events-none select-none">{{
|
<span class="pointer-events-none select-none">
|
||||||
item.name || '双击选择链接'
|
{{ item.name || '双击选择链接' }}
|
||||||
}}</span>
|
</span>
|
||||||
<IconifyIcon
|
<IconifyIcon
|
||||||
icon="ep:close"
|
icon="ep:close"
|
||||||
class="delete"
|
class="delete"
|
||||||
@@ -220,7 +214,7 @@ const handleAppLinkChange = (appLink: AppLink) => {
|
|||||||
@click="handleRemove(item)"
|
@click="handleRemove(item)"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 8个控制点 -->
|
<!-- 8 个控制点 -->
|
||||||
<span
|
<span
|
||||||
class="ctrl-dot"
|
class="ctrl-dot"
|
||||||
v-for="(dot, dotIndex) in CONTROL_DOT_LIST"
|
v-for="(dot, dotIndex) in CONTROL_DOT_LIST"
|
||||||
@@ -240,7 +234,7 @@ const handleAppLinkChange = (appLink: AppLink) => {
|
|||||||
确定
|
确定
|
||||||
</ElButton>
|
</ElButton>
|
||||||
</template>
|
</template>
|
||||||
</ElDialog>
|
</Modal>
|
||||||
|
|
||||||
<AppLinkSelectDialog
|
<AppLinkSelectDialog
|
||||||
ref="appLinkDialogRef"
|
ref="appLinkDialogRef"
|
||||||
|
|||||||
Reference in New Issue
Block a user