浏览代码

添加新数据需求

bill 2 年之前
父节点
当前提交
69b0477925

文件差异内容过多而无法显示
+ 1 - 1
server/test/SS-t-P1d6CwREny2/attach/sceneStore


+ 1 - 1
src/graphic/Controls/UIControl.js

@@ -292,7 +292,7 @@ export default class UIControl {
   /******************************************************************************************************************************************************************/
 
   prompt(msg) {
-    this._prompts.push(Message.success({ msg }));
+    this._prompts.push(Message.success(typeof msg === 'string' ? { msg } : msg));
   }
 
   // 进入持续添加出确认与取消框

+ 5 - 3
src/graphic/Load.js

@@ -135,11 +135,13 @@ export default class Load {
         if (data3d.measures) {
           for (let i = 0; i < data3d.measures.length; ++i) {
             //理论上基准线只能有一条
-            lineService.create(
-              this.getXY(width, height, data3d.measures[i][0]),
-              this.getXY(width, height, data3d.measures[i][1]),
+            //
+            const line = lineService.create(
+              this.getXY(width, height, data3d.measures[i].pos[0]),
+              this.getXY(width, height, data3d.measures[i].pos[1]),
               VectorCategory.Line.MeasureLine
             );
+            line.value = data3d.measures[i].dis
           }
         }
         if (data3d.basePoints) {

+ 1 - 1
src/graphic/Renderer/Draw.js

@@ -718,7 +718,7 @@ export default class Draw {
       this.context,
       coordinate.getScreenXY(startReal),
       coordinate.getScreenXY(endReal),
-      help.getRealDistance(startReal, endReal) + "m",
+      (vector.value ? (Math.round(vector.value * 100) / 100) : help.getRealDistance(startReal, endReal)) + "m",
       style
     );
   }

+ 1 - 1
src/store/photos.ts

@@ -6,7 +6,7 @@ export type PhotoRaw = {
   url: string
   meterPerPixel: number
   time: number,
-  measures: Array<Pos[]>,
+  measures: { pos: Pos[], dis: number}[],
   fixPoints: Array<Pos>,
   basePoints: Array<Pos>
   baseLines: Array<Pos[]>

+ 31 - 40
src/store/sync.ts

@@ -14,22 +14,7 @@ import {baseURL} from "@/dbo/local";
 
 const global = window as any;
 
-global.getImageCallback = () => {
-  console.log("原始getImageCallback");
-};
-global.getSceneStoreCallback = () => {
-  console.log("原始getSceneStoreCallback");
-};
-global.setSceneStoreCallback = () => {
-  console.log("原始setSceneStoreCallback");
-};
-global.uploadImageCallback = () => {
-  console.log("原始uploadImageCallback");
-};
-global.downloadImageCallback = () => {
-  console.log("原始downloadImageCallback");
-};
-
+let count = 0;
 export const api =
   import.meta.env.DEV && !global.android
     ? // const api = import.meta.env.DEV
@@ -52,6 +37,7 @@ export const api =
         },
         async downloadImage(file) {
           window.open(URL.createObjectURL(file));
+          return true;
         },
         async getFile(url) {
           if (url.includes(baseURL)) {
@@ -60,7 +46,6 @@ export const api =
           url = url.trim();
           const data = await axios.get(url, { responseType: "blob" });
           const base64 = await blobToBase64(data.data);
-          console.log("请求url:" + url, "返回:" + base64.substring(0, 20))
           return base64
         },
         async closePage() {
@@ -68,23 +53,18 @@ export const api =
         },
       }
     : {
-        // async setStore(data) {
-        //   return axios.post("sceneStore", data)
-        // },
-        // async getStore() {
-        //   return (await axios.get("/attach/sceneStore")).data
-        // },
         setStore(data) {
           return new Promise((resolve) => {
             console.log("调用setSceneStore参数", JSON.stringify(data));
-            global.android.setSceneStore(
-              params.m + "/store.json",
-              JSON.stringify(data)
-            );
             global.setSceneStoreCallback = (data) => {
               console.log("setSceneStoreCallback返回", data);
               resolve(data);
             };
+            global.android.setSceneStore(
+              params.m + "/store.json",
+              JSON.stringify(data),
+              "setSceneStoreCallback"
+            );
           });
         },
         getStore() {
@@ -94,24 +74,26 @@ export const api =
               console.log("getSceneStoreCallback返回", data);
               resolve(data);
             };
-            global.android.getSceneStore(params.m + "/store.json");
+            global.android.getSceneStore(params.m + "/store.json", "getSceneStoreCallback");
           });
         },
         getFile(fileUrl: string) {
           fileUrl = fileUrl.trim();
           if (import.meta.env.DEV) {
             return new Promise<string>((resolve) => {
-              global.getImageCallback = (base64) => {
-                console.error("getImageCallback返回");
-                // console.error("getFile", fileUrl, base64)
+              const apiName = `getImageCallback${count++}`
+              global[apiName] = (base64) => {
+                console.error("请求url:" + fileUrl, "返回:" + base64.substring(0, 60))
                 resolve(base64);
+                delete global[apiName]
               };
+              console.error("请求原始url:" + fileUrl)
               if (fileUrl.includes(params.m)) {
                 fileUrl = fileUrl.substring(fileUrl.indexOf(params.m) + params.m.length)
               }
               fileUrl = new URL(fileUrl, "http://www.a.com").pathname
-              global.android.getImage(params.m + fileUrl);
-              console.log(global, global.getImageCallback);
+              console.error("处理后url:" + fileUrl)
+              global.android.getImage(params.m + fileUrl, apiName);
             });
           } else {
             return Promise.resolve(fileUrl);
@@ -119,28 +101,35 @@ export const api =
         },
         uploadImage(file: File) {
           return new Promise<string>(async (resolve) => {
-            global.uploadImageCallback = (data) => {
+            const apiName = `uploadImageCallback${count++}`
+            global[apiName] = (data) => {
               console.log("上传图片成功,返回路径为:", data)
               resolve(data);
+              delete global[apiName]
             }
             const data = await blobToBase64(file);
             // console.log("上传图片", params.m + "/" + file.name, "参数:", data);
-            global.android.uploadImage(params.m + "/" + file.name, data);
+            global.android.uploadImage(params.m + "/" + file.name, data, apiName);
           });
         },
         downloadImage(file: File) {
-          return new Promise(async (resolve) => {
-            global.downloadImageCallback = resolve;
+          return new Promise<boolean>(async (resolve) => {
+            const apiName = `downloadImageCallback${count++}`
+            global[apiName] = () => {
+              console.log("已成功下载")
+              resolve(true);
+              delete global[apiName]
+            }
             const data = await blobToBase64(file);
             // file为base64
             console.log("下载图片", file.name);
-            global.android.downloadImage(file.name, data);
+            global.android.downloadImage(file.name, data, apiName);
           });
         },
         closePage() {
           return new Promise((resolve) => {
             global.closeWebViewCallback = resolve;
-            global.android.closeWebView();
+            global.android.closeWebView('closeWebViewCallback');
           });
         },
       };
@@ -182,7 +171,9 @@ export const downloadImage = async (
       ? (await axios.get(data, { responseType: "blob" })).data
       : data;
   const file = new File([blob], name, { type: "image/jpeg" });
-  await api.downloadImage(file);
+
+
+  return await api.downloadImage(file);
 };
 
 const syncSceneStore = () => {

+ 2 - 2
src/views/accidents/print.vue

@@ -54,8 +54,8 @@ const saveHandler = async () => {
   const blob = await new Promise<Blob>(
     resolve => canvas.toBlob(resolve, "image/jpeg", 0.95)
   )
-  await downloadImage(blob)
-  const hide = Message.success({ msg: "照片已生成" })
+  const success = await downloadImage(blob)
+  const hide = Message.success({ msg: success  ? "照片已生成" : "照片生成失败" })
   setTimeout(() => {
     hide()
     back()

+ 1 - 1
src/views/graphic/geos/arrow.vue

@@ -27,7 +27,7 @@ const props = defineProps<{geo: FocusVector}>()
 const vector = computed(() => dataService.getLine(props.geo.vectorId))
 const color = ref("#000000")
 useChange(() => {
-  color.value = vector.value.arrowColor
+  color.value = vector.value.color
 })
 
 

+ 17 - 17
src/views/graphic/menus.ts

@@ -124,23 +124,23 @@ export const mainMenusRaw: MenusRaw = [
 ];
 
 if (import.meta.env.DEV) {
-  // mainMenusRaw.unshift(
-  //   { key: UIType.CurveRoad, text: "弯路" }
-  // )
-  // mainMenusRaw.splice(1, 0, {
-  //   key: UITypeExtend.road,
-  //   text: "道路",
-  //   children: [
-  //     { key: UIType.OneEdgeOneLanRoad, text: "单向单车道直路" },
-  //     { key: UIType.OneEdgeTwoLanRoad, text: "单向双车道直路" },
-  //     { key: UIType.OneEdgeThreeLanRoad, text: "单向三车道直路" },
-  //     { key: UIType.TwoEdgeOneLanRoad, text: "双向单车道直路" },
-  //     { key: UIType.TwoEdgeTwoLanRoad, text: "双向双车道直路" },
-  //     { key: UIType.TwoEdgeThreeLanRoad, text: "双向三车道直路" },
-  //     { key: UITypeExtend.structure, text: "道路结构", extend: structureMenusRaw },
-  //     { key: UITypeExtend.template, text: "道路模板", extend: templateMenusRaw },
-  //   ]
-  // },)
+  mainMenusRaw.unshift(
+    { key: UIType.CurveRoad, text: "弯路" }
+  )
+  mainMenusRaw.splice(1, 0, {
+    key: UITypeExtend.road,
+    text: "道路",
+    children: [
+      { key: UIType.OneEdgeOneLanRoad, text: "单向单车道直路" },
+      { key: UIType.OneEdgeTwoLanRoad, text: "单向双车道直路" },
+      { key: UIType.OneEdgeThreeLanRoad, text: "单向三车道直路" },
+      { key: UIType.TwoEdgeOneLanRoad, text: "双向单车道直路" },
+      { key: UIType.TwoEdgeTwoLanRoad, text: "双向双车道直路" },
+      { key: UIType.TwoEdgeThreeLanRoad, text: "双向三车道直路" },
+      { key: UITypeExtend.structure, text: "道路结构", extend: structureMenusRaw },
+      { key: UITypeExtend.template, text: "道路模板", extend: templateMenusRaw },
+    ]
+  },)
 }
 
 export const photoMenusRaw: MenusRaw = [

+ 9 - 3
src/views/scene/photo.vue

@@ -58,7 +58,6 @@ const photo = genUseLoading(async () => {
     dom.offsetHeight
   )
   const {dataUrl: base64} = await data.finishPromise
-  console.log(data)
   const blob = base64ToBlob(base64)
   tempPhoto.value = URL.createObjectURL(blob)
 
@@ -79,8 +78,15 @@ const photo = genUseLoading(async () => {
       time: new Date().getTime(),
       meterPerPixel: data.meterPerPixel,
       measures: list.value
-        .map(data => getCurrentScreens(data.points))
-        .filter(poss => poss.length),
+        .map(data => {
+          const pos = getCurrentScreens(data.points)
+          if (pos.length) {
+            return { pos, dis: sdk.carry.measureMap.get(data).getDistance().value }
+          } else {
+            return null
+          }
+        })
+        .filter(poss => poss),
       baseLines: baseLines.value
         .map(data => getCurrentScreens(data.points))
         .filter(poss => poss.length),