提交 | 用户 | 时间
|
850106
|
1 |
<template> |
H |
2 |
<el-dialog :visible.sync="visible" title="接口详情" :close-on-click-modal="false" |
|
3 |
:close-on-press-escape="false" |
|
4 |
:append-to-body="true"> |
|
5 |
<el-tabs v-model="activeName" type="card"> |
|
6 |
<el-tab-pane label="接口描述" name="first"> |
|
7 |
<table> |
|
8 |
<el-descriptions class="margin-top" :column="1" border size=""> |
|
9 |
<el-descriptions-item> |
|
10 |
<template slot="label"> |
|
11 |
模型编码 |
|
12 |
</template> |
|
13 |
{{this.dataForm.modelCode}} |
|
14 |
</el-descriptions-item> |
|
15 |
<el-descriptions-item :label-style="labelStyle"> |
|
16 |
<template slot="label"> |
|
17 |
模型名称 |
|
18 |
</template> |
|
19 |
{{this.dataForm.modelName}} |
|
20 |
</el-descriptions-item> |
|
21 |
<el-descriptions-item :label-style="labelStyle"> |
|
22 |
<template slot="label"> |
|
23 |
模型版本 |
|
24 |
</template> |
|
25 |
{{this.dataForm.modelVersion}} |
|
26 |
</el-descriptions-item> |
|
27 |
<el-descriptions-item> |
|
28 |
<template slot="label"> |
|
29 |
url |
|
30 |
</template> |
|
31 |
{{this.dataForm.url}} |
|
32 |
</el-descriptions-item> |
|
33 |
<el-descriptions-item> |
|
34 |
<template slot="label"> |
|
35 |
方法 |
|
36 |
</template> |
|
37 |
{{this.dataForm.method}} |
|
38 |
</el-descriptions-item> |
|
39 |
<el-descriptions-item> |
|
40 |
<template slot="label"> |
|
41 |
输入参数 |
|
42 |
</template> |
|
43 |
{{this.dataForm.params}} |
|
44 |
</el-descriptions-item> |
|
45 |
<el-descriptions-item> |
|
46 |
<template slot="label"> |
|
47 |
参数示例 |
|
48 |
</template> |
|
49 |
{{this.dataForm.paramsExample}} |
|
50 |
</el-descriptions-item> |
|
51 |
<el-descriptions-item> |
|
52 |
<template slot="label"> |
|
53 |
输出结果 |
|
54 |
</template> |
|
55 |
{{this.dataForm.result}} |
|
56 |
</el-descriptions-item> |
|
57 |
<el-descriptions-item> |
|
58 |
<template slot="label"> |
|
59 |
结果示例 |
|
60 |
</template> |
|
61 |
{{this.dataForm.resultExample}} |
|
62 |
</el-descriptions-item> |
|
63 |
</el-descriptions> |
|
64 |
</table> |
|
65 |
</el-tab-pane> |
|
66 |
<el-tab-pane label="接口调用" name="second" v-if="isShowCallApi"> |
|
67 |
<el-form :model="executeForm" :rules="dataRule" ref="executeForm" label-width="0px"> |
|
68 |
<el-row> |
|
69 |
<el-col :span="21"> |
|
70 |
<el-form-item prop="url"> |
|
71 |
<el-input v-model="executeForm.url" placeholder="url" readonly> |
|
72 |
<template slot="prepend">{{executeForm.method}}</template> |
|
73 |
</el-input> |
|
74 |
</el-form-item> |
|
75 |
</el-col> |
|
76 |
<el-col :span="2" style="float: right;"> |
|
77 |
<el-button :loading="loading" type="primary" @click="executeHandle">执行</el-button> |
|
78 |
</el-col> |
|
79 |
<el-col :span="24"> |
|
80 |
<el-form-item prop="paramsExample"> |
|
81 |
<el-input v-model="executeForm.paramsExample" placeholder="请求参数" :rows="10" type="textarea"></el-input> |
|
82 |
</el-form-item> |
|
83 |
</el-col> |
|
84 |
<el-col :span="24"> |
|
85 |
<el-divider content-position="left">返回结果</el-divider> |
|
86 |
<el-form-item prop="response"> |
|
87 |
<el-input v-loading="loading" v-model="executeForm.response" placeholder="返回结果" :rows="10" type="textarea"></el-input> |
|
88 |
</el-form-item> |
|
89 |
</el-col> |
|
90 |
<distribution-curves v-if="isShowFPQXChart" ref="distributionCurves" v-loading="loading" ></distribution-curves> |
|
91 |
<el-col :span="24" > |
|
92 |
<wash-curves v-if="isShowYMKXXChart" ref="washCurves" v-loading="loading" ></wash-curves> |
|
93 |
</el-col> |
|
94 |
</el-row> |
|
95 |
</el-form> |
|
96 |
</el-tab-pane> |
|
97 |
</el-tabs> |
|
98 |
|
|
99 |
</el-dialog> |
|
100 |
</template> |
|
101 |
<script> |
|
102 |
import washCurves from './wash-curves-chart' |
|
103 |
import distributionCurves from './distribution-curves-chart' |
|
104 |
|
|
105 |
export default { |
|
106 |
data() { |
|
107 |
return { |
|
108 |
visible: false, |
|
109 |
loading: false, |
|
110 |
activeName: 'first', |
|
111 |
isShowCallApi: true, |
|
112 |
isShowFPQXChart: false, |
|
113 |
isShowYMKXXChart: false, |
|
114 |
chartFPQX: {}, |
|
115 |
dataForm: { |
|
116 |
modelId: '', |
|
117 |
modelName: '', |
|
118 |
modelCode: '', |
|
119 |
url: '', |
|
120 |
method: '', |
|
121 |
params: '', |
|
122 |
paramsExample: '', |
|
123 |
result: '', |
|
124 |
resultExample: '', |
|
125 |
}, |
|
126 |
labelStyle: { |
|
127 |
'font-weight': '600', |
|
128 |
'height': '40px', |
|
129 |
'min-width': '100px', |
|
130 |
'word-break': 'keep-all' |
|
131 |
}, |
|
132 |
executeForm: { |
|
133 |
url: '', |
|
134 |
method: '', |
|
135 |
paramsExample: '', |
|
136 |
response: '' |
|
137 |
} |
|
138 |
} |
|
139 |
}, |
|
140 |
components: { |
|
141 |
washCurves, |
|
142 |
distributionCurves |
|
143 |
}, |
|
144 |
computed: { |
|
145 |
dataRule() { |
|
146 |
return { |
|
147 |
params: [ |
|
148 |
{required: true, message: '参数不能为空', trigger: 'blur'} |
|
149 |
] |
|
150 |
} |
|
151 |
} |
|
152 |
}, |
|
153 |
methods: { |
|
154 |
init(row) { |
|
155 |
this.visible = true |
|
156 |
this.isShowCallApi = true |
|
157 |
this.isShowFPQXChart = false |
|
158 |
this.isShowYMKXXChart = false |
|
159 |
this.$nextTick(() => { |
|
160 |
this.dataForm = {} |
|
161 |
if(row.isShow != null){ |
|
162 |
this.isShowCallApi = row.isShow |
|
163 |
} |
|
164 |
if(this.isShowCallApi === true){ |
|
165 |
this.$refs['executeForm'].resetFields() |
|
166 |
} |
|
167 |
this.dataForm.modelId = row.id |
|
168 |
this.dataForm.modelCode = row.modelCode |
|
169 |
this.dataForm.modelName = row.modelName |
|
170 |
this.dataForm.modelVersion = row.modelVersion |
|
171 |
this.getInfo() |
|
172 |
}) |
|
173 |
}, |
|
174 |
getInfo() { |
|
175 |
this.$http.get(`/iailab-ntt-model/mcs/st-model-doc/${this.dataForm.modelId}`).then(({data: res}) => { |
|
176 |
if (res.code !== 0) { |
|
177 |
return this.$message.error(res.msg) |
|
178 |
} |
|
179 |
this.dataForm = { |
|
180 |
...this.dataForm, |
|
181 |
...res.data |
|
182 |
} |
|
183 |
|
|
184 |
if(this.isShowCallApi === true){ |
|
185 |
this.executeForm = { |
|
186 |
...this.executeForm, |
|
187 |
...res.data |
|
188 |
} |
|
189 |
} |
|
190 |
|
|
191 |
}).catch(() => { |
|
192 |
}) |
|
193 |
}, |
|
194 |
executeHandle() { |
|
195 |
this.loading = true |
|
196 |
this.$http['post'](this.executeForm.url, JSON.parse(this.executeForm.paramsExample)).then(({data: res}) => { |
|
197 |
this.loading = false |
|
198 |
if (res.code !== 0) { |
|
199 |
return this.$message.error(res.msg) |
|
200 |
} |
|
201 |
this.executeForm.response = JSON.stringify(res.data, null, 2) |
|
202 |
this.$message({ |
|
203 |
message: this.$t('prompt.success'), |
|
204 |
type: 'success' |
|
205 |
}) |
|
206 |
if (res.data != null){ |
|
207 |
//判断是否是分配曲线 |
|
208 |
this.isShowFPQXChart = this.dataForm.modelCode === 'distribution_curve' |
|
209 |
if(this.isShowFPQXChart){ |
|
210 |
this.$nextTick(() => { |
|
211 |
this.$refs.distributionCurves.init(res.data) |
|
212 |
}) |
|
213 |
} |
|
214 |
//判断是否是原煤可选曲线 |
|
215 |
this.isShowYMKXXChart = this.dataForm.modelCode === 'washability_curve' |
|
216 |
if(this.isShowYMKXXChart){ |
|
217 |
this.$nextTick(() => { |
|
218 |
this.$refs.washCurves.init(res.data) |
|
219 |
}) |
|
220 |
} |
|
221 |
} |
|
222 |
}).catch(() => { |
|
223 |
this.$message.error("调用失败!") |
|
224 |
this.loading = false |
|
225 |
}) |
|
226 |
} |
|
227 |
} |
|
228 |
} |
|
229 |
</script> |
|
230 |
<style scoped> |
|
231 |
|
|
232 |
</style> |