Explorar o código

书签bug修改

lkk hai 11 meses
pai
achega
b3cdb6f5eb
Modificáronse 1 ficheiros con 47 adicións e 21 borrados
  1. 47 21
      src/components/Bookmark/Bookmark.vue

+ 47 - 21
src/components/Bookmark/Bookmark.vue

@@ -62,7 +62,14 @@
       >
       </el-pagination>
     </div>
-    <el-dialog title="书签信息" :visible.sync="dialogVisible" width="300px">
+    <el-dialog
+      title="书签信息"
+      :visible.sync="dialogVisible"
+      width="300px"
+      :modal-append-to-body="false"
+      :close-on-click-modal="false"
+      :before-close="handleClose"
+    >
       <el-form ref="form" :model="form" label-width="80px" :rules="rules">
         <el-form-item label="书签名称" prop="name">
           <el-input v-model="form.name"></el-input>
@@ -70,7 +77,7 @@
         <el-button type="primary" size="mini" @click="onSubmit('form')"
           >保存</el-button
         >
-        <el-button size="mini" @click="dialogVisible = false">取消</el-button>
+        <el-button size="mini" @click="closeBook('form')">取消</el-button>
       </el-form>
     </el-dialog>
   </div>
@@ -158,27 +165,46 @@ export default {
     },
     onSubmit(item) {
       this.$refs[item].validate((valid) => {
-        let param = JSON.stringify({
-          camera: JSON.stringify({
-            position: viewer.camera.position,
-            heading: viewer.camera.heading,
-            roll: viewer.camera.roll,
-            pitch: viewer.camera.pitch,
-          }),
-          name: this.form.name,
-        });
-        this.form.info = param;
-        BookmarkAdd(this.form).then((res) => {
-          if (res.statuscode == 200) {
-            this.$message.success(res.message);
-            this.dialogVisible = false;
-            this.bookmarkquery();
-          } else {
-            this.$message.error(res.message);
-          }
-        });
+        if (valid) {
+          let param = JSON.stringify({
+            camera: JSON.stringify({
+              position: viewer.camera.position,
+              heading: viewer.camera.heading,
+              roll: viewer.camera.roll,
+              pitch: viewer.camera.pitch,
+            }),
+            name: this.form.name,
+          });
+          this.form.info = param;
+          BookmarkAdd(this.form).then((res) => {
+            if (res.statuscode == 200) {
+              this.$message.success(res.message);
+              this.dialogVisible = false;
+              this.form = {
+                name: "",
+                type: "bookmark",
+                info: "",
+              };
+              this.bookmarkquery();
+            } else {
+              this.$message.error(res.message);
+            }
+          });
+        }
       });
     },
+    closeBook(item) {
+      this.$refs[item].resetFields();
+      this.dialogVisible = false;
+      this.form = {
+        name: "",
+        type: "bookmark",
+        info: "",
+      };
+    },
+    handleClose() {
+      this.closeBook("form");
+    },
     clear() {
       viewer.entities.removeAll();
       this.bookmarkSearchText = "";