index.vue 8.97 KB
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="所属公司" prop="companyName">
        <el-input
          v-model="queryParams.companyName"
          placeholder="请输入所属公司"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="车辆类型" prop="carType">
        <el-select v-model="queryParams.carType" placeholder="请选择车辆类型" clearable style="width: 100%;"  size="small">
          <el-option label="轻型货车" value="轻型货车" />
          <el-option label="中型货车" value="中型货车" />
          <el-option label="大中型货车" value="大中型货车" />
        </el-select>
      </el-form-item>
      <el-form-item label="车牌号" prop="carCode">
        <el-input
          v-model="queryParams.carCode"
          placeholder="请输入车牌号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="车辆品牌" prop="carBrank">
        <el-input
          v-model="queryParams.carBrank"
          placeholder="请输入车辆品牌"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" 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>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['unit:carInfo:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['unit:carInfo:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['unit:carInfo:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['unit:carInfo:export']"
        >导出</el-button>
      </el-col>
	  <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="carInfoList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column type="index" width="55" align="center" label="序号"/>
      <el-table-column label="车牌号" align="center" prop="carCode" />
      <el-table-column label="车辆标识牌" align="center" prop="carIdentification" />
      <el-table-column label="所属公司" align="center" prop="companyName" />
      <el-table-column label="驾驶员" align="center" prop="driversName" />
      <el-table-column label="车辆品牌" align="center" prop="carBrank" />
      <el-table-column label="所属区域" align="center" prop="emissionStandard" />
      <el-table-column label="车辆类型" align="center" prop="carType" />
      <el-table-column label="SIM卡号" align="center" prop="carEquipment" />
<!--      <el-table-column label="审批状态" align="center" prop="status" >-->
<!--        <template slot-scope="scope">-->
<!--          {{ parseStatus(scope.row.status)}}-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column label="信用状态" align="center" prop="creditStatus" />-->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['unit:carInfo:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['unit:carInfo:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import { listCarInfo, getCarInfo, delCarInfo, addCarInfo, updateCarInfo, exportCarInfo } from "@/api/unit/carInfo";
import {parseStatus} from "../../../utils/trash";

export default {
  name: "CarInfo",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 运输车辆管理表格数据
      carInfoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        companyId: null,
        carType: null,
        carCode: null,
        carBrank: null,
        emissionStandard: null,
        roadTransportDate: null,
        drivingLicenseDate: null,
        enterDate: null,
        farmeNumber: null,
        carIdentification: null,
        containerVolume: null,
        carColor: null,
        carEquipment: null,
        roadTransport: null,
        drivingLicense: null,
        carFront: null,
        carLeft: null,
        carBehind: null,
        carRight: null,
        drivers: null,
        status: null,
        creditStatus: null,
        qrCode: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  watch:{
    '$route.query.carInfoRefresh':'getList'
  },
  methods: {
    /** 查询运输车辆管理列表 */
    getList() {
      this.loading = true;
      listCarInfo(this.queryParams).then(response => {
        this.carInfoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.pageNum = 1;
      this.queryParams.companyName = null;
      this.queryParams.carType = null;
      this.queryParams.carCode = null;
      this.queryParams.carBrank = null;
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.$tab.openPage("新增车辆信息","/carInfo/info",{carInfoRefresh:0});
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      const id = row.id || this.ids
      this.$tab.openPage("修改车辆信息","/carInfo/infoEdit",{carInfoId: id,carInfoRefresh:0});
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateCarInfo(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addCarInfo(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除运输车辆管理编号为"' + ids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delCarInfo(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有运输车辆管理数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportCarInfo(queryParams);
        }).then(response => {
          this.download(response.message);
        })
    }
  }
};
</script>