DeviceProfileModal.vue 2.2 KB
<template>
  <BasicModal v-bind="$attrs" width="55rem" @register="register" :title="getTitle">
    <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-show="current === 0" />
      <DeviceProfileStep2 @prev="handleStepPrev" @next="handleStep2Next" v-show="current === 1" />
      <DeviceProfileStep3 @prev="handleStepPrev" @redo="handleRedo" v-show="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(2);
      const isUpdate = ref(true);
      const getTitle = computed(() => (!unref(isUpdate) ? '新增设备配置' : '编辑设备配置'));

      const [register] = useModalInner((data) => {
        isUpdate.value = !!data?.isUpdate;
      });

      function handleStepPrev() {
        current.value--;
      }
      function handleStep1Next(step1Values: any) {
        current.value++;
        console.log(step1Values);
      }
      function handleStep2Next(step2Values: any) {
        current.value++;
        console.log(step2Values);
      }
      function handleRedo() {
        current.value = 0;
      }

      return {
        register,
        getTitle,
        current,
        handleStepPrev,
        handleStep1Next,
        handleStep2Next,
        handleRedo,
      };
    },
  });
</script>