瀏覽代碼

工料机汇总单价文件同步修改

olym 8 年之前
父節點
當前提交
383b28e750

+ 0 - 1
web/building_saas/glj/html/glj_index.html

@@ -97,7 +97,6 @@
 </div>
 <script type="text/javascript" src="/web/building_saas/glj/js/project_glj.js"></script>
 <script type="text/javascript" src="/web/building_saas/glj/js/composition.js"></script>
-<script type="text/javascript" src="/web/building_saas/glj/js/socket.js"></script>
 <script type="text/javascript" src="/web/building_saas/glj/js/common_spread.js"></script>
 <script type="text/javascript" src="/web/building_saas/glj/js/composition_spread.js"></script>
 <script type="text/javascript" src="/web/building_saas/glj/js/project_glj_spread.js"></script>

+ 38 - 11
web/building_saas/glj/js/project_glj.js

@@ -142,16 +142,14 @@ $(document).ready(function () {
     });
 
     // 是否主动更改数据
-    // $("#message").on('click', '#load-data', function() {
-    //     $("#notify").slideUp('fast');
-    //     if (changeInfo.length > 0) {
-    //         for (let index in changeInfo) {
-    //             let cell = gljSheet.getCell(changeInfo[index].row, changeInfo[index].col, GC.Spread.Sheets.SheetArea.viewport);
-    //             cell.value(changeInfo[index].newValue);
-    //         }
-    //     }
-    //     changeInfo = [];
-    // });
+    $("#message").on('click', '#load-data', function() {
+        $("#message").html('正在加载...');
+        // 重新加载数据到缓存
+        projectObj.project.projectGLJ.loadData(function() {
+            projectObj.project.projectGLJ.loadCacheData();
+            $("#notify").slideUp('fast');
+        });
+    });
 });
 
 /**
@@ -180,6 +178,9 @@ function init() {
     usedUnitPriceInfo = data.constData.usedUnitPriceInfo !== undefined ?
         data.constData.usedUnitPriceInfo : {};
 
+    // 连接socket服务器
+    socketInit();
+
     unitPriceFileInit(usedUnitPriceInfo.name, usedTenderList);
 
     setTimeout(spreadInit, 1);
@@ -261,6 +262,7 @@ function successTrigger(field, info) {
 
             // 触发websocket通知
             socket.emit('dataNotify', JSON.stringify(info));
+            console.log(info);
             break;
     }
     // 重新加载数据到缓存
@@ -268,4 +270,29 @@ function successTrigger(field, info) {
 
     // 更新定额工料机
     gljOprObj.refreshView();
-}
+}
+
+/**
+ * socket.io相关初始化
+ *
+ * @return {void}
+ */
+function socketInit() {
+    if (socket === null) {
+        socket = io('http://'+ host +':3300');
+        socket.on('connect', function () {
+            socket.emit('join', roomId);
+            console.log('单价文件同步连接成功');
+        });
+    }
+
+    // 接收到改变
+    socket.on('dataChange', function(data) {
+        data = JSON.parse(data);
+        if (data.newValue === undefined) {
+            return false;
+        }
+        $("#message").html('市场单位已被修改,<a href="javascript:void(0);" id="load-data">点击加载</a>');
+        $("#notify").slideDown('fast');
+    });
+}

+ 1 - 1
web/building_saas/js/message.js

@@ -142,7 +142,7 @@ $(document).ready(function() {
  * @return {void}
  */
 function changeNumByStep(step) {
-    let messageElement = $("#message");
+    let messageElement = $("#notify-info");
     let unreadElement = $("#unread-num");
     if (step === 0) {
         messageElement.removeClass('new-msg');

+ 7 - 1
web/building_saas/main/js/models/project_glj.js

@@ -13,9 +13,10 @@ function ProjectGLJ() {
 /**
  * 加载数据
  *
+ * @param {function} callback
  * @return {boolean}
  */
-ProjectGLJ.prototype.loadData = function () {
+ProjectGLJ.prototype.loadData = function (callback = null) {
     let self = this;
     if (self.isLoading) {
         return false;
@@ -40,6 +41,10 @@ ProjectGLJ.prototype.loadData = function () {
                 return false;
             }
             self.datas = response.data;
+            // 回调函数
+            if (callback !== null) {
+                callback(response.data);
+            }
             // 存入缓存
             projectObj.project.projectGLJ = self;
         }
@@ -129,4 +134,5 @@ ProjectGLJ.prototype.loadCacheData = function() {
     }
     jsonData = data.gljList !== undefined && data.gljList.length > 0 ? data.gljList : [];
     projectGLJSheet.setData(jsonData);
+    projectGLJSpread.specialColumn(jsonData);
 };

+ 1 - 1
web/common/html/header.html

@@ -14,7 +14,7 @@
                 <a class="dropdown-item" href="/user/preferences" target="_blank">偏好设置</a>
             </div>
         </div>
-        <a class="btn btn-link btn-sm <% if (unreadCount > 0) { %>new-msg<% } %>" id="message" data-toggle="modal" data-target="#msg" href="javacript:void(0);">
+        <a class="btn btn-link btn-sm <% if (unreadCount > 0) { %>new-msg<% } %>" id="notify-info" data-toggle="modal" data-target="#msg" href="javacript:void(0);">
             <i class="fa fa-envelope-o" aria-hidden="true"></i>&nbsp;<span id="unread-num"><%= unreadCount %></span>
         </a>
         <a class="btn btn-link btn-sm" href="/logout">注销</a>