<template>
  <div>
    <!-- 对话框(添加 / 修改) -->
    <el-drawer
      title="选择车辆"
      size="60%"
      :visible.sync="drawVisible"
      >
      <!-- 搜索工作栏 -->
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
        <el-form-item label="发动机号码" prop="engineNumber">
          <el-input v-model="queryParams.engineNumber" placeholder="请输入发动机号码" clearable
                    @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="车架号" prop="vin">
          <el-input v-model="queryParams.vin" placeholder="请输入车架号" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="车牌号" prop="licenseNumber">
          <el-input v-model="queryParams.licenseNumber" placeholder="请输入车牌号" clearable
                    @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="车辆型号" prop="carModel">
          <el-input v-model="queryParams.carModel" placeholder="请输入车辆型号" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="保养日期" prop="maintenanceDate">
          <el-date-picker v-model="queryParams.maintenanceDate" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss"
                          type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
                          :default-time="['00:00:00', '23:59:59']" />
        </el-form-item>
        <el-form-item label="保养里程" prop="maintenanceMileage">
          <el-input v-model="queryParams.maintenanceMileage" placeholder="请输入保养里程" clearable
                    @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="年检日期" prop="inspectionDate">
          <el-date-picker v-model="queryParams.inspectionDate" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss"
                          type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
                          :default-time="['00:00:00', '23:59:59']" />
        </el-form-item>
        <el-form-item label="保险日期" prop="insuranceDate">
          <el-date-picker v-model="queryParams.insuranceDate" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss"
                          type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
                          :default-time="['00:00:00', '23:59:59']" />
        </el-form-item>
        <el-form-item label="二级维护时间" prop="checkDate">
          <el-date-picker v-model="queryParams.checkDate" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss"
                          type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
                          :default-time="['00:00:00', '23:59:59']" />
        </el-form-item>
        <el-form-item label="车辆品牌" prop="carBrand">
          <el-input v-model="queryParams.carBrand" placeholder="请输入车辆品牌" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="车辆性质" prop="carNature">
          <el-input v-model="queryParams.carNature" placeholder="请输入车辆性质" clearable
                    @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="车辆注册日期" prop="carRegisterDate">
          <el-date-picker v-model="queryParams.carRegisterDate" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss"
                          type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
                          :default-time="['00:00:00', '23:59:59']" />
        </el-form-item>
        <el-form-item label="最近办理业务" prop="recentlyHandledBusiness">
          <el-input v-model="queryParams.recentlyHandledBusiness" placeholder="请输入最近办理业务" clearable
                    @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="最近办理业务的时间" prop="recentlyHandleBusinessTime">
          <el-date-picker v-model="queryParams.recentlyHandleBusinessTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss"
                          type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
                          :default-time="['00:00:00', '23:59:59']" />
        </el-form-item>
        <el-form-item label="行驶证图片" prop="carLicenseImg">
          <el-input v-model="queryParams.carLicenseImg" placeholder="请输入行驶证图片" clearable
                    @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="创建时间" prop="createTime">
          <el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss"
                          type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
                          :default-time="['00:00:00', '23:59:59']" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>

      <!-- 操作工具栏 -->
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="openForm(undefined)"
                     v-hasPermi="['base:car-main:create']">新增</el-button>
        </el-col>

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

      <el-table v-loading="formLoading" :data="list" :stripe="true" :show-overflow-tooltip="true">
        <el-table-column label="主键标识" align="center" prop="id" />
        <el-table-column label="发动机号码" align="center" prop="engineNumber" />
        <el-table-column label="车架号" align="center" prop="vin" />
        <el-table-column label="车牌号" align="center" prop="licenseNumber" />
        <el-table-column label="车辆型号" align="center" prop="carModel" />
        <el-table-column label="保养日期" align="center" prop="maintenanceDate" width="180">
          <template v-slot="scope">
            <span>{{ parseTime(scope.row.maintenanceDate) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="保养里程" align="center" prop="maintenanceMileage" />
        <el-table-column label="年检日期" align="center" prop="inspectionDate" width="180">
          <template v-slot="scope">
            <span>{{ parseTime(scope.row.inspectionDate) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="保险日期" align="center" prop="insuranceDate" width="180">
          <template v-slot="scope">
            <span>{{ parseTime(scope.row.insuranceDate) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="二级维护时间" align="center" prop="checkDate" width="180">
          <template v-slot="scope">
            <span>{{ parseTime(scope.row.checkDate) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="车辆品牌" align="center" prop="carBrand" />
        <el-table-column label="车辆性质" align="center" prop="carNature" />
        <el-table-column label="车辆注册日期" align="center" prop="carRegisterDate" width="180">
          <template v-slot="scope">
            <span>{{ parseTime(scope.row.carRegisterDate) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="最近办理业务" align="center" prop="recentlyHandledBusiness" />
        <el-table-column label="最近办理业务的时间" align="center" prop="recentlyHandleBusinessTime" width="180">
          <template v-slot="scope">
            <span>{{ parseTime(scope.row.recentlyHandleBusinessTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="行驶证图片" align="center" prop="carLicenseImg" />
        <el-table-column label="创建时间" align="center" prop="createTime" width="180">
          <template v-slot="scope">
            <span>{{ parseTime(scope.row.createTime) }}</span>
          </template>
        </el-table-column>
      </el-table>
    </el-drawer>
  </div>
</template>

<script>
import * as CarMainApi from '@/api/base/carmain';
export default {
  name: "ChooseCarDraw",
  components: {
  },
  data() {
    return {
      // 弹出层标题
      // 是否显示弹出层
      drawVisible: false,
      // 表单的加载中：1）修改时的数据加载；2）提交的按钮禁用
      formLoading: false,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
      //回参
      formData:{},
      // 车辆信息列表
      list: [],
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        engineNumber: null,
        vin: null,
        licenseNumber: null,
        carModel: null,
        maintenanceDate: [],
        maintenanceMileage: null,
        inspectionDate: [],
        insuranceDate: [],
        checkDate: [],
        carBrand: null,
        carNature: null,
        carRegisterDate: [],
        carLicenseImg: null,
        createTime: [],
      },

    };
  },
  methods: {

    /** 打开弹窗 */
    async open() {
      this.drawVisible = true;
      this.formLoading = true;
      try{
        const res = await CarMainApi.getCarMainPage(this.queryParams);
        this.list = res.data.records;
        this.total = res.data.total;
      }finally {
        this.formLoading = false;
      }
    },

    /** 查询列表 */
    async getList() {
      try {

        const res = await CarMainApi.getCarMainPage(this.queryParams);
        this.list = res.data.records;
        this.total = res.data.total;
      } finally {

      }
    },
    /** 搜索按钮操作 */
    handleQuery() {
      debugger;
      this.queryParams.pageNo = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },


    /** 提交按钮 */
    async submitForm() {

    },

  }
};
</script>
