|
@@ -1,11 +1,14 @@
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
import { computed, onMounted, onUnmounted, ref, useTemplateRef, watch } from 'vue';
|
|
import { computed, onMounted, onUnmounted, ref, useTemplateRef, watch } from 'vue';
|
|
|
|
+import { message } from 'ant-design-vue';
|
|
import qs from 'qs';
|
|
import qs from 'qs';
|
|
|
|
|
|
import { useRequest } from '@/hooks/request';
|
|
import { useRequest } from '@/hooks/request';
|
|
import { useViewVisible } from '@/hooks/view-visible';
|
|
import { useViewVisible } from '@/hooks/view-visible';
|
|
import { updateGroupModuleInfo } from '@/api';
|
|
import { updateGroupModuleInfo } from '@/api';
|
|
|
|
|
|
|
|
+import SvgIcon from '../SvgIcon.vue';
|
|
|
|
+
|
|
import { getVisual2DMsgType, visual2DEditorPageUrl, Visual2DMsgType } from '.';
|
|
import { getVisual2DMsgType, visual2DEditorPageUrl, Visual2DMsgType } from '.';
|
|
|
|
|
|
import type { DeviceGroupTree, GroupModuleInfo, IframeMsg } from '@/types';
|
|
import type { DeviceGroupTree, GroupModuleInfo, IframeMsg } from '@/types';
|
|
@@ -57,8 +60,15 @@ const handleIframeMsg = (e: MessageEvent<IframeMsg>) => {
|
|
sendDeviceData();
|
|
sendDeviceData();
|
|
} else if (msgType === getVisual2DMsgType(Visual2DMsgType.SendDeviceIds)) {
|
|
} else if (msgType === getVisual2DMsgType(Visual2DMsgType.SendDeviceIds)) {
|
|
updateGroupModule(e.data.deviceIds);
|
|
updateGroupModule(e.data.deviceIds);
|
|
|
|
+ } else if (msgType === getVisual2DMsgType(Visual2DMsgType.SaveModuleFailed)) {
|
|
|
|
+ hideExitView();
|
|
|
|
+
|
|
|
|
+ if (e.data.errMsg) {
|
|
|
|
+ message.error(e.data.errMsg);
|
|
|
|
+ }
|
|
} else if (msgType === getVisual2DMsgType(Visual2DMsgType.CloseEditor)) {
|
|
} else if (msgType === getVisual2DMsgType(Visual2DMsgType.CloseEditor)) {
|
|
- hideView();
|
|
|
|
|
|
+ hideExitView();
|
|
|
|
+ setTimeout(hideView, 1200);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
@@ -87,6 +97,27 @@ const handleClose = () => {
|
|
emit('close');
|
|
emit('close');
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+const { visible: exitVisible, showView: showExitView, hideView: hideExitView } = useViewVisible();
|
|
|
|
+const isExitLoading = ref(false);
|
|
|
|
+
|
|
|
|
+const handleNoSave = () => {
|
|
|
|
+ hideExitView();
|
|
|
|
+ hideView();
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const handleSave = () => {
|
|
|
|
+ const msg: IframeMsg = {
|
|
|
|
+ msgType: getVisual2DMsgType(Visual2DMsgType.SaveModule),
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ iframeRef.value?.contentWindow?.postMessage(msg, '*');
|
|
|
|
+ isExitLoading.value = true;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const handleExitClose = () => {
|
|
|
|
+ isExitLoading.value = false;
|
|
|
|
+};
|
|
|
|
+
|
|
defineExpose({
|
|
defineExpose({
|
|
showView,
|
|
showView,
|
|
hideView,
|
|
hideView,
|
|
@@ -101,19 +132,58 @@ defineExpose({
|
|
centered
|
|
centered
|
|
:closable="false"
|
|
:closable="false"
|
|
:mask-closable="false"
|
|
:mask-closable="false"
|
|
|
|
+ :keyboard="false"
|
|
:footer="null"
|
|
:footer="null"
|
|
:after-close="handleClose"
|
|
:after-close="handleClose"
|
|
destroy-on-close
|
|
destroy-on-close
|
|
>
|
|
>
|
|
|
|
+ <SvgIcon name="close" @click="showExitView" />
|
|
<iframe ref="editorIframe" :src="iframeUrl"></iframe>
|
|
<iframe ref="editorIframe" :src="iframeUrl"></iframe>
|
|
<ASpin v-if="!isIframeLoaded" class="center-loading visual-2d-editor-loading" :spinning="true" />
|
|
<ASpin v-if="!isIframeLoaded" class="center-loading visual-2d-editor-loading" :spinning="true" />
|
|
</AModal>
|
|
</AModal>
|
|
|
|
+ <AModal
|
|
|
|
+ v-model:open="exitVisible"
|
|
|
|
+ :title="$t('common.exitEdit')"
|
|
|
|
+ wrap-class-name="hvac-modal visual-2d-editor-exit-modal"
|
|
|
|
+ :width="400"
|
|
|
|
+ :z-index="1001"
|
|
|
|
+ centered
|
|
|
|
+ :mask-closable="false"
|
|
|
|
+ :after-close="handleExitClose"
|
|
|
|
+ >
|
|
|
|
+ <div>{{ $t('realTimeMonitor.saveChangesPrompt', { name: info.groupName }) }}</div>
|
|
|
|
+ <template #footer>
|
|
|
|
+ <AButton class="float-left" danger :disabled="isExitLoading" @click="handleNoSave">
|
|
|
|
+ {{ $t('common.noSave') }}
|
|
|
|
+ </AButton>
|
|
|
|
+ <AButton :disabled="isExitLoading" @click="hideExitView">{{ $t('common.cancel') }}</AButton>
|
|
|
|
+ <AButton type="primary" :loading="isExitLoading" @click="handleSave">{{ $t('common.save') }}</AButton>
|
|
|
|
+ </template>
|
|
|
|
+ </AModal>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<style lang="scss">
|
|
<style lang="scss">
|
|
.visual-2d-editor-modal {
|
|
.visual-2d-editor-modal {
|
|
padding: 32px;
|
|
padding: 32px;
|
|
|
|
|
|
|
|
+ .svg-icon-close {
|
|
|
|
+ position: absolute;
|
|
|
|
+ top: 8px;
|
|
|
|
+ right: 12px;
|
|
|
|
+ padding: 4px;
|
|
|
|
+ font-size: 16px;
|
|
|
|
+ color: rgb(255 255 255 / 75%);
|
|
|
|
+ cursor: pointer;
|
|
|
|
+ transition:
|
|
|
|
+ color 0.2s,
|
|
|
|
+ background-color 0.2s;
|
|
|
|
+
|
|
|
|
+ &:hover {
|
|
|
|
+ color: #fff;
|
|
|
|
+ background-color: rgb(255 255 255 / 12%);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
.ant-modal {
|
|
.ant-modal {
|
|
max-width: 1700px;
|
|
max-width: 1700px;
|
|
}
|
|
}
|
|
@@ -146,4 +216,10 @@ defineExpose({
|
|
border-radius: 8px;
|
|
border-radius: 8px;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+.visual-2d-editor-exit-modal {
|
|
|
|
+ .ant-modal-footer .ant-btn + .ant-btn:not(.ant-dropdown-trigger) {
|
|
|
|
+ margin-inline-start: 16px;
|
|
|
|
+ }
|
|
|
|
+}
|
|
</style>
|
|
</style>
|