fix: remove condition render wrapped around modals, which leads to @after-enter and v-model:show not working

This commit is contained in:
yangsy
2025-08-29 18:52:46 +08:00
parent cb8bf16d78
commit ac7100c408
4 changed files with 23 additions and 20 deletions

View File

@@ -75,12 +75,15 @@ import { useMutation } from '@tanstack/vue-query';
import { NForm, NFormItemGi, NGrid, NInputNumber, NModal, NTabPane, NTabs, NTimePicker } from 'naive-ui';
import { ref, toRefs, watch } from 'vue';
const props = defineProps<{ station: Station }>();
const props = defineProps<{
station?: Station;
}>();
const { station } = toRefs(props);
const show = defineModel<boolean>('show', { required: true, default: false });
const show = defineModel<boolean>('show', { required: true });
const queryControlStore = useQueryControlStore();
watch(show, (newValue) => {
const queryControlStore = useQueryControlStore();
if (newValue) {
console.log('对话框打开,停止轮询');
queryControlStore.disablePolling();
@@ -136,6 +139,7 @@ const deviceConfigParams = ref<DeviceParamItem[]>([]);
const { mutate: getDeviceParams } = useMutation({
mutationFn: async ({ deviceKeyPrefix }: { deviceKeyPrefix: string }) => {
if (!station.value) throw new Error('请先选择车站');
const { records } = await postDefParameterPage(station.value.code, {
model: {},
extra: { key_likeRight: deviceKeyPrefix },
@@ -175,6 +179,7 @@ const { mutate: getDeviceParams } = useMutation({
const { mutate: saveDeviceParams } = useMutation({
mutationFn: async ({ tabName, params }: { tabName: string; params: DeviceParamItem[] }) => {
if (!station.value) throw new Error('请先选择车站');
for (const item of params) {
if (tabName.includes(DeviceConfigParamPrefix.Monitor)) {
await putDefParameter(station.value.code, {
@@ -204,7 +209,7 @@ const { mutate: saveDeviceParams } = useMutation({
v-model:show="show"
preset="card"
style="width: 800px; height: 600px"
:title="`${station.name} - 设备参数配置`"
:title="`${station?.name} - 设备参数配置`"
:close-on-esc="false"
:mask-closable="false"
@after-enter="onAfterModalEnter"