<template>
  <div>
    <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <el-form-item label="故障码">
        <el-input v-model="formInline.faultCode" placeholder="请输入故障码"></el-input>
      </el-form-item>
      <el-form-item label="车辆VIN">
        <el-input v-model="formInline.carVin" placeholder="请输入VIN"></el-input>
      </el-form-item>
      <el-form-item label="开始报警时间">
        <el-input v-model="formInline.initiateDate" placeholder="请输入VIN"></el-input>
      </el-form-item>
      <el-form-item label="结束报警时间">
        <el-input v-model="formInline.finishDate" placeholder="请输入VIN"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="findSysFaultLogList()" icon="el-icon-search">查询</el-button>
        <el-button @click="resetFindSysFaultLogList()" icon="el-icon-refresh">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          icon="el-icon-plus"
          plain
          size="mini"
          type="primary"
          @click="dialogFormVisible=true"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          v-hasPermi="['system:role:edit']"
          :disabled="single"
          icon="el-icon-edit"
          plain
          size="mini"
          type="success"
          @click="handleUpdate"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          v-hasPermi="['system:role:remove']"
          :disabled="multiple"
          icon="el-icon-delete"
          plain
          size="mini"
          type="danger"
          @click="handleDelete"
        >删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          v-hasPermi="['system:role:export']"
          icon="el-icon-download"
          plain
          size="mini"
          type="warning"
          @click="handleExport"
        >导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <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="故障码"
        width="180">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.faultCode }}</span>
        </template>
      </el-table-column>

      <el-table-column
        label="车辆故障名称"
        width="180">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.faultName }}</span>
        </template>
      </el-table-column>

      <el-table-column
        label="车辆故障类型"
        width="180">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.faultTypeName }}</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.initiateDate }}</span>
        </template>
      </el-table-column>

      <el-table-column
        label="结束报警时间"
        width="180">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.finishDate }}</span>
        </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>

    <el-dialog title="修改故障日志信息" :visible.sync="dialogFormVisible">
      <el-form :model="updateform">
        <el-form-item label="主键ID" :label-width="formLabelWidth">
          <el-input v-model="updateform.id" autocomplete="off"></el-input>
        </el-form-item>

        <el-form-item label="故障码" :label-width="formLabelWidth">
          <el-input v-model="updateform.faultCode" autocomplete="off"></el-input>
        </el-form-item>

        <el-form-item label="车辆故障名称" :label-width="formLabelWidth">
          <el-input v-model="updateform.faultName" autocomplete="off"></el-input>
        </el-form-item>

        <el-form-item label="车辆故障类型" :label-width="formLabelWidth">
          <el-input v-model="updateform.faultTypeId" autocomplete="off"></el-input>
        </el-form-item>

        <el-form-item label="故障VIN编码" :label-width="formLabelWidth">
          <el-input v-model="updateform.carVin" autocomplete="off"></el-input>
        </el-form-item>

        <el-form-item label="开始报警时间" :label-width="formLabelWidth">
          <el-input v-model="updateform.initiateDate" autocomplete="off"></el-input>
        </el-form-item>

        <el-form-item label="结束报警时间" :label-width="formLabelWidth">
          <el-input v-model="updateform.finishDate" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="updateSysFaultLog()">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）,
//例如：import 《组件名称》 from '《组件路径》,
import {findSysFaultLogList} from "@/api/car/fault/log";
import {deleteSysFaultLog} from "@/api/car/fault/log";
import {updateSysFaultLog} from "@/api/car/fault/log";
export default {
  //import引入的组件需要注入到对象中才能使用"
  components: {},
  props: {},
  data() {
    //这里存放数据"

    return {
      //
      updateform:{},
      //修改弹出框是否显示
      dialogFormVisible:false,
      //查询条件
      tableData:[],
      formInline:{},
    };
  },
  //计算属性 类似于data概念",
  computed: {},
  //监控data中的数据变化",
  watch: {},
  //方法集合",
  methods: {
    //修改车辆故障码
    updateSysFaultLog(){
      alert(this.updateform.id);
      updateSysFaultLog(this.updateform).then((res)=>{
        alert(res.msg);
        if (200==res.code){
          this.findSysFaultLogList();
          this.dialogFormVisible=false;
        }
      })
    },
    //修改回显打开对话框
    handleEdit(row){
      this.updateform=row;
      this.dialogFormVisible=true;
    },
    //删除日志
    handleDelete(row){
      alert(row.id);
      deleteSysFaultLog(row.id).then((res)=>{
        alert(res.msg);
        if (200==res.code){
          this.findSysFaultLogList();
        }
      })
    },
    //重置
    resetFindSysFaultLogList(){
      this.findSysFaultLogList();
    },
    //查询日志列表
    findSysFaultLogList(){
      findSysFaultLogList(this.formInline).then((res)=>{
        this.tableData=res.data.rows;
      })
    }
  },
  //生命周期 - 创建完成（可以访问当前this实例）",
  created() {
    this.findSysFaultLogList();
  },
  //生命周期 - 挂载完成（可以访问DOM元素）",
  mounted() {
  },
  beforeCreate() {
  }, //生命周期 - 创建之前",
  beforeMount() {
  }, //生命周期 - 挂载之前",
  beforeUpdate() {
  }, //生命周期 - 更新之前",
  updated() {
  }, //生命周期 - 更新之后",
  beforeDestroy() {
  }, //生命周期 - 销毁之前",
  destroyed() {
  }, //生命周期 - 销毁完成",
  activated() {
  } //如果页面有keep-alive缓存功能，这个函数会触发",
};
</script>
<style scoped>

</style>
