This commit is contained in:
2025-06-25 18:50:39 +08:00
11 changed files with 785 additions and 43 deletions

3
.gitignore vendored
View File

@ -7,6 +7,9 @@ npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
**/*.log **/*.log
# 忽略所有 .tif 文件
*.tif
tests/**/coverage/ tests/**/coverage/
tests/e2e/reports tests/e2e/reports

View File

@ -47,6 +47,7 @@
"js-md5": "^0.8.3", "js-md5": "^0.8.3",
"jsencrypt": "3.3.2", "jsencrypt": "3.3.2",
"jszip": "^3.10.1", "jszip": "^3.10.1",
"leaflet": "^1.9.4",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"md5": "^2.3.0", "md5": "^2.3.0",
"mitt": "^3.0.1", "mitt": "^3.0.1",
@ -54,6 +55,7 @@
"ol": "^10.5.0", "ol": "^10.5.0",
"pinia": "2.2.6", "pinia": "2.2.6",
"proj4": "^2.19.3", "proj4": "^2.19.3",
"proj4leaflet": "^1.0.2",
"screenfull": "6.0.2", "screenfull": "6.0.2",
"spark-md5": "^3.0.2", "spark-md5": "^3.0.2",
"vue": "3.5.13", "vue": "3.5.13",

View File

@ -0,0 +1,63 @@
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RecognizeRecordVO, RecognizeRecordForm, RecognizeRecordQuery } from '@/api/safety/recognizeRecord/types';
/**
* 查询识别记录列表
* @param query
* @returns {*}
*/
export const listRecognizeRecord = (query?: RecognizeRecordQuery): AxiosPromise<RecognizeRecordVO[]> => {
return request({
url: '/safety/recognizeRecord/list',
method: 'get',
params: query
});
};
/**
* 查询识别记录详细
* @param id
*/
export const getRecognizeRecord = (id: string | number): AxiosPromise<RecognizeRecordVO> => {
return request({
url: '/safety/recognizeRecord/' + id,
method: 'get'
});
};
/**
* 新增识别记录
* @param data
*/
export const addRecognizeRecord = (data: RecognizeRecordForm) => {
return request({
url: '/safety/recognizeRecord',
method: 'post',
data: data
});
};
/**
* 修改识别记录
* @param data
*/
export const updateRecognizeRecord = (data: RecognizeRecordForm) => {
return request({
url: '/safety/recognizeRecord',
method: 'put',
data: data
});
};
/**
* 删除识别记录
* @param id
*/
export const delRecognizeRecord = (id: string | number | Array<string | number>) => {
return request({
url: '/safety/recognizeRecord/' + id,
method: 'delete'
});
};

View File

@ -0,0 +1,123 @@
export interface RecognizeRecordVO {
id: any;
/**
* 设备名称
*/
deviceName: string;
/**
* 识别类别1无人机识别 2监控拍摄
*/
recordCategory: string;
/**
* 违章类型(多个逗号分隔)
*/
violationType: string;
/**
* 图片路径
*/
picture: string;
/**
* 图片路径Url
*/
pictureUrl: string;
/**
* 故障描述
*/
describe: string;
/**
* 创建时间
*/
createTime: string;
}
export interface RecognizeRecordForm extends BaseEntity {
/**
* 主键id
*/
id?: string | number;
/**
* 项目id
*/
projectId?: string | number;
/**
* 设备序列号
*/
deviceSerial?: string;
/**
* 设备名称
*/
deviceName?: string;
/**
* 识别类别1无人机识别 2监控拍摄
*/
recordCategory?: string;
/**
* 违章类型(多个逗号分隔)
*/
violationType?: string;
/**
* 图片路径
*/
picture?: string;
/**
* 违规数量
*/
num?: number;
/**
* 故障描述
*/
description?: string;
/**
* 备注
*/
remark?: string;
}
export interface RecognizeRecordQuery extends PageQuery {
/**
* 项目id
*/
projectId?: string | number;
/**
* 故障描述
*/
description?: string;
/**
* 设备名称
*/
deviceName?: string;
/**
* 识别类别1无人机识别 2监控拍摄
*/
recordCategory?: string;
/**
* 违章类型(多个逗号分隔)
*/
violationType?: string;
/**
* 创建时间
*/
createTime?: string;
/**
* 日期范围参数
*/
params?: any;
}

View File

@ -209,6 +209,18 @@ export const deptTreeSelect = (): AxiosPromise<DeptTreeVO[]> => {
}); });
}; };
/**
* 新增用户文件关联
* @param data 文件关联数据
*/
export const uploadCertList = (data: { userId: string | number; fileId: string }) => {
return request({
url: '/system/userFile',
method: 'post',
data: data
});
};
export default { export default {
listUser, listUser,
getUser, getUser,

View File

@ -46,6 +46,7 @@ export interface UserVO extends BaseEntity {
postIds: any; postIds: any;
roleId: any; roleId: any;
admin: boolean; admin: boolean;
filePath?: string;
} }
/** /**
@ -65,6 +66,7 @@ export interface UserForm {
remark?: string; remark?: string;
postIds: string[]; postIds: string[];
roleIds: string[]; roleIds: string[];
filePath?: string;
} }
export interface UserInfoVO { export interface UserInfoVO {

View File

@ -106,7 +106,7 @@ export const constantRoutes: RouteRecordRaw[] = [
}, },
{ {
path: '/progress/progressPaper', path: '/progress/progressPaper',
component: () => import('@/views/progress/progressPaper/index.vue'), component: () => import('@/views/progress/progressPaper/test.vue'),
hidden: true hidden: true
}, },
{ {

View File

@ -82,6 +82,7 @@ import Static from 'ol/source/ImageStatic';
import proj4 from 'proj4'; import proj4 from 'proj4';
import { register } from 'ol/proj/proj4'; import { register } from 'ol/proj/proj4';
import gcoord from 'gcoord'; import gcoord from 'gcoord';
import { createXYZ } from 'ol/tilegrid';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const orthophoto = '@/assets/images/orthophoto.tif'; const orthophoto = '@/assets/images/orthophoto.tif';
const selector = ref<LassoSelector | null>(null); const selector = ref<LassoSelector | null>(null);
@ -408,53 +409,109 @@ const getList = async () => {
const imageExtent = ref(null); const imageExtent = ref(null);
const imageLayer = ref(null); const imageLayer = ref(null);
import { get as getProjection } from 'ol/proj';
const initGeoTiff = async () => { const initGeoTiff = async () => {
const tiff = await fromUrl('/image/clean_rgba_cleaned.tif'); // const tiff = await fromUrl('/image/clean_rgba_cleaned.tif');
const image = await tiff.getImage(); // const image = await tiff.getImage();
const width = image.getWidth(); // const width = image.getWidth();
const height = image.getHeight(); // const height = image.getHeight();
const bbox = image.getBoundingBox(); // [minX, minY, maxX, maxY] // const bbox = image.getBoundingBox(); // [minX, minY, maxX, maxY]
console.log('bbox', bbox); // console.log('bbox', bbox);
const rasters = await image.readRasters({ interleave: true }); // const rasters = await image.readRasters({ interleave: true });
// 创建 Canvas // // 创建 Canvas
const canvas = document.createElement('canvas'); // const canvas = document.createElement('canvas');
canvas.width = width; // canvas.width = width;
canvas.height = height; // canvas.height = height;
const ctx = canvas.getContext('2d')!; // const ctx = canvas.getContext('2d')!;
const imageData: any = ctx.createImageData(width, height); // const imageData: any = ctx.createImageData(width, height);
// 设置 RGBA 数据 // // 设置 RGBA 数据
imageData.data.set(rasters); // ✅ 完整设置,不用手动循环 // imageData.data.set(rasters); // ✅ 完整设置,不用手动循环
ctx.putImageData(imageData, 0, 0); // ctx.putImageData(imageData, 0, 0);
// 将 canvas 转成 Data URL 用作图层 source // // 将 canvas 转成 Data URL 用作图层 source
const imageUrl = canvas.toDataURL(); // const imageUrl = canvas.toDataURL();
// 转换为 WGS84 经纬度 // // 转换为 WGS84 经纬度
const minLonLat = transform([bbox[0], bbox[1]], 'EPSG:32648', 'EPSG:4326'); // const minLonLat = transform([bbox[0], bbox[1]], 'EPSG:32648', 'EPSG:4326');
const maxLonLat = transform([bbox[2], bbox[3]], 'EPSG:32648', 'EPSG:4326'); // const maxLonLat = transform([bbox[2], bbox[3]], 'EPSG:32648', 'EPSG:4326');
// 转为 GCJ02高德地图坐标系 // // 转为 GCJ02高德地图坐标系
const gcjMin = gcoord.transform(minLonLat as [number, number, number], gcoord.WGS84, gcoord.GCJ02); // const gcjMin = gcoord.transform(minLonLat as [number, number, number], gcoord.WGS84, gcoord.GCJ02);
const gcjMax = gcoord.transform(maxLonLat as [number, number, number], gcoord.WGS84, gcoord.GCJ02); // const gcjMax = gcoord.transform(maxLonLat as [number, number, number], gcoord.WGS84, gcoord.GCJ02);
// 再转 EPSG:3857 供 OpenLayers 使用 // // 再转 EPSG:3857 供 OpenLayers 使用
// const minXY = fromLonLat(gcjMin);
// const maxXY = fromLonLat(gcjMax);
// imageExtent.value = [...minXY, ...maxXY];
// imageLayer.value = new ImageLayer({
// source: new Static({
// url: imageUrl,
// imageExtent: imageExtent.value,
// projection: 'EPSG:3857'
// })
// });
// console.log('imageExtent', imageExtent.value);
// 1. 你的原始瓦片的边界(来自 .tfw 或你知道的数据)
// 1. 你的 bbox 是 WGS84 经纬度
const bbox = [107.13149481208748, 23.80411597354268, 107.13487254421389, 23.80801427852998];
// 2. 转成 GCJ02高德坐标系
const gcjMin = gcoord.transform([bbox[0], bbox[1]], gcoord.WGS84, gcoord.GCJ02);
const gcjMax = gcoord.transform([bbox[2], bbox[3]], gcoord.WGS84, gcoord.GCJ02);
// 3. 再转换成 EPSG:3857用于 OpenLayers
const minXY = fromLonLat(gcjMin); const minXY = fromLonLat(gcjMin);
const maxXY = fromLonLat(gcjMax); const maxXY = fromLonLat(gcjMax);
imageExtent.value = [...minXY, ...maxXY]; // 4. 组成瓦片范围 extent
const tileExtent = [...minXY, ...maxXY];
console.log('tileExtent', tileExtent);
imageLayer.value = new ImageLayer({ // 5. 创建 tileGrid
source: new Static({ const tileGrid = createXYZ({
url: imageUrl, extent: tileExtent,
imageExtent: imageExtent.value, tileSize: 256,
projection: 'EPSG:3857' minZoom: 10,
maxZoom: 18
});
// 6. 使用 Web Mercator 投影 EPSG:3857
const projection = getProjection('EPSG:3857');
// 7. 创建瓦片图层
imageLayer.value = new TileLayer({
source: new XYZ({
projection,
tileGrid,
tileUrlFunction: (tileCoord) => {
if (!tileCoord) return '';
let [z, x, y] = tileCoord;
console.log(z, x, y);
y = Math.pow(2, z) - y - 1;
return `http://192.168.110.2:8000/api/projects/3/tasks/c2e3227f-343f-48b1-88c0-1432d6eab33f/orthophoto/tiles/${z}/${x}/${y}`;
}
}) })
}); });
console.log('imageExtent', imageExtent.value); const source = imageLayer.value.getSource();
const projections = source.getProjection();
console.log('图层使用的坐标系:', projections?.getCode());
}; };
let map: any = null; let map: any = null;
const layerData = reactive<any>({}); const layerData = reactive<any>({});
const centerPosition = ref(fromLonLat([107.12932403398425, 23.805564054229908])); const centerPosition = ref(fromLonLat([107.12932403398425, 23.805564054229908]));
const initOLMap = () => { const initOLMap = () => {
// 创造地图实例 console.log(111);
const borderLayer = createExtentBorderLayer(imageExtent.value); // const scoure = new TileLayer({
// // 设置图层的数据源为XYZ类型。XYZ是一个通用的瓦片图层源它允许你通过URL模板来获取瓦片
// source: new XYZ({
// url: 'http://192.168.110.2:8000/api/projects/3/tasks/c2e3227f-343f-48b1-88c0-1432d6eab33f/orthophoto/tiles/{z}/{x}/{y}'
// })
// });
// console.log(scoure);
map = new Map({ map = new Map({
// 设置地图容器的ID // 设置地图容器的ID
target: 'olMap', target: 'olMap',
@ -473,8 +530,9 @@ const initOLMap = () => {
source: new XYZ({ source: new XYZ({
url: 'http://webst02.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scale=1&style=8' url: 'http://webst02.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scale=1&style=8'
}) })
}), })
imageLayer.value // imageLayer.value
// imageLayer.value
], ],
// 设置地图的视图参数 // 设置地图的视图参数
// View表示地图的视图它定义了地图的中心点、缩放级别、旋转角度等参数。 // View表示地图的视图它定义了地图的中心点、缩放级别、旋转角度等参数。
@ -790,10 +848,10 @@ const toggleFeatureHighlight = (feature: Feature, addIfNotExist = true) => {
onMounted(async () => { onMounted(async () => {
// 地图初始化 // 地图初始化
geoTiffLoading.value = true; // geoTiffLoading.value = true;
await initGeoTiff(); await initGeoTiff();
initOLMap(); initOLMap();
geoTiffLoading.value = false; // geoTiffLoading.value = false;
map.addLayer(sharedLayer); map.addLayer(sharedLayer);
selector.value = new LassoSelector(map, sharedSource, (features, isInvert = false) => { selector.value = new LassoSelector(map, sharedSource, (features, isInvert = false) => {
features.forEach((feature) => { features.forEach((feature) => {

View File

@ -0,0 +1,156 @@
<template>
<div ref="mapContainer" class="map-container"></div>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import Map from 'ol/Map';
import View from 'ol/View';
import TileLayer from 'ol/layer/Tile';
import XYZ from 'ol/source/XYZ';
import TileGrid from 'ol/tilegrid/TileGrid';
import { fromLonLat, transform, transformExtent } from 'ol/proj';
import { fromUrl } from 'geotiff';
import gcoord from 'gcoord';
import ImageLayer from 'ol/layer/Image';
import Static from 'ol/source/ImageStatic';
import { Feature } from 'ol';
import { Polygon } from 'ol/geom';
import { Stroke, Style } from 'ol/style';
import VectorLayer from 'ol/layer/Vector';
import VectorSource from 'ol/source/Vector';
const mapContainer = ref<HTMLDivElement | null>(null);
// 您提供的经纬度范围EPSG:4326
const extent4326 = [107.13149481208748, 23.80411597354268, 107.13487254421389, 23.80801427852998];
// 计算中心点(经纬度)
const centerLon = (extent4326[0] + extent4326[2]) / 2;
const centerLat = (extent4326[1] + extent4326[3]) / 2;
// 转换 extent 到 EPSG:3857
const extent3857 = transformExtent(extent4326, 'EPSG:4326', 'EPSG:3857');
// 生成 resolutions256像素瓦片
const resolutions = Array.from({ length: 20 }, (_, z) => 156543.03392804097 / Math.pow(2, z));
onMounted(async () => {
// const tiff = await fromUrl('/image/clean_rgba_cleaned.tif');
// const image = await tiff.getImage();
// const width = image.getWidth();
// const height = image.getHeight();
// const bbox = image.getBoundingBox(); // [minX, minY, maxX, maxY]
// console.log('bbox', bbox);
// const rasters = await image.readRasters({ interleave: true });
// // 创建 Canvas
// const canvas = document.createElement('canvas');
// canvas.width = width;
// canvas.height = height;
// const ctx = canvas.getContext('2d')!;
// const imageData: any = ctx.createImageData(width, height);
// // 设置 RGBA 数据
// imageData.data.set(rasters); // ✅ 完整设置,不用手动循环
// ctx.putImageData(imageData, 0, 0);
// // 将 canvas 转成 Data URL 用作图层 source
// const imageUrl = canvas.toDataURL();
// // 转换为 WGS84 经纬度
// const minLonLat = transform([bbox[0], bbox[1]], 'EPSG:32648', 'EPSG:4326');
// const maxLonLat = transform([bbox[2], bbox[3]], 'EPSG:32648', 'EPSG:4326');
// console.log('minLonLat', minLonLat);
// console.log('maxLonLat', maxLonLat);
// // 转为 GCJ02高德地图坐标系
// const gcjMin = gcoord.transform(minLonLat as [number, number, number], gcoord.WGS84, gcoord.GCJ02);
// const gcjMax = gcoord.transform(maxLonLat as [number, number, number], gcoord.WGS84, gcoord.GCJ02);
// // 再转 EPSG:3857 供 OpenLayers 使用
// const minXY = fromLonLat(gcjMin);
// const maxXY = fromLonLat(gcjMax);
let imageExtent = [11926280.148303444, 2729254.667731837, 11926657.474014785, 2729714.281185133];
console.log('imageExtent', imageExtent);
console.log('extent3857', extent3857);
if (!mapContainer.value) return;
const tileGrid = new TileGrid({
extent: imageExtent,
origin: [-20037508.342789244, 20037508.342789244], // Web Mercator 左上角
resolutions,
tileSize: 256
});
// 高德卫星图图层 (EPSG:3857)
const gaodeLayer = new TileLayer({
source: new XYZ({
url: 'https://webst02.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}',
maxZoom: 19,
wrapX: true
}),
opacity: 1
});
// 自定义瓦片图层EPSG:3857
const customLayer = new TileLayer({
source: new XYZ({
url: 'http://192.168.110.2:8000/api/projects/3/tasks/c2e3227f-343f-48b1-88c0-1432d6eab33f/orthophoto/tiles/{z}/{x}/{y}'
// extent: imageExtent
})
});
const layer = customLayer; // eg: TileLayer<XYZ>
const source = layer.getSource();
const projection = source?.getProjection();
console.log('图层坐标系:', projection?.getCode());
const borderLayer = createExtentBorderLayer(imageExtent);
const testLayer = createExtentBorderLayer([
...fromLonLat([107.13149481208748, 23.80411597354268]),
...fromLonLat([107.13487254421389, 23.80801427852998])
]);
// 创建地图
const map = new Map({
target: mapContainer.value,
layers: [gaodeLayer, customLayer, borderLayer, testLayer],
view: new View({
projection: 'EPSG:3857',
center: fromLonLat([centerLon, centerLat]),
zoom: 16,
minZoom: 10
// extent: extent3857 // 限制视图范围
})
});
});
const createExtentBorderLayer = (extent: number[]) => {
// 构造矩形坐标,闭合成环,顺序可以是顺时针或逆时针
const coords = [
[
[extent[0], extent[1]],
[extent[0], extent[3]],
[extent[2], extent[3]],
[extent[2], extent[1]],
[extent[0], extent[1]]
]
];
const polygonFeature = new Feature(new Polygon(coords));
polygonFeature.setStyle(
new Style({
stroke: new Stroke({
color: 'red', // 你想要的边框颜色
width: 3 // 线宽
}),
fill: null // 不填充,纯边框
})
);
return new VectorLayer({
source: new VectorSource({
features: [polygonFeature]
})
});
};
</script>
<style scoped>
.map-container {
width: 100%;
height: 100vh;
}
</style>

View File

@ -0,0 +1,283 @@
<template>
<div class="p-2">
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
<el-form-item label="类别" prop="recordCategory">
<el-select v-model="queryParams.recordCategory" placeholder="请选择类别" clearable>
<el-option v-for="dict in recordCategoryType" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item label="类型" prop="violationType">
<el-select v-model="queryParams.violationType" placeholder="请选择违章类型" clearable>
<el-option v-for="dict in violation_level_type" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item label="故障描述" prop="description">
<el-input v-model="queryParams.description" placeholder="请输入故障描述" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="创建时间" prop="createTime">
<el-date-picker clearable v-model="queryParams.createTime" type="date" value-format="YYYY-MM-DD" placeholder="请选择创建时间" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</transition>
<el-card shadow="never">
<el-table v-loading="loading" :data="recognizeRecordList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="主键id" align="center" prop="id" v-if="false" />
<el-table-column label="设备名称" align="center" prop="deviceName" />
<el-table-column label="识别类别" align="center" prop="recordCategory">
<template #default="scope">
{{ scope.row.recordCategory === '1' ? '无人机识别' : '监控拍摄' }}
</template>
</el-table-column>
<el-table-column label="违章类型" align="center" prop="violationType">
<template #default="scope">
<dict-tag :options="violation_level_type" :value="scope.row.violationType" />
</template>
</el-table-column>
<el-table-column label="图片路径" align="center" prop="picture" width="100">
<template #default="scope">
<image-preview :src="scope.row.picture" :width="50" :height="50" />
</template>
</el-table-column>
<el-table-column label="故障描述" align="center" prop="description" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template #default="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="danger" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['safety:recognizeRecord:remove']"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card>
<!-- 添加或修改识别记录对话框 -->
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
<el-form ref="recognizeRecordFormRef" :model="form" :rules="rules" label-width="80px">
<el-form-item label="项目id" prop="projectId">
<el-input v-model="form.projectId" placeholder="请输入项目id" />
</el-form-item>
<el-form-item label="设备序列号" prop="deviceSerial">
<el-input v-model="form.deviceSerial" placeholder="请输入设备序列号" />
</el-form-item>
<el-form-item label="设备名称" prop="deviceName">
<el-input v-model="form.deviceName" placeholder="请输入设备名称" />
</el-form-item>
<el-form-item label="违章类型" prop="violationType">
<el-select v-model="form.violationType" placeholder="请选择违章类型">
<el-option v-for="dict in violation_level_type" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
</el-select>
</el-form-item>
<el-form-item label="图片路径" prop="picture">
<image-upload v-model="form.picture" />
</el-form-item>
<el-form-item label="违规数量" prop="num">
<el-input v-model="form.num" placeholder="请输入违规数量" />
</el-form-item>
<el-form-item label="故障描述" prop="description">
<el-input v-model="form.description" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup name="RecognizeRecord" lang="ts">
import { listRecognizeRecord, getRecognizeRecord, delRecognizeRecord, addRecognizeRecord, updateRecognizeRecord } from '@/api/safety/recognizeRecord';
import { RecognizeRecordVO, RecognizeRecordQuery, RecognizeRecordForm } from '@/api/safety/recognizeRecord/types';
import { useUserStoreHook } from '@/store/modules/user';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { violation_level_type } = toRefs<any>(proxy?.useDict('violation_level_type'));
const recognizeRecordList = ref<RecognizeRecordVO[]>([]);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref<Array<string | number>>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const recordCategoryType = ref<{ label: string; value: string | number }[]>([
{ label: '无人机识别', value: '1' },
{ label: '监控拍摄', value: '2' }
]);
const queryFormRef = ref<ElFormInstance>();
const recognizeRecordFormRef = ref<ElFormInstance>();
// 获取用户 store
const userStore = useUserStoreHook();
// 从 store 中获取项目列表和当前选中的项目
const currentProject = computed(() => userStore.selectedProject);
const dialog = reactive<DialogOption>({
visible: false,
title: ''
});
const initFormData: RecognizeRecordForm = {
id: undefined,
projectId: undefined,
deviceSerial: undefined,
deviceName: undefined,
recordCategory: undefined,
violationType: undefined,
picture: undefined,
num: undefined,
description: undefined,
remark: undefined
};
const data = reactive<PageData<RecognizeRecordForm, RecognizeRecordQuery>>({
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10,
projectId: undefined,
deviceName: undefined,
recordCategory: undefined,
violationType: undefined,
createTime: undefined,
params: {}
},
rules: {
id: [{ required: true, message: '主键id不能为空', trigger: 'blur' }],
projectId: [{ required: true, message: '项目id不能为空', trigger: 'blur' }]
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询识别记录列表 */
const getList = async () => {
loading.value = true;
const res = await listRecognizeRecord(queryParams.value);
recognizeRecordList.value = res.rows;
total.value = res.total;
loading.value = false;
};
/** 取消按钮 */
const cancel = () => {
reset();
dialog.visible = false;
};
/** 表单重置 */
const reset = () => {
form.value = { ...initFormData };
recognizeRecordFormRef.value?.resetFields();
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: RecognizeRecordVO[]) => {
ids.value = selection.map((item) => item.id);
single.value = selection.length != 1;
multiple.value = !selection.length;
};
/** 新增按钮操作 */
const handleAdd = () => {
reset();
dialog.visible = true;
dialog.title = '添加识别记录';
};
/** 修改按钮操作 */
const handleUpdate = async (row?: RecognizeRecordVO) => {
reset();
const _id = row?.id || ids.value[0];
const res = await getRecognizeRecord(_id);
Object.assign(form.value, res.data);
dialog.visible = true;
dialog.title = '修改识别记录';
};
/** 提交按钮 */
const submitForm = () => {
recognizeRecordFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
if (form.value.id) {
await updateRecognizeRecord(form.value).finally(() => (buttonLoading.value = false));
} else {
await addRecognizeRecord(form.value).finally(() => (buttonLoading.value = false));
}
proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false;
await getList();
}
});
};
/** 删除按钮操作 */
const handleDelete = async (row?: RecognizeRecordVO) => {
const _ids = row?.id || ids.value;
await proxy?.$modal.confirm('是否确认删除识别记录编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
await delRecognizeRecord(_ids);
proxy?.$modal.msgSuccess('删除成功');
await getList();
};
/** 导出按钮操作 */
const handleExport = () => {
proxy?.download(
'safety/recognizeRecord/export',
{
...queryParams.value
},
`recognizeRecord_${new Date().getTime()}.xlsx`
);
};
onMounted(() => {
getList();
});
//监听项目id刷新数据
const listeningProject = watch(
() => currentProject.value.id,
(nid, oid) => {
queryParams.value.projectId = nid;
getList();
}
);
onUnmounted(() => {
listeningProject();
});
</script>

View File

@ -112,7 +112,7 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" fixed="right" width="180" class-name="small-padding fixed-width"> <el-table-column label="操作" fixed="right" width="230" class-name="small-padding fixed-width">
<template #default="scope"> <template #default="scope">
<el-tooltip v-if="scope.row.userId !== 1" content="修改" placement="top"> <el-tooltip v-if="scope.row.userId !== 1" content="修改" placement="top">
<el-button v-hasPermi="['system:user:edit']" link type="primary" icon="Edit" @click="handleUpdate(scope.row)"></el-button> <el-button v-hasPermi="['system:user:edit']" link type="primary" icon="Edit" @click="handleUpdate(scope.row)"></el-button>
@ -131,6 +131,9 @@
<el-tooltip v-if="scope.row.userId !== 1" content="编辑关联项目" placement="top"> <el-tooltip v-if="scope.row.userId !== 1" content="编辑关联项目" placement="top">
<el-button v-hasPermi="['system:user:edit']" link type="primary" icon="Edit" @click="handleUpdateProject(scope.row)"></el-button> <el-button v-hasPermi="['system:user:edit']" link type="primary" icon="Edit" @click="handleUpdateProject(scope.row)"></el-button>
</el-tooltip> </el-tooltip>
<el-tooltip v-if="scope.row.userId !== 1" content="上传证书目录" placement="top">
<el-button v-hasPermi="['system:user:edit']" link type="primary" icon="Upload" @click="handleUploadCert(scope.row)"></el-button>
</el-tooltip>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -257,7 +260,7 @@
</el-dialog> </el-dialog>
<!-- 用户导入对话框 --> <!-- 用户导入对话框 -->
<el-dialog v-model="upload.open" :title="upload.title" width="400px" append-to-body> <el-dialog draggable v-model="upload.open" :title="upload.title" width="400px" append-to-body>
<el-upload <el-upload
ref="uploadRef" ref="uploadRef"
:limit="1" :limit="1"
@ -292,11 +295,22 @@
</div> </div>
</template> </template>
</el-dialog> </el-dialog>
<el-dialog title="上传证书目录" v-model="certDialog" width="30%" destroy-on-close>
<!-- <File-upload v-model="fileUpload" :limit="5"></File-upload> -->
<ImageUpload v-model="fileUpload" :limit="5"></ImageUpload>
<template #footer>
<span>
<el-button @click="certDialog = false">取消</el-button>
<el-button type="primary" @click="uploadCert">确定</el-button>
</span>
</template>
</el-dialog>
</div> </div>
</template> </template>
<script setup name="User" lang="ts"> <script setup name="User" lang="ts">
import api from '@/api/system/user'; import api, { uploadCertList } from '@/api/system/user';
import { UserForm, UserQuery, UserVO } from '@/api/system/user/types'; import { UserForm, UserQuery, UserVO } from '@/api/system/user/types';
import { DeptTreeVO, DeptVO } from '@/api/system/dept/types'; import { DeptTreeVO, DeptVO } from '@/api/system/dept/types';
import { RoleVO } from '@/api/system/role/types'; import { RoleVO } from '@/api/system/role/types';
@ -372,7 +386,8 @@ const initFormData: UserForm = {
status: '0', status: '0',
remark: '', remark: '',
postIds: [], postIds: [],
roleIds: [] roleIds: [],
filePath: undefined
}; };
const initData: PageData<UserForm, UserQuery> = { const initData: PageData<UserForm, UserQuery> = {
@ -679,6 +694,31 @@ const handleUpdateProject = (row) => {
shuttleVisible.value = true; shuttleVisible.value = true;
} }
}; };
const certDialog = ref(false);
const certId = ref<string | number>(undefined);
const fileUpload = ref<string>();
//上传证书
const handleUploadCert = (row: UserVO) => {
certId.value = row.userId;
fileUpload.value = row.filePath;
certDialog.value = true;
};
const uploadCert = async () => {
if (!fileUpload.value) {
proxy?.$modal.msgError('请上传证书目录');
return;
}
let res = await uploadCertList({
userId: certId.value,
fileId: fileUpload.value
});
console.log(res);
certDialog.value = false;
proxy?.$modal.msgSuccess('上传证书目录成功');
};
</script> </script>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>