return 的使用 及字段拼接 完整的页面布局逻辑实现

<template>
  <div
    v-loading="loading"
    element-loading-text="加载中"
    element-loading-background="rgba(0, 0, 0, 0.8)"
  >
    <el-row type="flex" align="middle">
      <el-col :span="21">
        <el-row :gutter="20" type="flex" align="middle">
          <el-col :span="4">
            <el-input
              v-model="carNo"
              placeholder="输入车牌号进行查询"
            ></el-input>
          </el-col>
          <el-col :span="4" v-if="this.userTypes == 6 || this.userTypes == 7">
            <el-input v-model="corpName" placeholder="输入公司名称查询">
            </el-input>
          </el-col>
          <el-col :span="4" v-if="this.userTypes == 6 || this.userTypes == 7">
            <el-input
              v-model="chargeStationName"
              placeholder="输入站点名称查询"
            >
            </el-input>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="primary"
              size="small"
              icon="el-icon-search"
              @click="getData"
              :disabled="isDisable"
              >搜索</el-button
            >
          </el-col>
          <el-col :span="2">
            <el-button
              :disabled="isDisable"
              type="primary"
              size="small"
              icon="el-icon-refresh-left"
              @click="reset"
              >重置</el-button
            >
          </el-col>
        </el-row>
      </el-col>
      <el-col :span="3">
        <el-button
          v-if="userTypes == 6 || userTypes == 7"
          :disabled="isDisable"
          type="danger"
          size="small"
          style="margin-left: 20px"
          @click="$router.push('/carTj')"
          >综合统计分析</el-button
        >
      </el-col>
    </el-row>

    <div>
      <el-table
        ref="multipleTable"
        :data="tableData"
        highlight-current-row
        class="table"
        fit
        height="650"
      >
        <el-table-column
          label="序号"
          type="index"
          width="50"
          align="center"
        ></el-table-column>

        <el-table-column
          v-if="this.userTypes == 6 || this.userTypes == 7"
          width="220"
          label="企业名称"
          prop="corpName"
          show-overflow-tooltip
        >
          <!-- <template slot-scope="scope">
            <el-popover trigger="hover" placement="top">
              {{ scope.row.corpName }}
              <div slot="reference" class="name-wrapper">
                {{ scope.row.corpName }}
              </div>
            </el-popover>
          </template> -->
        </el-table-column>

        <el-table-column
          v-if="this.userTypes == 6 || this.userTypes == 7"
          label="站点名称"
          prop="chargeStationName"
          show-overflow-tooltip
        >
          <!-- <template slot-scope="scope">
            <el-popover trigger="hover" placement="top">
              {{ scope.row.chargeStationName }}
              <div slot="reference" class="name-wrapper">
                {{ scope.row.chargeStationName }}
              </div>
            </el-popover>
          </template> -->
        </el-table-column>
        <el-table-column
          prop="carNo"
          label="车牌号"
          align="center"
        ></el-table-column>
        <el-table-column
          label="货物危险种类"
          align="center"
          :formatter="dangerousTypeColumn"
        >
        </el-table-column>
        <el-table-column
          prop="cargoName"
          label="货物名称"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column
          prop="carType"
          label="车型"
          min-width="100"
          align="center"
          :formatter="carTypeColumn"
        ></el-table-column>
        <el-table-column
          prop="effectiveFlag"
          label="有效状态"
          min-width="50"
          :show-overflow-tooltip="true"
        >
          <template slot-scope="scope">
            <el-tag type="success" v-if="scope.row.effectiveFlag == '1'"
              >有效</el-tag
            >
            <el-tag type="danger" v-if="scope.row.effectiveFlag == '0'"
              >失效</el-tag
            >
            <!-- <span v-if="scope.row.effectiveFlag == '0'">失效</span>
          <span v-if="scope.row.effectiveFlag == '1'">有效</span> -->
          </template>
        </el-table-column>
        <el-table-column label="操作" width="400" align="center">
          <template slot-scope="scope">
            <!-- <el-button type="text" @click="popUp(scope.row)">查看</el-button> -->
            <el-button type="primary" @click="popUp(scope.row.id)" size="mini"
              >查看</el-button
            >
            <!-- v-if="lookBut" -->
            <el-button
              @click="deleteRow(scope.row.id)"
              size="mini"
              type="danger"
              :disabled="delDisable"
              v-if="butonShow"
              >删除</el-button
            >
            <el-button
              type="info"
              size="mini"
              @click="carInvalid(scope.row.id, 0)"
              v-if="
                scope.row.effectiveFlag == 1 &&
                (userTypes == 7 || userTypes == 6)
              "
              >失效</el-button
            >
            <el-button
              type="success"
              size="mini"
              @click="carInvalid(scope.row.id, 1)"
              v-if="
                scope.row.effectiveFlag == 0 &&
                (userTypes == 7 || userTypes == 6)
              "
              >恢复</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <!-- 查看弹窗 -->
      <!-- <el-dialog title="车辆新增详情" :visible.sync="dialogVisible" width="80%" >
        <carLook  :id="Id" ref="carLookRef" /> 
      </el-dialog> -->
      <carLook :id="Id" v-if="windowing" @close="windowing = false"></carLook>
    </div>
    <div class="bottom_container">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="form.pageNumber"
        :page-sizes="pageSizes"
        :page-size="form.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
import axios from "axios";
// import carLook from "./carLook";
import carLook from "./carEdit";
export default {
  name: "police",
  components: {
    carLook,
  },
  data() {
    return {
      butonShow: true,
      corpName: "",
      chargeStationName: "",
      // 修改按钮控制
      alertBut: false,
      // 查看按钮空
      lookBut: false,
      delDisable: false,
      userTypes: "",
      windowing: false,
      userModel: "",
      dialogVisible: false,
      loading: false,
      isDisable: false,
      tableData: [],
      //  弹窗数据
      windowsData: [],
      Id: "",
      input: "",
      pageSizes: [10, 15, 20, 40],
      form: {
        pageNumber: 1,
        pageSize: 10,
      },
      carNo: "",
      corpId: "",
      carType: "",
      nuclearLoad: "",
      carPerson: "",
      // 运输证号
      ysId: "",
      // 发动机
      carFdjId: "",
      carPersonPho: "",
      installGps: "",
      total: 10,
      corpName: "",
      //按钮提示
      confirmMsg: "",
      //车辆状态
      value: "",
      options: [
        {
          value: "0",
          label: "失效",
        },
        {
          value: "1",
          label: "有效",
        },
      ],
    };
  },
  created() {
    // this.loading = true;
    this.getData();
    this.userModel = JSON.parse(window.localStorage.getItem("userModel"));
    this.userTypes = this.userModel.userType;
    let then = this;
    if (this.userModel.userType == 7) {
      let authority = this.$route.query.menu.authority;
      if (authority) {
        localStorage.setItem("carLIst", 0);
      }
      var popUp = localStorage.getItem("carLIst");
      if (popUp == 0) {
        then.butonShow = true;
      } else {
        then.butonShow = false;
      }
    }
  },

  methods: {
    //车辆失效功能
    carInvalid(id, type) {
      let that = this;
      if (type == 0) {
        that.confirmMsg = "确定将车辆设置为失效状态吗!!!";
      }
      if (type == 1) {
        that.confirmMsg = "确定将车辆设置为正常状态吗!!!";
      }
      that
        .$confirm(that.confirmMsg, "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
        .then(() => {
          that.isdisable = true;
          this.$axios
            .get(
              this.GLOBAL.myhf + `/car/carInvalid?carId=${id}&type=${type}`,
              {
                withCredentials: true,
              }
            )
            .then(function (response) {
              if (response.data.info === "success") {
                that.isdisable = false;
                that.getData();
                that.$message({
                  message: response.data.msg,
                  type: "success",
                });
              } else {
                that.$message.error(response.data.msg);
              }
            });
        })
        .catch(function (error) {});
    },
    // 分页函数
    handleSizeChange(val) {
      this.form.pageSize = val;
      this.getData();
    },
    handleCurrentChange(val) {
      this.form.pageNumber = val;
      this.getData();
    },
    // 弹窗取值函数
    popUp(id) {
      this.Id = id;
      this.windowing = true;
    },
    // 搜索
    getData() {
      let that = this;
      that.loading = true;
      that.isDisable = true;
      axios
        .get(
          this.GLOBAL.myhf +
            "/car/search?carNo=" +
            that.carNo +
            "&pageSize=" +
            that.form.pageSize +
            // 站点名称
            "&chargeStationName=" +
            that.chargeStationName +
            // 公司名称
            "&corpName=" +
            that.corpName +
            "&pageNum=" +
            that.form.pageNumber +
            "&effectiveFlag=" +
            that.value,
          { withCredentials: true }
        )
        .then(function (res) {
          that.isDisable = false;
          that.loading = false;
          // if (res.data.info == "success") {
          if (res.data.info == "success" && res.data.data != null) {
            that.tableData = res.data.data.list;

            that.total = res.data.data.total;
          } else {
            that.isDisable = false;
            that.tableData = null;
            that.total = 0;
          }
        })
        .catch(function (error) {});
    },
    reset() {
      let that = this;
      that.isDisable = true;
      that.loading = true;
      that.carNo = "";
      that.value = "";
      (that.corpName = ""),
        (that.chargeStationName = ""),
        (that.form.pageSize = 10);
      that.form.pageNumber = 1;
      //  setTimeout(() =>{  }, 2000);
      that.getData();
    },
    // 删除方法
    deleteRow(row) {
      let that = this;
      that.delDisable = true;
      this.$confirm("确认要删除么?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          that.delDisable = false;
          axios
            .get(this.GLOBAL.myhf + "/car/logicDel?id=" + row, {
              withCredentials: true,
            })
            .then(function (response) {
              if (response.data.info == "success") {
                that.getData();
                that.$message({
                  message: "删除成功",
                  type: "success",
                });
              } else {
                that.$message.error(response.data.msg);
              }
            });
        })
        .catch(function (error) {
          that.isDisable = false;
          // that.$message({
          //   type: "info",
          //   message: "已取消删除"
          // });
        });
    },
    dangerousTypeColumn(row, column) {
      switch (row.dangerousType) {
        case "0":
          return "炸品:炸药";
          break;
        case "1":
          return "压缩气体:氧气、氢气";
          break;
        case "2":
          return "易燃液体:汽油、柴油";
          break;
        case "3":
          return "易燃固体";
          break;
        case "4":
          return "氧化物、有机过氧化物";
          break;
        case "5":
          return "有毒物质:氰化物";
          break;
        case "6":
          return "放射性物质";
          break;
        case "7":
          return "腐蚀品:硫酸";
          break;
        case "8":
          return "其他危险品:电池组";
          break;
      }
    },
    carTypeColumn(row, column) {
      if (row.auxiliarycarCarType != "") {
        //有挂车
        let carType = this.getCarType(row.carType);
        switch (row.auxiliarycarCarType) {
          case "0":
            return carType + "、" + "重型普通半挂车";
            break;
          case "1":
            return carType + "、" + "重型罐式半挂车";
            break;
          case "2":
            return carType + "、" + "重型箱式半挂车";
            break;
          case "3":
            return carType + "、" + "重型集装箱半挂车";
            break;
        }
      } else {
        return this.getCarType(row.carType);
      }
    },
    getCarType(type) {
      switch (type) {
        case "0":
          return "轻型厢式货车";
          break;
        case "1":
          return "中型厢式货车";
          break;
        case "2":
          return "中型罐式货车";
          break;
        case "3":
          return "重型罐式货车";
          break;
        case "4":
          return "重型厢式货车";
          break;
        case "5":
          return "重型半挂牵引车";
          break;
        case "6":
          return "低温液体槽罐车";
          break;
        case "7":
          return "罐式危险品运输车";
          break;
        case "8":
          return "易燃液体厢式运输车";
          break;
        case "9":
          return "重型罐式危险品运输车";
          break;
        case "10":
          return "杂项废机油废电瓶厢式运输车";
          break;
        case "11":
          return "毒性和感染性物品厢式运输车";
          break;
        case "12":
          return "爆破器材运输车、烟花爆竹运输车";
          break;
        case "13":
          return "重型普通货车";
          break;
      }
    },
  },
};
</script>
<style scoped>
.table {
  margin-top: 1rem;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  padding: 0 2rem;
}
>>> .el-dialog__header {
  /* width: 100%;
  height: 2rem; */
  background: #72bfff !important;
}
.name-wrapper {
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}
</style>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小四是个处女座

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值