<template>
    <div class="dashboard-container">
        <div class="search-content">
            <el-input style="width: 220px;" placeholder="请输入终端编码" clearable v-model="searchData.terminalCode"></el-input>
            <el-input style="width: 220px;" placeholder="请输入终端名称" clearable v-model="searchData.terminalName"></el-input>
            <el-select style="width: 220px;" clearable placeholder="请选择终端状态" v-model="searchData.status">
                <el-option label="在线" value="1"></el-option>               
                <el-option label="离线" value="2"></el-option>               
            </el-select>
            <div class="search-btn">        
                <div class="search" @click="searchBtn()">查询</div>
                <div class="reset" @click="reset()">重置</div>
            </div>
        </div>

        <div class="table-content">
            <div style="width: 100%;height: 30px;">
                <div class="btn" style="margin-right: -3px;" @click="reset()">刷新</div>
            </div>
            <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%">
                <el-table-column prop="terminalCodes" label="终端编码">
                </el-table-column>
                <el-table-column prop="terminalName" label="终端名称" show-overflow-tooltip="true">
                </el-table-column>
                <el-table-column prop="status" label="终端状态">
                    <template slot-scope="scope">
                        <div class="startUsing" v-if="scope.row.status == '在线'">在线</div>
                        <div class="Deactivate" v-else>离线</div>
                    </template>
                </el-table-column>
                <el-table-column prop="travelMileFormat" label="当前所在位置">
                  <template slot-scope="scope">
                    {{ scope.row.travelMileFormat }}-{{ scope.row.lineDirName }}
                  </template>
                </el-table-column>
                <el-table-column prop="currenTime" label="更新时间">
                </el-table-column>
            </el-table>
            <div class="pagination">
                <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :page-sizes="[10, 15, 20]"
                :page-size="searchData.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total">
                </el-pagination>
            </div>
        </div>
    </div>
</template>
<script>
import {getVehicleMonitoringList} from '@/api/systemMonitoring'
export default {
    name:'vehicleMonitoring',
    components:{

    },
    data() {
        return {
            tableData:[],
            searchData:{
                pageNum: 1,
                pageSize: 10,
                terminalCode:'',
                terminalName:'',
                status:''
            },
            total:0
        }
    },
    created() {
      if(this.$route.params.pageNum){
        this.searchData.status = this.$route.params.status
      }
        this.getList(this.searchData)
    },
    methods:{
       getList(params) {
        getVehicleMonitoringList(params).then(res => {            
            if(res.code == 200) {
                this.tableData = res.data.records
                this.total = res.data.total
            }
        })
       },
       searchBtn() {
        this.searchData.pageNum = 1
        this.getList(this.searchData)
       },
       handleSizeChange(val) {
        this.searchData.pageSize = val
        this.getList(this.searchData)
       },
       handleCurrentChange(val) {
        this.searchData.pageNum = val
        this.getList(this.searchData)
       },
       reset() {
        this.searchData = {            
            pageNum: 1,
            pageSize: 10,
            terminalCode:'',
            terminalName:'',
            status:''            
        }
        this.getList(this.searchData)
       }
    }
}
</script>
<style lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }

  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
.dashboard-container {
  .search-content {
    width: 100%;
    height: 74px;
    background-color: #fff;
    display: flex;
    align-items: center;
    padding-left: 10px;

    .el-input {
      margin: 0 10px;
    }

    .el-select {
      margin: 0 10px;
    }

    .search-btn {
      display: flex;
      align-items: center;
      height: 100%;      
      margin-left: 10px;

      div {
        // margin: 0 6px;
        display: inline-block;
        width: 80px;
        height: 40px;
        border-radius: 2px;
        font-size: 14px;
        line-height: 40px;
        text-align: center;
      }

      div:hover {
        cursor: pointer;
      }

      .search {
        margin-right: 10px;
        background-color: #2766DD;
        color: #F7F8FB;
      }

      .search:hover {
        background-color: #4D85F4;
      }

      .reset {
        color: #333334;
        border: 1px solid #D7D7D7;
      }

      .reset:hover {
        color: #1F9FFF;
        border: 1px solid #1F9FFF;
      }
    }
  }

  .table-content {
    margin-top: 15px;
    width: 100%;
    background-color: #fff;
    padding: 0 20px 20px;

    .btn {
      margin: 15px 20px 15px 0;
      cursor: pointer;
      float: left;
      text-align: center;
      width: 98px;
      height: 34px;
      border-radius: 2px;
      border: 1px solid #ABC7FD;
      line-height: 34px;
      font-weight: 400;
      font-size: 14px;
      color: #2250C8;
      background-color: #E7EEFF;
    }

    .btn:hover {
      color: #FFFFFF;
      background-color: #2250C8;
      border: 1px solid #2250C8;
    }

    .btn:active {
      color: #FFFFFF;
      background-color: #194DA4;
      border: 1px solid #194DA4;
    }

    .startUsing {
        width: 54px;
        height: 24px;
        margin: 14.5px auto 0;
        line-height: 24px;
        text-align: center;
        font-size: 12px;
        color: #00974D;
        border-radius: 4px;
        background-color: #E7FAF0;
        border: 1px solid #BEFDDD;
      }

      .Deactivate {
        width: 54px;
        height: 24px;
        margin: 14.5px auto 0;
        line-height: 24px;
        text-align: center;
        font-size: 12px;
        color: #FF9933;
        border-radius: 4px;
        background-color: #FFF3E8;
        border: 1px solid #FDE6CF;
      }

    .operateBtn {
      display: flex;
      justify-content: center;
      color: #2866DD;

      div {
        font-size: 14px;
        margin: 0 5px;
        cursor: pointer;
      }
    }

    .pagination {
      margin: 10px 0;
      width: 100%;
      height: 20px;

      .el-pagination {
        float: right;
        margin: 10px 0;
      }
    }
  }

}
</style>