Blame view

antis-ncc-admin/src/views/basic/dynamicModel/index.vue 1.24 KB
03207d5d   wwk   1
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
  
  <template>
    <component :is="currentView" :config="config" :modelId="modelId" :isPreview="isPreview"
      v-show="showPage" />
  </template>
  
  <script>
  import { getConfigData } from '@/api/onlineDev/visualDev'
  import Form from './form'
  import List from './list'
  
  export default {
    name: 'dynamicModel',
    components: { Form, List },
    data() {
      return {
        currentView: '',
        showPage: false,
        isPreview: false,
        modelId: '',
        config: {}
      }
    },
    created() {
      let isPreview = this.$route.query.isPreview || false
      if (isPreview) {
        this.modelId = this.$route.query.id
        this.isPreview = true
      } else {
        this.modelId = this.$route.meta.relationId
      }
      if (!this.modelId) return
      this.getConfigData()
    },
    methods: {
      getConfigData() {
        getConfigData(this.modelId).then(res => {
          if (res.code !== 200) {
            this.$store.dispatch('tagsView/delView', this.$route)
            this.$router.replace('/404')
          }
          if (!res.data) return
          this.config = res.data
          if (res.data.webType == '1') {
            this.currentView = 'Form'
          } else {
            this.currentView = 'List'
          }
          this.showPage = true
        }).catch(() => { })
      }
    }
  }
  </script>