zhongzewei 7 years ago
parent
commit
6931064e30

+ 7 - 0
modules/ration_repository/controllers/repository_views_controller.js

@@ -31,6 +31,13 @@ class ViewsController extends BaseController{
                 userID: req.session.managerData.userID
             });
     }
+    redirectInstallation(req, res){
+        res.render('maintain/ration_repository/anzhuang.html',
+            {
+                userAccount: req.session.managerData.username,
+                userID: req.session.managerData.userID
+            });
+    }
 }
 
 export default ViewsController;

+ 33 - 1
modules/ration_repository/models/schemas.js

@@ -82,6 +82,36 @@ let rationAssItemSchema = new Schema({
     maxValue: String
 }, { _id: false });
 
+//安装增加费-费用规则
+let feeRuleSchema = new Schema({
+    ID: String,
+    sectionId: String, //分册章节id
+    code: String,
+    rule: String,
+    base: String,
+    feeRate: Number,
+    labour: Number,
+    material: Number,
+    machine: Number
+});
+
+//安装增加费-分册章节
+let installSectionSchema = new Schema({
+    ID: String,
+    feeItemId: String,
+    name: String,
+    feeRule: [feeRuleSchema]
+});
+
+//安装增加费-费用项
+let installFeeItemSchema = new Schema({
+    ID: String,
+    feeItem: String, //费用项
+    feeType: String, //费用类型
+    position: String, //记取位置
+    section: []
+});
+
 //定额
 var rationItemSchema = new Schema({
     ID:Number,
@@ -132,7 +162,9 @@ let coeListModel = db.model("std_ration_lib_coe_list",coeListSchema, "std_ration
 let rationRepository = db.model("std_ration_lib_map", RepositoryMapSchema, "std_ration_lib_map");
 let rationChapterTreeModel = db.model("std_ration_lib_ration_chapter_trees", rationChapterTreeSchema, "std_ration_lib_ration_chapter_trees");
 let rationItemModel = db.model("std_ration_lib_ration_items",rationItemSchema, "std_ration_lib_ration_items");
+let installSectionModel = db.model("std_ration_lib_installationSection", installSectionSchema, "std_ration_lib_installationSection")
+let installFeeItemModel = db.model("std_ration_lib_installation", installFeeItemSchema, "std_ration_lib_installation");
 //补充定额
 let compleRationModel = db.model('complementary_ration_items', compleRationSchema, 'complementary_ration_items');
 
-export{coeListModel, rationRepository, rationChapterTreeModel, rationItemModel, compleRationModel};
+export{coeListModel, rationRepository, rationChapterTreeModel, rationItemModel, installFeeItemModel, installSectionModel, compleRationModel};

+ 1 - 0
modules/ration_repository/routes/ration_rep_routes.js

@@ -26,6 +26,7 @@ module.exports =  function (app) {
     app.get('/rationRepository/ration',viewsController.auth, viewsController.init, viewsController.redirectRation);
     app.get('/rationRepository/lmm', viewsController.auth, viewsController.init, viewsController.redirectGlj);
     app.get('/rationRepository/coeList', viewsController.auth, viewsController.init, viewsController.redirectCoeList);
+    app.get('/rationRepository/installation', viewsController.auth, viewsController.init, viewsController.redirectInstallation);
 
     apiRouter.post("/getCompilationList", rationRepositoryController.auth, rationRepositoryController.init, rationRepositoryController.getCompilationList);
 

+ 28 - 2
modules/std_glj_lib/models/gljModel.js

@@ -67,8 +67,8 @@ class GljDao  extends OprDao{
         }
     }
 
-    getGljItemsByRep(repositoryId,callback = null){
-        let me = this;
+    async getGljItemsByRep(repositoryId,callback = null){
+   /*     let me = this;
         if (callback === null) {
             return gljModel.find({"repositoryId": repositoryId});
         } else {
@@ -79,7 +79,33 @@ class GljDao  extends OprDao{
                     callback(false,data);
                 }
             })
+        }*/
+
+        let me = this;
+        let rst = [];
+        //批量获取异步
+        let functions = [];
+        let count = await gljModel.find({repositoryId: repositoryId, $or: [{deleted: null}, {deleted: false}]}).count();
+        let findCount = Math.ceil(count/500);
+        for(let i = 0, len = findCount; i < len; i++){
+            functions.push((function(flag) {
+                return function (cb) {
+                    gljModel.find({repositoryId: repositoryId, deleted: null}, cb).skip(flag).sort({ID: 1}).limit(500);
+                }
+            })(i*500));
         }
+        async.parallel(functions,  function (err, results) {
+            if(err){
+                callback(err, null);
+            }
+            else{
+                for(let stdGljs of results){
+                    rst = rst.concat(stdGljs);
+                }
+                me.sortToNumber(rst);
+                callback(0, rst);
+            }
+        });
     }
 
     getGljItemByType (repositoryId, type, callback){

+ 1 - 1
web/maintain/ration_repository/dinge.html

@@ -37,7 +37,7 @@
                       <a class="nav-link px-3" id="fuzhu" href="#">附注条件</a>
                   </li>
                   <li class="nav-item">
-                      <a class="nav-link px-3" href="anzhuang.html">安装增加费</a>
+                      <a class="nav-link px-3" id="anzhuang" href="anzhuang.html">安装增加费</a>
                   </li>
               </ul>
         </nav>

+ 4 - 0
web/maintain/ration_repository/js/coe.js

@@ -16,6 +16,10 @@ var pageObj = {
             $(this).attr('href', "/rationRepository/lmm" + "?repository=" + getQueryString("repository"))
         });
 
+        $("#anzhuang").click(function(){
+            $(this).attr('href', "/rationRepository/installation" + "?repository=" + getQueryString("repository"))
+        });
+
         var libID = getQueryString("repository");
         var libName = storageUtil.getSessionCache("RationGrp","repositoryID_" + libID);
         if (libName) {

+ 5 - 0
web/maintain/ration_repository/js/ration.js

@@ -9,6 +9,11 @@ $("#gongliao").click(function(){
 $("#fuzhu").click(function(){
     $(this).attr('href', "/rationRepository/coeList" + "?repository=" + getQueryString("repository"))
 });
+
+$("#anzhuang").click(function(){
+    $(this).attr('href', "/rationRepository/installation" + "?repository=" + getQueryString("repository"))
+});
+
 const digital = {
     gljPrc: -3,//计算定额基价时单个工料机价格取三位
     rationBasePrc: -2,

+ 6 - 2
web/maintain/ration_repository/js/repository_glj.js

@@ -10,6 +10,10 @@ $("#fuzhu").click(function(){
     $(this).attr('href', "/rationRepository/coeList" + "?repository=" + getQueryString("repository"))
 });
 
+$("#anzhuang").click(function(){
+    $(this).attr('href', "/rationRepository/installation" + "?repository=" + getQueryString("repository"))
+});
+
 var pageOprObj = {
     rationLibName : null,
     rationLibId: null,
@@ -119,7 +123,7 @@ repositoryGljObj = {
         $.ajax({
             type:"POST",
             url:"api/getGljTree",
-            data:{"gljLibID": gljLibID},
+            data:{data: JSON.stringify({"gljLibId": gljLibID})},
             dataType:"json",
             cache:false,
             timeout:20000,
@@ -147,7 +151,7 @@ repositoryGljObj = {
             data:{"repositoryId": gljLibID},
             dataType:"json",
             cache:false,
-            timeout:5000,
+            timeout:10000,
             success:function(result){
                 if(!result.error) {
                     me.gljList = result.data;

+ 1 - 1
web/maintain/std_glj_lib/js/glj.js

@@ -165,7 +165,7 @@ let repositoryGljObj = {
             data:{"repositoryId": repId},
             dataType:"json",
             cache:false,
-            timeout:5000,
+            timeout:20000,
             success:function(result){
                 if(!result.error) {
                     me.gljList = result.data;

+ 1 - 1
web/maintain/std_glj_lib/js/gljComponent.js

@@ -507,7 +507,7 @@ let gljComponentOprObj = {
         let me = gljComponentOprObj, gljBasePrc = 0;
         for(let i = 0; i < component.length; i++){
             let roundBasePrc = scMathUtil.roundTo(parseFloat(component[i].basePrice), -2);
-            gljBasePrc += scMathUtil.roundTo(roundBasePrc * parseFloat(component[i].consumeAmt), -2);
+            gljBasePrc = scMathUtil.roundTo(scMathUtil.roundTo(roundBasePrc * parseFloat(component[i].consumeAmt), -2) + gljBasePrc, -2);
         }
         return gljBasePrc;
     }