Blame view

antis-ncc-admin/src/views/systemData/dataInterface/Preview.vue 1.95 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
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
  <template>
    <div class="NCC-preview-main">
      <div class="NCC-common-page-header">
        <el-page-header @back="goBack" content="接口预览" />
        <div class="options">
          <el-button @click="goBack">{{$t('common.cancelButton')}}</el-button>
        </div>
      </div>
      <el-form ref="dataForm" class="main" label-position="top" v-loading="formLoading">
        <el-form-item label="Request URL">
          <el-input v-model="url">
            <template slot="prepend">GET</template>
          </el-input>
        </el-form-item>
        <el-form-item label="Response body" class="value-item">
          <el-input v-model="responseData" type="textarea" :rows="30" />
        </el-form-item>
      </el-form>
    </div>
  </template>
  
  <script>
  import { previewDataInterface } from '@/api/systemData/dataInterface'
  import NCCCodeEditor from '@/components/NCCEditor/monaco'
  
  export default {
    components: {
      NCCCodeEditor
    },
    data() {
      return {
        title: '',
        formLoading: false,
        responseData: '',
        url: '',
        options: {
          readOnly: true,
          language: 'json'
        }
      }
    },
    methods: {
      goBack() {
        this.$emit('close')
      },
      init(id) {
        this.id = id || ''
        this.formLoading = true
        this.responseData = ''
        this.$nextTick(() => {
          this.url = `${this.define.comUrl}/api/system/DataInterface/${id}/Actions/Response`
          previewDataInterface(this.id).then(res => {
            this.responseData = JSON.stringify(res, null, 4)
            this.formLoading = false
          }).catch(() => {
            this.formLoading = false
          })
        })
  
      },
    }
  }
  </script>
  <style lang="scss" scoped>
  .main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    .value-item {
      flex: 1;
      margin-bottom: 0;
      >>> .el-form-item__content {
        height: calc(100% - 32px);
        .el-textarea {
          height: 100%;
          .el-textarea__inner {
            height: 100%;
          }
        }
      }
    }
  }
  </style>