Vehicle-Networking-ui/src/views/car/fault/test.vue

245 lines
6.7 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<div>
<div style="text-align: center">
<h1>添加报文规则</h1>
</div>
<el-form :inline="true" :model="formInline" class="demo-form-inline">
<el-form-item label="VIN">
<el-select v-model="formInline.sysCarId" placeholder="请选择VIN码">
<el-option v-for="i in vin" :key="i" :label="i.carVin" :value="i.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="报文名称">
<el-select v-model="formInline.sysMessageTypeId" placeholder="报文名称">
<el-option v-for="i in messageTypeCar" :key="i" :label="i.messageName" :value="i.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="一级故障范围">
<el-input v-model="formInline.messageOne"></el-input>
</el-form-item>
<el-form-item label="二级故障范围">
<el-input v-model="formInline.messageTwo"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="addMessageTypeCar()">添加规则</el-button>
</el-form-item>
</el-form>
<div style="text-align: center">
<h1>测试规则</h1>
</div>
<el-form :inline="true" :model="formCare" class="demo-form-inline">
<el-form-item label="VIN">
<el-input v-model="formCare.carVin"></el-input>
</el-form-item>
<el-form-item>
<el-button @click="findMessageTypeCarList">查询</el-button>
</el-form-item>
</el-form>
<el-table
:data="tableData"
style="width: 100%">
<el-table-column
label="ID"
width="180">
<template slot-scope="scope">
<span style="margin-left: 10px">{{ scope.row.id }}</span>
</template>
</el-table-column>
<el-table-column
label="车辆vin码"
width="180">
<template slot-scope="scope">
<span style="margin-left: 10px">{{ scope.row.carVin }}</span>
</template>
</el-table-column>
<el-table-column
label="报文编码"
width="180">
<template slot-scope="scope">
<span style="margin-left: 10px">{{ scope.row.messageCode }}</span>
</template>
</el-table-column>
<el-table-column
label="报文名称"
width="180">
<template slot-scope="scope">
<span style="margin-left: 10px">{{ scope.row.messageName }}</span>
</template>
</el-table-column>
<el-table-column
label="一级故障范围"
width="180">
<template slot-scope="scope">
<span style="margin-left: 10px">{{ scope.row.messageOne }}</span>
</template>
</el-table-column>
<el-table-column
label="二级故障范围"
width="180">
<template slot-scope="scope">
<span style="margin-left: 10px">{{ scope.row.messageTwo }}</span>
</template>
</el-table-column>
<el-table-column
label="测试"
width="180">
<template slot-scope="scope">
<el-input v-model="scope.row.messageTest"></el-input>
</template>
</el-table-column>
<el-table-column>
<template slot-scope="scope">
<el-button
size="mini"
type="danger"
@click="ruleMessageTypeCar(scope.row)">测试</el-button>
</template>
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button
icon="el-icon-edit"
size="mini"
type="text"
@click="handleEdit(scope.row)">修改</el-button>
<el-button
icon="el-icon-delete"
size="mini"
type="text"
@click="handleDelete(scope.row)"></el-button>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script>
//这里可以导入其他文件比如组件工具js第三方插件jsjson文件图片文件等等,
//例如import 《组件名称》 from '《组件路径》,
import {findMessageTypeCarList} from "@/api/car/fault/test";
import {ruleMessageTypeCar} from "@/api/car/fault/test";
import {addMessageTypeCar} from "@/api/car/fault/test";
import {findSysCarList} from "@/api/car/fault/test";
import {findSysMessageTypeList} from "@/api/car/fault/test";
import {deleteMessageTypeCarId} from "@/api/car/fault/test";
export default {
//import引入的组件需要注入到对象中才能使用"
components: {},
props: {},
data() {
//这里存放数据"
return {
//报文名称下拉框
messageTypeCar:[],
//VIN下拉框
vin:[],
//添加规则
formInline:{},
//测试故障规则
MessageTypeCar:{
id:"",
},
//表格数据
tableData:[],
formCare:{},
};
},
//计算属性 类似于data概念",
computed: {},
//监控data中的数据变化",
watch: {},
//方法集合",
methods: {
//删除报文规则
handleDelete(row){
deleteMessageTypeCarId(row.id).then((res)=>{
alert(res.msg);
if (200==res.code){
this.findMessageTypeCarList();
}
})
},
//添加规则
addMessageTypeCar(){
addMessageTypeCar(this.formInline).then((res)=>{
alert(res.msg);
if (200==res.code){
this.findMessageTypeCarList();
}
})
},
//报文名称下拉框
findSysMessageTypeList(){
findSysMessageTypeList().then((res)=>{
this.messageTypeCar=res.data;
})
},
//VIN下拉框
findSysCarList(){
findSysCarList().then((res)=>{
this.vin=res.data;
})
},
//测试故障规则
ruleMessageTypeCar(row){
this.MessageTypeCar=row;
// alert(this.MessageTypeCar.id);
ruleMessageTypeCar(this.MessageTypeCar).then((res)=>{
alert(res.msg);
if (200==res.code){
}
})
},
//查询故障规则
findMessageTypeCarList() {
findMessageTypeCarList(this.formCare).then((res) => {
this.tableData = res.data.rows;
})
}
},
//生命周期 - 创建完成可以访问当前this实例",
created() {
this.findMessageTypeCarList();
this.findSysCarList();
this.findSysMessageTypeList();
},
//生命周期 - 挂载完成可以访问DOM元素",
mounted() {
},
beforeCreate() {
}, //生命周期 - 创建之前",
beforeMount() {
}, //生命周期 - 挂载之前",
beforeUpdate() {
}, //生命周期 - 更新之前",
updated() {
}, //生命周期 - 更新之后",
beforeDestroy() {
}, //生命周期 - 销毁之前",
destroyed() {
}, //生命周期 - 销毁完成",
activated() {
} //如果页面有keep-alive缓存功能这个函数会触发",
};
</script>
<style scoped>
</style>