<template>
  <div>
    <el-form ref="from" :model="from" status-icon class="demo-ruleForm">
      <el-form-item label="车辆VIN" prop="pass">
        <el-input v-model="from.carVinId" type="text" autocomplete="off" />
      </el-form-item>

      <el-form-item label="车辆类型" prop="pass">
        <el-input v-model="from.carTypeId" type="text" autocomplete="off" />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
        <el-button @click="resetForm('ruleForm')">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="tableData" style="width: 100%">

      <el-table-column label="车辆VIN" width="180">
        <template slot-scope="scope">
          <el-tag size="medium">{{ scope.row.carVinId }}</el-tag>
        </template>
      </el-table-column>

      <el-table-column label="车辆类型" width="180">
        <template slot-scope="scope">
          <el-tag size="medium">{{ scope.row.carTypeId }}</el-tag>
        </template>
      </el-table-column>

      <el-table-column label="电子围栏ID" width="180">
        <template slot-scope="scope">
          <el-tag size="medium">{{ scope.row.fenceId }}</el-tag>
        </template>
      </el-table-column>

      <el-table-column label="车辆状态" width="180">
        <template slot-scope="scope">
          <el-tag size="medium">{{ scope.row.status }}</el-tag>
        </template>
      </el-table-column>

      <el-table-column label="电池厂商" width="180">
        <template slot-scope="scope">
          <el-tag size="medium">{{ scope.row.batteryManufacturer }}</el-tag>
        </template>
      </el-table-column>

      <el-table-column label="电机厂商" width="180">
        <template slot-scope="scope">
          <el-tag size="medium">{{ scope.row.motorManufacturer }}</el-tag>
        </template>
      </el-table-column>

      <el-table-column label="电机编号" width="180">
        <template slot-scope="scope">
          <el-tag size="medium">{{ scope.row.motorNumber }}</el-tag>
        </template>
      </el-table-column>

      <el-table-column label="电池编号" width="180">
        <template slot-scope="scope">
          <el-tag size="medium">{{ scope.row.batteryNumber }}</el-tag>
        </template>
      </el-table-column>

      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleShi(scope.$index , scope.row)">实时轨迹</el-button>
          <!--        修改车辆信息-->
          <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>

  </div>
</template>

<script>

import { carList } from '../../api/carList/list'

export default {
  name: 'CarList',
  filters: {
    statusFilter(status) {
      const statusMap = {
        published: 'success',
        draft: 'gray',
        deleted: 'danger'
      }
      return statusMap[status]
    }
  },
  data() {
    return {
      list: null,
      listLoading: true,
      from: {
        carVinId: null,
        carTypeId: null
      },
      tableData: []
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    fetchData: function() {
      this.listLoading = true
      carList().then(response => {
        this.tableData = response.data.data
        console.log(2222222222222222)
        this.listLoading = false
      })
    },
    // 实时轨迹
    handleShi() {},
    // 修改
    handleEdit() {},
    // 删除
    handleDelete() {}
  }
}
</script>
<style>
 .el-input{
   width: 200px;
 }
</style>
