干燥机配套车间生产管理系统/云平台前端
baoshiwei
2023-03-10 1fb197352b6a263646e4ccd3ed1c7854ede031dd
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
<template>
  <component :is="currentModal" :formData="formData" v-model:visible="modalVisible"></component>
</template>
<script setup lang="ts" name="dynamic-notice">
  import { ref, defineExpose, shallowRef, ComponentOptions, nextTick, defineAsyncComponent } from 'vue';
  const props = defineProps({
    path: { type: String, default: '' },
    formData: { type: Object, default: {} },
  });
  const modalVisible = ref<Boolean>(false);
  const currentModal = shallowRef<Nullable<ComponentOptions>>(null);
  const formData = ref<any>(props.formData);
 
  const componentType = {
  };
 
  /**
   * 跟换组件和传值事件
   */
  function detail() {
    setTimeout(() => {
      if (props.path) {
        nextTick(() => {
          currentModal.value = componentType[props.path];
          formData.value = props.formData;
          modalVisible.value = true;
        });
      }
    }, 200);
  }
 
  defineExpose({
    detail,
  });
</script>