Browse Source

修改boardFactory为异步

bill 1 year ago
parent
commit
44fcb243fe

+ 1 - 1
src/view/case/caseFile.vue

@@ -35,7 +35,7 @@
             v-model="row.filesTitle"
             placeholder="请输入文件名"
             focus
-            :maxleng="50"
+            :maxlength="50"
             style="width: 280px"
           >
             <template #append>

+ 2 - 2
src/view/case/draw/board/editCAD/Layer.js

@@ -57,10 +57,10 @@ export default class Layer {
     this.canvas = canvas;
     draw.initContext(this.canvas);
     this.bindEvents();
-    this.load.load(vectorData).then(() => {
+    return this.load.load(vectorData).then(() => {
       //。。。
       this.renderer.autoRedraw();
-    })
+    });
   }
 
   bindEvents() {

+ 2 - 3
src/view/case/draw/board/index.js

@@ -11,7 +11,7 @@ import { uploadFile } from "@/store/system";
 //   }
 // }
 
-export const create = (store, canvas) => {
+export const create = async (store, canvas) => {
   const refs = {
     ctx: canvas.getContext("2d"),
     bus: mitt(),
@@ -20,8 +20,7 @@ export const create = (store, canvas) => {
   };
 
   const layer = new Layer();
-  console.log(store);
-  layer.start(canvas, store);
+  await layer.start(canvas, store);
   layer.uiControl.bus.on("showAttribute", ({ type, value: data }) => {
     const shape = {
       data: { type },

+ 26 - 26
src/view/case/draw/board/useBoard.ts

@@ -105,9 +105,34 @@ export const useBoard = (props: Ref<BoardProps | null>) => {
       props.value.fileId,
       props.value.type
     );
-    const boardRaw = (board.value = boardFactory(store, props.value.dom));
+    const boardRaw = (board.value = await boardFactory(store, props.value.dom));
   });
 
+  watchEffect(
+    () => {
+      if (!props.value || !board.value) {
+        return;
+      }
+      if (props.value.fileId === -1) {
+        board.value
+          .calcTableShape([
+            ["案发时间", ""],
+            ["案发地点", ""],
+            ["绘图单位", ""],
+            ["绘图人", ""],
+            ["绘图时间", ""],
+          ])
+          .then((data) => {
+            board.value!.setDefaultTable(data.content, null);
+            board.value!.initHistory();
+          });
+      } else {
+        board.value.initHistory();
+      }
+    },
+    { flush: "post" }
+  );
+
   watchEffect((onCleanup) => {
     if (!board.value) {
       return;
@@ -152,31 +177,6 @@ export const useBoard = (props: Ref<BoardProps | null>) => {
     }
   });
 
-  watchEffect(
-    () => {
-      if (!props.value || !board.value) {
-        return;
-      }
-      if (props.value.fileId === -1) {
-        board.value
-          .calcTableShape([
-            ["案发时间", ""],
-            ["案发地点", ""],
-            ["绘图单位", ""],
-            ["绘图人", ""],
-            ["绘图时间", ""],
-          ])
-          .then((data) => {
-            board.value!.setDefaultTable(data.content, null);
-            board.value!.initHistory();
-          });
-      } else {
-        board.value.initHistory();
-      }
-    },
-    { flush: "post" }
-  );
-
   return {
     board,
     state,