소스 검색

1. 显示至最底层
2. 刷新全部节点数据

MaiXinRong 1 주 전
부모
커밋
b5a8917abf
3개의 변경된 파일84개의 추가작업 그리고 6개의 파일을 삭제
  1. 38 6
      app/controller/quality_controller.js
  2. 45 0
      app/public/js/quality_info.js
  3. 1 0
      app/router.js

+ 38 - 6
app/controller/quality_controller.js

@@ -307,15 +307,19 @@ module.exports = app => {
                 default: throw '未知数据类型';
             }
         }
+        async _load(data) {
+            if (!data.filter) throw '参数错误';
+            const filter = data.filter.split(';');
+            const result = {};
+            for (const f of filter) {
+                result[f] = await this._loadData(f, data, result);
+            }
+            return result;
+        }
         async load(ctx) {
             try {
                 const data = JSON.parse(ctx.request.body.data);
-                if (!data.filter) throw '参数错误';
-                const filter = data.filter.split(';');
-                const result = {};
-                for (const f of filter) {
-                    result[f] = await this._loadData(f, data, result);
-                }
+                const result = await this._load(data);
                 ctx.body = { err: 0, msg: '', data: result };
             } catch (err) {
                 ctx.log(err);
@@ -531,6 +535,34 @@ module.exports = app => {
             }
         }
 
+
+        async _forceRefreshStatus() {
+            const qualities = await this.ctx.service.quality.getAllDataByCondition({ where: { tid: this.ctx.tender.id } });
+            for (const q of qualities) {
+                await this.ctx.service.quality.loadQualityDetail(q);
+                await this.ctx.service.quality.checkQualityStatusAndSave(q);
+            }
+        }
+        async force(ctx) {
+            try {
+                if (!ctx.subProject.page_show.quality) throw '该功能已关闭';
+                const data = JSON.parse(ctx.request.body.data);
+                if (!data.type) throw '参数错误';
+                switch (data.type) {
+                    case 'all':
+                        await this._forceRefreshStatus();
+                        break;
+                    default: throw '参数错误';
+                }
+                const result = data.load ? this._load(data.load) : {};
+                ctx.body = { err: 0, msg: '', data: result };
+            } catch (err) {
+                console.log(err);
+                ctx.log(err);
+                ctx.ajaxErrorBody(err, '操作失败');
+            }
+        }
+
         /**
          * 变更管理 页面 (Get)
          *

+ 45 - 0
app/public/js/quality_info.js

@@ -902,6 +902,15 @@ $(document).ready(() => {
             }
             this.refreshQuality();
         }
+        forceRefresh(node) {
+            this.node = node;
+            if (node.quality) {
+                node.gxby_status = node.quality.gxby_status;
+                node.gxby_date = node.quality.gxby_date;
+                node.dagl_status = node.quality.dagl_status;
+            }
+            this.refreshQuality();
+        }
     }
     const qualityObj = new Quality();
 
@@ -920,6 +929,42 @@ $(document).ready(() => {
             return target.hitTestType === spreadNS.SheetArea.viewport || target.hitTestType === spreadNS.SheetArea.rowHeader;
         },
         items: {
+            showLast: {
+                name: '显示至最底层',
+                callback: function (key, opt, menu, e) {
+                    const node = SpreadJsObj.getSelectObject(xmjSheet);
+                    if (!node) return;
+
+                    setTimeout(() => {
+                        showWaitingView();
+                        xmjTree.expandByCustom(x => {
+                            return x.expanded || (x.id === node.id) || (x.full_path.indexOf(node.ledger_id + '-') >= 0);
+                        });
+                        SpreadJsObj.refreshTreeRowVisible(xmjSheet);
+                        closeWaitingView();
+                    }, 100);
+                },
+                disabled: function (key, opt) {
+                    const node = SpreadJsObj.getSelectObject(xmjSheet);
+                    return !node;
+                }
+            },
+            refreshSpr: '----',
+            forceRefresh: {
+                name: '刷新全部节点数据',
+                callback: function(key, opt, menu, e) {
+                    const data = { type: 'all' };
+                    const node = SpreadJsObj.getSelectObject(xmjSheet);
+                    if (node) data.load = { filter: 'detail', rela_type: node.rela_type, rela_id: node.rela_id, rela_name: node.rela_name,};
+                    postData('force', data, function(result) {
+                        if (node) {
+                            node.quality = result.detail;
+                            qualityObj.forceRefresh(node);
+                        }
+                    });
+                }
+            },
+            pushSpr: '----',
             pushInc: {
                 name: '推送状态',
                 callback: function (key, opt, menu, e) {

+ 1 - 0
app/router.js

@@ -485,6 +485,7 @@ module.exports = app => {
     app.post('/sp/:id/quality/tender/:tid/file/del', sessionAuth, subProjectCheck, tenderCheck, tenderPermissionCheck, 'qualityController.delFile');
     app.post('/sp/:id/quality/tender/:tid/file/save', sessionAuth, subProjectCheck, tenderCheck, tenderPermissionCheck, 'qualityController.saveFile');
     app.post('/sp/:id/quality/tender/:tid/push', sessionAuth, subProjectCheck, tenderCheck, tenderPermissionCheck, 'qualityController.pushStatus');
+    app.post('/sp/:id/quality/tender/:tid/force', sessionAuth, subProjectCheck, tenderCheck, tenderPermissionCheck, 'qualityController.force');
     app.get('/sp/:id/quality/rule', sessionAuth, subProjectCheck, projectManagerCheck, 'qualityController.rule');
     app.post('/sp/:id/quality/rule/save', sessionAuth, subProjectCheck, projectManagerCheck, 'qualityController.ruleSave');
     app.post('/sp/:id/quality/tender/:tid/rule/save', sessionAuth, subProjectCheck, tenderCheck, projectManagerCheck, 'qualityController.ruleSave');