PhysicalModelModal.vue
2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<template>
<div>
<BasicModal
:maskClosable="false"
v-bind="$attrs"
width="55rem"
@register="register"
@ok="handleSubmit"
@cancel="handleCancel"
>
<Tabs v-model:activeKey="activeKey" :size="size">
<TabPane key="1" tab="属性">
<Attr v-show="activeKey === '1'" ref="AttrRef" />
</TabPane>
<TabPane disabled key="2" tab="服务">
<Service v-show="activeKey === '2'" ref="ServiceRef" />
</TabPane>
<TabPane disabled key="3" v-show="activeKey === '3'" tab="事件">
<Events v-show="activeKey === '3'" ref="EventsRef" />
</TabPane>
</Tabs>
</BasicModal>
</div>
</template>
<script lang="ts" setup>
import { ref, unref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { Tabs, TabPane } from 'ant-design-vue';
import Attr from './cpns/Attr.vue';
import Service from './cpns/Service.vue';
import Events from './cpns/Events.vue';
defineEmits(['register']);
const activeKey = ref('1');
const size = ref('small');
const AttrRef = ref<InstanceType<typeof Attr>>();
const ServiceRef = ref<InstanceType<typeof Service>>();
const EventsRef = ref<InstanceType<typeof Events>>();
const isUpdate = ref(false);
const isViewDetail = ref('');
const [register, { closeModal, setModalProps }] = useModalInner(async (data) => {
setModalProps({ loading: true });
isUpdate.value = data.isUpdate;
isViewDetail.value = data.isView;
// AttrRef.value?.setFormData()
setModalProps({ loading: false });
if (!unref(isViewDetail)) {
const title = !unref(isUpdate) ? '编辑物模型' : '新增物模型';
setModalProps({ title, showOkBtn: true, showCancelBtn: true });
if (!unref(isUpdate)) {
}
} else {
setModalProps({ showOkBtn: false, showCancelBtn: false, title: '查看物模型' });
}
});
const handleCancel = () => {
AttrRef.value?.resetFormData();
closeModal();
};
const handleSubmit = async () => {
const value = await AttrRef.value?.getFormData();
if (!value) return;
console.log('搜集值', value);
};
</script>
<style lang="less" scope></style>