Browse Source

修改多人协同方式

laiguoran 4 years ago
parent
commit
55c227a405
3 changed files with 44 additions and 33 deletions
  1. 5 5
      app/controller/stage_controller.js
  2. 24 22
      app/public/js/path_tree.js
  3. 15 6
      app/public/js/stage.js

+ 5 - 5
app/controller/stage_controller.js

@@ -333,7 +333,7 @@ module.exports = app => {
                             const uid = ctx.stage.curAuditor ? ctx.stage.curAuditor.aid : ctx.stage.status === auditConst.status.uncheck ? ctx.session.sessionUser.accountId : null;
                             responseData.data.cooperation = uid !== null ? await ctx.service.ledgerCooperation.getValidData(
                                 ctx.tender.id, uid) : [];
-                            responseData.data.cooperationPwd = uid !== null ? await ctx.service.cooperationPwd.getValidData(ctx.tender.id, uid) : [];
+                            // responseData.data.cooperationPwd = uid !== null ? await ctx.service.cooperationPwd.getValidData(ctx.tender.id, uid) : [];
                             const stageTimes = (ctx.stage.status === auditConst.status.checkNo && ctx.stage.user_id !== ctx.session.sessionUser.accountId) ? ctx.stage.times - 1 : ctx.stage.times;
                             responseData.data.cooperationConfirm = uid !== null ? await ctx.service.cooperationConfirm.getValidData(ctx.tender.id, ctx.stage.id, stageTimes, uid) : [];
                             break;
@@ -1830,10 +1830,10 @@ module.exports = app => {
                         await ctx.service.cooperationConfirm.del(data.postData);
                         responseData.data.cooperationConfirm = await ctx.service.cooperationConfirm.getValidData(ctx.tender.id, ctx.stage.id, ctx.stage.times, ctx.session.sessionUser.accountId);
                         break;
-                    case 'save-pwd':
-                        const result = await ctx.service.cooperationPwd.save(data.postData);
-                        responseData.data.cooperationPwd = await ctx.service.cooperationPwd.getValidData(ctx.tender.id, ctx.session.sessionUser.accountId);
-                        break;
+                    // case 'save-pwd':
+                    //     const result = await ctx.service.cooperationPwd.save(data.postData);
+                    //     responseData.data.cooperationPwd = await ctx.service.cooperationPwd.getValidData(ctx.tender.id, ctx.session.sessionUser.accountId);
+                    //     break;
                     default:
                         throw '参数有误';
                 }

+ 24 - 22
app/public/js/path_tree.js

@@ -1167,12 +1167,14 @@ const createNewPathTree = function (type, setting) {
                 if (p) p.check = p.pwd === pwd;
             }
         }
-        loadPwd(data, cacheKey) {
+        loadPwd(data, cacheKey, confirmList) {
             this.loadingPwd = true;
             try {
                 this.pwdCacheKey = cacheKey;
+                this.confirmList = confirmList;
                 this.pwd = data;
                 this._loadPwdCache();
+                this._loadOnlineConfirm();
                 for (const p of this.pwd) {
                     p.node = this.getItems(p.ledger_id);
                     this.lockNode(p, !p.check);
@@ -1206,22 +1208,22 @@ const createNewPathTree = function (type, setting) {
                 }
             }
         }
-        loadOnlinePwd(data, pwdList, confirmList) {
-            this.loadingPwd = true;
-            try {
-                this.pwdList = pwdList;
-                this.confirmList = confirmList;
-                this.pwd = data;
-                this._loadOnlinePwd();
-                this._loadOnlineConfirm();
-                // 旧数据上传,新数据补齐
-                for (const p of this.pwd) {
-                    p.node = this.getItems(p.ledger_id);
-                    this.lockNode(p, !p.check);
-                }
-            } catch(err) {}
-            this.loadingPwd = false;
-        }
+        // loadOnlinePwd(data, pwdList, confirmList) {
+        //     this.loadingPwd = true;
+        //     try {
+        //         this.pwdList = pwdList;
+        //         this.confirmList = confirmList;
+        //         this.pwd = data;
+        //         this._loadOnlinePwd();
+        //         this._loadOnlineConfirm();
+        //         // 旧数据上传,新数据补齐
+        //         for (const p of this.pwd) {
+        //             p.node = this.getItems(p.ledger_id);
+        //             this.lockNode(p, !p.check);
+        //         }
+        //     } catch(err) {}
+        //     this.loadingPwd = false;
+        // }
 
         getStageItems(id) {
             return this.stageItems[itemsPre + id];
@@ -1411,7 +1413,7 @@ const createNewPathTree = function (type, setting) {
                 pn.lock = isLock;
                 refresh.push(this.getNodeIndex(pn));
             }
-            // if (!this.loadingPwd) this._savePwdCache();
+            if (!this.loadingPwd) this._savePwdCache();
             return refresh;
         }
     }
@@ -1642,7 +1644,7 @@ const createNewPathTree = function (type, setting) {
                 this.loadCompareNode(source, c, cur, loadFun);
             }
         }
-    
+
         generateSortNodes() {
             const self = this;
             const addSortNode = function (node) {
@@ -1656,13 +1658,13 @@ const createNewPathTree = function (type, setting) {
                 addSortNode(n);
             }
         }
-    
+
         loadCompareTree(data, loadFun) {
             for (const c of data.billsTree.children) {
                 this.loadCompareNode(data, c, null, loadFun);
             }
         }
-    
+
         calculateDiffer() {
             if (this.setting.calcDiffer) {
                 for (const d of this.datas) {
@@ -1670,7 +1672,7 @@ const createNewPathTree = function (type, setting) {
                 }
             }
         }
-    
+
         loadCompareData(data1, data2) {
             this.loadCompareTree(data1, this.setting.loadInfo1);
             this.loadCompareTree(data2, this.setting.loadInfo2);

+ 15 - 6
app/public/js/stage.js

@@ -335,7 +335,16 @@ $(document).ready(() => {
                 html.push('<td>', p.check ? `已解锁:${p.pwd}` : `<a name="ledger-unlock" lid="${p.ledger_id}" href="javascript: void(0);">解锁</a>`, '</td>');
             }
             html.push('<td>', p.company, '</td>');
-            html.push('<td>', p.check ? (p.confirm ? (moment(p.confirm_time).format('YYYY-MM-DD HH:mm') + ' ' + (coopwd ? `<a name="ledger-unconfirm" href="javascript: void(0);" lid="${p.ledger_id}">重新审批</a>` : '')) : `<a name="ledger-confirm" href="javascript: void(0);" lid="${p.ledger_id}" class="btn btn-sm btn-success">确认</a>`) : '' ,'</td>');
+            if (p.check && p.confirm) {
+                html.push('<td>', moment(p.confirm_time).format('YYYY-MM-DD HH:mm') + ' ' + (coopwd ? `<a name="ledger-unconfirm" href="javascript: void(0);" lid="${p.ledger_id}">重新审批</a>` : ''), '</td>');
+            } else if (!p.check && p.confirm) {
+                html.push('<td>', moment(p.confirm_time).format('YYYY-MM-DD HH:mm'), '</td>');
+            } else if (p.check && !p.confirm) {
+                html.push('<td>', `<a name="ledger-confirm" href="javascript: void(0);" lid="${p.ledger_id}" class="btn btn-sm btn-success">确认</a>`, '</td>');
+            } else {
+                html.push('<td>', '</td>');
+            }
+            // html.push('<td>', p.check ? (p.confirm ? (moment(p.confirm_time).format('YYYY-MM-DD HH:mm') + ' ' + (coopwd ? `<a name="ledger-unconfirm" href="javascript: void(0);" lid="${p.ledger_id}">重新审批</a>` : '')) : `<a name="ledger-confirm" href="javascript: void(0);" lid="${p.ledger_id}" class="btn btn-sm btn-success">确认</a>`) : '' ,'</td>');
             html.push('</tr>');
         }
         $('#cooperationList').html(html.join(''));
@@ -1946,8 +1955,8 @@ $(document).ready(() => {
         treeCalc.calculateAll(stageTree);
         // 加载解锁相关
         if (result.cooperation) {
-            // stageTree.loadPwd(result.cooperation, 'bills-p-' + userID + '-' + window.location.pathname.split('/')[2]);
-            stageTree.loadOnlinePwd(result.cooperation, result.cooperationPwd, result.cooperationConfirm);
+            stageTree.loadPwd(result.cooperation, 'bills-p-' + userID + '-' + window.location.pathname.split('/')[2], result.cooperationConfirm);
+            // stageTree.loadOnlinePwd(result.cooperation, result.cooperationPwd, result.cooperationConfirm);
             $('#cooperationCount').html(stageTree.pwd.length || '');
             if (stageTree.pwd.length > 0) $('#cooperationCount').parent().show();
             setCooperationSelectHtml();
@@ -4112,9 +4121,9 @@ $(document).ready(() => {
         if (p.pwd === $('#unlock-pwd').val()) {
             const refresh = stageTree.lockNode(p, false);
             // 修改线上
-            postData(window.location.pathname + '/save/cooperation', { type: 'save-pwd', postData: { ledger_id: lid, pwd: $('#unlock-pwd').val() } }, function (result) {
-                stageTree.pwdList = result.cooperationPwd;
-            });
+            // postData(window.location.pathname + '/save/cooperation', { type: 'save-pwd', postData: { ledger_id: lid, pwd: $('#unlock-pwd').val() } }, function (result) {
+            //     stageTree.pwdList = result.cooperationPwd;
+            // });
             SpreadJsObj.reloadRowsReadonly(slSpread.getActiveSheet(), refresh);
             stagePosSpreadObj.loadCurPosData();
             $('#unlock').modal('hide');