<template>
  <div>
    <template>
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="全部" name="all">
          <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
            <el-form-item label="VIN码" prop="vin">
              <el-input
                v-model="queryParams.vin"
                placeholder="请输入VIN码"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="状态" prop="status">
              <el-select v-model="queryParams.status" clearable placeholder="状态">
                <el-option
                  v-for="dict in dict.type.sys_car_fault_log_status"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                  />
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
              <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
          </el-form>

          <rl-row>
            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
          </rl-row>

          <el-table v-loading="loading" :data="messageList" stripe>
            <el-table-column label="故障编号" align="center" prop="sysCarFaultId" />
            <el-table-column label="VIN码" align="center" prop="vin" />
            <el-table-column label="开始时间" align="center" prop="createTime" />
            <el-table-column label="结束时间" align="center" prop="updateTime" />
            <el-table-column align="center" label="状态" prop="status">
              <template slot-scope="scope">
                <dict-tag :options="dict.type.sys_car_fault_log_status" :value="scope.row.status" />
              </template>
            </el-table-column>
          </el-table>
          <pagination
            v-show="total > 0"
            :total="total"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
          />

        </el-tab-pane>
        <el-tab-pane label="解决" name="resolve">
          <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
            <el-form-item label="VIN码" prop="vin">
              <el-input
                v-model="queryParams.vin"
                placeholder="请输入VIN码"
                clearable
                @ceyup.enter.native="handleQuery"
            />
            </el-form-item>
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
              <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
          </el-form>
          <rl-row>
            <right-toolbar :showSearch.sync="showSearch" @queryTable="getListSolve"></right-toolbar>
          </rl-row>
          <el-table v-loading="loading" :data="StatusSolveList" stripe>
            <el-table-column label="故障编号" align="center" prop="sysCarFaultId" />
            <el-table-column label="VIN码" align="center" prop="vin" />
            <el-table-column label="开始时间" align="center" prop="createTime" />
            <el-table-column label="结束时间" align="center" prop="updateTime" />
          </el-table>
          <pagination
            v-show="totalSolve > 0"
            :total="totalSolve"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getListSolve"
          />
        </el-tab-pane>
        <el-tab-pane label="处理中" name="processing">
          <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
            <el-form-item label="VIN码" prop="vin">
              <el-input
                v-model="queryParams.vin"
                placeholder="请输入VIN码"
                clearable
                @ceyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
              <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
          </el-form>
          <rl-row>
            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
          </rl-row>
          <el-table v-loading="loading" :data="StatusProcessList" stripe>
            <el-table-column label="故障编号" align="center" prop="sysCarFaultId" />
            <el-table-column label="VIN码" align="center" prop="vin" />
            <el-table-column label="开始时间" align="center" prop="createTime" />
            <el-table-column label="结束时间" align="center" prop="updateTime" />


          </el-table>
          <pagination
            v-show="totalProcess > 0"
            :total="totalProcess"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getListProcess"
          />
        </el-tab-pane>
        <el-tab-pane label="忽略" name="ignore">
          <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
            <el-form-item label="VIN码" prop="vin">
              <el-input
                v-model="queryParams.vin"
                placeholder="请输入VIN码"
                clearable
                @ceyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
              <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
          </el-form>
          <rl-row>
            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
          </rl-row>
          <el-table v-loading="loading" :data="StatusIgnoreList" stripe>
            <el-table-column label="故障编号" align="center" prop="sysCarFaultId" />
            <el-table-column label="VIN码" align="center" prop="vin" />
            <el-table-column label="开始时间" align="center" prop="createTime" />
            <el-table-column label="结束时间" align="center" prop="updateTime" />
          </el-table>
          <pagination
            v-show="totalIgnore > 0"
            :total="totalIgnore"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getListIgnore"
          />
        </el-tab-pane>
      </el-tabs>


    </template>
  </div>
</template>

<script>
import { listLog ,listStatusIgnore,listStatusProcess,listStatusSolve} from '/src/api/breakdown/Log';

export default {
  dicts:['sys_car_fault_log_status'],
  name:"log",
  components:{},
  props:{},
  data() {
    return {
      activeName:'all',
      loading:true,
      messageList:[],
      StatusSolveList:[],
      StatusProcessList:[],
      StatusIgnoreList:[],
      //总条数
      total:0,
      totalIgnore:0,
      totalProcess:0,
      totalSolve:0,
      // 显示搜索条件
      showSearch: true,
      queryParams:{
        pageNum:1,
        pageSize:10,
        vin:null,
        status:null
      }
    };
  },
  computed:{},
  watch:{},
  methods:{
    handleClick(tab,event) {
      console.log(tab,event);
      this.getList();
    },
    getList() {
      this.loading = true;
      listLog(this.queryParams).then(response => {
        this.messageList = response.data.rows;
        this.total = response.data.total;
        this.loading = false;
      }).catch(() => {
        this.loading = false;
      });

    },
    getListIgnore(){
      listStatusIgnore(this.queryParams).then(response => {
        this.StatusIgnoreList = response.data.rows;
        this.totalIgnore = response.data.total;
        this.loading = false;
      }).catch(() => {
        this.loading = false;
      });
    },
    getListProcess(){
      listStatusProcess(this.queryParams).then(response=>{
        this.StatusProcessList=response.data.rows;
        this.totalProcess=response.data.total;
        this.loading=false;
      }).catch(()=>{
        this.loading=false
      })
    },
    getListSolve(){
      listStatusSolve(this.queryParams).then(response=>{
        this.StatusSolveList=response.data.rows;
        this.totalSolve=response.data.total;
        this.loading=false;
      }).catch(()=>{
        this.loading=false
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  },
  created() {
    this.getList();
    this.getListIgnore()
    this.getListProcess()
    this.getListSolve()
  },
  mounted() {},
  beforeCreate() {},
  beforeMount() {},
  beforeUpdate() {},
  updated() {},
  beforeDestroy() {},
  destroyed() {},
  activated() {}
};
</script>

<style scoped>
.el-table {
  width:100%;
}
.el-pagination {
  margin:20px 0;
  text-align:right;
}
</style>

