Explorar el Código

fix: 修改bug

bill hace 2 años
padre
commit
524973989a

+ 26 - 2
src/graphic/Renderer/Draw.js

@@ -24,7 +24,6 @@ export const help = {
       [stateService.getDraggingItem(), "Dragging"],
       [stateService.getFocusItem(), "Focus"],
     ];
-    console.log(itemsEntry);
     let currentAttr;
 
     //console.log(itemsEntry)
@@ -1135,6 +1134,31 @@ export default class Draw {
         }
       }
     }
+
+    if (vector.category === VectorCategory.Point.FixPoint) {
+      let select = false;
+      const geo = stateService.getFocusItem();
+      if (geo) {
+        const realVector = dataService.getGeo(geo.type, geo.vectorId);
+        select = realVector && realVector.linkedPointId === vector.vectorId;
+      }
+
+      if (attr || select) {
+        this.context.beginPath();
+        const padding = style.radius * coordinate.ratio;
+        this.context.moveTo(pt.x - padding, pt.y - padding);
+        this.context.lineTo(pt.x + padding, pt.y - padding);
+        this.context.lineTo(pt.x + padding, pt.y + padding);
+        this.context.lineTo(pt.x - padding, pt.y + padding);
+        this.context.strokeStyle = "rgba(255, 153, 0, 1)";
+        this.context.fillStyle = "rgba(255, 153, 0, 0.30)";
+        this.context.lineWidth = 2 * coordinate.ratio;
+        this.context.setLineDash([6 * coordinate.ratio, 2 * coordinate.ratio]);
+        this.context.closePath();
+        this.context.stroke();
+        this.context.fill();
+      }
+    }
     ctx.restore();
   }
 
@@ -1184,7 +1208,7 @@ export default class Draw {
       const realVector = dataService.getGeo(geo.type, geo.vectorId);
       select = realVector && realVector.linkedTextId === vector.vectorId;
     }
-    if (select || foo) {
+    if (select || foo === "Focus") {
       this.context.beginPath();
       const padding = 2 * coordinate.ratio;
       this.context.moveTo(bound[0].x - padding, bound[0].y - padding);

+ 16 - 8
src/store/sync.ts

@@ -70,7 +70,7 @@ export const api = !global.android
           return URL.createObjectURL(base64ToBlob(base64));
         }
       },
-      async photograph() {
+      async photograph(rotate = true) {
         const file = await new Promise<File>((resolve) => {
           const input = document.createElement("input");
           input.type = "file";
@@ -81,10 +81,10 @@ export const api = !global.android
         });
 
         const url = await this.uploadImage(file);
-        return await normalImage(url);
+        return rotate ? await normalImage(url) : url;
       },
-      async selectPhotoAlbum() {
-        return await this.photograph();
+      async selectPhotoAlbum(rotate = true) {
+        return await this.photograph(rotate);
       },
       async closePage() {
         return router.push({ name: writeRouteName.scene });
@@ -184,23 +184,31 @@ export const api = !global.android
           global.android.downloadImage(file.name, data, apiName);
         });
       },
-      photograph() {
+      photograph(rotate = true) {
         return new Promise<string>((resolve) => {
           const apiName = `photograph${count++}`;
           global[apiName] = (data) => {
             console.log("拍照后路径:", data);
-            data ? normalImage(data).then(resolve) : resolve(null);
+            data
+              ? rotate
+                ? normalImage(data).then(resolve)
+                : resolve(data)
+              : resolve(null);
             delete global[apiName];
           };
           global.android.cameraPhotograph(params.m, apiName);
         });
       },
-      selectPhotoAlbum() {
+      selectPhotoAlbum(rotate = true) {
         return new Promise<string>((resolve) => {
           const apiName = `selectPhotoAlbum${count++}`;
           global[apiName] = (data) => {
             console.log("获得相册图片路径:", data);
-            data ? normalImage(data).then(resolve) : resolve(null);
+            data
+              ? rotate
+                ? normalImage(data).then(resolve)
+                : resolve(data)
+              : resolve(null);
             delete global[apiName];
           };
           global.android.selectPhotoAlbum(params.m, apiName);

+ 2 - 2
src/views/graphic/geos/magnifier.vue

@@ -31,7 +31,7 @@ const menus = reactive([
               icon: "photo",
               text: "拍照",
               onClick: async () => {
-                const data = await api.photograph();
+                const data = await api.photograph(false);
                 data && syncVector(data);
               },
             },
@@ -40,7 +40,7 @@ const menus = reactive([
               icon: "map",
               text: "相册",
               onClick: async () => {
-                const data = await api.selectPhotoAlbum();
+                const data = await api.selectPhotoAlbum(false);
                 data && syncVector(data);
               },
             },

+ 5 - 3
src/views/graphic/header.vue

@@ -173,9 +173,11 @@ const saveStore = genUseLoading(async () => {
 
 const saveHandler = async () => {
   await saveStore();
-  await router.replace({
-    name: isRoad.value ? writeRouteName.roads : writeRouteName.accidents,
-  });
+  if (!isRoad.value) {
+    await router.replace({
+      name: isRoad.value ? writeRouteName.roads : writeRouteName.accidents,
+    });
+  }
 };
 
 const createTable = async () => {

+ 13 - 11
src/views/photos/index.vue

@@ -124,17 +124,19 @@ watchEffect(() => {
       router.push(writeRouteName.scene);
     } else {
       api[photoType.value]().then((url) => {
-        photos.value.push({
-          id: getId(),
-          url,
-          urlRaw: url,
-          time: new Date().getTime(),
-          meterPerPixel: null,
-          measures: [],
-          baseLines: [],
-          fixPoints: [],
-          basePoints: [],
-        });
+        if (url) {
+          photos.value.push({
+            id: getId(),
+            url,
+            urlRaw: url,
+            time: new Date().getTime(),
+            meterPerPixel: null,
+            measures: [],
+            baseLines: [],
+            fixPoints: [],
+            basePoints: [],
+          });
+        }
       });
     }
     photoType.value = null;

+ 15 - 2
src/views/roads/index.vue

@@ -77,6 +77,7 @@ import UiIcon from "@/components/base/components/icon/index.vue";
 import { useConfirm } from "@/hook";
 import { api } from "@/store/sync";
 import { photos } from "@/store/photos";
+import { getId } from "@/utils";
 
 const sortPhotos = computed(() => [...roadPhotos.value].reverse());
 const active = ref<RoadPhoto>();
@@ -84,6 +85,18 @@ const selectMode = ref(false);
 const selects = ref<RoadPhoto[]>([]);
 const menus = [
   {
+    key: "copy",
+    icon: "copy",
+    text: "创建副本",
+    onClick: () => {
+      const copy = JSON.parse(JSON.stringify(active.value)) as RoadPhoto;
+      copy.id = getId();
+      copy.time = new Date().getTime();
+      roadPhotos.value.push(copy);
+      gotoDraw(copy);
+    },
+  },
+  {
     key: "road",
     icon: "edit",
     text: "修改",
@@ -148,10 +161,10 @@ const delSelects = async () => {
   }
 };
 
-const gotoDraw = () => {
+const gotoDraw = (road = active.value) => {
   router.push({
     name: writeRouteName.graphic,
-    params: { mode: Mode.Road, id: active.value.id, action: "update" },
+    params: { mode: Mode.Road, id: road.id, action: "update" },
   });
 };
 

+ 23 - 1
src/views/roads/tabulation.vue

@@ -136,6 +136,7 @@ import MainPanel from "@/components/main-panel/index.vue";
 import { downloadImage, uploadImage } from "@/store/sync";
 import { Mode } from "@/views/graphic/menus";
 import Message from "@/components/base/components/message/message.vue";
+import { useConfirm } from "@/hook";
 
 const roadPhoto = computed<RoadPhoto>(() => {
   let route, params, data;
@@ -212,10 +213,31 @@ const getLayoutImage = async () => {
   const blob = await new Promise<Blob>((resolve) =>
     canvas.toBlob(resolve, "image/jpeg", 0.95)
   );
-  await downloadImage(blob);
+  await downloadImage(blob, roadPhoto.value.id + ".jpg");
   return await uploadImage(blob);
 };
 const saveHandler = async () => {
+  let index = 1;
+  let prex = "未命名";
+  while (true) {
+    if (roadPhotos.value.some((road) => road.title === `${prex}${index}`)) {
+      index++;
+    } else {
+      break;
+    }
+  }
+
+  roadPhoto.value.title = roadPhoto.value.title.trim() || `${prex}${index}`;
+  // const repeatIndex = roadPhotos.value.findIndex(
+  //   (road) => road !== roadPhoto.value && road.title === roadPhoto.value.title
+  // );
+  // if (~repeatIndex && !(await useConfirm("检测到您有相同文件名的文件,确定要覆盖吗?"))) {
+  //   return;
+  // }
+  // if (~repeatIndex) {
+  //   roadPhotos.value.splice(repeatIndex, 1);
+  // }
+
   roadPhoto.value.table = {
     ...history.value.value,
     url: await getLayoutImage(),