田源
2024-07-18 e977b8737d88aa1bd0286fe27bf4fd22cb2501d9
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<template>
  <el-dialog v-dialogDrag
             :title="title"
             :visible.sync="visible"
             :width="width"
             :fullscreen="fullscreen"
             :append-to-body="true"
             top="0"
             class="avue-dialog"
             :destroy-on-close="true"
             @close="dialogClose">
    <component :is="currentComponent"
               ref="uiViewRef"
               key="ViewDialog"
               :style="fullscreen?'':'height:'+height"
               :btmType="paramVOS.type"
               :context="paramVOS.context"
               :inDialog="true"
               :canEdit="false"
               actionType="view"
               :sourceData="sourceData"
               :dataStore="dataStore"
               :paramVOS="paramVOS"></component>
    <!--<ui-view ref="uiViewRef"
             key="ViewDialog"
             :style="fullscreen?'':'height:'+height"
             :btmType="paramVOS.type"
             :context="paramVOS.context"
             :inDialog="true"
             :canEdit="false"
             actionType="view"
             :sourceData="sourceData"
             :dataStore="dataStore"
             :paramVOS="paramVOS"
    ></ui-view>-->
 
  </el-dialog>
</template>
 
<script>
import {validatenull} from "@/util/validate";
 
export default {
  name: "ViewDialog",
  components:{},
  props: {
    sourceData: {
      //所属区域的上一区域选中数据
      type: Object,
      default: {}
    },
    dataStore: {
      //弹窗时按钮所属区域选中数据
      type: Array,
      default: []
    },
    paramVOS: {
      type: Object,
      default: {}
    }
  },
  data(){
    return {
      visible:false,
      currentComponent: null,
    }
  },
  computed:{
    title(){
      return this.paramVOS.title || "查看详情"
    },
    width() {
      if (!validatenull(this.paramVOS.width)) {
        if (this.paramVOS.width.includes("px") || this.paramVOS.width.includes("%")) {
          return this.paramVOS.width;
        } else {
          return this.paramVOS.width + "px";
        }
      } else {
        return "60%";
      }
    },
    height(){
      if (!validatenull(this.paramVOS.height)) {
        if (this.paramVOS.height.includes("px") || this.paramVOS.height.includes("%")) {
          return this.paramVOS.height;
        } else {
          return this.paramVOS.height + "px";
        }
      } else {
        return "auto"
      }
    },
    fullscreen(){
      if(this.paramVOS.width || this.paramVOS.height){
        return false;
      }else if(this.paramVOS.form){
        return false;
      }
      return true;
    }
  },
  created() {
 
  },
  mounted() {
    this.loadCompoent();
  },
  methods: {
    loadCompoent(){
      // 动态导入组件
      import(`@/views/${this.paramVOS.component}.vue`).then((module) => {
        // 成功导入后,将组件注册到Vue实例中
        this.currentComponent = module.default;
      }).catch((error) => {
        // 处理导入失败的情况
        console.log('组件加载失败:', error);
      });
    },
    dialogClose() {
      this.visible = false;
    },
  }
}
</script>
 
<style scoped>
 
</style>