一、后端返回数据
后端返回的数据格式如下:
{ "msg": "success", "data": [ { "rule": 1, "result": "exception", "remark": "334668" }, { "rule": 2, "result": "planid", "remark": "AR220811000002" } ] }
二、前后端数据交互
三、前端代码
<template> <div> <h3>推置引擎测试界面</h3> <el-form :inline="true" :model="formInline" class="demo-form-inline"> <el-form-item label="异常id"> <el-input v-model="formInline.exceptionid" placeholder="异常id"></el-input> </el-form-item> <el-form-item label="方案id"> <el-input v-model="formInline.planid" placeholder="方案id"></el-input> </el-form-item> <el-form-item> <el-button type="primary" @click="onSubmit">查询</el-button> </el-form-item> </el-form> <el-table :data="tableData" style="width: 90%"> <el-table-column prop="rule" label="规则" width="180"> </el-table-column> <el-table-column prop="result" label="结果" width="180"> </el-table-column> <el-table-column prop="remark" label="备注" width="600"> </el-table-column> </el-table> </div> </template> <script> export default { data() { return { formInline: { exceptionid: '', planid: '', rule: '', result: '', remark:'', }, requestpara: { exceptionid: '', planid: '', }, tableData: [], } }, methods: { onSubmit() { this.requestpara.exceptionid = this.formInline.exceptionid this.requestpara.planid = this.formInline.planid this.$http.post('http://127.0.0.1:8000/calculate_testengine/',this.requestpara) .then((response) => { var res = JSON.parse(response.bodyText) console.log(res) if (res.msg == 'success'){ this.tableData = res.data; } else { console.log(res.data) } } ); } } } </script> <style> </style>