DeviceProfileModal.vue
2.4 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<template>
<BasicModal
v-bind="$attrs"
width="55rem"
@register="register"
:title="getTitle"
@ok="handleSubmit"
@cancel="handleCancel"
>
<div class="step-form-form">
<a-steps :current="current">
<a-step title="设备配置" />
<a-step title="传输配置" />
<a-step title="告警配置" />
</a-steps>
</div>
<div class="mt-5">
<DeviceProfileStep1 @next="handleStep1Next" v-if="current === 0" />
<DeviceProfileStep2 @prev="handleStepPrev" @next="handleStep2Next" v-if="current === 1" />
<DeviceProfileStep3 @prev="handleStepPrev" @redo="handleRedo" v-if="current === 2" />
</div>
</BasicModal>
</template>
<script lang="ts">
import { defineComponent, ref, computed, unref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import DeviceProfileStep1 from '/@/views/device/profile/step/DeviceProfileStep1.vue';
import DeviceProfileStep2 from '/@/views/device/profile/step/DeviceProfileStep2.vue';
import DeviceProfileStep3 from '/@/views/device/profile/step/DeviceProfileStep3.vue';
import { Steps } from 'ant-design-vue';
export default defineComponent({
name: 'DeviceModal',
components: {
BasicModal,
DeviceProfileStep1,
DeviceProfileStep2,
DeviceProfileStep3,
[Steps.name]: Steps,
[Steps.Step.name]: Steps.Step,
},
props: {
userData: { type: Object },
},
setup(_) {
const current = ref(0);
const isUpdate = ref(true);
const getTitle = computed(() => (!unref(isUpdate) ? '新增设备配置' : '编辑设备配置'));
const [register] = useModalInner((data) => {
isUpdate.value = !!data?.isUpdate;
if (!unref(isUpdate)) {
current.value = 0;
}
});
function handleStepPrev() {
current.value--;
}
function handleStep1Next() {
current.value++;
}
function handleStep2Next() {
current.value++;
}
function handleRedo() {
current.value = 0;
}
const handleSubmit = () => {
console.log();
};
const handleCancel = () => {
console.log();
};
return {
handleSubmit,
handleCancel,
register,
getTitle,
current,
handleStepPrev,
handleStep1Next,
handleStep2Next,
handleRedo,
};
},
});
</script>