소스 검색

编办页面各个标准库的统计数据

olym 7 년 전
부모
커밋
67d7906181

+ 5 - 0
modules/users/controllers/compilation_controller.js

@@ -117,6 +117,7 @@ class CompilationController extends BaseController {
         let compilationList = [];
         let valuationData = {};
         let valuationList = {};
+        let libCount = {};
         try {
             let compilationModel = new CompilationModel();
             compilationList = await compilationModel.getCompilationList();
@@ -127,6 +128,9 @@ class CompilationController extends BaseController {
                 throw '不存在数据';
             }
 
+            // 获取计价规则中对应的标准库数据
+            let engineeringLibModel = new EngineeringLibModel();
+            libCount = await engineeringLibModel.getLibCount(valuationData);
         } catch (error) {
             console.log(error);
         }
@@ -138,6 +142,7 @@ class CompilationController extends BaseController {
             valuationData: valuationData,
             valuationList: valuationList,
             valuationId: valuationId,
+            libCount: libCount,
             section: section,
             layout: 'users/views/layout/layout'
         };

+ 46 - 0
modules/users/models/engineering_lib_model.js

@@ -163,6 +163,52 @@ class EngineeringLibModel extends BaseModel {
         return result;
     }
 
+    /**
+     * 获取对应标准库数量
+     *
+     * @param {Object} valuationData
+     * @return {Object}
+     */
+    async getLibCount(valuationData) {
+        let result = {};
+        if (valuationData.engineering_list === undefined || valuationData.engineering_list.length <= 0) {
+            return result;
+        }
+
+        // 整理需要查找的数据
+        let findIdList = [];
+        for(let engineering of valuationData.engineering_list) {
+            findIdList.push(engineering.engineering_id);
+        }
+
+        let condition = {_id: {$in: findIdList}};
+        let libData = await this.findDataByCondition(condition, null, false);
+        if (libData === null) {
+            return result;
+        }
+
+        // 整理数据
+        let countData = {};
+        for(let tmp of libData) {
+            countData[tmp._id] = {
+                bill_count: tmp.bill_lib.length,
+                ration_count: tmp.ration_lib.length,
+                glj_count: tmp.glj_lib.length,
+                fee_count: tmp.fee_lib.length,
+                artificial_count: tmp.artificial_lib.length,
+            };
+        }
+
+
+        for(let engineering of valuationData.engineering_list) {
+            if (countData[engineering.engineering_id] !== undefined) {
+                result[engineering.engineering] = countData[engineering.engineering_id];
+            }
+        }
+
+        return result;
+    }
+
 }
 
 export default EngineeringLibModel;

+ 12 - 3
web/users/views/compilation/add.html

@@ -36,6 +36,8 @@
                                 <th>标准清单</th>
                                 <th>定额库</th>
                                 <th>工料机库</th>
+                                <th>费率标准</th>
+                                <th>人工系数</th>
                                 <th>操作</th>
                             </tr>
                             </thead>
@@ -43,9 +45,16 @@
                                 <% engineeringList.forEach(function(engineering) {%>
                                 <tr>
                                     <td><%= engineering.name %></td>
-                                    <td>0</td>
-                                    <td>0</td>
-                                    <td>0</td>
+                                    <td><%= libCount !== null && libCount[engineering.value + ''] !== undefined ?
+                                        libCount[engineering.value + ''].bill_count : 0 %></td>
+                                    <td><%= libCount !== null && libCount[engineering.value + ''] !== undefined ?
+                                        libCount[engineering.value + ''].ration_count : 0 %></td>
+                                    <td><%= libCount !== null && libCount[engineering.value + ''] !== undefined ?
+                                        libCount[engineering.value + ''].glj_count : 0 %></td>
+                                    <td><%= libCount !== null && libCount[engineering.value + ''] !== undefined ?
+                                        libCount[engineering.value + ''].fee_count : 0 %></td>
+                                    <td><%= libCount !== null && libCount[engineering.value + ''] !== undefined ?
+                                        libCount[engineering.value + ''].artificial_count : 0 %></td>
                                     <td><a href="/compilation/<%= section %>/<%= valuationId %>/<%= engineering.value %>">编辑</a></td>
                                 </tr>
                                 <% }) %>

+ 2 - 0
web/users/views/compilation/engineering.html

@@ -70,6 +70,8 @@
                                 </div>
                                 <a href="#" class="btn btn-link btn-sm add-compilation" data-model="glj">添加</a>
                             </div>
+                        </div>
+                        <div class="row">
                             <div class="form-group col-md-4">
                                 <label>费率标准</label>
                                 <div class="fee-list">