index.vue 11.2 KB
<template>
  <div class="system-container">
    <div class="container">
      <h1>围栏列表</h1>
      <div class="m-b-md title_tips">用于统计和展示设备的围栏关联信息</div>

      <!-- 搜索区域 开始 -->
      <div class="search_box">
        <el-form :model="searchForm" :inline="true" size="small">
          <el-form-item>
            <div class="pre_select_box">
              <el-select v-model="searchForm.timeType" class="small_select mr5" placeholder="请选择">
                <el-option label="创建时间" value="1"></el-option>
                <el-option label="监控时间" value="2"></el-option>
              </el-select>
              <el-date-picker v-model="searchForm.timeDate" class="data_picker" value-format="yyyy-MM-dd" type="daterange" range-separator="~" start-placeholder="开始日期" end-placeholder="结束日期">
              </el-date-picker>
            </div>
          </el-form-item>
          <el-form-item label="状态:">
            <el-select v-model="searchForm.enableStatus" class="small_select">
              <el-option label="全部" value=""></el-option>
              <el-option v-for="(item,index) in FENCE_TYPE_LIST" :key="index" :label="item.label" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="监控类型:">
            <el-select v-model="searchForm.triggerType" class="small_select">
              <el-option label="全部" value=""></el-option>
              <el-option v-for="(item,index) in FENCE_MONITOR_LIST" :key="index" :label="item.label" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="围栏类型:">
          <el-select v-model="searchForm.source" class="small_select">
            <el-option label="全部" value=""></el-option>
            <el-option label="有线设备围栏" value="1"></el-option>
            <el-option label="无线设备围栏" value="0"></el-option>
          </el-select>
        </el-form-item>
          <el-form-item label="关键字:">
            <el-input placeholder="设备号 | 姓名 | 车架号|围栏名称" class="long_input" maxlength="20" v-model.trim="searchForm.term">
            </el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" @click="getList(1)">搜索</el-button>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-refresh" @click="rest()">重置</el-button>
          </el-form-item>
        </el-form>
      </div>
      <!-- 搜索区域 end -->

      <!-- 按钮区域 开始 -->
      <div class="links_group">
        <span>围栏列表</span>
        <div>
          <auth-button type="primary" icon="el-icon-plus" size="mini" pid="ADD_WIRELESS_DEVICE_FENCE" @click.native="addFence({source:0})">新增无线设备围栏</auth-button>
          <el-button type="primary" icon="el-icon-plus" size="mini" @click="addFence({source:1})">新增有线设备围栏</el-button>
          <el-button type="primary" icon="el-icon-download" size="mini" :loading="dloading" @click="downloadExcel">导出Excel</el-button>
        </div>
      </div>
      <!-- 按钮区域 end -->

      <!-- 列表 开始 -->
      <div class="table_box">
        <el-table class="el_table" border size="small" :data="tableData" v-loading="loading">
          <el-table-column label="围栏名称" prop="fenceName" show-overflow-tooltip></el-table-column>
          <el-table-column label="围栏类型" prop="fenceName" show-overflow-tooltip>
            <template slot-scope="{row}">{{ fenceSource[row.source]||'--' }}</template>
          </el-table-column>
          <el-table-column label="监控类型" prop="triggerType" show-overflow-tooltip></el-table-column>
          <el-table-column label="监控时间" prop="timeType" show-overflow-tooltip width="160">
            <template slot-scope="{row}">{{row.startTime}}~{{row.endTime}}</template>
          </el-table-column>
          <el-table-column label="关联设备数" prop="linkDeviceCnt" show-overflow-tooltip></el-table-column>
          <el-table-column label="报警设备数" prop="alarmDeviceCnt" show-overflow-tooltip></el-table-column>
          <el-table-column label="状态" prop="enableStatusDesc" show-overflow-tooltip></el-table-column>
          <el-table-column label="报警次数" prop="alarmCnt" show-overflow-tooltip></el-table-column>
          <el-table-column label="最新报警时间" prop="lastAlarmDate" show-overflow-tooltip>
            <template slot-scope="{row}">{{row.lastAlarmDate||'--'}}</template>
          </el-table-column>
          <el-table-column label="创建时间" prop="createdDate" show-overflow-tooltip></el-table-column>
          <el-table-column label="创建人" prop="creator" show-overflow-tooltip>
            <template slot-scope="{row}">{{row.creator||'--'}}</template>
          </el-table-column>
          <el-table-column label="操作" prop="creator" width="200" fixed="right">
            <template slot-scope="{row}">
              <el-link type="primary" class="el_link" :underline="false" @click="updateStatus(row)">{{row.enableStatus == 1?'关闭':'开启'}}</el-link>
              <el-link type="primary" class="el_link" :underline="false" @click="addFence(row)">编辑</el-link>
              <el-link type="primary" class="el_link" :underline="false" @click="removeFence(row)">删除</el-link>
              <el-link type="primary" class="el_link" :underline="false" @click="lookDetail(row)">查看预警</el-link>
            </template>
          </el-table-column>
        </el-table>
        <div class="pagination_list">
          <el-pagination background layout="sizes, total,prev, pager, next, jumper" :total="pageTotal" :current-page.sync="pageNumber" :page-size.sync="pageSize" :page-sizes="pageSizes" @current-change="getList" @size-change="changePageSize" />
        </div>
      </div>
      <!-- <glsx-table ref="glsxTable" v-loading="loading" :list="tableData" :column="columnList" :pageTotal="pageTotal" @change="getList">
        <div slot="operate" slot-scope="{scope}" width="170">
          <el-link type="primary" :underline="false" @click="updateStatus(scope)">{{scope.enableStatus == 1?'关闭':'开启'}}</el-link>
          <el-link type="primary" :underline="false" @click="lookDetail(scope)">编辑</el-link>
          <el-link type="primary" :underline="false" @click="lookDetail(scope)">删除</el-link>
          <el-link type="primary" :underline="false" @click="lookDetail(scope)">查看预警</el-link>
        </div>
      </glsx-table> -->
      <!-- 列表 end -->
    </div>

  </div>
</template>

<script>
import GlsxTable from "@/components/glsx-table";
import { GET_FAKEOFFLINE_LIST, GET_FAKEOFFLINE_EXPORT } from "services/report";
import {
  EXPORT_FENCE_INFO,
  STARTSTOP_FENCE_INFO,
  DELETE_FENCE_INFO,
  GET_FENCE_LIST,
} from "@/services/fence";
import { deepClone, showToast, showModal, downFileByPath } from "@/utils/util";
import moment from "moment";
import { FENCE_MONITOR_LIST, FENCE_TYPE_LIST } from "@/common/constants";
export default {
  components: {
    GlsxTable,
  },
  data() {
    return {
      searchForm: { timeType: "1", enableStatus: "", triggerType: "" },
      tableData: [],
      pageTotal: 0,
      pageSize: 10,
      pageNumber: 1,
      pageSizes: [10, 20, 30, 40],
      dloading: false,
      showPopover: false,
      loading: false,
      FENCE_MONITOR_LIST,
      FENCE_TYPE_LIST,
      fenceSource: {
        0: "无线设备围栏",
        1: "有线设备围栏",
      },
    };
  },

  mounted() {
    this.getList();
  },
  methods: {
    // 获取查询参数
    getParams() {
      let oParams = deepClone(this.searchForm);
      let o = oParams.timeDate;
      if (o && o.length > 0) {
        oParams.beginDate = o[0];
        oParams.endDate = o[1];
      }
      delete oParams.timeDate;
      return oParams;
    },

    // 获取列表
    getList(current) {
      let oParams = this.getParams();
      oParams.pageSize = this.pageSize;
      oParams.pageNumber = current || 1;
      this.loading = true;
      if (current) {
        this.pageNumber = current;
      }
      GET_FENCE_LIST(oParams)
        .then((res) => {
          this.loading = false;
          let { data } = res;
          let { list, totalElements } = data;
          this.pageTotal = totalElements || 0;
          this.tableData = list || [];
        })
        .catch((error) => {
          this.loading = false;
        });
    },

    // 查看详情
    lookDetail(row) {
      let path = `/trialRun#/alarmCenter/fence`;
      // let endPath = `${path}?fenceId=${row.id}&name=${row.fenceName}`
      let endPath = `${path}?name=${row.fenceName}`
      this.$root.parentCommon.setBreadCrumbs(path);
      history.pushState({}, endPath, endPath);
      //this.$router.push({ path: path, query: { fenceId: row.id,name:row.name } });
    },

    // 导出excel
    downloadExcel() {
      let _this = this;
      let oParams = this.getParams();
      _this.dloading = true;

      EXPORT_FENCE_INFO(oParams).then((res) => {
        _this.dloading = false;
        if (res.code != 200) {
          return false;
        }
        downFileByPath(res.data);
        //window.open(res.data);
      });
    },

    // 重置
    rest() {
      this.searchForm = { timeType: "1", enableStatus: "", triggerType: "" };
      this.pageSize = 10;
      this.pageNumber = 1;
      this.getList();
    },

    // 开启关闭
    updateStatus(row) {
      let _this = this;
      let _typeList = {
        1: "关闭",
        0: "开启",
      };
      showModal({
        message: `确定${_typeList[row.enableStatus]}'${row.fenceName}'吗?`,
        showCancelButton: true,
        type: "warning",
        success: function () {
          let oParams = {};
          oParams.fenceId = row.id;
          STARTSTOP_FENCE_INFO(oParams).then((res) => {
            if (res.code == 200) {
              showToast({
                message: `${_typeList[row.enableStatus]}成功`,
                type: "success",
              });
              _this.getList();
            }
          });
        },
      });
    },

    //每页展示
    changePageSize(e) {
      this.pageSize = e;
      this.getList();
    },

    // 删除围栏
    removeFence(row) {
      let _this = this;
      showModal({
        message: `确定删除${row.fenceName}吗?`,
        showCancelButton: true,
        type: "warning",
        success: function () {
          let oParams = {};
          oParams.fenceId = row.id;
          DELETE_FENCE_INFO(oParams).then((res) => {
            if (res.code == 200) {
              showToast({
                message: "删除成功",
                type: "success",
              });
              _this.getList();
            }
          });
        },
      });
    },

    // 新增围栏
    addFence(row) {
      let path = `/oEshield#/monitor/addFence?source=${row.source}`;
      if (row && row.id) {
        path = `/oEshield#/monitor/addFence?id=${row.id}&source=${row.source}`;
      }
      history.pushState({}, path, path);
      //window.open(path);
    },
  },
};
</script>

<style lang="scss" scoped>
@import "@/styles/common.scss";
.table_box {
  margin: 10px 0;
}
</style>>