ソースを参照

Merge branch 'master' into olym

olym 8 年 前
コミット
5ac0c885c4

+ 6 - 1
modules/main/models/ration.js

@@ -43,13 +43,18 @@ let rationSchema = new Schema({
     adjustState: String,
     content: String,
     rationProjName: String,
+    // 说明
     comments: String,
     // 费用字段
     fees: [subSchema.feesSchema],
     // 标记字段
     flags: [subSchema.flagsSchema],
     deleteInfo: deleteSchema,
-    rationAssList: [rationAssItemSchema]
+    rationAssList: [rationAssItemSchema],
+    // 工作内容
+    content: String,
+    // 计算规则
+    ruleText: String
 });
 
 let ration = db.model("ration", rationSchema, "ration");

+ 10 - 4
modules/ration_repository/controllers/search_controller.js

@@ -2,17 +2,23 @@
  * Created by Mai on 2017/6/5.
  */
 var rationItem = require('../models/ration_item');
+let rationChapter = require('../models/ration_section_tree');
 var callback = function(req, res, err, message, data){
     res.json({error: err, message: message, data: data});
 };
 
 module.exports = {
     getRationItem: function (req, res) {
-        var rId = req.body.rationLibId, code = req.body.code;
-        var rationData = {}
+        let rId = req.body.rationLibId, code = req.body.code;
         rationItem.getRationItem(rId, code).then(function (result) {
-            rationData = result._doc;
-            callback(req, res, null, '', rationData);
+            let rationData = JSON.stringify(result._doc);
+            rationData = JSON.parse(rationData);
+            rationChapter.getRationChapter(rationData.rationRepId, rationData.sectionId).then(function (result) {
+                rationData.chapter = result._doc;
+                callback(req, res, null, '', rationData);
+            }).catch(function (err, message) {
+                callback(req, res, null, '', rationData);
+            });
         }).catch(function (err, message) {
             callback(req, res, err, message, null);
         })

+ 16 - 0
modules/ration_repository/models/ration_section_tree.js

@@ -100,4 +100,20 @@ rationChapterTreeDAO.prototype.updateNodes = function(nodes,callback){
     });
 };
 
+rationChapterTreeDAO.prototype.getRationChapter = function (repId, chapterID, callback) {
+    if (callback) {
+        rationChapterTreeModel.findOne({rationRepId: repId, ID: chapterID}, '-_id').exec()
+            .then(function (result, err) {
+                if (err) {
+                    callback(1, '找不到定额章节' , null);
+                } else {
+                    callback(0, '', result);
+                }
+            });
+        return null;
+    } else {
+        return rationChapterTreeModel.findOne({rationRepId: repId, ID: chapterID}, '-_id').exec();
+    }
+}
+
 module.exports = new rationChapterTreeDAO()

+ 1 - 1
web/building_saas/main/html/main.html

@@ -148,7 +148,7 @@
                                       <div class="main-data-bottom ovf-hidden" id="subSpread" style="display: none">
                                       </div>
                                       <div class="main-data-bottom ovf-hidden" style="display: none" id="comments">
-                                          <textarea class="form-control" rows="8"></textarea>
+                                          <textarea class="form-control" rows="8" readonly=""></textarea>
                                       </div>
                                       <div id="tzjnrCon" class="main-data-bottom">
                                           <div class="main-data-bottom ovf-hidden" style="width: 40%; float: left;" id="jobSpread">

+ 23 - 12
web/building_saas/main/js/controllers/project_controller.js

@@ -36,21 +36,30 @@ ProjectController = {
         }
     },
     addRation: function (project, sheetController, std) {
-        if (!project || !sheetController) { return null; }
+        if (!project || !sheetController) { return; }
 
-        var selected = project.mainTree.selected;
-        var newSource = null, newNode = null;
-        if(selected==null){
-            return;
-        }
-        if (selected.sourceType === project.Bills.getSourceType() && selected.source.children.length === 0) {
-            if (std) {
-                newSource = project.Ration.insertStdRation(selected.source.getID(), null, std);
-                project.ration_glj.addRationGLJ(newSource,std);
+        let selected = project.mainTree.selected, newSource = null, newNode = null;
+        if (selected === null) { return; }
+
+        if (selected.sourceType === project.Bills.getSourceType() && selected.depth() > 0) {
+            if (selected.source.children.length > 0) {
+                alert('当前清单已有清单子项,不能套用定额。');
+            } else if (false) {
+                alert('当前清单已有公式计算,不能套用定额。');
             } else {
-                newSource = project.Ration.insertRation(selected.source.getID());
+                let firstChild = selected.firstChild();
+                if (firstChild && firstChild.sourceType === project.VolumePrice.getSourceType()) {
+                    alert('当前位置已有量价,不能套用定额。');
+                } else {
+                    if (std) {
+                        newSource = project.Ration.insertStdRation(selected.source.getID(), null, std);
+                        project.ration_glj.addRationGLJ(newSource,std);
+                    } else {
+                        newSource = project.Ration.insertRation(selected.source.getID());
+                    }
+                }
+                newNode = project.mainTree.insert(selected.getID(), selected.tree.rootID());
             }
-            newNode = project.mainTree.insert(selected.getID(), selected.tree.rootID());
         } else if (selected.sourceType === project.Ration.getSourceType()) {
             if (std) {
                 newSource = project.Ration.insertStdRation(selected.source[project.masterField.ration], selected.source, std);
@@ -59,6 +68,8 @@ ProjectController = {
                 newSource = project.Ration.insertRation(selected.source[project.masterField.ration], selected.source);
             }
             newNode = project.mainTree.insert(selected.getParentID(), selected.getNextSiblingID());
+        } else if (selected.sourceType === project.VolumePrice.getSourceType()) {
+            alert('当前位置已有量价,不能套用定额。');
         }
         if (newNode) {
             newNode.source = newSource;

+ 7 - 1
web/building_saas/main/js/models/ration.js

@@ -148,12 +148,18 @@ var Ration = {
         ration.prototype.insertStdRation = function (billsID, preRation, std) {
             var br = this.getBillsSortRation(billsID), updateData = this.getInsertRationData(billsID, preRation), newRation = null;
             updateData.forEach(function (data) {
+
                 if (data.updateType === 'ut_create') {
                     data.updateData.code = std.code;
                     data.updateData.name = std.name;
-                    data.updateData.caption=std.caption;
+                    data.updateData.caption = std.caption;
                     data.updateData.unit = std.unit;
                     data.updateData.libID = std.rationRepId;
+                    data.updateData.content = std.jobContent;
+                    if (std.chapter) {
+                        data.updateData.comments = std.chapter.explanation;
+                        data.updateData.ruleText = std.chapter.ruleText;
+                    }
                     data.updateData.rationAssList =  projectObj.project.ration_ass.CreateNewAss(std);
                     newRation = data.updateData;
                 }

+ 4 - 1
web/building_saas/main/js/views/main_tree_col.js

@@ -40,7 +40,10 @@ let MainTreeCol = {
         },
         forCalcBase: function (node) {
             // to do according to billsParentType
-            return MainTreeCol.readOnly.billsParent && MainTreeCol.readOnly.non_bills;
+            return MainTreeCol.readOnly.billsParent(node) && MainTreeCol.readOnly.non_bills(node);
+        },
+        forUnitFee: function (node) {
+            return MainTreeCol.readOnly.ration(node) && MainTreeCol.readOnly.billsParent(node);
         }
     },
     cellType: {

+ 2 - 2
web/building_saas/main/js/views/project_view.js

@@ -8,9 +8,9 @@ var projectObj = {
     mainController: null,
     gljSpreed:null,
     beforeMainTreeSelectedChange: function (node) {
-        if (node) {
+        /*if (node) {
             subViewObj.saveComments(node);
-        }
+        }*/
     },
     checkCommonField: function (editingText, colSetting) {
         let value;

+ 7 - 5
web/building_saas/main/js/views/sub_view.js

@@ -129,11 +129,13 @@ let subViewObj = {
         $($(this).attr('href')).show();
     },
     loadComments: function (node) {
-        let select = node;
-        if (node && (node.sourceType === projectObj.project.Bills.getSourceType() || node.sourceType === projectObj.project.Ration.getSourceType())) {
-            $('#comments>textarea').val(node.data.comments).removeAttr('readOnly');
-        } else {
-            $('#rationComments>textarea').val('').attr('readOnly', true);
+        if (node) {
+            if (node.sourceType === projectObj.project.Bills.getSourceType()) {
+                $('#comments>textarea').val(node.data.comments)
+            } else if (node.sourceType === projectObj.project.Ration.getSourceType()) {
+                console.log(node.data);
+                $('#comments>textarea').val(node.data.content);
+            }
         }
     },
     saveComments: function (node) {