|
@@ -8,18 +8,19 @@
|
|
|
</template>
|
|
|
<template v-slot:content>
|
|
|
<div class="location-list">
|
|
|
- <template v-for="fence in fenceList">
|
|
|
- <div :key="`fence_${fence.id}`" class="list-item">
|
|
|
+ <template v-for="evt in evtList">
|
|
|
+ <div :key="`evt_${evt.id}`" class="list-item">
|
|
|
<span class="over-flow-hidden" style="width: 40%">
|
|
|
- {{ fence.name }}
|
|
|
+ {{ evt.evtDesc }}
|
|
|
</span>
|
|
|
<span class="over-flow-hidden" style="width: 40%">
|
|
|
- {{ fence.updateTime }}
|
|
|
+ {{ dayjs(evt.evtTime).format('YYYY-MM-DD HH:mm') }}
|
|
|
</span>
|
|
|
<span class="over-flow-hidden" style="width: 20%">
|
|
|
</span>
|
|
|
</div>
|
|
|
</template>
|
|
|
+ <socket-message :onMessage="onMessage" :ws="ws"></socket-message>
|
|
|
</div>
|
|
|
</template>
|
|
|
</pannel>
|
|
@@ -27,254 +28,85 @@
|
|
|
|
|
|
<script>
|
|
|
|
|
|
+import { listFenceVioEvt } from '@/api/bd/fenceVioEvt';
|
|
|
+import SocketMessage from '@/components/WebsocketMessage/index.vue';
|
|
|
import Pannel from '@/views/bd/pannel/index.vue';
|
|
|
-// this.drawtool = new BDLayers.Lib.Tools.CBDrawTool('mytool', this.mapView, 'Rectangle', true); // 绘制矩形,参数1:id,参数2:地图,参数3:绘制类型,参数4:是否可拖拽编辑
|
|
|
-// this.drawtool.enable(); // 开始绘制
|
|
|
-// this.drawtool.disable(); // 结束绘制
|
|
|
-// this.drawtool.clear(); // 清除绘制内容
|
|
|
-// this.drawtool.setDrawMode(type); // 设置绘制类型
|
|
|
-// this.drawtool.on('drawend', (geom) => {}) // 绘制结束事件
|
|
|
-// this.drawtool.on('selectDraw', geom => {}) // 绘制完毕后选择绘制图形
|
|
|
+import FingerprintJS from '@fingerprintjs/fingerprintjs';
|
|
|
+import dayjs from 'dayjs';
|
|
|
+
|
|
|
export default {
|
|
|
- name: 'fence',
|
|
|
- components: { Pannel },
|
|
|
+ name: 'fenceVioEvt',
|
|
|
+ components: {
|
|
|
+ SocketMessage,
|
|
|
+ Pannel,
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
- playItem: {},
|
|
|
- editState: false,
|
|
|
- editPolyInfo: {},
|
|
|
- layer: null,
|
|
|
- dialogVisible: false,
|
|
|
- editingDrawGeom: null,
|
|
|
- drawState: false,
|
|
|
- drawtool: null,
|
|
|
- form: {
|
|
|
- name: '',
|
|
|
- },
|
|
|
- rules: {
|
|
|
- name: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: '请输入围栏名称',
|
|
|
- trigger: 'blur',
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- fenceList: [],
|
|
|
+ evtList: [],
|
|
|
+ fp: null,
|
|
|
+ ws: null,
|
|
|
};
|
|
|
},
|
|
|
// 组件卸载前清空图层信息
|
|
|
beforeDestroy() {
|
|
|
- window.map.removeLayersById('vl');
|
|
|
- this.drawtool.disabled();
|
|
|
},
|
|
|
created() {
|
|
|
- // 地图绘制工具
|
|
|
- this.drawtool = new BDLayers.Lib.Tools.CBDrawTool('myTool', window.map, 'Polygon', true);
|
|
|
- // 监听图形编辑
|
|
|
- this.drawtool.on('selectDraw', geom => {
|
|
|
- this.editingDrawGeom = geom.target.geometry ? geom.target.geometry : geom.target.geom
|
|
|
- ? geom.target.geom
|
|
|
- : geom.target;
|
|
|
- if (this.editingDrawGeom.isEditing && this.editingDrawGeom.isEditing()) {
|
|
|
- // 点击地图 图形取消编辑状态
|
|
|
- window.map.map.once('click', () => {
|
|
|
- this.editingDrawGeom.endEdit();
|
|
|
- this.dialogVisible = true;
|
|
|
- });
|
|
|
- } else {
|
|
|
- window.map.map.once('click', () => {
|
|
|
- this.editingDrawGeom = null;
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- this.drawtool.on('drawend', (geom) => {
|
|
|
- this.editingDrawGeom = geom.target.geometry ? geom.target.geometry : geom.target.geom
|
|
|
- ? geom.target.geom
|
|
|
- : geom.target;
|
|
|
- this.dialogVisible = true;
|
|
|
- this.drawState = false;
|
|
|
- });
|
|
|
+
|
|
|
},
|
|
|
mounted() {
|
|
|
- this.getFenceList();
|
|
|
+ this.getFenceVioEvtList();
|
|
|
+ this.getFingerprint();
|
|
|
},
|
|
|
methods: {
|
|
|
- getFenceList() {
|
|
|
- if (!this.layer) {
|
|
|
- this.layer = new BDLayers.Lib.Layer.CBVectorLayer('vl');
|
|
|
- window.map.addCustomLayers(this.layer);
|
|
|
- }
|
|
|
- const result = [
|
|
|
- {
|
|
|
- id: 1,
|
|
|
- name: '高空施工作业危险区域',
|
|
|
- }, {
|
|
|
- id: 2,
|
|
|
- name: '危化品堆放区域',
|
|
|
- },
|
|
|
- ];
|
|
|
- this.editingDrawGeom = null;
|
|
|
- const polygon = this.drawPoly({
|
|
|
- coordinates: [
|
|
|
- [
|
|
|
- [118.86318437, 31.52265586],
|
|
|
- [118.86620514, 31.52541921],
|
|
|
- [118.86520697, 31.52406319],
|
|
|
- [118.86318437, 31.52265586],
|
|
|
- ],
|
|
|
- ],
|
|
|
- bizAttr: {
|
|
|
- name: 'test',
|
|
|
- },
|
|
|
- });
|
|
|
- this.layer.addGeometry(polygon);
|
|
|
- result[0].polygon = polygon;
|
|
|
- const polygon1 = this.drawPoly({
|
|
|
- coordinates: [
|
|
|
- [
|
|
|
- [118.86318437, 31.52265586],
|
|
|
- [118.86620514, 31.52541921],
|
|
|
- [118.86520697, 31.52406319],
|
|
|
- [118.86318437, 31.52265586],
|
|
|
- ],
|
|
|
- ],
|
|
|
- bizAttr: {
|
|
|
- name: 'test',
|
|
|
- },
|
|
|
- });
|
|
|
- this.layer.addGeometry(polygon1);
|
|
|
- result[1].polygon = polygon1;
|
|
|
- this.fenceList = result;
|
|
|
- window.map.flyToPoint([118.86318437, 31.52265586], {
|
|
|
- zoom: 13,
|
|
|
- pitch: 0,
|
|
|
- bearing: 20,
|
|
|
- duration: 5000,
|
|
|
- });
|
|
|
- },
|
|
|
- cancelEdit() {
|
|
|
- this.drawtool.clear();
|
|
|
- this.dialogVisible = false;
|
|
|
- },
|
|
|
- saveEdit() {
|
|
|
- this.$refs.form.validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- const resultCoor = [];
|
|
|
- const coordinates = [];
|
|
|
- this.editingDrawGeom._coordinates.forEach(coor => {
|
|
|
- const {
|
|
|
- x,
|
|
|
- y,
|
|
|
- } = coor;
|
|
|
- resultCoor.push(`${x} ${y}`);
|
|
|
- coordinates.push([x, y]);
|
|
|
- });
|
|
|
- resultCoor.push(resultCoor[0]);
|
|
|
- this.form.poly = `POLYGON((${resultCoor.join(',')}))`;
|
|
|
- this.$message({
|
|
|
- type: 'success',
|
|
|
- message: '保存!',
|
|
|
- });
|
|
|
- this.dialogVisible = false;
|
|
|
- this.drawtool.clear();
|
|
|
- const polygon = this.drawPoly({
|
|
|
- coordinates: coordinates,
|
|
|
- labelSymbol: {
|
|
|
- labelText: this.form.name,
|
|
|
- },
|
|
|
- bizAttr: this.form,
|
|
|
- });
|
|
|
- this.layer.addGeometry(polygon);
|
|
|
- this.editingDrawGeom = null;
|
|
|
- this.editState = false;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
+ dayjs,
|
|
|
+ async getFenceVioEvtList() {
|
|
|
+ const { rows } = await listFenceVioEvt({
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
});
|
|
|
+ this.evtList = rows;
|
|
|
+ debugger
|
|
|
},
|
|
|
- startDraw() {
|
|
|
- this.editingDrawGeom = null;
|
|
|
- this.drawState = true;
|
|
|
- this.drawtool.enable();
|
|
|
+ async getFingerprint() {
|
|
|
+ // 初始化FingerprintJS
|
|
|
+ const fp = await FingerprintJS.load();
|
|
|
+ // 获取访问者的指纹
|
|
|
+ const result = await fp.get();
|
|
|
+ // 配置
|
|
|
+ const {
|
|
|
+ osCpu,
|
|
|
+ webGlBasics,
|
|
|
+ languages,
|
|
|
+ audioBaseLatency,
|
|
|
+ reducedTransparency,
|
|
|
+ vendor,
|
|
|
+ vendorFlavors,
|
|
|
+ fonts,
|
|
|
+ fontPreferences,
|
|
|
+ plugins,
|
|
|
+ forcedColors,
|
|
|
+ domBlockers,
|
|
|
+ pdfViewerEnabled,
|
|
|
+ audio,
|
|
|
+ canvas,
|
|
|
+ webGlExtensions,
|
|
|
+ math,
|
|
|
+ ...components
|
|
|
+ } = result.components;
|
|
|
+ const extendedComponents = {
|
|
|
+ ...components,
|
|
|
+ };
|
|
|
+ const fingerprintId = FingerprintJS.hashComponents(extendedComponents);
|
|
|
+ this.ws = `/ws/evt/${fingerprintId}`;
|
|
|
},
|
|
|
- /**
|
|
|
- *
|
|
|
- * @param coordinates
|
|
|
- * [
|
|
|
- * [
|
|
|
- * [118.86318437, 31.52265586],
|
|
|
- * [118.86620514, 31.52541921],
|
|
|
- * [118.86520697, 31.52406319],
|
|
|
- * [118.86318437, 31.52265586],
|
|
|
- * ],
|
|
|
- * ]
|
|
|
- * @param symbol
|
|
|
- * @param bizAttr
|
|
|
- * @param labelSymbol
|
|
|
- * @returns {BDLayers.Lib.Overlays.Polygon}
|
|
|
- */
|
|
|
- drawPoly({
|
|
|
- coordinates,
|
|
|
- symbol = {},
|
|
|
- bizAttr = {},
|
|
|
- labelSymbol = {},
|
|
|
- }) {
|
|
|
- const polygon = new BDLayers.Lib.Overlays.Polygon('p1', {
|
|
|
- coordinates: coordinates,
|
|
|
- symbol: Object.assign({
|
|
|
- lineColor: '#34495e',
|
|
|
- lineWidth: 2,
|
|
|
- polygonFill: '#1bbc9b',
|
|
|
- polygonOpacity: 0.4,
|
|
|
- }, symbol),
|
|
|
- labelSymbol: Object.assign({
|
|
|
- labelText: '多边形',
|
|
|
- labelTextSize: 10,
|
|
|
- }, labelSymbol),
|
|
|
- bizAttr: bizAttr,
|
|
|
- });
|
|
|
- //多边形的点击事件
|
|
|
- polygon.on('click', (data) => {
|
|
|
- console.log(data.target.options);
|
|
|
- if (this.editState) {
|
|
|
- return;
|
|
|
- }
|
|
|
- this.form.name = data.target.options.bizAttr.name;
|
|
|
- this.editingDrawGeom = data.target.geometry ? data.target.geometry : data.target.geom
|
|
|
- ? data.target.geom
|
|
|
- : data.target;
|
|
|
- this.$confirm('检测到选中了围栏,请选择操作类型?', '提示', {
|
|
|
- confirmButtonText: '编辑围栏',
|
|
|
- cancelButtonText: '删除围栏',
|
|
|
- type: 'warning',
|
|
|
- }).then(() => {
|
|
|
- // 开始编辑围栏
|
|
|
- this.editState = true;
|
|
|
- this.editingDrawGeom.startEdit();
|
|
|
- }).catch(() => {
|
|
|
- this.editingDrawGeom.remove();
|
|
|
- this.editState = false;
|
|
|
- this.editingDrawGeom = null;
|
|
|
- this.$message({
|
|
|
- type: 'info',
|
|
|
- message: '删除围栏',
|
|
|
- });
|
|
|
- });
|
|
|
- // 点击地图 图形取消编辑状态
|
|
|
- window.map.map.once('click', () => {
|
|
|
- this.editingDrawGeom.endEdit();
|
|
|
- this.dialogVisible = true;
|
|
|
- });
|
|
|
+ onMessage(a) {
|
|
|
+ const data = JSON.parse(a.data);
|
|
|
+ this.$notify({
|
|
|
+ title: '警告',
|
|
|
+ message: `${data.msg.fenceName}发生闯禁事件。`,
|
|
|
+ type: 'warning',
|
|
|
});
|
|
|
- return polygon;
|
|
|
- },
|
|
|
- delFence(fence) {
|
|
|
- // polygon.geom.startEdit();
|
|
|
- fence.polygon.geom.remove();
|
|
|
- },
|
|
|
- editFence(fence) {
|
|
|
-
|
|
|
+ this.getFenceVioEvtList();
|
|
|
},
|
|
|
},
|
|
|
};
|