<template>
  <div>
    <!--查询-->
    <el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-row>
        <el-col :span="8"><div class="grid-content bg-purple">
          <el-form-item label="车辆VIN" prop="pass">
            <el-input type="text" v-model="ruleForm.carVin" autocomplete="off"></el-input>
          </el-form-item>
        </div></el-col>
        <el-col :span="8"><div class="grid-content bg-purple-light">
          <el-form-item label="开始报警" prop="pass">
            <el-input type="text" v-model="ruleForm.startwarningTime" autocomplete="off"></el-input>
          </el-form-item>
        </div></el-col>
        <el-col :span="8"><div class="grid-content bg-purple-light">
          <el-form-item label="结束报警" prop="pass">
            <el-input type="text" v-model="ruleForm.endwarningTime" autocomplete="off"></el-input>
          </el-form-item>
        </div></el-col>
        <el-col :span="8"><div class="grid-content bg-purple">
          <el-form-item>
            <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
            <el-button @click="resetForm('ruleForm')">重置</el-button>
          </el-form-item>
        </div></el-col>
      </el-row>
    </el-form>

    <!--日志列表-->
    <el-table
      :data="tableData"
      style="width: 100%">
      <el-table-column
        label="id"
        width="180">
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="top">
            <div slot="reference" class="name-wrapper">
              {{ scope.row.logId }}
            </div>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column
        label="故障码"
        width="180">
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="top">
            <div slot="reference" class="name-wrapper">
              {{ scope.row.faultcodeNumber }}
            </div>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column
        label="车辆VIN"
        width="180">
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="top">
            <div slot="reference" class="name-wrapper">
              {{ scope.row.carInformationVIN }}
            </div>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column
        label="开始报警时间"
        width="180">
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="top">
            <div slot="reference" class="name-wrapper">
              {{ scope.row.startwarningTime }}
            </div>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column
        label="结束报警时间"
        width="180">
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="top">
            <div slot="reference" class="name-wrapper">
              {{ scope.row.endwarningTime }}
            </div>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            size="mini"
            @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!--分页-->
    <center>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="ruleForm.pageNum"
        :page-sizes="[3, 5, 10, 15]"
        :page-size="ruleForm.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </center>
  </div>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）,
//例如：import 《组件名称》 from '《组件路径》,
  import {getfaultlog} from "@/api/fault/faultlog";

export default {
    name: "Faultlog",
    //import引入的组件需要注入到对象中才能使用"
    components: {},
    props: {},
    data() {
      //这里存放数据"

      return {
        ruleForm:{
          pageNum:1,
          pageSize:10
        },
        total:0,
        tableData:[]
      };
    },
    //计算属性 类似于data概念",
    computed: {},
    //监控data中的数据变化",
    watch: {},
    //方法集合",
    methods: {
      //查询
      submitForm(){
        this.getfaultlog();
      },
      //故障码展示
      getfaultlog(){
        getfaultlog(this.ruleForm).then(response=>{
          this.tableData=response.data.faultLogListRespList
          this.total=response.data.total
        })
      },
      //分页
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
        this.ruleForm.pageSize=val
        this.getList()
      },
      handleCurrentChange(val) {
        console.log(`当前页: ${val}`);
        this.ruleForm.pageNum=val
        this.getList()
      },
    },
    //生命周期 - 创建完成（可以访问当前this实例）",
    created() {
      this.getfaultlog()
    },
    //生命周期 - 挂载完成（可以访问DOM元素）",
    mounted() {
    },
    beforeCreate() {
    }, //生命周期 - 创建之前",
    beforeMount() {
    }, //生命周期 - 挂载之前",
    beforeUpdate() {
    }, //生命周期 - 更新之前",
    updated() {
    }, //生命周期 - 更新之后",
    beforeDestroy() {
    }, //生命周期 - 销毁之前",
    destroyed() {
    }, //生命周期 - 销毁完成",
    activated() {
    } //如果页面有keep-alive缓存功能，这个函数会触发",
  };
</script>
<style scoped>

</style>
