Przeglądaj źródła

广东定额库后端,定额后新增一列“管理费费率(%)”

vian 6 lat temu
rodzic
commit
9f8cfa9e2d

+ 1 - 0
modules/all_models/stdRation_ration.js

@@ -46,6 +46,7 @@ const rationItemSchema = new Schema({
     feeType: Number,
     jobContent: String,
     annotation: String,
+    manageFeeRate: String, // 管理费费率
     rationGljList: [rationGljItemSchema],
     rationCoeList: Array,
     rationAssList: [rationAssItemSchema],

+ 11 - 74
modules/ration_repository/controllers/ration_controller.js

@@ -117,79 +117,16 @@ class RationController extends BaseController{
             callback(req, res, 1, err, null);
         }
     }
-}
-
-export default RationController;
-
-/*
-module.exports = {
-    getRationItemsBySection: function(req, res){
-        var sectionId = req.body.sectionID;
-        rationItem.getRationItemsBySection(sectionId, function(err, message, rst){
-            if (err) {
-                callback(req, res, err, message, null);
-            } else {
-                callback(req, res, err, message, rst);
-            }
-        });
-    },
-    mixUpdateRationItems: function(req, res){
-        var sectionId = req.body.sectionID,
-            rationLibId = req.body.rationLibId,
-            updateItems = JSON.parse(req.body.updateItems),
-            addItems = JSON.parse(req.body.addItems),
-            removeIds = JSON.parse(req.body.removeIds);
-        rationItem.mixUpdateRationItems(rationLibId, sectionId, updateItems, addItems, removeIds, function(err, message, rst){
-            if (err) {
-                callback(req, res, err, message, null);
-            } else {
-                callback(req, res, err, message, rst);
-            }
-        });
-    },
-    removeRationItems: function(req, res){
-        var rIds = JSON.parse(req.body.updateItems);
-        if (rIds && rIds.length > 0) {
-            rationItem.removeRationItems(rIds, function(err, message, rst){
-                if (err) {
-                    callback(req, res, err, message, null);
-                } else {
-                    callback(req, res, err, message, rst);
-                }
-            });
+    async updateRationBySection(req, res) {
+        const data = JSON.parse(req.body.data);
+        try {
+            const { rationRepId, sectionList, updateData } = data;
+            await rationItem.updateRationBySection(rationRepId, sectionList, updateData);
+            callback(req, res, 0, 'success', null);
+        } catch (err) {
+            callback(req, res, 1, err, null);
         }
-    },
-    updateRationBasePrc: function (req, res) {
-        let data = JSON.parse(req.body.data);
-        rationItem.updateRationBasePrc(data, function (err, message) {
-            if(err){
-                callback(req, res, err, message, null);
-            }
-            else{
-                callback(req, res, err, message, null);
-            }
-        })
-    },
-    getRationGljIds: function (req, res) {
-        let data = JSON.parse(req.body.data);
-        rationItem.getRationGljIds(data, function (err, message, ids) {
-            if(err){
-                callback(req, res, err, message, null);
-            }
-            else{
-                callback(req, res, err, message, ids);
-            }
-        })
-    },
-    getRationsCodes: function (req, res) {
-        let data = JSON.parse(req.body.data);
-        rationItem.getRationsCodes(data, function (err, message, codes) {
-            if(err){
-                callback(req, res, err, message, null);
-            }
-            else{
-                callback(req, res, err, message, codes);
-            }
-        })
     }
-}*/
+}
+
+export default RationController;

+ 5 - 0
modules/ration_repository/models/ration_item.js

@@ -760,6 +760,11 @@ rationItemDAO.prototype.updateRationTemplate = async function (rationRepId, rati
     return validData;
 };
 
+// 根据章节列表批量更新定额
+rationItemDAO.prototype.updateRationBySection = async function (rationRepId, sectionList, updateData) {
+    await rationItemModel.updateMany({rationRepId, sectionId: {$in: sectionList}}, updateData);
+}
+
 //计算导入数据的价格
 rationItemDAO.prototype.calcForRation = function (stdGljList, ration, overWriteUrl) {
     let rationGljList = ration.rationGljList,

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

@@ -63,6 +63,7 @@ module.exports =  function (app) {
     apiRouter.post("/updateJobContent",rationController.auth, rationController.init, rationController.updateJobContent);
     apiRouter.post("/updateAnnotation",rationController.auth, rationController.init, rationController.updateAnnotation);
     apiRouter.post("/updateRationTemplate",rationController.auth, rationController.init, rationController.updateRationTemplate);
+    apiRouter.post("/updateRationBySection",rationController.auth, rationController.init, rationController.updateRationBySection);
 
     apiRouter.post("/createNewGljTypeNode",repositoryGljController.auth, gljController.init, gljController.createNewGljTypeNode);
     apiRouter.post("/updateGljNodes",repositoryGljController.auth, gljController.init, gljController.updateGljNodes);

+ 15 - 0
public/web/id_tree.js

@@ -215,6 +215,21 @@ var idTree = {
              }) + node.children.count;*/
         };
 
+        // 获取节点所有后代节点
+        Node.prototype.getPosterity = function() {
+            let posterity = [];
+            getNodes(this.children);
+            return posterity;
+            function getNodes(nodes) {
+                for (let node of nodes) {
+                    posterity.push(node);
+                    if (node.children.length > 0){
+                        getNodes(node.children);
+                    }
+                }
+            }
+        };
+
         Node.prototype.setExpanded = function (expanded) {
             var setNodesVisible = function (nodes, visible) {
                 nodes.forEach(function (node) {

+ 2 - 0
public/web/sheet/sheet_common.js

@@ -12,6 +12,7 @@ var sheetCommonObj = {
         spreadBook.options.tabStripVisible = false;
         //spreadBook.options.showHorizontalScrollbar = false;
         spreadBook.options.allowUserDragDrop = false;
+        spreadBook.options.allowUserDragFill = false;
         spreadBook.options.scrollbarMaxAlign = true;
         spreadBook.options.allowContextMenu = false;
         spreadBook.options.allowUndo = false;
@@ -50,6 +51,7 @@ var sheetCommonObj = {
         spreadBook.options.cutCopyIndicatorVisible = false;
         spreadBook.options.allowExtendPasteRange = true;
         spreadBook.options.allowUserDragDrop = false;
+        spreadBook.options.allowUserDragFill = false;
         spreadBook.options.allowUndo = false;
         spreadBook.options.allowContextMenu = false;
         var spreadNS = GC.Spread.Sheets;

+ 24 - 0
web/maintain/ration_repository/dinge.html

@@ -579,6 +579,30 @@
                 </div>
             </div>
         </div>
+        <!-- 设置管理费费率 -->
+        <div class="modal fade" id="set-rate-dialog" data-backdrop="static">
+            <div class="modal-dialog" role="document">
+                <div class="modal-content">
+                    <div class="modal-header">
+                        <h5 class="modal-title">设置管理费率</h5>
+                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                            <span aria-hidden="true">&times;</span>
+                        </button>
+                    </div>
+                    <div class="modal-body">
+                        <form>
+                            <div class="form-group">
+                                <input type="text" class="form-control" placeholder="输入费率" id="manage-fee-rate" autofocus="autofocus">
+                            </div>
+                        </form>
+                    </div>
+                    <div class="modal-footer">
+                        <a href="javascript:void(0);" class="btn btn-primary" data-dismiss="modal" id="set-rate-confirm">确定</a>
+                        <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                    </div>
+                </div>
+            </div>
+        </div>
         <%include ../../common/html/uploadImg.html %>
         <!--弹出html填写帮助-->
         <!--弹出html填写帮助-->

+ 2 - 1
web/maintain/ration_repository/js/ration.js

@@ -76,7 +76,8 @@ let rationOprObj = {
             {headerName:"机械费",headerWidth:80,dataCode:"machinePrice", dataType: "Number", formatter: "0.00", hAlign: "right"},
             {headerName:"基价",headerWidth:80,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right"},
             {headerName:"显示名称(以%s表示参数)",headerWidth:240,dataCode:"caption", dataType: "String"},
-            {headerName:"取费专业",headerWidth:70,dataCode:"feeType", dataType: "Number", hAlign: "center"}
+            {headerName:"取费专业",headerWidth:70,dataCode:"feeType", dataType: "Number", hAlign: "center"},
+            {headerName:"管理费费率(%)",headerWidth:100,dataCode:"manageFeeRate", dataType: "String", hAlign: "center"},
         ],
         view:{
             comboBox:[

+ 64 - 0
web/maintain/ration_repository/js/section_tree.js

@@ -135,6 +135,7 @@ let sectionTreeObj = {
             this.setOptions(this.workBook, this.setting.options);
             this.sheet.options.clipBoardOptions = GC.Spread.Sheets.ClipboardPasteOptions.values;
             this.bindEvents(this.sheet);
+            this.buildContextMenu();
         }
     },
 
@@ -229,6 +230,50 @@ let sectionTreeObj = {
             sheetCommonObj.setColumnWidthByRate($('#sectionSpread').width() - 65, this.workBook, [{rateWidth: IDRate}, {rateWidth: nameRate}]);
         }
     },
+    buildContextMenu: function () {//右键菜单
+        const me = this;
+        $.contextMenu({
+            selector: '#sectionSpread',
+            build: function($triggerElement, e){
+                //控制允许右键菜单在哪个位置出现
+                const target = SheetDataHelper.safeRightClickSelection($triggerElement, e, me.workBook);
+                const sheet = me.workBook.getSheet(0);
+                if (target.hitTestType === 3) {
+                    if (typeof target.row !== 'undefined') {
+                        const section = me.cache[target.row];
+                        me.initSelection(section);
+                    }
+                    return {
+                        callback: function(){},
+                        items: {
+                            "setManage": {
+                                name: "设置管理费率",
+                                disabled: function () {
+                                    const section = me.cache[target.row];
+                                    return locked || !section;
+                                },
+                                icon: "fa-pencil-square-o",
+                                callback: function (key, opt) {
+                                    $('#set-rate-dialog').modal('show');
+                                }
+                            }
+                        }
+                    };
+                }
+            }
+        });
+    },
+    // 获取章节节点的叶子章节列表ID(自身及后代)
+    getSectionLeafList: function (section) {
+        if (!section) {
+            return [];
+        }
+        const posterity = section.getPosterity();
+        const allSections = [section, ...posterity];
+        return allSections
+            .filter(section => !section.children.length)
+            .map(section => section.data.ID);
+    },
     initSectionTree: function (sectionTree) {
         //init
         this.buildSheet();
@@ -337,6 +382,25 @@ let sectionTreeObj = {
         me.upMoveBtn.click(function () {
             me.upMove(me.tree.selected);
         });
+        // 设置管理费费率,设置给其下所有定额
+        $('#set-rate-confirm').click(function () {
+            $.bootstrapLoading.start();
+            const rate = $('#manage-fee-rate').val();
+            const section = me.tree.selected;
+            const sectionList = me.getSectionLeafList(section);
+            const postData = {
+                rationRepId: pageOprObj.rationLibId,
+                sectionList,
+                updateData: { manageFeeRate: rate }
+            };
+            $('#manage-fee-rate').val('');
+            CommonAjax.post('/rationRepository/api/updateRationBySection', postData, function () {
+                me.initSelection(section);
+                $.bootstrapLoading.end();
+            }, function () {
+                $.bootstrapLoading.end();
+            });
+        });
     },
 
     insert: function () {