Browse Source

Merge branch 'master' of http://192.168.1.41:3000/maixinrong/Calculation

TonyKang 5 years ago
parent
commit
50c952092c

+ 1 - 0
app/controller/ledger_controller.js

@@ -266,6 +266,7 @@ module.exports = app => {
          */
         async _addDeal(ctx, data) {
             if (!data.type || !data.dealBills) throw '数据错误';
+            data.dealBills.unit_price = this.ctx.helper.round(data.dealBills.unit_price, ctx.tender.info.decimal.up);
             if (data.type === 'child') {
                 return await ctx.service.ledger.addChild(ctx.tender.id, data.id, data.dealBills);
             } else if (data.type === 'next') {

+ 1 - 0
app/controller/revise_controller.js

@@ -455,6 +455,7 @@ module.exports = app => {
         }
         async _addDeal(revise, data) {
             if (!data.type || !data.dealBills) throw '数据错误';
+            data.dealBills.unit_price = this.ctx.helper.round(data.dealBills.unit_price, this.ctx.tender.info.decimal.up);
             if (data.type === 'child') {
                 return await this.ctx.service.reviseBills.addChild(revise.tid, data.id, data.dealBills, revise.id);
             } else if (data.type === 'next') {

+ 110 - 127
app/public/js/ledger.js

@@ -1034,7 +1034,7 @@ $(document).ready(function() {
                     }
                 },
                 'batchInsertBillsPos': {
-                    name: '批量插入清单-部位',
+                    name: '批量插入清单-计量单元',
                     icon: 'fa-sign-in',
                     disabled: function (key, opt) {
                         if (!checkTzMeasureType()) return true;
@@ -1479,6 +1479,110 @@ $(document).ready(function() {
             }
         }
     });
+    const stdLibCellDoubleClick = function (e, info) {
+        const stdSheet = info.sheet;
+        const mainSheet = ledgerSpread.getActiveSheet();
+        if (!stdSheet.zh_setting || !stdSheet.zh_tree || !mainSheet.zh_tree) { return; }
+
+        const stdTree = stdSheet.zh_tree;
+        const stdNode = stdTree.nodes[info.row];
+
+        const mainTree = mainSheet.zh_tree;
+        const sel = mainSheet.getSelections()[0];
+        const mainNode = mainTree.nodes[sel.row];
+        if (!stdNode) { return; }
+        if (info.sheet.zh_setting.stdType === 'gcl') {
+            if (mainNode.code && mainNode.code !== '' && !mainTree.isLeafXmj(mainNode)) {
+                toastr.warning('非最底层项目下,不应添加清单');
+                return;
+            }
+        }
+
+        postData(window.location.pathname + '/update', {
+            postType: 'add-std',
+            postData: {
+                id: ledgerTree.getNodeKey(mainNode),
+                tender_id: mainNode.tender_id,
+                stdType: info.sheet.zh_setting.stdType,
+                stdLibId: stdNode.list_id,
+                stdNode: stdTree.getNodeKey(stdNode)
+            }
+        }, function (result) {
+            const refreshNode = mainTree.loadPostData(result);
+            treeOperationObj.refreshTree(mainSheet, refreshNode);
+            if (refreshNode.create && refreshNode.create.length > 0) {
+                mainSheet.setSelection(refreshNode.create[refreshNode.create.length - 1].index, sel.col, sel.rowCount, sel.colCount);
+            } else {
+                const node = _.find(ledgerTree.nodes, {code: stdNode.code, name: stdNode.name});
+                if (node) {
+                    mainSheet.setSelection(ledgerTree.nodes.indexOf(node), sel.col, sel.rowCount, sel.colCount);
+                }
+            }
+            treeOperationObj.refreshOperationValid(mainSheet);
+            ledgerSpread.focus();
+            posOperationObj.loadCurPosData();
+        });
+    };
+    const stdXmjSetting = {
+        selector: '#std-xmj',
+        stdType: 'xmj',
+        treeSetting: {
+            id: 'chapter_id',
+            pid: 'pid',
+            order: 'order',
+            level: 'level',
+            rootId: -1,
+            keys: ['id', 'list_id', 'chapter_id'],
+        },
+        spreadSetting: {
+            cols: [
+                {title: '项目节编号', field: 'code', hAlign: 0, width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
+                {title: '名称', field: 'name', hAlign: 0, width: 150, formatter: '@', readOnly: true},
+                {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true}
+            ],
+            treeCol: 0,
+            emptyRows: 0,
+            headRows: 1,
+            headRowHeight: [32],
+            defaultRowHeight: 21,
+            headerFont: '12px 微软雅黑',
+            font: '12px 微软雅黑',
+            headColWidth: [0],
+        },
+        cellDoubleClick: stdLibCellDoubleClick,
+        page: 'ledger',
+        tid: getTenderId(),
+    };
+    const stdGclSetting = {
+        selector: '#std-gcl',
+        stdType: 'gcl',
+        treeSetting: {
+            id: 'bill_id',
+            pid: 'pid',
+            order: 'order',
+            level: 'level',
+            rootId: -1,
+            keys: ['id', 'list_id', 'bill_id']
+        },
+        spreadSetting: {
+            cols: [
+                {title: '清单编号', field: 'b_code', hAlign: 0, width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
+                {title: '名称', field: 'name', hAlign: 0, width: 150, formatter: '@', readOnly: true},
+                {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true}
+            ],
+            treeCol: 0,
+            emptyRows: 0,
+            headRows: 1,
+            headRowHeight: [32],
+            defaultRowHeight: 21,
+            headerFont: '12px 微软雅黑',
+            font: '12px 微软雅黑',
+            headColWidth: [0],
+        },
+        cellDoubleClick: stdLibCellDoubleClick,
+        page: 'ledger',
+        tid: getTenderId(),
+    };
     // 展开收起标准清单
     $('a', '#side-menu').bind('click', function (e) {
         e.preventDefault();
@@ -1516,56 +1620,14 @@ $(document).ready(function() {
             showSideTools(tab.hasClass('active'));
             if (tab.attr('content') === '#std-xmj') {
                 if (!stdXmj) {
-                    stdXmj = new stdLib('#std-xmj', 'xmj', {
-                        id: 'chapter_id',
-                        pid: 'pid',
-                        order: 'order',
-                        level: 'level',
-                        rootId: -1,
-                        keys: ['id', 'list_id', 'chapter_id'],
-                    }, {
-                        cols: [
-                            {title: '项目节编号', field: 'code', hAlign: 0, width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
-                            {title: '名称', field: 'name', hAlign: 0, width: 150, formatter: '@', readOnly: true},
-                            {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true}
-                        ],
-                        treeCol: 0,
-                        emptyRows: 0,
-                        headRows: 1,
-                        headRowHeight: [32],
-                        defaultRowHeight: 21,
-                        headerFont: '12px 微软雅黑',
-                        font: '12px 微软雅黑',
-                        headColWidth: [0],
-                    });
-                    stdXmj.loadLib($('select', '#std-xmj').val());
+                    stdXmj = new stdLib(stdXmjSetting);
+                    //stdXmj.loadLib($('select', '#std-xmj').val());
                 }
                 stdXmj.spread.refresh();
             } else if (tab.attr('content') === '#std-gcl') {
                 if (!stdGcl) {
-                    stdGcl = new stdLib('#std-gcl', 'gcl', {
-                        id: 'bill_id',
-                        pid: 'pid',
-                        order: 'order',
-                        level: 'level',
-                        rootId: -1,
-                        keys: ['id', 'list_id', 'bill_id']
-                    }, {
-                        cols: [
-                            {title: '清单编号', field: 'b_code', hAlign: 0, width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
-                            {title: '名称', field: 'name', hAlign: 0, width: 150, formatter: '@', readOnly: true},
-                            {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true}
-                        ],
-                        treeCol: 0,
-                        emptyRows: 0,
-                        headRows: 1,
-                        headRowHeight: [32],
-                        defaultRowHeight: 21,
-                        headerFont: '12px 微软雅黑',
-                        font: '12px 微软雅黑',
-                        headColWidth: [0],
-                    });
-                    stdGcl.loadLib($('select', '#std-gcl').val());
+                    stdGcl = new stdLib(stdGclSetting);
+                    //stdGcl.loadLib($('select', '#std-gcl').val());
                 }
                 stdGcl.spread.refresh();
             } else if (tab.attr('content') === '#deal-bills') {
@@ -1628,85 +1690,6 @@ $(document).ready(function() {
             posSpread.refresh();
         }
     });
-
-    class stdLib {
-        constructor(selector, stdType, treeSetting, spreadSetting) {
-            const self = this;
-            this.obj = $(selector + '-spread')[0];
-            this.stdType = stdType;
-            this.treeSetting = treeSetting;
-            treeSetting.preUrl = this.url;
-            this.spreadSetting = spreadSetting;
-            this.spread = SpreadJsObj.createNewSpread(this.obj);
-            SpreadJsObj.initSheet(this.spread.getActiveSheet(), this.spreadSetting);
-            SpreadJsObj.forbiddenSpreadContextMenu(selector, this.spread);
-            this.spread.getActiveSheet().bind(GC.Spread.Sheets.Events.CellDoubleClick, function (e, info) {
-                const stdSheet = info.sheet;
-                const mainSheet = ledgerSpread.getActiveSheet();
-                if (!stdSheet.zh_setting || !stdSheet.zh_tree || !mainSheet.zh_tree) { return; }
-
-                const stdTree = stdSheet.zh_tree;
-                const stdNode = stdTree.nodes[info.row];
-
-                const mainTree = mainSheet.zh_tree;
-                const sel = mainSheet.getSelections()[0];
-                const mainNode = mainTree.nodes[sel.row];
-                if (!stdNode) { return; }
-                if (stdType === 'gcl') {
-                    if (mainNode.code && mainNode.code !== '' && !mainTree.isLeafXmj(mainNode)) {
-                        toastr.warning('非最底层项目下,不应添加清单');
-                        return;
-                    }
-                }
-
-                postData(window.location.pathname + '/update', {
-                    postType: 'add-std',
-                    postData: {
-                        id: ledgerTree.getNodeKey(mainNode),
-                        tender_id: mainNode.tender_id,
-                        stdType: stdType,
-                        stdLibId: stdNode.list_id,
-                        stdNode: stdTree.getNodeKey(stdNode)
-                    }
-                }, function (result) {
-                    const refreshNode = mainTree.loadPostData(result);
-                    treeOperationObj.refreshTree(mainSheet, refreshNode);
-                    if (refreshNode.create && refreshNode.create.length > 0) {
-                        mainSheet.setSelection(refreshNode.create[refreshNode.create.length - 1].index, sel.col, sel.rowCount, sel.colCount);
-                    } else {
-                        const node = _.find(ledgerTree.nodes, {code: stdNode.code, name: stdNode.name});
-                        if (node) {
-                            mainSheet.setSelection(ledgerTree.nodes.indexOf(node), sel.col, sel.rowCount, sel.colCount);
-                        }
-                    }
-                    treeOperationObj.refreshOperationValid(mainSheet);
-                    ledgerSpread.focus();
-                    posOperationObj.loadCurPosData();
-                });
-            });
-            this.pathTree = createNewPathTree('base', this.treeSetting);
-            this.cacheLib = [];
-            $('select', selector).change(function () {
-                self.loadLib(parseInt(this.value));
-            });
-        }
-        loadLib (listId) {
-            const cacheData = this.cacheLib.find(function (lib) {
-                return lib.id === listId;
-            });
-            if (cacheData) {
-                this.pathTree.loadDatas(cacheData.data);
-                SpreadJsObj.loadSheetData(this.spread.getActiveSheet(), 'tree', this.pathTree);
-            } else {
-                const self = this;
-                postData('/std-lib/get-data', {stdType: this.stdType, list_id: listId}, function (data) {
-                    self.cacheLib.push({id: listId, data: data});
-                    self.pathTree.loadDatas(data);
-                    SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'tree', self.pathTree);
-                });
-            }
-        }
-    }
     class DealBills {
         constructor (selector, spreadSetting) {
             const self = this;
@@ -1806,7 +1789,7 @@ $(document).ready(function() {
             // 初始化 部位数量复核表 参数
             this.posSpreadSetting = {
                 cols: [
-                    {title: '部位', field: 'bw', hAlign: 0, width: 80, formatter: '@'},
+                    {title: '名称', field: 'bw', hAlign: 0, width: 80, formatter: '@'},
                     {title: '图册号', field: 'drawingCode', hAlign: 0, formatter: '@', width: 60},
                 ],
                 emptyRows: this.posCount,

+ 1 - 1
app/public/js/ledger_audit.js

@@ -146,7 +146,7 @@ $(document).ready(() => {
             }
         };
         if (!tab.hasClass('active')) {
-            $('a', '#side-menu').removeClass('active');
+            $('a', '.side-menu').removeClass('active');
             tab.addClass('active');
             $('.tab-content .tab-pane').removeClass('active');
             tabPanel.addClass('active');

+ 1 - 1
app/public/js/measure_compare.js

@@ -219,8 +219,8 @@ $(document).ready(() => {
         }
     });
     (function (select, sheet) {
-        if (!sheet.zh_tree) return;
         $(select).click(function () {
+            if (!sheet.zh_tree) return;
             const tag = $(this).attr('tag');
             const tree = sheet.zh_tree;
             switch (tag) {

+ 112 - 129
app/public/js/revise.js

@@ -682,9 +682,10 @@ $(document).ready(() => {
                     }
                 },
                 'batchInsertBillsPos': {
-                    name: '批量插入节点-部位',
+                    name: '批量插入清单-计量单元',
                     icon: 'fa-sign-in',
                     disabled: function (key, opt) {
+                        if (!isTz) return true;
                         const select = SpreadJsObj.getSelectObject(billsSheet);
                         if (select) {
                             if (select.code && select.code !== '') {
@@ -1087,87 +1088,6 @@ $(document).ready(() => {
         }
     });
 
-    class stdLib {
-        constructor(selector, stdType, treeSetting, spreadSetting) {
-            const self = this;
-            this.obj = $(selector + '-spread')[0];
-            this.stdType = stdType;
-            this.treeSetting = treeSetting;
-            treeSetting.preUrl = this.url;
-            this.spreadSetting = spreadSetting;
-            this.spread = SpreadJsObj.createNewSpread(this.obj);
-            SpreadJsObj.initSheet(this.spread.getActiveSheet(), this.spreadSetting);
-            if (!readOnly) {
-                this.spread.getActiveSheet().bind(GC.Spread.Sheets.Events.CellDoubleClick, function (e, info) {
-                    const stdSheet = info.sheet;
-                    const mainSheet = billsSheet;
-                    if (!stdSheet.zh_setting || !stdSheet.zh_tree || !mainSheet.zh_tree) { return; }
-
-                    const stdTree = stdSheet.zh_tree;
-                    const stdNode = stdTree.nodes[info.row];
-                    const mainTree = mainSheet.zh_tree;
-                    const sel = mainSheet.getSelections()[0];
-                    const mainNode = mainTree.nodes[sel.row];
-                    if (!stdNode) return;
-
-                    if (stdType === 'gcl') {
-                        if (mainNode.code && mainNode.code !== '' && !mainTree.isLeafXmj(mainNode)) {
-                            toastr.warning('非最底层项目下,不应添加节点');
-                            return;
-                        }
-                    }
-
-                    postData(window.location.pathname + '/update', {
-                        postType: 'add-std',
-                        postData: {
-                            id: mainTree.getNodeKey(mainNode),
-                            tender_id: mainNode.tender_id,
-                            stdType: stdType,
-                            stdLibId: stdNode.list_id,
-                            stdNode: stdTree.getNodeKey(stdNode)
-                        }
-                    }, function (result) {
-                        const refreshNode = mainTree.loadPostData(result);
-                        billsTreeSpreadObj.refreshTree(mainSheet, refreshNode);
-                        if (sel) {
-                            if (refreshNode.create && refreshNode.create.length > 0) {
-                                mainSheet.setSelection(refreshNode.create[refreshNode.create.length - 1].index, sel.col, sel.rowCount, sel.colCount);
-                            } else {
-                                const node = _.find(mainTree.nodes, {code: stdNode.code, name: stdNode.name});
-                                if (node) {
-                                    mainSheet.setSelection(mainTree.nodes.indexOf(node), sel.col, sel.rowCount, sel.colCount);
-                                }
-                            }
-                        }
-                        billsTreeSpreadObj.refreshOperationValid(mainSheet);
-                        billsSpread.focus();
-                        posSpreadObj.loadCurPosData();
-                    });
-                });
-            }
-            this.pathTree = createNewPathTree('base', this.treeSetting);
-            this.cacheLib = [];
-            $('select', selector).change(function () {
-                self.loadLib(parseInt(this.value));
-            });
-        }
-        loadLib (listId) {
-            const cacheData = this.cacheLib.find(function (lib) {
-                return lib.id === listId;
-            });
-            if (cacheData) {
-                this.pathTree.loadDatas(cacheData.data);
-                SpreadJsObj.loadSheetData(this.spread.getActiveSheet(), 'tree', this.pathTree);
-            } else {
-                const self = this;
-                postData('/std-lib/get-data', {stdType: this.stdType, list_id: listId}, function (data) {
-                    self.cacheLib.push({id: listId, data: data});
-                    self.pathTree.loadDatas(data);
-                    SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'tree', self.pathTree);
-                });
-            }
-        }
-    }
     class DealBills {
         constructor (selector, spreadSetting) {
             const self = this;
@@ -1260,7 +1180,7 @@ $(document).ready(() => {
             // 初始化 部位数量复核表 参数
             this.posSpreadSetting = {
                 cols: [
-                    {title: '部位', field: 'bw', hAlign: 0, width: 80, formatter: '@'},
+                    {title: '名称', field: 'bw', hAlign: 0, width: 80, formatter: '@'},
                     {title: '图册号', field: 'drawingCode', hAlign: 0, formatter: '@', width: 60},
                 ],
                 emptyRows: this.posCount,
@@ -1504,6 +1424,113 @@ $(document).ready(() => {
     if (posSpread) {
         posSpread.refresh();
     }
+
+    const stdLibCellDoubleClick = function (e, info) {
+        const stdSheet = info.sheet;
+        const mainSheet = billsSheet;
+        if (!stdSheet.zh_setting || !stdSheet.zh_tree || !mainSheet.zh_tree) { return; }
+
+        const stdTree = stdSheet.zh_tree;
+        const stdNode = stdTree.nodes[info.row];
+        const mainTree = mainSheet.zh_tree;
+        const sel = mainSheet.getSelections()[0];
+        const mainNode = mainTree.nodes[sel.row];
+        if (!stdNode) return;
+
+        if (info.sheet.zh_setting.stdType === 'gcl') {
+            if (mainNode.code && mainNode.code !== '' && !mainTree.isLeafXmj(mainNode)) {
+                toastr.warning('非最底层项目下,不应添加节点');
+                return;
+            }
+        }
+
+        postData(window.location.pathname + '/update', {
+            postType: 'add-std',
+            postData: {
+                id: mainTree.getNodeKey(mainNode),
+                tender_id: mainNode.tender_id,
+                stdType: info.sheet.zh_setting.stdType,
+                stdLibId: stdNode.list_id,
+                stdNode: stdTree.getNodeKey(stdNode)
+            }
+        }, function (result) {
+            const refreshNode = mainTree.loadPostData(result);
+            billsTreeSpreadObj.refreshTree(mainSheet, refreshNode);
+            if (sel) {
+                if (refreshNode.create && refreshNode.create.length > 0) {
+                    mainSheet.setSelection(refreshNode.create[refreshNode.create.length - 1].index, sel.col, sel.rowCount, sel.colCount);
+                } else {
+                    const node = _.find(mainTree.nodes, {code: stdNode.code, name: stdNode.name});
+                    if (node) {
+                        mainSheet.setSelection(mainTree.nodes.indexOf(node), sel.col, sel.rowCount, sel.colCount);
+                    }
+                }
+            }
+            billsTreeSpreadObj.refreshOperationValid(mainSheet);
+            billsSpread.focus();
+            posSpreadObj.loadCurPosData();
+        });
+    };
+    const stdXmjSetting = {
+        selector: '#std-xmj',
+        stdType: 'xmj',
+        treeSetting: {
+            id: 'chapter_id',
+            pid: 'pid',
+            order: 'order',
+            level: 'level',
+            rootId: -1,
+            keys: ['id', 'list_id', 'chapter_id'],
+        },
+        spreadSetting: {
+            cols: [
+                {title: '项目节编号', field: 'code', hAlign: 0, width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
+                {title: '名称', field: 'name', hAlign: 0, width: 150, formatter: '@', readOnly: true},
+                {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true}
+            ],
+            treeCol: 0,
+            emptyRows: 0,
+            headRows: 1,
+            headRowHeight: [32],
+            defaultRowHeight: 21,
+            headerFont: '12px 微软雅黑',
+            font: '12px 微软雅黑',
+            headColWidth: [0],
+        },
+        cellDoubleClick: stdLibCellDoubleClick,
+        page: 'revise',
+        tid: window.location.pathname.split('/')[2],
+    };
+    const stdGclSetting = {
+        selector: '#std-gcl',
+        stdType: 'gcl',
+        treeSetting: {
+            id: 'bill_id',
+            pid: 'pid',
+            order: 'order',
+            level: 'level',
+            rootId: -1,
+            keys: ['id', 'list_id', 'bill_id']
+        },
+        spreadSetting: {
+            cols: [
+                {title: '清单编号', field: 'b_code', hAlign: 0, width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
+                {title: '名称', field: 'name', hAlign: 0, width: 150, formatter: '@', readOnly: true},
+                {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true}
+            ],
+            treeCol: 0,
+            emptyRows: 0,
+            headRows: 1,
+            headRowHeight: [32],
+            defaultRowHeight: 21,
+            headerFont: '12px 微软雅黑',
+            font: '12px 微软雅黑',
+            headColWidth: [0],
+        },
+        cellDoubleClick: stdLibCellDoubleClick,
+        page: 'revise',
+        tid: window.location.pathname.split('/')[2],
+    };
     // 展开收起标准节点
     $('a', '#side-menu').bind('click', function (e) {
         e.preventDefault();
@@ -1518,56 +1545,12 @@ $(document).ready(() => {
             showSideTools(tab.hasClass('active'));
             if (tab.attr('content') === '#std-xmj') {
                 if (!stdXmj) {
-                    stdXmj = new stdLib('#std-xmj', 'xmj', {
-                        id: 'chapter_id',
-                        pid: 'pid',
-                        order: 'order',
-                        level: 'level',
-                        rootId: -1,
-                        keys: ['id', 'list_id', 'chapter_id'],
-                    }, {
-                        cols: [
-                            {title: '项目节编号', field: 'code', hAlign: 0, width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
-                            {title: '名称', field: 'name', hAlign: 0, width: 150, formatter: '@', readOnly: true},
-                            {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true}
-                        ],
-                        treeCol: 0,
-                        emptyRows: 0,
-                        headRows: 1,
-                        headRowHeight: [32],
-                        defaultRowHeight: 21,
-                        headerFont: '12px 微软雅黑',
-                        font: '12px 微软雅黑',
-                        headColWidth: [0],
-                    });
-                    stdXmj.loadLib($('select', '#std-xmj').val());
+                    stdXmj = new stdLib(stdXmjSetting);
                 }
                 stdXmj.spread.refresh();
             } else if (tab.attr('content') === '#std-gcl') {
                 if (!stdGcl) {
-                    stdGcl = new stdLib('#std-gcl', 'gcl', {
-                        id: 'bill_id',
-                        pid: 'pid',
-                        order: 'order',
-                        level: 'level',
-                        rootId: -1,
-                        keys: ['id', 'list_id', 'bill_id']
-                    }, {
-                        cols: [
-                            {title: '清单编号', field: 'b_code', hAlign: 0, width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
-                            {title: '名称', field: 'name', hAlign: 0, width: 150, formatter: '@', readOnly: true},
-                            {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true}
-                        ],
-                        treeCol: 0,
-                        emptyRows: 0,
-                        headRows: 1,
-                        headRowHeight: [32],
-                        defaultRowHeight: 21,
-                        headerFont: '12px 微软雅黑',
-                        font: '12px 微软雅黑',
-                        headColWidth: [0],
-                    });
-                    stdGcl.loadLib($('select', '#std-gcl').val());
+                    stdGcl = new stdLib(stdGclSetting);
                 }
                 stdGcl.spread.refresh();
             } else if (tab.attr('content') === '#deal-bills') {

+ 9 - 1
app/public/js/stage.js

@@ -456,7 +456,15 @@ $(document).ready(() => {
     };
     ledgerSpreadSetting.dgnUpFields = ['deal_dgn_qty1', 'deal_dgn_qty2', 'c_dgn_qty1', 'c_dgn_qty2'];
     ledgerSpreadSetting.getColor = function (sheet, data, col, defaultColor) {
-        return data && data.end_contract_qty > data.quantity ? '#f8d7da' : defaultColor;
+        if (data) {
+            if (data.is_tp) {
+                return data.end_contract_tp > data.total_price ? '#f8d7da' : defaultColor;
+            } else {
+                return data.end_contract_qty > data.quantity ? '#f8d7da' : defaultColor;
+            }
+        } else {
+            return defaultColor;
+        }
     };
     SpreadJsObj.initSheet(slSpread.getActiveSheet(), ledgerSpreadSetting);
     slSpread.getActiveSheet().frozenColumnCount(5);

+ 7 - 3
app/public/js/stage_gather.js

@@ -103,9 +103,13 @@ $(document).ready(function () {
         for (let iRow = 0, iLength = sheet.getRowCount(); iRow < iLength; iRow++) {
             const node = sheet.zh_data[iRow];
             if (node) {
-                const bOverRangeQty = node.quantity ? node.end_gather_qty > ZhCalc.mul(node.quantity, nPercent) : node.end_gather_qty;
-                const bOverRangeDealQty = node.deal_bills_qty ? node.end_gather_qty > ZhCalc.mul(node.deal_bills_qty, nPercent) : node.end_gather_qty;
-                const bOverRange = bQty ? bOverRangeQty : (bDealQty ? bOverRangeDealQty : bOverRangeQty || bOverRangeDealQty);
+                const bOverRangeTz = node.end_gather_qty
+                    ? (node.quantity ? node.end_gather_qty > ZhCalc.mul(node.quantity, nPercent) : node.end_gather_qty)
+                    : (node.total_price ? node.end_gather_tp > ZhCalc.mul(node.total_price, nPercent) : node.end_gather_tp);
+                const bOverRangeDeal = node.end_gather_qty
+                    ? (node.deal_bills_qty ? node.end_gather_qty > ZhCalc.mul(node.deal_bills_qty, nPercent) : node.end_gather_qty)
+                    : (node.deal_bills_tp ? node.end_gather_tp > ZhCalc.mul(node.deal_bills_tp, nPercent) : node.end_gather_tp);
+                const bOverRange = bQty ? bOverRangeTz : (bDealQty ? bOverRangeDeal : bOverRangeTz || bOverRangeDeal);
                 const color = bOverRange ? '#f8d7da' : '';
                 sheet.getRange(iRow, -1, 1, -1).backColor(color);
             }

+ 85 - 0
app/public/js/std_lib.js

@@ -0,0 +1,85 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Mai
+ * @date
+ * @version
+ */
+
+/**
+ * setting = { selector, stdType, treeSetting, spreadSetting, cellDoubleClick, page, };
+ */
+
+class stdLib {
+    constructor(setting) {
+        const self = this;
+        this.setting = setting;
+        this.obj = $(setting.selector + '-spread')[0];
+        this.stdType = setting.stdType;
+        this.treeSetting = setting.treeSetting;
+        this.spreadSetting = setting.spreadSetting;
+        this.spreadSetting.stdType = setting.stdType;
+        this.spread = SpreadJsObj.createNewSpread(this.obj);
+        SpreadJsObj.initSheet(this.spread.getActiveSheet(), this.spreadSetting);
+        SpreadJsObj.forbiddenSpreadContextMenu(setting.selector, this.spread);
+        this.spread.getActiveSheet().bind(spreadNS.Events.CellDoubleClick, setting.cellDoubleClick);
+        this.spread.getActiveSheet().bind(spreadNS.Events.SelectionChanged, function (e, info) {
+            if (!info.oldSelections[0] || info.newSelections[0].row !== info.oldSelections[0].row) {
+                SpreadJsObj.saveTopAndSelect(info.sheet, self.cacheKey.node);
+            }
+        });
+        this.spread.getActiveSheet().bind(spreadNS.Events.TopRowChanged, function (e, info) {
+            SpreadJsObj.saveTopAndSelect(info.sheet, self.cacheKey.node);
+        });
+        this.pathTree = createNewPathTree('base', this.treeSetting);
+        this.cacheLib = [];
+        this.cacheKey = {
+            lib: this.setting.page + '-' + this.setting.tid + '-' + this.setting.stdType,
+        };
+        $('select', setting.selector).change(function () {
+            self.loadLib(parseInt(this.value), true);
+        });
+        this._loadCacheLib();
+    }
+
+    _loadCacheLib() {
+        let libId = getLocalCache(this.cacheKey.lib);
+        if (libId) {
+            $('select', this.setting.selector).val(libId);
+            this.loadLib(parseInt(libId));
+        } else {
+            this.loadLib(parseInt($('select', this.setting.selector).val()));
+        }
+    }
+
+    loadLib (listId, reload = false) {
+        this.cacheKey.node = this.setting.page + '-' + this.setting.tid + '-' + this.setting.stdType + '-' + listId;
+        const self = this;
+        const locateMemory = function () {
+            if (!reload) {
+                SpreadJsObj.loadTopAndSelect(self.spread.getActiveSheet(), self.cacheKey.node);
+            } else {
+                removeLocalCache(self.cacheKey.node);
+            }
+        };
+        const cacheData = this.cacheLib.find(function (lib) {
+            return lib.id === listId;
+        });
+        if (cacheData) {
+            this.pathTree.loadDatas(cacheData.data);
+            SpreadJsObj.loadSheetData(this.spread.getActiveSheet(), 'tree', this.pathTree);
+            locateMemory();
+            setLocalCache(this.cacheKey.lib, listId);
+        } else {
+            postData('/std-lib/get-data', {stdType: this.stdType, list_id: listId}, function (data) {
+                self.cacheLib.push({id: listId, data: data});
+                self.pathTree.loadDatas(data);
+                SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'tree', self.pathTree);
+                locateMemory();
+                setLocalCache(self.cacheKey.lib, listId);
+            });
+        }
+    }
+}

+ 1 - 1
app/public/js/tender_list.js

@@ -334,7 +334,7 @@ function getTenderTreeHtml () {
     }
 }
 function bindTenderUrl() {
-    $('a', '.c-body').bind('click', function () {
+    $('.c-body').on('click', 'a', function () {
         const tenderId = parseInt($(this).attr('id'));
         const tender = _.find(tenders, function (t) {
             return t.id === tenderId;

+ 1 - 1
app/public/js/tender_list_info.js

@@ -367,7 +367,7 @@ function getTenderTreeHtml () {
     }
 }
 function bindTenderUrl() {
-    $('a', '.c-body').bind('click', function () {
+    $('.c-body').on('click', 'a', function () {
         const tenderId = parseInt($(this).attr('id'));
         const tender = _.find(tenders, function (t) {
             return t.id === tenderId;

+ 1 - 1
app/public/js/tender_list_progress.js

@@ -345,7 +345,7 @@ function getTenderTreeHtml () {
     }
 }
 function bindTenderUrl() {
-    $('a', '.c-body').bind('click', function () {
+    $('.c-body').on('click', 'a', function () {
         const tenderId = parseInt($(this).attr('id'));
         const tender = _.find(tenders, function (t) {
             return t.id === tenderId;

+ 6 - 67
app/service/report_memory.js

@@ -34,67 +34,6 @@ module.exports = app => {
             this.stageImData = null;
         }
 
-        async _checkTender(tid) {
-            if (this.ctx.tender) return;
-            const tender = await this.ctx.service.tender.getTender(tid);
-            tender.info = await this.ctx.service.tenderInfo.getTenderInfo(tid);
-            this.ctx.tender = tender;
-        }
-
-        async _checkStage(sid) {
-            if (!this.ctx.stage) {
-                const status = audit.stage.status;
-                const stage = await this.ctx.service.stage.getDataById(sid);
-                stage.auditors = await this.ctx.service.stageAudit.getAuditors(stage.id, stage.times);
-                stage.curAuditor = await this.ctx.service.stageAudit.getCurAuditor(stage.id, stage.times);
-
-                const accountId = this.ctx.session.sessionUser.accountId, auditorIds = this._.map(stage.auditors, 'aid'), shareIds = [];
-                if (accountId === stage.user_id) { // 原报
-                    if (stage.curAuditor) {
-                        stage.readOnly = stage.curAuditor.aid !== accountId;
-                    } else {
-                        stage.readOnly = stage.status !== status.uncheck && stage.status !== status.checkNo;
-                    }
-                    stage.curTimes = stage.times;
-                    if (stage.status === status.uncheck || stage.status === status.checkNo) {
-                        stage.curOrder = 0;
-                    } else if (stage.status === status.checked) {
-                        stage.curOrder = this._.max(this._.map(stage.auditors, 'order'));
-                    } else {
-                        stage.curOrder = stage.curAuditor.aid === accountId ? stage.curAuditor.order : stage.curAuditor.order - 1;
-                    }
-                } else if (auditorIds.indexOf(accountId) !== -1) { // 审批人
-                    if (stage.status === status.uncheck) {
-                        throw '您无权查看该数据';
-                    }
-                    stage.curTimes = stage.status === status.checkNo ? stage.times - 1 : stage.times;
-                    if (stage.status === status.checked) {
-                        stage.curOrder = this._.max(this._.map(stage.auditors, 'order'));
-                    } else if (stage.status === status.checkNo) {
-                        const audit = await this.service.stageAudit.getDataByCondition({
-                            sid: stage.id, times: stage.times - 1, status: status.checkNo
-                        });
-                        stage.curOrder = audit.order;
-                    } else {
-                        stage.curOrder = accountId === stage.curAuditor.aid ? stage.curAuditor.order : stage.curAuditor.order - 1;
-                    }
-                } else if (shareIds.indexOf(accountId) !== -1) { // 分享人
-                    if (stage.status === status.uncheck) {
-                        throw '您无权查看该数据';
-                    }
-                    stage.curTimes = stage.status === status.checkNo ? stage.times - 1 : stage.times;
-                    stage.curOrder = stage.status === status.checked ? this._.max(this._.map(stage.auditors, 'order')) : stage.curAuditor.order - 1;
-                }
-
-                this.ctx.stage = stage;
-                let time = this.ctx.stage.readOnly ? this.ctx.stage.cache_time_r : this.ctx.stage.cache_time_l;
-                if (!time) {
-                    time = this.ctx.stage.in_time ? this.ctx.stage.in_time : new Date();
-                }
-                this.ctx.stage.cacheTime = time.getTime();//this.ctx.stage.readOnly ? (this.ctx.stage.cache_time_r).getTime(): (this.ctx.stage.cache_time_l).getTime();
-            }
-        }
-
         // build-time: 162-384ms, redis-cache: 0-41ms, mysql + IO: 116-146ms
         // 一定程度上算是大Value缓存,数据多了以后:
         // 1. 达到redis内存阈值时,数据会swap到磁盘,此时将消耗IO时间
@@ -186,8 +125,8 @@ module.exports = app => {
         }
 
         async getStageImTzData(tid, sid) {
-            await this._checkTender(tid);
-            await this._checkStage(sid);
+            await this.ctx.service.tender.checkTender(tid);
+            await this.ctx.service.stage.checkStage(sid);
             const cache = await this._getReportMemoryCache('mem_stage_im_tz', tid, sid, this.ctx.stage.cacheTime);
             if (cache) {
                 // console.log('cache');
@@ -211,8 +150,8 @@ module.exports = app => {
         }
 
         async getStageImTzBillsData(tid, sid) {
-            await this._checkTender(tid);
-            await this._checkStage(sid);
+            await this.ctx.service.tender.checkTender(tid);
+            await this.ctx.service.stage.checkStage(sid);
             const cache = await this._getReportMemoryCache('mem_stage_im_tz_bills', tid, sid, this.ctx.stage.cacheTime);
             if (cache) return cache;
 
@@ -232,8 +171,8 @@ module.exports = app => {
         }
 
         async getStageImZlData(tid, sid) {
-            await this._checkTender(tid);
-            await this._checkStage(sid);
+            await this.ctx.service.tender.checkTender(tid);
+            await this.ctx.service.stage.checkStage(sid);
             const cache = await this._getReportMemoryCache('mem_stage_im_zl', tid, sid, this.ctx.stage.cacheTime);
             if (cache) return cache;
 

+ 55 - 0
app/service/stage.js

@@ -27,6 +27,61 @@ module.exports = app => {
             this.tableName = 'stage';
         }
 
+
+        async checkStage(sid) {
+            if (!this.ctx.stage) {
+                const status = auditConst.status;
+                const stage = await this.ctx.service.stage.getDataById(sid);
+                stage.auditors = await this.ctx.service.stageAudit.getAuditors(stage.id, stage.times);
+                stage.curAuditor = await this.ctx.service.stageAudit.getCurAuditor(stage.id, stage.times);
+
+                const accountId = this.ctx.session.sessionUser.accountId, auditorIds = this._.map(stage.auditors, 'aid'), shareIds = [];
+                if (accountId === stage.user_id) { // 原报
+                    if (stage.curAuditor) {
+                        stage.readOnly = stage.curAuditor.aid !== accountId;
+                    } else {
+                        stage.readOnly = stage.status !== status.uncheck && stage.status !== status.checkNo;
+                    }
+                    stage.curTimes = stage.times;
+                    if (stage.status === status.uncheck || stage.status === status.checkNo) {
+                        stage.curOrder = 0;
+                    } else if (stage.status === status.checked) {
+                        stage.curOrder = this._.max(this._.map(stage.auditors, 'order'));
+                    } else {
+                        stage.curOrder = stage.curAuditor.aid === accountId ? stage.curAuditor.order : stage.curAuditor.order - 1;
+                    }
+                } else if (auditorIds.indexOf(accountId) !== -1) { // 审批人
+                    if (stage.status === status.uncheck) {
+                        throw '您无权查看该数据';
+                    }
+                    stage.curTimes = stage.status === status.checkNo ? stage.times - 1 : stage.times;
+                    if (stage.status === status.checked) {
+                        stage.curOrder = this._.max(this._.map(stage.auditors, 'order'));
+                    } else if (stage.status === status.checkNo) {
+                        const audit = await this.service.stageAudit.getDataByCondition({
+                            sid: stage.id, times: stage.times - 1, status: status.checkNo
+                        });
+                        stage.curOrder = audit.order;
+                    } else {
+                        stage.curOrder = accountId === stage.curAuditor.aid ? stage.curAuditor.order : stage.curAuditor.order - 1;
+                    }
+                } else if (shareIds.indexOf(accountId) !== -1) { // 分享人
+                    if (stage.status === status.uncheck) {
+                        throw '您无权查看该数据';
+                    }
+                    stage.curTimes = stage.status === status.checkNo ? stage.times - 1 : stage.times;
+                    stage.curOrder = stage.status === status.checked ? this._.max(this._.map(stage.auditors, 'order')) : stage.curAuditor.order - 1;
+                }
+
+                this.ctx.stage = stage;
+                let time = this.ctx.stage.readOnly ? this.ctx.stage.cache_time_r : this.ctx.stage.cache_time_l;
+                if (!time) {
+                    time = this.ctx.stage.in_time ? this.ctx.stage.in_time : new Date();
+                }
+                this.ctx.stage.cacheTime = time.getTime();//this.ctx.stage.readOnly ? (this.ctx.stage.cache_time_r).getTime(): (this.ctx.stage.cache_time_l).getTime();
+            }
+        }
+
         /**
          * 获取 最新一期 期计量
          * @param tenderId

+ 7 - 0
app/service/tender.js

@@ -334,6 +334,13 @@ module.exports = app => {
             return result;
         }
 
+        async checkTender(tid) {
+            if (this.ctx.tender) return;
+            const tender = await this.ctx.service.tender.getTender(tid);
+            tender.info = await this.ctx.service.tenderInfo.getTenderInfo(tid);
+            this.ctx.tender = tender;
+        }
+
     }
 
     return Tender;

+ 2 - 2
app/view/ledger/explode_modal.ejs

@@ -52,7 +52,7 @@
     <div class="modal-dialog modal-lg" role="document">
         <div class="modal-content">
             <div class="modal-header">
-                <h5 class="modal-title">批量插入清单部位</h5>
+                <h5 class="modal-title">批量插入清单-计量单元</h5>
             </div>
             <div class="modal-body">
                 <div class="row">
@@ -60,7 +60,7 @@
                         <h6>清单信息</h6>
                         <div class="batch-l-t">
                         </div>
-                        <h6>部位数量复核表</h6>
+                        <h6>计量单元数量复核表</h6>
                         <div class="batch-l-b">
                         </div>
                     </div>

+ 2 - 2
app/view/revise/info_modal.ejs

@@ -3,7 +3,7 @@
     <div class="modal-dialog modal-lg" role="document">
         <div class="modal-content">
             <div class="modal-header">
-                <h5 class="modal-title">批量插入清单部位</h5>
+                <h5 class="modal-title">批量插入清单-计量单元</h5>
             </div>
             <div class="modal-body">
                 <div class="row">
@@ -11,7 +11,7 @@
                         <h6>清单信息</h6>
                         <div class="batch-l-t">
                         </div>
-                        <h6>部位数量复核表</h6>
+                        <h6>计量单元数量复核表</h6>
                         <div class="batch-l-b">
                         </div>
                     </div>

+ 18 - 1
app/view/tender/detail.ejs

@@ -268,7 +268,24 @@
         },
         tooltip : {
             trigger: 'axis',
-            formatter: "{b} <br/>{a}:{c} %<br/>{a1}:{c1} %"
+            formatter: function (params, ticket, callback) {
+                let sHint = '';
+                for (const param of params) {
+                    if (sHint !== '') {
+                        sHint += '<br>';
+                    }
+                    if (sHint === '' && param.name !== '') {
+                        sHint = param.name + '<br>';
+                    }
+                    sHint += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:9px;height:9px;background-color:' + param.color +'"></span>';
+                    if (param.data) {
+                        sHint += param.seriesName + ': ' + param.data + ' %';
+                    } else {
+                        sHint += param.seriesName + ': -';
+                    }
+                }
+                return sHint;
+            },
         },
         legend: {
             data:['累计完成','本月完成']

+ 3 - 0
config/web.js

@@ -134,6 +134,7 @@ const JsFiles = {
                     "/public/js/zh_calc.js",
                     "/public/js/path_tree.js",
                     "/public/js/ledger_tree_col.js",
+                    "/public/js/std_lib.js",
                     "/public/js/ledger.js",
                 ],
                 mergeFile: 'explode',
@@ -182,6 +183,7 @@ const JsFiles = {
                     "/public/js/ledger_search.js",
                     "/public/js/zh_calc.js",
                     "/public/js/path_tree.js",
+                    "/public/js/std_lib.js",
                     "/public/js/revise.js",
                 ],
                 mergeFile: 'revise',
@@ -201,6 +203,7 @@ const JsFiles = {
                     "/public/js/ledger_search.js",
                     "/public/js/zh_calc.js",
                     "/public/js/path_tree.js",
+                    "/public/js/std_lib.js",
                     "/public/js/revise.js",
                 ],
                 mergeFile: 'revise',