ソースを参照

'添加画布跳转编辑页'

zhangyu 4 年 前
コミット
5c02892c4a
1 ファイル変更40 行追加17 行削除
  1. 40 17
      src/components/homeView/createPlanarDialog.vue

+ 40 - 17
src/components/homeView/createPlanarDialog.vue

@@ -12,6 +12,7 @@
             <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm" label-position="top">
                 <el-form-item label="所属楼层" prop="buildFloor">
                     <el-cascader
+                        ref="buildFloor"
                         style="width: 260px"
                         v-model="ruleForm.buildFloor"
                         :options="buildFloorData"
@@ -94,6 +95,8 @@ export default {
                 label: "localName",
                 children: "floor",
             },
+            floorName: "",
+            folderName: "",
             value: [],
             outerVisible: false,
             dynamicTags: [],
@@ -178,37 +181,57 @@ export default {
         },
         // 创建平面图接口
         async createPlan() {
+            /**
+             * 是否选中已有的文件夹对象
+             * folder(undefind/folder对象)
+             */
+            const folder = this.folderData.find((folder) => {
+                return folder.id === this.ruleForm.folder;
+            });
+            const floorNode = this.$refs.buildFloor.getCheckedNodes()[0];
+            const buildingId = this.ruleForm.buildFloor[0];
+            const floorId = this.ruleForm.buildFloor[1];
+            const floorName = floorNode.label;
+            const floorMap = floorNode.data.info && floorNode.data.info.floorMap ? floorNode.data.info.floorMap : "";
+            const folderName = folder ? folder.name : this.ruleForm.folder;
             const params = {
                 name: this.ruleForm.name,
-                buildingId: this.ruleForm.buildFloor[0],
-                floorId: this.ruleForm.buildFloor[1],
+                buildingId,
+                floorId,
             };
+
             // 判断是否添加标签字段
             if (this.dynamicTags.length) params.label = this.dynamicTags;
             // 判断是否新建文件夹
-            if (
-                this.folderData.find((folder) => {
-                    return folder.id === this.ruleForm.folder;
-                })
-            ) {
+            if (folder) {
                 params.folderId = this.ruleForm.folder;
             } else {
                 params.folderName = this.ruleForm.folder;
             }
-            console.log(params);
             const res = await planarCreate(params);
             if (res.result === "success" && res.entityList.length) {
-                /**
-                 * 新建画布成功后需跳转到编辑页(未实现)
-                 */
-                console.error("未实现跳转到编辑页需后续添加。。。", res);
-
-                this.$emit("createPlanar", {
-                    folderId: res.entityList[0].folderId,
-                    folderName: res.entityList[0].folderName,
-                });
+                const entity = res.entityList[0];
+                // this.$emit("createPlanar", {
+                //     folderId: entity.folderId,
+                //     folderName: entity.folderName,
+                // });
                 this.$message.success("新建画布成功!");
                 this.outerVisible = false;
+                this.$router.push({
+                    name: "Editer",
+                    query: {
+                        buildingId: entity.buildingId,
+                        floorId: entity.floorId,
+                        id: entity.id,
+                        graphId: entity.graphId,
+                        folderId: entity.folderId,
+                        name: entity.name,
+                        state: "Draft",
+                        floorMap,
+                        folderName,
+                        floorName,
+                    },
+                });
             } else {
                 this.$message.error(res.message);
             }