index.vue 10.3 KB
<template>
  <div class="system-container">
    <div class="container">
      <h1>POI列表</h1>
      <div class="m-b-md title_tips">
        支持使用者自定义黑区、二押点以及异常聚集点POI信息,对应POI信息会参与大数据算法,并以“黑区警情”对外呈现。
      </div>

      <!-- 搜索区域 开始 -->
      <div class="search_box">
        <el-form :model="searchForm" :inline="true" size="small">
          <el-form-item label="关键字:">
            <el-input
              placeholder="POI名称|创建人"
              maxlength="20"
              v-model.trim="searchForm.keywords"
            >
            </el-input>
          </el-form-item>
          <el-form-item label="创建时间">
            <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>
          </el-form-item>
          <el-form-item label="POI类型:">
            <el-select v-model="searchForm.poiType" class="small_select">
              <el-option label="全部" value=""></el-option>
              <el-option label="黑区圆心" value="1"></el-option>
              <el-option label="二押点" value="2"></el-option>
              <el-option label="异常聚集点" value="3"></el-option>
            </el-select>
          </el-form-item>
          <!-- <el-form-item label="POI归属:">
            <el-popover
              v-model="showGlsxOranization"
              placement="bottom-start"
              width="400"
              trigger="click"
            >
              <div>
                <glsx-organization @change="onChange"></glsx-organization>
              </div>
              <el-input
                v-model="searchForm.orgName"
                :placeholder="searchForm.specialShopName || '所属组织'"
                slot="reference"
                readonly
                clearable
              >
              </el-input>
            </el-popover>
          </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>POI列表</span>
        <div>
          <el-button
            type="primary"
            icon="el-icon-plus"
            size="mini"
            @click="addFence()"
            >新增POI</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="POI名称"
            prop="poiName"
            show-overflow-tooltip
          />
          <el-table-column
            label="POI类型"
            prop="poiTypeStr"
            show-overflow-tooltip
          />
          <el-table-column
            label="状态"
            prop="enableStatusStr"
            show-overflow-tooltip
          />
          <el-table-column
            label="创建时间"
            prop="createdDate"
            show-overflow-tooltip
            width="160"
          />
          <el-table-column
            label="创建人"
            prop="createUserName"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            label="POI归属"
            prop="belongLevels"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            label="操作"
            prop="creator"
            width="150"
            fixed="right"
            align="center"
          >
            <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)"
                v-if="row.enableStatus == 1"
                >编辑</el-link
              >
              <el-link
                type="primary"
                class="el_link"
                :underline="false"
                @click="removeFence(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>
      <!-- 列表 end -->
    </div>
  </div>
</template>
  
  <script>
import {
  EXPORT_FENCE_INFO,
  STARTSTOP_FENCE_INFO,
  DELETE_FENCE_INFO,
} from "@/services/fence";
import {
  GET_POI_LIST,
  EXPORT_POI_INFO,
  DELETE_POI_INFO,
  MODIFY_POI_INFO,
} from "@/services/poi";
import { deepClone, showToast, showModal, downFileByPath } from "@/utils/util";
import GlsxOrganization from "@/components/glsx-organization";
export default {
  components: {
    GlsxOrganization,
  },
  data() {
    return {
      searchForm: { poiType: "" },
      tableData: [],
      pageTotal: 0,
      pageSize: 10,
      pageNumber: 1,
      pageSizes: [10, 20, 30, 40],
      dloading: false,
      showPopover: false,
      loading: false,
      showGlsxOranization: false,
    };
  },

  mounted() {
    this.getList();
  },
  methods: {
    // 获取查询参数
    getParams() {
      let oParams = deepClone(this.searchForm);
      let o = oParams.timeDate;
      if (o && o.length > 0) {
        oParams.createBeginDate = o[0];
        oParams.createEndDate = o[1];
      }
      delete oParams.timeDate;
      delete oParams.orgName;
      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_POI_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_POI_INFO(oParams).then((res) => {
        _this.dloading = false;
        if (res.code != 200) {
          return false;
        }
        downFileByPath(res.data);
        //window.open(res.data);
      });
    },

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

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

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

    // 删除poi
    removeFence(row) {
      let _this = this;
      showModal({
        message: `确认删除【${row.poiName}】的【${row.poiTypeStr}】POI信息吗?`,
        showCancelButton: true,
        type: "warning",
        success: function () {
          let oParams = {};
          oParams.id = row.id;
          DELETE_POI_INFO(oParams).then((res) => {
            if (res.code == 200) {
              showToast({
                message: "删除成功",
                type: "success",
              });
              _this.getList();
            }
          });
        },
      });
    },

    // 新增POI
    addFence(row) {
      let path = `/oEshield#/monitor/addPoi`;
      if (row) {
        path = `/oEshield#/monitor/addPoi?id=${row.id}`;
      }
      history.pushState({}, path, path);
      //window.open(path);
    },

    // 监听归属
    onChange(e) {
      this.showGlsxOranization = false;
      console.log(e);
      if (e) {
        //this.orgInfo = e.origin;
        // this.searchForm.orgType = e.origin.type;
        this.$set(this.searchForm, "orgId", e.origin.orgId);
        this.$set(this.searchForm, "orgName", e.origin.orgName);
      }
    },
  },
};
</script>
  
  <style lang="scss" scoped>
@import "@/styles/common.scss";
.table_box {
  margin: 10px 0;
}
</style>>