<template>
  <div class="app-container scroll-auto">
    <el-form
      ref="queryForm"
      :model="queryParams"
      size="small"
      :inline="true"
      v-show="showSearch"
    >
      <!--el-form-item label="区县公司" prop="countyOrgNm">
        <el-input
          v-model="queryParams.countyOrgNm"
          placeholder="请输入区县公司"
		  clearable
        />
      </el-form-item>
      <el-form-item label="项目负责人" prop="curator">
        <el-input
          v-model="queryParams.curator"
          placeholder="请输入项目负责人"
		  clearable
        /-->
      </el-form-item>
      <el-form-item label="车牌号" prop="vehicleNo">
        <el-input v-model="queryParams.vehicleNo" clearable placeholder="请输入车牌号" />
      </el-form-item>
      <el-form-item label="车组" prop="vehicleGroup">
        <el-input v-model="queryParams.vehicleGroup" clearable placeholder="请输入车组" />
      </el-form-item>
	   <el-form-item label="日期" prop="monitorDate">
	     <el-date-picker
	       v-model="queryParams.monitorDate"
	       style="width: 240px; margin-right: 8px"
	       type="daterange"
	       range-separator="至"
	       start-placeholder="开始日期"
	       end-placeholder="结束日期"
	       value-format="yyyy-MM-dd"
	       :clearable="false"
	     >
	     </el-date-picker>
	   </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>
    <div class="table">
      <el-table ref="renewalTable" border style="width: 100%" :header-cell-style="{fontSize: '12px', backgroundColor: '#f8f8f8',color:'#333',fontWeight: 'bold'}" v-loading="loading" :data="dataList">
        <<el-table-column prop="" label="序号" width="80" align="center">
          <template slot-scope="scope">
            {{
              scope.$index +
              (queryParams.pageNum - 1) * queryParams.pageSize +
              1
            }}
          </template>
        </el-table-column>
		<el-table-column
				  label="所属车组"
				  prop="vehicleGroup"
				  align="center"
				>  </el-table-column>
       
        
        <el-table-column
          label="车牌号"
          prop="vehicleNo"
          align="center"
        >
        </el-table-column>
       
      
        <el-table-column
          prop="occurDate"
          label="发生时间"
          align="center"
                 
        />
        <el-table-column
          label="最新状态"
          prop="alarmDesc"
          align="center"
        >
		<template slot-scope="scope" >
				<el-tag type="danger"  v-if="scope.row.alarmCd!='0'" effect="text">{{scope.row.alarmDesc}}</el-tag>
				<el-tag type="success" v-else>{{scope.row.alarmDesc}}</el-tag>
		</template>
        </el-table-column>
		<el-table-column
		  prop="remark"
		  label="备注"
		  align="center"
		  width="400"       
		/>
        <el-table-column
          label="更新时间"
          prop="createTime"
          align="center"
        >
        </el-table-column>
		
        <el-table-column
          label="操作"
          align="center"
          width="120"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-document"
              @click="handleRecord(scope.row)"
              >作业记录</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <pagination
        class="page-box"
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>

    

  <work-track
    :visible.sync="trackDialogVisible"
    :vehicle-info="currentVehicle"
  />
  </div>
</template>

<script>

import {
  listVehicleAlarmHist
} from "@/api/powerdistribution/vehicle-monitoring";
import WorkTrack from "./../components/WorkTrack.vue";

export default {
  components: {
    WorkTrack
  },
  data() {
    return {
      dataList: [],
      // 显示搜索条件
      showSearch: true,
      // 遮罩层
      loading: true,
      total: 0,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        countyOrgNm: "", // 区县公司
        curator: "", // 项目负责人
        vehicleNo: "", // 车牌号
				alarmCd: "3",
        vehicleGroup: "", // 车组
		monitorDate: [
		 
		],
      },
      
   
      // 行驶记录相关
      trackDialogVisible: false,
	  
	  
      // 当前选中的车辆信息
      currentVehicle: {},
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      listVehicleAlarmHist({ ...this.queryParams,
	   startDate: this.queryParams.monitorDate[0],
	   endDate: this.queryParams.monitorDate[1]
	   }).then((response) => {
        this.dataList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        countyOrgNm: "",
        curator: "",
        vehicleNo: "",
        vehicleGroup: "",
		alarmCd: "3",
		monitorDate: [
		 
		],
      };
      this.resetForm("queryForm");
      this.handleQuery();
    },
  
   
    /** 查看行驶记录 */
    handleRecord(row) {
      this.currentVehicle =row;
       this.trackDialogVisible = true;
    },
	
  },
};
</script>
<style lang="scss" scoped>
.table {
  height: calc(100% - 150px);
}
::v-deep {
  .el-table {
    height: 100%;
    width: 100%;
    .el-table__body-wrapper {
      width: 100% !important;
      height: calc(100% - 50px) !important; // 表格高度减去表头的高度
      overflow-y: scroll;
    }
  }
  .el-form--inline .el-form-item {
    margin-right: 10px;
    margin-bottom: 10px;
  }
  // 上传按钮样式调整
  .el-upload {
    display: inline-block;
  }
  .el-button--text {
    padding: 0 8px;
  }
}

.track-container {
  min-height: 400px;
  // 添加地图容器的样式
}

.record-container {
  min-height: 400px;
  padding: 20px;

  .mb20 {
    margin-bottom: 20px;
  }

  ::v-deep {
    .el-table {
      margin-bottom: 20px;
    }
  }
}
</style>
