识别记录
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@ -7,6 +7,9 @@ npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
**/*.log
|
||||
# 忽略所有 .tif 文件
|
||||
*.tif
|
||||
|
||||
|
||||
tests/**/coverage/
|
||||
tests/e2e/reports
|
||||
|
63
src/api/safety/recognizeRecord/index.ts
Normal file
63
src/api/safety/recognizeRecord/index.ts
Normal 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'
|
||||
});
|
||||
};
|
125
src/api/safety/recognizeRecord/types.ts
Normal file
125
src/api/safety/recognizeRecord/types.ts
Normal file
@ -0,0 +1,125 @@
|
||||
export interface RecognizeRecordVO {
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* 故障描述
|
||||
*/
|
||||
describe?: string;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
remark?: string;
|
||||
|
||||
}
|
||||
|
||||
export interface RecognizeRecordQuery extends PageQuery {
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
projectId?: string | number;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
deviceName?: string;
|
||||
|
||||
/**
|
||||
* 识别类别(1无人机识别 2监控拍摄)
|
||||
*/
|
||||
recordCategory?: string;
|
||||
|
||||
/**
|
||||
* 违章类型(多个逗号分隔)
|
||||
*/
|
||||
violationType?: string;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
createTime?: string;
|
||||
|
||||
/**
|
||||
* 日期范围参数
|
||||
*/
|
||||
params?: any;
|
||||
}
|
||||
|
||||
|
||||
|
@ -82,6 +82,7 @@ import Static from 'ol/source/ImageStatic';
|
||||
import proj4 from 'proj4';
|
||||
import { register } from 'ol/proj/proj4';
|
||||
import gcoord from 'gcoord';
|
||||
import { createXYZ } from 'ol/tilegrid';
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const orthophoto = '@/assets/images/orthophoto.tif';
|
||||
const selector = ref<LassoSelector | null>(null);
|
||||
@ -408,53 +409,109 @@ const getList = async () => {
|
||||
|
||||
const imageExtent = ref(null);
|
||||
const imageLayer = ref(null);
|
||||
import { get as getProjection } from 'ol/proj';
|
||||
|
||||
const initGeoTiff = 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');
|
||||
// 转为 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 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');
|
||||
// // 转为 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);
|
||||
|
||||
// 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 maxXY = fromLonLat(gcjMax);
|
||||
|
||||
imageExtent.value = [...minXY, ...maxXY];
|
||||
// 4. 组成瓦片范围 extent
|
||||
const tileExtent = [...minXY, ...maxXY];
|
||||
console.log('tileExtent', tileExtent);
|
||||
|
||||
imageLayer.value = new ImageLayer({
|
||||
source: new Static({
|
||||
url: imageUrl,
|
||||
imageExtent: imageExtent.value,
|
||||
projection: 'EPSG:3857'
|
||||
// 5. 创建 tileGrid
|
||||
const tileGrid = createXYZ({
|
||||
extent: tileExtent,
|
||||
tileSize: 256,
|
||||
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;
|
||||
const layerData = reactive<any>({});
|
||||
const centerPosition = ref(fromLonLat([107.12932403398425, 23.805564054229908]));
|
||||
const initOLMap = () => {
|
||||
// 创造地图实例
|
||||
const borderLayer = createExtentBorderLayer(imageExtent.value);
|
||||
console.log(111);
|
||||
// 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({
|
||||
// 设置地图容器的ID
|
||||
target: 'olMap',
|
||||
@ -473,8 +530,9 @@ const initOLMap = () => {
|
||||
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'
|
||||
})
|
||||
}),
|
||||
imageLayer.value
|
||||
})
|
||||
// imageLayer.value
|
||||
// imageLayer.value
|
||||
],
|
||||
// 设置地图的视图参数
|
||||
// View表示地图的视图,它定义了地图的中心点、缩放级别、旋转角度等参数。
|
||||
@ -790,10 +848,10 @@ const toggleFeatureHighlight = (feature: Feature, addIfNotExist = true) => {
|
||||
|
||||
onMounted(async () => {
|
||||
// 地图初始化
|
||||
geoTiffLoading.value = true;
|
||||
// geoTiffLoading.value = true;
|
||||
await initGeoTiff();
|
||||
initOLMap();
|
||||
geoTiffLoading.value = false;
|
||||
// geoTiffLoading.value = false;
|
||||
map.addLayer(sharedLayer);
|
||||
selector.value = new LassoSelector(map, sharedSource, (features, isInvert = false) => {
|
||||
features.forEach((feature) => {
|
||||
|
283
src/views/safety/recognizeRecord/index.vue
Normal file
283
src/views/safety/recognizeRecord/index.vue
Normal 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="describe">
|
||||
<el-input v-model="form.describe" 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,
|
||||
describe: 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>
|
Reference in New Issue
Block a user