瀏覽代碼

feat: 清单指引库,清单下有内容时,名称变绿

vian 3 年之前
父節點
當前提交
1a3bca10fb

+ 2 - 2
modules/ration_repository/models/ration_item.js

@@ -298,7 +298,7 @@ rationItemDAO.prototype.getRationItemsByLib = async function (rationRepId, showH
         return [];
     }
     let startDate = new Date();
-    let rations = await rationItemModel.find({rationRepId: rationRepId}, returnFields);
+    let rations = await rationItemModel.find({rationRepId: rationRepId}, returnFields).lean();
     console.log(`Date: ${new Date() - startDate}====================================`);
     if(!showHint){
         return rations;
@@ -343,7 +343,7 @@ rationItemDAO.prototype.getRationItemsByLib = async function (rationRepId, showH
                 hintsArr.push(`附注:`);
                 hintsArr = hintsArr.concat(ration.annotation.split('\n'));
             }
-            ration._doc.hint = hintsArr.join('<br>');
+            ration.hint = hintsArr.join('<br>');
         }
         return rations;
     }

+ 12 - 1
modules/std_billsGuidance_lib/facade/facades.js

@@ -278,7 +278,18 @@ async function getLibWithBills(libID){
     if(!billsLib){
         throw '引用的清单规则库不存在!';
     }
-    let bills = await stdBillsModel.find({billsLibId: billsLib.billsLibId}, '-_id code name ID NextSiblingID ParentID jobs items comment');
+    let bills = await stdBillsModel.find({billsLibId: billsLib.billsLibId}, '-_id code name ID NextSiblingID ParentID jobs items comment').lean();
+    const guideItems = await billsGuideItemsModel.find({ libID: guidanceLib[0].ID }, '-_id billsID').lean();
+    const billsMap = {};
+    for (const item of guideItems) {
+        billsMap[item.billsID] = true;
+    }
+    for (const item of bills) {
+        if (billsMap[item.ID]) {
+            item.hasGuide = true;
+        }
+    }
+    
     return {guidanceLib: guidanceLib[0], bills};
 }
 

+ 19 - 0
web/maintain/billsGuidance_lib/js/billsGuidance.js

@@ -850,6 +850,16 @@ const billsGuidance = (function () {
             })
         });
     }
+    // 设置清单名称文本色
+    function setBillsForeColor(billsNodes) {
+        const sheet = bills.workBook.getActiveSheet();
+        renderSheetFunc(sheet, function () {
+            for(let bills of billsNodes){
+                const row = bills.serialNo();
+                sheet.setStyle(row, 1, { foreColor: bills.data.hasGuide ? 'darkgreen' : 'black' });
+            }
+        });
+    }
     //清单设置悬浮提示信息
     //@param {Array}billsNodes(清单节点) {Array}jobs(总的工作内容数据) {Array}items(总的项目特征数据)
     function setBillsHint(billsNodes, jobs, items) {
@@ -973,6 +983,7 @@ const billsGuidance = (function () {
         module.controller.showTreeData();
         if(module === bills){
             setBillsHint(bills.tree.items, stdBillsJobData, stdBillsFeatureData);
+            setBillsForeColor(bills.tree.items);
         }
     }
     //更新清单备注
@@ -1091,6 +1102,10 @@ const billsGuidance = (function () {
                     refreshBtn(newNode);
                 }
             }
+            if (!bills.tree.selected.data.hasGuide && bills.tree.selected.guidance.tree.items.length) {
+                bills.tree.selected.data.hasGuide = true;
+                setBillsForeColor([bills.tree.selected]);
+            }
             if(callback){
                 callback();
             }
@@ -1183,6 +1198,10 @@ const billsGuidance = (function () {
             refreshBtn(bills.tree.selected.guidance.tree.selected);
             setNodesColor(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
             showCheckBox(guideItem.workBook.getActiveSheet(), bills.tree.selected.guidance.tree.items);
+            if (bills.tree.selected.data.hasGuide && !bills.tree.selected.guidance.tree.items.length) {
+                bills.tree.selected.data.hasGuide = false;
+                setBillsForeColor([bills.tree.selected]);
+            }
             $.bootstrapLoading.end();
             guideItem.workBook.focus(true)
         });