完成仓库模块

This commit is contained in:
Zy
2026-04-23 17:59:36 +08:00
parent 985860c9de
commit 9d4416b238
39 changed files with 5040 additions and 80 deletions

View File

@@ -6,7 +6,7 @@
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
<el-form-item label="执行状态" prop="status">
<el-select>
<el-select v-model="queryParams.status">
<el-option v-for="item in com_inspection_task_status" :key="item.value" :value="item.value" :label="item.label"></el-option>
</el-select>
</el-form-item>
@@ -74,6 +74,7 @@
<script setup name="Record" lang="ts">
import { listRecord, getRecord, delRecord, addRecord, updateRecord } from '@/api/system/InspectionRecord/index';
import { RecordVO, RecordQuery, RecordForm } from '@/api/system/InspectionRecord/type';
import { getUserByRoleKey } from '@/api/system/user';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { com_inspection_task_status } = toRefs<any>(proxy?.useDict('com_inspection_task_status'));
@@ -123,6 +124,7 @@ const { queryParams, form } = toRefs(data);
/** 查询巡检记录主列表 */
const getList = async () => {
loading.value = true;
const res = await listRecord(queryParams.value);
recordList.value = res.rows;
total.value = res.total;

View File

@@ -107,7 +107,6 @@ function checkoutItem(id: string) {
checkoutPointlist.value.push(id);
const find = pointslist.value.find((item) => item.id === id);
if (find && find.location) {
console.log(find.location, find.pointName);
if (find && find.location) {
addPointMarker(id, find.location, find.pointName);
}
@@ -172,7 +171,6 @@ function init() {
pathPoints: res.data.pathPoints, // 巡检路线经纬度
totalPoints: res.data.totalPoints // 巡检点
};
console.log('巡检路线详情:', form.value);
nextTick(() => {
if (routeid.value) {
checkoutPointlist.value = res.data.totalPoints ? res.data.totalPoints.split(',') : [];
@@ -187,7 +185,6 @@ function init() {
}
// 回显路线
if (res.data.pathPoints) {
console.log('回显巡检点:', res.data.pathPoints);
renderSavedPath(res.data.pathPoints);
}
}
@@ -242,7 +239,6 @@ onMounted(async () => {
if (drawnPolylines.value.length > 0) {
map.value.remove(drawnPolylines.value[0]);
}
drawnPolylines.value = [e.obj];
// 画完继续允许画下一条(但永远只保留一条)
initDrawTool();
@@ -315,47 +311,67 @@ function clearAll() {
// !!! 核心:获取绘制的路线经纬度数组
function getPolylinePath() {
if (drawnPolylines.value.length === 0) return [];
const lastLine = drawnPolylines.value.at(-1);
console.log('最后一条线的路径:', lastLine.getPath());
const lastLine = drawnPolylines.value.pop();
const path = lastLine.getPath().map((p) => [p.lng, p.lat]);
return path;
}
/**
* 修复高德地图 Polyline 闭合路线最后一段不显示
* 解决:最后两点坐标相同 → 长度0 → 不渲染
*/
function fixClosePath(path: number[][]): number[][] {
if (!path || path.length < 2) return path;
const newPath = [...path];
// 如果是闭合路线(最后一点 ≈ 第一点)
const first = newPath[0];
const last = newPath[newPath.length - 1];
// 判断是否几乎重合
const isSame = Math.abs(last[0] - first[0]) < 1e-8 && Math.abs(last[1] - first[1]) < 1e-8;
if (isSame) {
// 【关键】最后一点极微小偏移,强制生成线段
newPath[newPath.length - 1] = [last[0] + 0.0000001, last[1] + 0.0000001];
}
return newPath;
}
// !== 提交 =============================================================================
const submitForm = () => {
formRef.value?.validate(async (valid: boolean) => {
if (valid) {
// 获取路线经纬度
const path = getPolylinePath() as [number, number][];
if (path.length === 0) {
ElMessage.warning('请绘制巡检路线');
return;
}
// 转成字符串传给后端
const [start_lng, start_lat] = path.shift() as [number, number];
const [end_lng, end_lat] = path.pop() as [number, number];
form.value.startLng = `${start_lng}`;
form.value.startLat = `${start_lat}`;
form.value.endLng = `${end_lng}`;
form.value.endLat = `${end_lat}`;
form.value.pathPoints = JSON.stringify(path);
form.value.totalPoints = checkoutPointlist.value.join(',');
console.log('提交数据:', form.value);
if (routeid.value) {
updateRoute(form.value).then(() => {
ElMessage.success('编辑成功');
cancelForm();
});
} else {
addRoute(form.value).then(() => {
ElMessage.success('添加成功');
cancelForm();
});
}
// if (valid) {
// 获取路线经纬度
const path = getPolylinePath() as [number, number][];
if (path.length === 0) {
ElMessage.warning('请绘制巡检路线');
return;
}
// 转成字符串传给后端
const [start_lng, start_lat] = path.at(0) as [number, number];
const [end_lng, end_lat] = path.at(-1) as [number, number];
form.value.startLng = `${start_lng}`;
form.value.startLat = `${start_lat}`;
form.value.endLng = `${end_lng}`;
form.value.endLat = `${end_lat}`;
form.value.pathPoints = JSON.stringify(path);
form.value.totalPoints = checkoutPointlist.value.join(',');
if (routeid.value) {
updateRoute(form.value).then(() => {
ElMessage.success('编辑成功');
cancelForm();
});
} else {
addRoute(form.value).then(() => {
ElMessage.success('添加成功');
cancelForm();
});
}
// }
});
};
// 返回

View File

@@ -55,6 +55,7 @@
<script setup name="Route" lang="ts">
import { list_statapi } from '@/api/system/Inspection';
import { getUserByRoleKey } from '@/api/system/user';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@@ -74,12 +75,15 @@ const data = reactive({
});
const checkdata = ref([]);
// TODO 巡检人员名称
const { queryParams } = toRefs(data);
const inspectionUserlist = ref([]);
/** 查询巡检路线列表 */
const getList = async () => {
loading.value = true;
// const inspectionUseres = await getUserByRoleKey('inspection');
// inspectionUserlist.value = inspectionUseres.data;
const res = await list_statapi(queryParams.value);
routeList.value = res.rows;
total.value = res.total;