lsc пре 2 година
родитељ
комит
bfb3348935
2 измењених фајлова са 78 додато и 12 уклоњено
  1. 77 12
      src/components/pages/Grid.vue
  2. 1 0
      src/config/config.js

+ 77 - 12
src/components/pages/Grid.vue

@@ -329,10 +329,12 @@ export default {
 
       var src = newItems[this.dragging]; //获取数组下标
       var dst = newItems[this.draggingE];
-      newItems[this.dragging] = dst;
-      newItems[this.draggingE] = src;
-      // newItems2.splice(dst, 0, ...newItems.splice(src, 1)); //交换位置
-      this.data = newItems;
+      // newItems[this.dragging] = dst;
+      // newItems[this.draggingE] = src;
+      // // newItems2.splice(dst, 0, ...newItems.splice(src, 1)); //交换位置
+      // this.data = newItems;
+      this.data[this.dragging] = dst;
+      this.data[this.draggingE] = src;
       this.updateRoomData();
       this.dragging = null; //拖动结束后,清除数据
       this.draggingE = null;
@@ -550,6 +552,15 @@ export default {
         }
       }
 
+      let mindinfo = this.mindInfo(
+        this.gIndex,
+        "us.mindNetwork",
+        this.data[this.gIndex],
+        "",
+        this.userinfo ? this.userinfo.userid : this.userid,
+        this.RoomInfo.id
+      );
+      this.updateSocket(this.mindInfo);
       this.updateRoomData();
       this.dialogVisible = false;
       this.$forceUpdate();
@@ -717,9 +728,9 @@ export default {
             this.dialogVisible2 = true;
             // this.data.splice(0,1)
             // this.updateRoomData()
-            this.timer = setInterval(() => {
-              this.selectRoom2(uid);
-            }, 5000);
+            // this.timer = setInterval(() => {
+            //   this.selectRoom2(uid);
+            // }, 5000);
           } else {
             // this.$message.error("此房间不存在或已被解散");
           }
@@ -741,9 +752,9 @@ export default {
             this.data = JSON.parse(res.data[0][0].data);
             this.dialogVisible3 = false;
             this.dialogVisible2 = true;
-            this.timer = setInterval(() => {
-              this.selectRoom2(uid);
-            }, 5000);
+            // this.timer = setInterval(() => {
+            //   this.selectRoom2(uid);
+            // }, 5000);
           } else {
             this.$message.error("此房间不存在或已被解散");
           }
@@ -790,17 +801,71 @@ export default {
         })
         .catch(() => {});
     },
+
+    /*
+     * mind 消息类
+     * 参数一 : 第几个网格
+     * 参数二 :  type 操作类型
+     * 参数三 : content 行内容
+     * 参数四 : next 下一行
+     */
+    mindInfo(id, type, content, next, navid, userid, roomid) {
+      var _data = {
+        sendId: userid, //发送人id
+        receiveId: roomid, //文件id
+        //type: navid ? 'us.nav' : 'us.word',    //消息类型
+        messageInfo: {
+          id: id, //操作ID
+          type: type, //类型
+          content: content, //内容
+          docId: roomid, //文档id
+          // pageId: US.pageId, //当前页面id
+        },
+      };
+      return _data;
+    },
+    updateSocket(mindinfo) {
+      let params = [
+        {
+          type: "send",
+          mindinfo: JSON.stringify(mindinfo),
+        },
+      ];
+      this.ajax
+        .post(this.$store.state.soket, params)
+        .then((res) => {
+          console.log(res);
+        })
+        .catch((err) => {
+          console.error(err);
+        });
+    },
   },
   beforeDestroy() {
-    clearInterval(this.timer);
+    // clearInterval(this.timer);
+    window.removeEventListener("message");
   },
   created() {
+    // window.parent.postMessage({ cid: cid, type: "U.MD.O.P.pollingAsyn" }, "*");
     for (var i = 0; i < 16; i++) {
       this.data.push("");
     }
     this.data.push("");
     this.getUser();
-    // this.selectRoom(this.userid);
+    window.addEventListener("message", function (e) {
+      // 监听 message 事件
+      if (e.data.type && e.data.type == "mindNetwork_update") {
+        this.data[e.data.idnex] = e.data.data;
+      } else if (e.data.close && e.data.type == "mindNetwork_delete") {
+        // e.data.info
+        this.data.splice(e.data.index, 1);
+      } else if (e.data.close && e.data.type == "mindNetwork_move") {
+        var newItems = [...JSON.parse(JSON.stringify(this.data))]; //拷贝一份数据进行交换操作。
+        this.data[e.data.moveIndex1] = newItems[e.data.moveIndex2];
+        this.data[e.data.moveIndex2] = newItems[e.data.moveIndex1];
+      }
+      this.$forceUpdate();
+    });
   },
 };
 </script>

+ 1 - 0
src/config/config.js

@@ -10,6 +10,7 @@ const store = new Vuex.Store({
         userInfo: {},
         nCount: 0,
         api: 'https://pbl.cocorobo.cn/api/pbl/',
+        socket: "http://poll.cocorobo.cn",
         // api: 'http://localhost:7003/api/pbl/',
     },