index.vue 7.05 KB
<template>
  <div style="margin: 40px" class="app-container">
    <el-form
      :inline="true"
      :model="queryParams"
      class="demo-form-inline"
      size="small"
    >
      <el-form-item label="航班号">
        <el-input
          v-model.trim="queryParams.purposeOfFlightNo"
          placeholder="航班号"
          @keyup.enter.native="getList"
        ></el-input>
      </el-form-item>
      <el-form-item label="状态">
        <el-select v-model="queryParams.status" placeholder="状态">
          <el-option label="有效" value="1"></el-option>
          <el-option label="停用" value="3"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          @click="getList"
          size="mini"
          >查询</el-button
        >
      </el-form-item>
    </el-form>
    <el-button
      style="margin-bottom: 20px"
      type="primary"
      icon="el-icon-plus"
      size="mini"
      @click="$router.push({ name: 'flightAllocConfigAdd', params: { handle: 'add' } })"
      >添加</el-button
    >
    <el-table :data="flyList" v-loading="loading" size="small">
      <el-table-column
        prop="purposeOfFlightNo"
        label="航班号"
        align="center"
      ></el-table-column>

      <el-table-column prop="status" label="状态" align="center">
        <template slot-scope="scope">
          <span v-if="scope.row.status === '0'">无效</span>
          <span v-if="scope.row.status === '1'">有效</span>
          <span v-if="scope.row.status === '2'">配置中</span>
          <span v-if="scope.row.status === '3'">停用</span>
        </template>
      </el-table-column>

      <el-table-column prop="createUserName" label="操作人" align="center">
      </el-table-column>

      <el-table-column prop="createTime" label="更新时间" align="center">
        <template slot-scope="scope">
          {{ scope.row.createTime | formatTimer }}
        </template>
      </el-table-column>

      <el-table-column label="操作" prop="id" align="center">
        <template slot-scope="scope">
          <el-button
            type="text"
            size="mini"
            icon="el-icon-view"
            @click="handleClick(scope.row.id, 'detail')"
            >查看</el-button
          >
          <el-button
            type="text"
            size="mini"
            icon="el-icon-edit"
            @click="handleClick(scope.row.id, 'update')"
            >修改</el-button
          >
          <el-button
            type="text"
            size="mini"
            icon="el-icon-delete"
            @click="del(scope.row.id, scope.row.status)"
            >删除</el-button
          >
          <el-button
            type="text"
            size="mini"
            icon="el-icon-video-pause"
            @click="changeStatus(scope.row.id, 3)"
            v-if="scope.row.status == '1'"
            >停用</el-button
          >
          <el-button
            type="text"
            size="mini"
            icon="el-icon-video-play"
            @click="changeStatus(scope.row.id, 1)"
            v-else
            >启用</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="getList"
      @current-change="getList"
      :current-page.sync="curPage"
      :page-sizes="[10, 20, 30, 40]"
      :page-size.sync="limit"
      layout="prev, pager, next, jumper, sizes, total"
      :total="total"
      background
      :hide-on-single-page="true"
      style="margin-top: 40px; text-align: right"
    >
    </el-pagination>
  </div>
</template>

<script>
import {
  findFlightNo,
  delFlightId,
  enableOrDisable,
} from "@/api/destinationFlight";

import { parseTime } from "@/utils/FedEx";

export default {
  data() {
    return {
      queryParams: {
        purposeOfFlightNo: "",
        status:"1",
        start: 0,
        limit: 10,
      },
      flyList: [],
      curPage: 1,
      limit: 10,
      total: 0,
      loading: false,
    };
  },
  methods: {
    getList() {
      this.queryParams.limit = this.limit;
      if (this.curPage > 1) {
        this.queryParams.start = (this.curPage - 1) * this.queryParams.limit;
      } else {
        this.queryParams.start = 0;
      }
      this.loading = true;
      findFlightNo(this.queryParams).then((response) => {
        if (response.code != 200) {
          this.$message({
            showClose: true,
            message: response.msg,
            type: "error",
          });
          reuturn;
        }
        this.flyList = response.data.list;
        this.total = response.data.totalCount;
        this.loading = false;
      });
    },
    //跳转到查看,修改页面
    handleClick(flightiId, handle) {
      this.$router.push({
        name: "flightAllocConfigInfo",
        params: { handle: handle, id: flightiId },
      });
    },
    //删除规则
    del(id, status) {
      if (status == "1") {
        this.$confirm("航班规则生效中,无法删除,请停用后再操作", "警告", {
          confirmButtonText: "确定",
          showCancelButton: false,
          type: "warning",
        });
      } else {
        this.$confirm("是否确认删除此航班规则?", "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          showCancelButton: true,
          type: "warning",
        })
          .then(function () {
            return delFlightId(id);
          })
          .then(() => {
            this.getList();
            this.msgSuccess("删除成功");
          })
          .catch(function () {});
      }
    },
    //启用,停用
    changeStatus(id, status) {
      let tip = status === 1 ? "启用" : "停用";
      this.$confirm("是否确认" + tip + "此航班规则?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return enableOrDisable(id, status);
        })
        .then(() => {
          this.getList();
          this.msgSuccess(tip + "成功");
        })
        .catch(function () {});
    },
    parseDate(time) {
      // debugger
      let str = new Date(time).format("yyyy-MM-dd");
      // let str =  parseTime(date, 'yyyy-dd-mm');
      return str;
    },
  },
  created() {
    this.getList();
  },
  filters: {
    formatTimer: function (time) {

      let time1 = new Date(time.replace(/-/g, '/').replace('T', ' ')).toISOString() // 转为国际标准化时间
 
      return time1.split('T')[0] + " " + time1.split('T')[1].substring(0,8);
      // let date = new Date(value);
      // let y = date.getFullYear();
      // let MM = date.getMonth() + 1;
      // MM = MM < 10 ? "0" + MM : MM;
      // let d = date.getDate();
      // d = d < 10 ? "0" + d : d;
      // let h = date.getHours();
      // h = h < 10 ? "0" + h : h;
      // let m = date.getMinutes();
      // m = m < 10 ? "0" + m : m;
      // let s = date.getSeconds();
      // s = s < 10 ? "0" + s : s;
      // return y + "-" + MM + "-" + d + " " + h + ":" + m + ":" + s;
    },
  },
};
</script>