<template>
  <div>
    <h1>车辆监控页面</h1>

    <!--    列表-->
    <el-table :data="vehicleList" style="width: 100%" border>
      <el-table-column label="车辆id" width="90" align="center">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.vehicleId }}</span>
        </template>
      </el-table-column>
      <el-table-column label="车辆类型" width="90" align="center">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.vehicleTypeName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="电机厂商" width="150" align="center">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.motorManufacturer }}</span>
        </template>
      </el-table-column>
      <el-table-column label="电池厂商" width="150" align="center">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.batteryManufacturer }}</span>
        </template>
      </el-table-column>
      <el-table-column label="电机编号" width="180" align="center">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.motorNumber }}</span>
        </template>
      </el-table-column>
      <el-table-column label="电池编号" width="180" align="center">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.batteryNumber }}</span>
        </template>
      </el-table-column>

       <el-table-column label="vin码" width="180" align="center">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.vin }}</span>
        </template>
      </el-table-column>


      <!--      <el-table-column label="vin码" width="180" align="center">-->
      <!--        <template slot-scope="scope">-->
      <!--          <span style="margin-left: 10px">{{ scope.row.vin }}</span>-->
      <!--        </template>-->
      <!--      </el-table-column>-->
      <el-table-column label="车辆状态" width="120" align="center">
        <template slot-scope="scope">
          <span style="margin-left: 10px" v-if="1==scope.row.vehicleState">
            <el-tag type="success">在线</el-tag>
          </span>
          <span style="margin-left: 10px" v-if="0==scope.row.vehicleState">
            <el-tag type="danger">离线</el-tag>
          </span>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="180" align="center">
        <template slot-scope="scope">
          <el-button size="mini" type="danger" @click="findByVehicle(scope.row.vin)">查看实时数据</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

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

export default {
  //import引入的组件需要注入到对象中才能使用"
  components: {},
  props: {},
  data() {
    //这里存放数据"
    return {
      //车辆列表
      vehicleList: [],

      //总页数
      total: 0,

      //车辆类型
      vehicleTypes: [],
      //对话框的参数
      formLabelWidth: '120px',
      dialogEdit: false,
      dialogInsert: false,
      // 弹出层标题
      title: ""

    };
  },
  //计算属性 类似于data概念",
  computed: {},
  //监控data中的数据变化",
  watch: {},
  //方法集合",
  methods: {
    //获取车辆列表
    getVehicleList() {
      detectionList().then(
        res => {
          this.vehicleList = res.data;
        }
      )
    },

    //分页
    handleSizeChange(val) {
      this.vehicleListParams.pageSize = val;
      this.getVehicleList();
    },
    handleCurrentChange(val) {
      this.vehicleListParams.pageNum = val;
      this.getVehicleList();
    },

    //获取车辆类型
    getVehicleTypes() {
      getVehicleTypes().then(
        res => {
          this.vehicleTypes = res.data;
        }
      )
    },
    findByVehicle(vin){

    }
  },
  //生命周期 - 创建完成（可以访问当前this实例）",
  created() {
    //获取车辆列表
    this.getVehicleList ()

    //获取车辆类型
    this.getVehicleTypes()
  },
  //生命周期 - 挂载完成（可以访问DOM元素）",
  mounted() {
  },
  beforeCreate() {
  }, //生命周期 - 创建之前",
  beforeMount() {
  }, //生命周期 - 挂载之前",
  beforeUpdate() {
  }, //生命周期 - 更新之前",
  updated() {
  }, //生命周期 - 更新之后",
  beforeDestroy() {
  }, //生命周期 - 销毁之前",
  destroyed() {
  }, //生命周期 - 销毁完成",
  activated() {
  } //如果页面有keep-alive缓存功能，这个函数会触发",
};
</script>
<style scoped>

</style>
