Sfoglia il codice sorgente

Merge branch '1.0.0_online' of http://192.168.1.41:3000/SmartCost/ConstructionOperation into 1.0.0_online

TonyKang 6 anni fa
parent
commit
d1138fd8fc

+ 1 - 1
modules/bills_lib/models/bills_lib_interfaces.js

@@ -294,7 +294,7 @@ billsLibDao.prototype.getCurrentUniqId = function(callback){
 }
 //----------------------------Bills---------------------
 billsLibDao.prototype.getBills = function (billsLibId, callback) {
-    Bills.find({billsLibId: billsLibId, deleted: false}, "-_id",  function(err, billsData){
+    Bills.find({billsLibId: billsLibId, deleted: false}, "-_id", {lean: true}, function(err, billsData){
         if(err){
             callback(1, "Error", null);
         }

+ 1 - 1
modules/ration_repository/controllers/ration_repository_controller.js

@@ -269,7 +269,7 @@ class RationRepositoryController extends baseController {
             let stdGLJList = {};
             let stdGLJListByID = {};
             for (const tmp of stdGLJData) {
-                if (tmp.priceProperty && tmp.priceProperty.price1) {
+                if (tmp.priceProperty && Object.keys(tmp.priceProperty).length) {
                     tmp.basePrice = tmp.priceProperty.price1;
                 }
                 stdGLJList[tmp.code.toString()] = tmp.ID;

+ 26 - 29
modules/ration_repository/models/ration_item.js

@@ -497,10 +497,9 @@ rationItemDAO.prototype.updateRationBasePrc = function (basePrcArr, overWriteUrl
                                         gljArr.push({gljId: theGlj.ID, basePrice: adjBasePrice, gljParentType: gljParentType, unit: theGlj.unit});
                                     } else {
                                         if(theGlj.priceProperty && Object.keys(theGlj.priceProperty).length > 0){
-                                            let priceKeys = Object.keys(theGlj.priceProperty);
                                             gljArr.push({
                                                 gljId: theGlj.ID,
-                                                basePrice: parseFloat(theGlj.priceProperty[priceKeys[0]]),
+                                                basePrice: parseFloat(theGlj.priceProperty.price1),
                                                 gljParentType: gljParentType,
                                                 unit: theGlj.unit});
                                         } else {
@@ -731,35 +730,33 @@ rationItemDAO.prototype.calcForRation = function (stdGljList, ration, overWriteU
     for(let rationGlj of rationGljList) {
         let glj = stdGljList[rationGlj.gljId];
         let gljPType = parseInt(glj.gljType.toString().match(/\d+?/)[0]);
-        if (glj.priceProperty && Object.keys(glj.priceProperty).length > 0) {
-            let priceKeys = Object.keys(glj.priceProperty);
-            gljArr.push({
-                gljId: glj.ID,
-                basePrice: parseFloat(glj.priceProperty[priceKeys[0]]),
-                consumeAmt: rationGlj.consumeAmt,
-                gljParentType: gljPType,
-                unit: glj.unit
-            });
-        } else {
-            gljArr.push({gljId: glj.ID, basePrice: parseFloat(glj.basePrice), consumeAmt: rationGlj.consumeAmt, gljParentType: gljPType, unit: glj.unit});
-        }
-        let updatePrc = null;
-        let overWriteCalc = false;  //需要重写算法
-        if (overWriteUrl) {
-            let overWriteExports = require(overWriteUrl);
-            if (typeof overWriteExports.calcRation !== 'undefined') {
-                overWriteCalc = true;
-                updatePrc = overWriteExports.calcRation(gljArr, scMathUtil);
-            }
-        }
-        if (!overWriteCalc) {
-            updatePrc = calcRation(gljArr);
+        let newGlj = {
+            gljId: glj.ID,
+            consumeAmt: rationGlj.consumeAmt,
+            gljParentType: gljPType,
+            unit: glj.unit
+        };
+        newGlj.basePrice = glj.priceProperty && Object.keys(glj.priceProperty).length > 0
+            ? parseFloat(glj.priceProperty.price1)
+            : parseFloat(glj.basePrice);
+        gljArr.push(newGlj);
+    }
+    let updatePrc = null;
+    let overWriteCalc = false;  //需要重写算法
+    if (overWriteUrl) {
+        let overWriteExports = require(overWriteUrl);
+        if (typeof overWriteExports.calcRation !== 'undefined') {
+            overWriteCalc = true;
+            updatePrc = overWriteExports.calcRation(gljArr, scMathUtil);
         }
-        ration.labourPrice = updatePrc.labourPrice.toString();
-        ration.materialPrice = updatePrc.materialPrice.toString();
-        ration.machinePrice = updatePrc.machinePrice.toString();
-        ration.basePrice = updatePrc.basePrice.toString();
     }
+    if (!overWriteCalc) {
+        updatePrc = calcRation(gljArr);
+    }
+    ration.labourPrice = updatePrc.labourPrice.toString();
+    ration.materialPrice = updatePrc.materialPrice.toString();
+    ration.machinePrice = updatePrc.machinePrice.toString();
+    ration.basePrice = updatePrc.basePrice.toString();
 };
 
 /**

+ 4 - 3
modules/std_glj_lib/models/gljModel.js

@@ -15,12 +15,13 @@ import async from "async";
 
 class GljDao  extends OprDao{
     getGljTypes (gljLibId, callback){
-        gljClassModel.find({"repositoryId": gljLibId, "$or": [{"isDeleted": null}, {"isDeleted": false}, {deleted: false} ]},function(err,data){
+        gljClassModel.find({"repositoryId": gljLibId, "$or": [{"isDeleted": null}, {"isDeleted": false}, {deleted: false} ]},
+            '-_id', {lean: true}, function(err,data){
             if(err) callback("获取工料机类型错误!",false)
             else {
                 callback(0, data);
             }
-        })
+        });
     }
 
     _exist(data, attr){
@@ -46,7 +47,7 @@ class GljDao  extends OprDao{
 
     async getGljItemsByRep(repositoryId,callback = null){
         try {
-            let rst = await gljModel.find({repositoryId: repositoryId});
+            let rst = await gljModel.find({repositoryId: repositoryId}).lean();
             callback(0, rst);
         } catch (err) {
             callback(1, null);

+ 5 - 3
public/web/sheet/sheet_common.js

@@ -237,15 +237,17 @@ var sheetCommonObj = {
                     itemObj = {};
                 }
             } else if (pastedInfo.pasteData.text[i] === "\t" || pastedInfo.pasteData.text[i] === "\r") {
-                itemObj[setting.header[propId].dataCode] = pastedInfo.pasteData.text.slice(preStrIdx, i);
+                if (setting.header[propId]) {
+                    itemObj[setting.header[propId].dataCode] = pastedInfo.pasteData.text.slice(preStrIdx, i);
+                }
                 propId++;
                 preStrIdx = i + 1;
                 //if the last copied-cell were empty, should check whether the end of text
-                if (i == pastedInfo.pasteData.text.length - 1) {
+                if (i == pastedInfo.pasteData.text.length - 1 && setting.header[propId]) {
                     itemObj[setting.header[propId].dataCode] = pastedInfo.pasteData.text.slice(preStrIdx);
                     rst.push(itemObj);
                 }
-            } else if (i == pastedInfo.pasteData.text.length - 1) {
+            } else if (i == pastedInfo.pasteData.text.length - 1 && setting.header[propId]) {
                 itemObj[setting.header[propId].dataCode] = pastedInfo.pasteData.text.slice(preStrIdx);
                 rst.push(itemObj);
             }

+ 12 - 4
web/common/js/slideResize.js

@@ -15,6 +15,8 @@
  * */
 
 const SlideResize = (function() {
+    // 水平拖动条的宽度
+    let resizeWidth = 10;
     //函数防抖
     let timer = null;
     function deBounce(fn, wait) {
@@ -26,14 +28,13 @@ const SlideResize = (function() {
     //设置水平拖动条的宽度
     //@param {Object dom}resize滚动条
     function setResizeWidth (resize) {
-        const fixedWidth = 10;
         //滚动条节点 及 同层非滚动条节点的索引
         let bros = resize.parent().children();
         let index = bros.index(resize),
             otherIndex = index ? 0 : 1;
         const other = resize.parent().children(`:eq(${otherIndex})`);
         let resizeParentWidth = resize.parent().width();
-        let resizeDecimalWidth = fixedWidth / resizeParentWidth,
+        let resizeDecimalWidth = resizeWidth / resizeParentWidth,
             otherDecimalWidth = 1 - resizeDecimalWidth;
         let resizePercentWidth = resizeDecimalWidth * 100 + '%',
             otherPercentWidth = otherDecimalWidth * 100 + '%';
@@ -68,7 +69,6 @@ const SlideResize = (function() {
         });
         $('body').mousemove(function (e) {
             if (drag) {
-                console.log('drag');
                 let moveSize = e.clientX - startPoint;
                 leftChange = leftWidth + moveSize;
                 leftChange = leftChange < limit.min ? limit.min : leftChange;
@@ -259,5 +259,13 @@ const SlideResize = (function() {
         }
     }
 
-    return {setResizeWidth, horizontalSlide, loadHorizonWidth, verticalSlide, loadVerticalHeight, loadMultiVerticalHeight}
+    return {
+        resizeWidth,
+        setResizeWidth,
+        horizontalSlide,
+        loadHorizonWidth,
+        verticalSlide,
+        loadVerticalHeight,
+        loadMultiVerticalHeight
+    }
 })();

+ 5 - 5
web/maintain/basic_info_lib/js/basic_info_edit.js

@@ -60,18 +60,18 @@ $(document).ready(function () {
             ]},
             {dispName: '招标信息', key: 'biddingInfo', readOnly: true, items: [
                 {dispName: '招标人', key: 'bidInviter', value: ''},
-                {dispName: '法定代表人或其他授权人', key: 'representative', value: ''},
-                {dispName: '造价工程师', key: 'costEngineer', value: ''}
+                {dispName: '法定代表人或其他授权人', key: 'tenderRepresentative', value: ''},
+                {dispName: '造价工程师', key: 'tenderCostEngineer', value: ''}
             ]},
             {dispName: '投标信息', key: 'bidInfo', readOnly: true, items: [
                 {dispName: '投标人', key: 'bidder', value: ''},
                 {dispName: '法定代表人或其授权人', key: 'representative', value: ''},
-                {dispName: '造价工程师', key: 'costEngineer', value: ''}
+                {dispName: '造价工程师', key: 'bidCostEngineer', value: ''}
             ]},
             {dispName: '工程造价咨询信息', key: 'engineeringCostConsultationInfo', readOnly: true, items: [
-                {dispName: '工程造价咨询人', key: 'consultant', value: ''},
+                {dispName: '工程造价咨询人', key: 'consultRepresentative', value: ''},
                 {dispName: '法定代表人或其授权人', key: 'representative', value: ''},
-                {dispName: '造价工程师', key: 'costEngineer', value: ''}
+                {dispName: '造价工程师', key: 'consultCostEngineer', value: ''}
             ]}
         ];
         try {

+ 4 - 0
web/maintain/main_col_lib/js/main_tree_col.js

@@ -132,6 +132,10 @@ let MainTreeCol = {
                 '根', '组', '系统', '台', '套', '株', '丛', '缸', '支', '只', '块', '座', '对', '份', '樘', '攒', '榀']);
             return combo;
         },
+        // 工作内容
+        jobContent: function () {
+
+        },
         feeRate: function () {
             return feeRateObject.getFeeRateEditCellType();
         },

+ 98 - 86
web/maintain/ration_repository/js/coe.js

@@ -533,11 +533,13 @@ let gljAdjOprObj = {
         header: [
             {headerName:"调整类型", headerWidth:80, dataCode:"coeType", dataType: "String", hAlign: "center", vAlign: "center", readOnly: false},
             {headerName:"人材机编码", headerWidth:80, dataCode:"gljCode", dataType: "String", formatter: '@', hAlign: "center", vAlign: "center", readOnly: false},
-            {headerName:"名称", headerWidth:100, dataCode:"gljName", dataType: "String", hAlign: "center", vAlign: "center", readOnly: true},
+            // readOnly: true --> false,需要兼容粘贴列包含只读项
+            {headerName:"名称", headerWidth:100, dataCode:"gljName", dataType: "String", hAlign: "center", vAlign: "center", readOnly: false},
             {headerName:"操作符", headerWidth:60, dataCode:"operator", dataType: "String", hAlign: "center", vAlign: "center", readOnly: false},
             {headerName:"数量", headerWidth:80, dataCode:"amount", dataType: "String", hAlign: "center", vAlign: "center" , readOnly: false},
             {headerName:"替换为编码", headerWidth:80, dataCode:"replaceCode", dataType: "String", formatter: '@', hAlign: "center", vAlign: "center", readOnly: false},
-            {headerName:"替换为名称", headerWidth:100, dataCode:"replaceName", dataType: "String", hAlign: "center", vAlign: "center", readOnly: true}
+            // readOnly: true --> false
+            {headerName:"替换为名称", headerWidth:100, dataCode:"replaceName", dataType: "String", hAlign: "center", vAlign: "center", readOnly: false}
         ],
         comboItems: {
             //调整类型下拉菜单
@@ -557,7 +559,6 @@ let gljAdjOprObj = {
         me.workSheet.bind(GC.Spread.Sheets.Events.EditStarting, me.onEditStart);
         me.workSheet.bind(GC.Spread.Sheets.Events.EditEnded, me.onEditEnded);
         me.workSheet.bind(GC.Spread.Sheets.Events.EnterCell, me.onEnterCell);
-        me.workSheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
         me.workSheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
     },
     buildBaseCell: function (sheet) {
@@ -589,16 +590,37 @@ let gljAdjOprObj = {
     onEditStart: function (sender, args) {
         let me = gljAdjOprObj;
         let dataCode = me.setting.header[args.col].dataCode;
-        if(!coeOprObj.currentCoe || args.row >= me.currentGljAdjList.length  ){//超出编辑范围
-            if(dataCode=== 'gljCode' || dataCode=== 'replaceCode') args.cancel = true;
+        // 超出范围-没有选中的调整主项
+        if (!coeOprObj.currentCoe) {
+            args.cancel = true;
             return;
         }
-        if(dataCode=== 'gljCode' && me.currentGljAdjList[args.row].coeType !== '单个工料机'&& me.currentGljAdjList[args.row].coeType !== '替换人材机'){ //单个人才机和替换人材机,编码才能编辑
+        // 名称、替换为名称总是不可编辑(表头设置readOnly没有设置为true,因为需要粘贴)
+        let alwaysNotEditable = ['gljName', 'replaceName'];
+        if (alwaysNotEditable.includes(dataCode)) {
             args.cancel = true;
             return;
         }
-        if(dataCode=== 'replaceCode' && me.currentGljAdjList[args.row].coeType !== '替换人材机'){//替换人材机类型 替换编码才能编辑
+        // 新一行编辑时,除了总是可编辑的单元格:调整类型、操作符、数量,其他不可编辑
+        let alwaysEditable = ['coeType', 'operator', 'amount'];
+        if (args.row > me.currentGljAdjList.length - 1 &&
+            !alwaysEditable.includes(dataCode)) {
             args.cancel = true;
+            return;
+        }
+        let curSubCoe = me.currentGljAdjList[args.row];
+        if (!curSubCoe) {
+            return;
+        }
+        // 调整类型不为“单个工料机”和“替换人材机”时,人材机编码不可编辑
+        if (!['单个工料机', '替换人材机'].includes(curSubCoe.coeType) && dataCode === 'gljCode') {
+            args.cancel = true;
+            return;
+        }
+        // 调整类型不为“替换人材机”时,替换为编码不可编辑
+        if (curSubCoe.coeType !== '替换人材机' && dataCode === 'replaceCode') {
+            args.cancel = true;
+            return;
         }
     },
     onEditEnded: function (sender, args) {
@@ -666,85 +688,77 @@ let gljAdjOprObj = {
             }
         }
     },
-    onClipboardPasting: function (sender, info) {
-
-    },
-    getValidPasteDatas: function (pasteItems, info) {//2018-12-21  这里的if else 太多了,不好维护
+    getValidPasteData: function (pasteItems, info) {
         let me = gljAdjOprObj;
-        let rst = [];
-        for(let i = 0, len = pasteItems.length; i < len; i++){
-            let row = i + info.cellRange.row;
-            let validObj = {};
-            //update
-            if(row < me.currentGljAdjList.length){
-                let updateObj = me.currentGljAdjList[row];
-                validObj.index = row;//要有下标做为匹配的依据,不然在复制多行并且某个单元格是只读的情况下,这里返回的updateList个数会比选中的行数少,造成更新行和实际不匹配的情况
-                if(typeof pasteItems[i].coeType !== 'undefined' && typeof pasteItems[i].gljCode !== 'undefined'){
-                    let gljName = me.getGljName(pasteItems[i].gljCode, me.gljList);
-                    if((updateObj.coeType === '单个工料机'||updateObj.coeType === '替换人材机') && gljName){
-                        validObj.coeType = pasteItems[i].coeType;
-                        validObj.gljCode = pasteItems[i].gljCode;
-                        validObj.gljName = gljName;
-                    }
-                    else if((pasteItems[i].coeType !== '单个工料机'||pasteItems[i].coeType !== '替换人材机') && me.setting.comboItems.coeType.indexOf(pasteItems[i].coeType) !== -1){
-                        validObj.coeType = pasteItems[i].coeType;
-                    }
+        function isDef(v) {
+            return v !== undefined && v !== null;
+        }
+        // 粘贴项匹配处理
+        let rules = {
+            coeType: function (v, cur, tar) {
+                if (v === '') {
+                    tar.coeType = v;
+                    tar.gljCode = v;
+                    tar.gljName = v;
+                    tar.replaceCode = v;
+                    tar.replaceName = v;
+                } else if (me.setting.comboItems.coeType.includes(v)) {
+                    tar.coeType = v;
                 }
-                else if(typeof pasteItems[i].coeType === 'undefined' && typeof pasteItems[i].gljCode !== 'undefined'){
-                    let gljName = me.getGljName(pasteItems[i].gljCode, me.gljList);
-                    if(typeof updateObj.coeType !== 'undefined' && (updateObj.coeType === '单个工料机'||updateObj.coeType === '替换人材机') && gljName){
-                        validObj.gljCode = pasteItems[i].gljCode;
-                        validObj.gljName = gljName;
+            },
+            gljCode: function (v, cur, tar) {
+                if (v === '') {
+                    tar.gljCode = v;
+                    tar.gljName = v;
+                } else if (['单个工料机', '替换人材机'].includes(tar.coeType) ||
+                    (!isDef(tar.coeType) && isDef(cur) && ['单个工料机', '替换人材机'].includes(cur.coeType))) {
+                    let gljName = me.getGljName(v, me.gljList);
+                    if (gljName) {
+                        tar.gljCode = v;
+                        tar.gljName = gljName;
                     }
                 }
-                else if(typeof pasteItems[i].coeType !== 'undefined' && typeof pasteItems[i].gljCode === 'undefined'){
-                    if(me.setting.comboItems.coeType.indexOf(pasteItems[i].coeType) !== -1){
-                        validObj.coeType = pasteItems[i].coeType;
-                        if(validObj.coeType !== '单个工料机' && typeof updateObj.coeType !== '单个工料机' && updateObj.gljCode.toString().trim().length > 0){
-                            validObj.gljCode = '';
-                            validObj.gljName = '';
-                        }
-                    }
-                } else {
-                    if(typeof pasteItems[i].operator !== 'undefined' && me.setting.comboItems.operator.indexOf(pasteItems[i].operator) !== -1){
-                        validObj.operator = pasteItems[i].operator;
-                    }
-                    if(typeof pasteItems[i].amount !== 'undefined' && !isNaN(pasteItems[i].amount)){
-                        validObj.amount = pasteItems[i].amount;
-                    }
+            },
+            amount: function (v, cur, tar) {
+                if (!isNaN(v)) {
+                    tar.amount = v;
                 }
-                if(typeof pasteItems[i].replaceCode !== 'undefined' && updateObj.coeType === '替换人材机'){
-                    let gljName = me.getGljName(pasteItems[i].replaceCode, me.gljList);
-                    validObj.replaceCode = pasteItems[i].replaceCode;
-                    validObj.replaceName = gljName;
+            },
+            operator: function (v, cur, tar) {
+                if (v === '' || me.setting.comboItems.operator.includes(v)) {
+                    tar.operator = v;
                 }
-            }
-            else {
-                if(typeof pasteItems[i].coeType !== 'undefined' && typeof pasteItems[i].gljCode !== 'undefined'){
-                    let gljName = me.getGljName(pasteItems[i].gljCode, me.gljList);
-                    if((pasteItems[i].coeType === '单个工料机'||pasteItems[i].coeType === '替换人材机') && gljName){
-                        validObj.coeType = pasteItems[i].coeType;
-                        validObj.gljCode = pasteItems[i].gljCode;
-                        validObj.gljName = gljName;
-                    }
-                    else if((pasteItems[i].coeType !== '单个工料机'||pasteItems[i].coeType !== '替换人材机') && me.setting.comboItems.coeType.indexOf(pasteItems[i].coeType) !== -1){
-                        validObj.coeType = pasteItems[i].coeType;
+            },
+            replaceCode: function (v, cur, tar) {
+                if (v === '') {
+                    tar.replaceCode = v;
+                    tar.replaceName = v;
+                } else if (tar.coeType === '替换人材机' ||
+                    (!isDef(tar.coeType) && isDef(cur) && cur.coeType === '替换人材机')) {
+                    let replaceName = me.getGljName(v, me.gljList);
+                    if (replaceName) {
+                        tar.replaceCode = v;
+                        tar.replaceName = replaceName;
                     }
                 }
-                else if(typeof pasteItems[i].gljCode === 'undefined') {
-                    if(typeof pasteItems[i].coeType !== 'undefined' && me.setting.comboItems.coeType.indexOf(pasteItems[i].coeType) !== -1){
-                        validObj.coeType = pasteItems[i].coeType;
-                    }
-                    if(typeof pasteItems[i].operator !== 'undefined' && me.setting.comboItems.operator.indexOf(pasteItems[i].operator) !== -1){
-                        validObj.operator = pasteItems[i].operator;
-                    }
-                    if(typeof pasteItems[i].amount !== 'undefined' && !isNaN(pasteItems[i].amount)){
-                        validObj.amount = pasteItems[i].amount;
-                    }
+            }
+        };
+        let rst = [];
+        for(let i = 0, len = pasteItems.length; i < len; i++){
+            let row = i + info.cellRange.row;
+            let target = {},
+                curObj = me.currentGljAdjList[row],
+                pasteItem = pasteItems[i];
+            if(row < me.currentGljAdjList.length){
+                target.index = row;//要有下标做为匹配的依据,不然在复制多行并且某个单元格是只读的情况下,这里返回的updateList个数会比选中的行数少,造成更新行和实际不匹配的情况
+            }
+            for (let pasteKey in pasteItem) {
+                if (rules[pasteKey]) {
+                    rules[pasteKey](pasteItem[pasteKey], curObj, target);
                 }
             }
-            if(Object.keys(validObj).length > 0){
-                rst.push(validObj);
+            if(Object.keys(target).length > 0){
+                rst.push(target);
             }
         }
         return rst;
@@ -752,23 +766,21 @@ let gljAdjOprObj = {
     onClipboardPasted: function (sender, info) {
         let me = gljAdjOprObj, row;
         let items = sheetCommonObj.analyzePasteData(me.setting, info);
-        let validDatas = me.getValidPasteDatas(items, info);
-        for(let i = 0, len = validDatas.length; i < len; i++){
+        let validData = me.getValidPasteData(items, info);
+        for(let i = 0, len = validData.length; i < len; i++){
             row = i + info.cellRange.row;
             //update
-            if(row < me.currentGljAdjList.length && typeof validDatas[i].index !=='undefined'){
-                let updateObj = me.currentGljAdjList[validDatas[i].index];//这里改成读取下标
-                delete  validDatas[i].index; //清除下标
-                for(let attr in validDatas[i]){
-                    updateObj[attr] = validDatas[i][attr];
-                }
+            if(row < me.currentGljAdjList.length && typeof validData[i].index !=='undefined'){
+                let updateObj = me.currentGljAdjList[validData[i].index];//这里改成读取下标
+                delete  validData[i].index; //清除下标
+                Object.assign(updateObj, validData[i])
             }
             //insert
             else{
-                me.currentGljAdjList.push(validDatas[i]);
+                me.currentGljAdjList.push(validData[i]);
             }
         }
-        if(validDatas.length > 0){
+        if(validData.length > 0){
             coeOprObj.save([], [coeOprObj.currentCoe], [], false, function () {
                 me.show(me.currentGljAdjList);
             });

+ 15 - 13
web/maintain/ration_repository/js/ration.js

@@ -370,6 +370,9 @@ let rationOprObj = {
         me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
         me.workBook.commandManager().setShortcutKey('rationDelete', GC.Spread.Commands.Key.del, false, false, false, false);
     },
+    isDef: function (v) {
+        return v !== undefined && v !== null;
+    },
     onLeaveCell: function (sender, args) {
         let me = rationOprObj;
         me.lastCol = me.setting.header[args.col];
@@ -430,13 +433,17 @@ let rationOprObj = {
         }
     },
     onCellEditEnd: function(sender, args) {
-        let edV = args.sheet.getValue(args.row, args.col);
-        if(edV){
-            args.sheet.setValue(args.row, args.col, edV.toString().trim());
-        }
-        let me = rationOprObj, rObj = sheetsOprObj.combineRationRowData(me.workBook.getSheet(0), me.setting, args.row),
-            updateArr = [], addArr = [];
+        let me = rationOprObj;
+        // 输入编号、名称、单位时,如果输入回车符或粘贴回车符,提交时应转换为空格。
         let dataCode = me.setting.header[args.col].dataCode;
+        let deESCFields = ['code', 'name', 'unit'];
+        if(deESCFields.includes(dataCode)){
+            args.editingText = me.isDef(args.editingText) ? args.editingText.toString().replace(/[\r, \n]/g, ' ') : '';
+            args.sheet.setValue(args.row, args.col, args.editingText);
+        }
+        let rObj = sheetsOprObj.combineRationRowData(me.workBook.getSheet(0), me.setting, args.row),
+            updateArr = [],
+            addArr = [];
         me.editingRowIdx = args.row;
         if (me.currentEditingRation["ID"]) {
             if((!args.editingText || args.editingText.toString().trim().length === 0) && args.col === 0){
@@ -749,13 +756,10 @@ let rationOprObj = {
             sheetAss = rationAssistOprObj.sheet, settingAss = rationAssistOprObj.setting,
             sheetInst = rationInstObj.sheet, settingInst = rationInstObj.setting;
         if (me.workBook) {
-            if (me.currentRations && me.currentRations["_SEC_ID_" + sectionID] && me.currentRations["_SEC_ID_" + sectionID].length > 0) {
+            sheetCommonObj.cleanData(me.workBook.getSheet(0), me.setting, -1);
+            if (me.currentRations && me.currentRations["_SEC_ID_" + sectionID]) {
                 let cacheSection = me.currentRations["_SEC_ID_" + sectionID];
-                sheetCommonObj.cleanData(me.workBook.getSheet(0), me.setting, -1);
                 sheetsOprObj.showData(me.workBook.getSheet(0), me.setting, cacheSection);
-                //combo
-                //sheetCommonObj.setStaticCombo(me.workBook.getActiveSheet(), 0, 2, cacheSection.length, rationUnits, 10, false);
-                //--sheetCommonObj.setDynamicCombo(me.workBook.getActiveSheet(), 0, 2, me.workBook.getActiveSheet().getRowCount(), rationUnits, 10, false);
                 if(me.mixDel === 1){
                     let row = me.workBook.getSheet(0).getSelections()[0].row;
                     if (cacheSection && row < cacheSection.length) {
@@ -780,10 +784,8 @@ let rationOprObj = {
 
             } else {
                 sheetCommonObj.setDynamicCombo(sheetAss, 0, 5, sheetAss.getRowCount(), rationAssistOprObj.setting.comboItems, false, false);
-                //--sheetCommonObj.setDynamicCombo(me.workBook.getActiveSheet(), 0, 2, me.workBook.getActiveSheet().getRowCount(), rationUnits, 10, false);
                 //清除ration数据及工料机数据
                 rationGLJOprObj.currentRationItem = null;
-                sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
                 sheetCommonObj.cleanSheet(sheetGLJ, settingGLJ, -1);
                 sheetCommonObj.cleanSheet(sheetCoe, settingCoe, -1);
                 sheetCommonObj.cleanSheet(sheetAss, settingAss, -1);

+ 3 - 1
web/maintain/ration_repository/js/section_tree.js

@@ -692,7 +692,9 @@ let sectionTreeObj = {
             if (!sectionNode) {
                 return;
             }
-            me.sheet.setActiveCell(sectionNode.serialNo(), 1);
+            let sectionRow = sectionNode.serialNo();
+            me.sheet.setActiveCell(sectionRow, 1);
+            me.sheet.showRow(sectionRow, GC.Spread.Sheets.VerticalPosition.top);
             let doAfterGetRation = function (rations) {
                 let findRation = _.find(rations, {code: rationCode}),
                     rIdx = rations.indexOf(findRation),

+ 10 - 6
web/maintain/std_glj_lib/js/glj.js

@@ -36,9 +36,9 @@ $(document).ready(function () {
     rightElesObj.left = $('#midContent');
     rightElesObj.right = $('#rightContent');
     SlideResize.horizontalSlide(rightElesObj, {min: 200, max: `$('#dataRow').width() - $('#leftContent').width() - 200`}, function () {
-        let resizeRate = 500 / $('#midContent').width(),
+        let resizeRate = SlideResize.resizeWidth * 100 / $('#midContent').width(),
             sheetRate = 100 - resizeRate;
-        $('#leftResize').css('width', `${resizeRate}%`);
+        $('#slideResizeLeft').css('width', `${resizeRate}%`);
         $('#GLJListSheet').css('width', `${sheetRate}%`);
        refreshALlWorkBook();
     });
@@ -752,11 +752,15 @@ let repositoryGljObj = {
         return objA[me.colMapping.colToField[col]] !== objB[[me.colMapping.colToField[col]]];
     },
     onCellEditEnd: function(sender, args) {
-        let me = repositoryGljObj, that = gljComponentOprObj,
-            updateArr = [], addArr = [], updateBasePrcArr = [];
-        let deESCFields = ['code', 'name', 'specs'];//消除转义字符
+        let me = repositoryGljObj,
+            that = gljComponentOprObj,
+            updateArr = [],
+            addArr = [],
+            updateBasePrcArr = [];
+        // 输入编号、名称、规格时,如果输入回车符或粘贴回车符,提交时应转换为空格。
+        let deESCFields = ['code', 'name', 'specs'];
         if(deESCFields.includes(me.setting.header[args.col]['dataCode'])){
-            args.editingText = me.isDef(args.editingText) ? args.editingText.toString().replace(/[\r, \n]/g, '') : '';
+            args.editingText = me.isDef(args.editingText) ? args.editingText.toString().replace(/[\r, \n]/g, ' ') : '';
             args.sheet.setValue(args.row, args.col, args.editingText);
         }
         let rObj = sheetsOprObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row, me);

+ 155 - 74
web/over_write/js/neimenggu_2017.js

@@ -36,63 +36,83 @@ if(typeof materialComponent !== 'undefined'){
     //可以作为材料工料机组成物的工料机类型:普通材料
     materialComponent = [201];
 }
+
+// 计算单个人材机定额价小数位数
+let singleDecimal = -6,
+    // 汇总小数位数
+    summaryDecimal = -2,
+    // 中间过程
+    processDecimal = -6;
+
 //覆盖前端定额基价计算
 //基价=人工费+材料费+机械费+管理费利润
 //管理费利润=Round(人工费*(管理费消耗量+利润消耗量)%,2) 注:书中管理费、利润的单位都是“%”
+//材料费相关:应该是先算单位不是%的,算一个临时材料费,然后%的单个材料费算法是临时材料费*消耗量*0.01,然后最终的材料费是临时材料费+%的单个材料费
 if (typeof rationGLJOprObj !== 'undefined' && typeof rationGLJOprObj.rationCal !== 'undefined') {
     rationGLJOprObj.rationCal = function () {
         let me = rationGLJOprObj;
         let price = {gljType1: [], gljType2: [], gljType3: []},
+            // 临时材料费(非%单位的材料)
+            tempPrice = {gljType1: 0, gljType2: 0, gljType3: 0},
             rst = {labourPrice: 0, materialPrice: 0, machinePrice: 0},
             rationBasePrc = 0;
         let manageProfitConsume = 0;   //管理费、利润消耗量
         if(me.currentRationItem && me.cache['_GLJ_' + me.currentRationItem.ID]){
             let cacheArr = me.cache['_GLJ_' + me.currentRationItem.ID];
+            // 获取临时材料费
             cacheArr.forEach(function (gljData) {
-                if(gljData.gljType && gljData.basePrice && gljData.consumeAmt){
+                if(gljData.gljType && gljData.consumeAmt && gljData.unit !== '%'){
                     let parentGLJType = parseInt(String(gljData.gljType)[0]);
                     if (parentGLJType <= 3) { // 人工、材料、机械
-                        // 单位为%,单条基价计算为定额价*消耗量*0.01
-                        if (gljData.unit === '%') {
-                            price['gljType' + parentGLJType].push(scMathUtil.roundTo(gljData.basePrice * gljData.consumeAmt * 0.01, -3));//取三位
-                        } else {
-                            price['gljType' + parentGLJType].push(scMathUtil.roundTo(gljData.basePrice * gljData.consumeAmt, -3));//取三位
-                        }
+                        let single = scMathUtil.roundTo(gljData.basePrice * gljData.consumeAmt, singleDecimal);
+                        tempPrice['gljType' + parentGLJType] = scMathUtil.roundTo(tempPrice['gljType' + parentGLJType] + single, processDecimal);
                     }
-                    if([6, 7].includes(gljData.gljType)){
-                        manageProfitConsume = scMathUtil.roundTo(manageProfitConsume + gljData.consumeAmt, -6);
+                }
+            });
+            // 临时材料费放入待汇总价格数组中
+            for (let attr in price) {
+                price[attr].push(tempPrice[attr])
+            }
+            cacheArr.forEach(function (gljData) {
+                if(gljData.gljType && gljData.consumeAmt){
+                    let parentGLJType = parseInt(String(gljData.gljType)[0]);
+                    if (parentGLJType <= 3 && gljData.unit === '%') { // 人工、材料、机械
+                        // %的单个材料费算法是临时材料费*消耗量*0.01
+                        price['gljType' + parentGLJType].push(scMathUtil.roundTo(tempPrice['gljType' + parentGLJType] * gljData.consumeAmt * 0.01, singleDecimal));
+                    } else if([6, 7].includes(gljData.gljType)){
+                        manageProfitConsume = scMathUtil.roundTo(manageProfitConsume + gljData.consumeAmt, processDecimal);
                     }
                 }
             });
             if(price.gljType1.length > 0){
                 let labourPrice = 0;
                 price.gljType1.forEach(function (singlePrc) {
-                    labourPrice = scMathUtil.roundTo(labourPrice + singlePrc, me.processDecimal);
+                    labourPrice = scMathUtil.roundTo(labourPrice + singlePrc, processDecimal);
                 });
-                let roundPrice = scMathUtil.roundTo(labourPrice, -2);
+                let roundPrice = scMathUtil.roundTo(labourPrice, summaryDecimal);
                 rst.labourPrice = roundPrice;
-                rationBasePrc = scMathUtil.roundTo(rationBasePrc + roundPrice, -2);
+                rationBasePrc = scMathUtil.roundTo(rationBasePrc + roundPrice, summaryDecimal);
                 //管理费利润
-                let manageProfitPrc = scMathUtil.roundTo(roundPrice * manageProfitConsume * 0.01, -2);
-                rationBasePrc = scMathUtil.roundTo(rationBasePrc + manageProfitPrc, -2);
+                let manageProfitPrc = scMathUtil.roundTo(roundPrice * manageProfitConsume * 0.01, summaryDecimal);
+                rationBasePrc = scMathUtil.roundTo(rationBasePrc + manageProfitPrc, summaryDecimal);
             }
             if(price.gljType2.length > 0){
                 let materialPrice = 0;
                 price.gljType2.forEach(function (singlePrc) {
-                    materialPrice = scMathUtil.roundTo(materialPrice + singlePrc, me.processDecimal);
+                    materialPrice = scMathUtil.roundTo(materialPrice + singlePrc, processDecimal);
                 });
-                let roundPrice = scMathUtil.roundTo(materialPrice, -2);
+                let roundPrice = scMathUtil.roundTo(materialPrice, summaryDecimal);
                 rst.materialPrice = roundPrice;
-                rationBasePrc = scMathUtil.roundTo(rationBasePrc + roundPrice, -2);
+                rationBasePrc = scMathUtil.roundTo(rationBasePrc + roundPrice, summaryDecimal);
             }
             if(price.gljType3.length > 0){
                 let machinePrice = 0;
                 price.gljType3.forEach(function (singlePrc) {
-                    machinePrice = scMathUtil.roundTo(machinePrice + singlePrc, me.processDecimal);
+                    machinePrice = scMathUtil.roundTo(machinePrice + singlePrc, processDecimal);
                 });
-                let roundPrice = scMathUtil.roundTo(machinePrice, -2);
+                let roundPrice = scMathUtil.roundTo(machinePrice, summaryDecimal);
                 rst.machinePrice = roundPrice;
-                rationBasePrc = scMathUtil.roundTo(rationBasePrc + roundPrice, -2);
+                rationBasePrc = scMathUtil.roundTo(rationBasePrc + roundPrice, summaryDecimal);
             }
             rst.rationBasePrc = rationBasePrc;
         }
@@ -100,62 +120,123 @@ if (typeof rationGLJOprObj !== 'undefined' && typeof rationGLJOprObj.rationCal !
     }
 }
 
-if (typeof module !== 'undefined') {
-    module.exports = {
-        // 计算定额基价
-        calcRation: function (gljArr, scMathUtil) {
-            let labourPrc = [],
-                materialPrc = [],
-                machinePrc = [],
-                manageProfitConsume = 0,
-                singlePrc,
-                updatePrc = {labourPrice: 0, materialPrice: 0, machinePrice: 0, manageProfitPrice: 0, basePrice: 0};
-            gljArr.forEach(function (gljItem) {
-                if(gljItem.gljParentType !== -1){
-                    if (gljItem.gljParentType <= 3 && gljItem.unit === '%') {
-                        singlePrc = scMathUtil.roundTo(gljItem.basePrice * gljItem.consumeAmt * 0.01, -3);
-                    } else {
-                        singlePrc = scMathUtil.roundTo(gljItem.basePrice * gljItem.consumeAmt, -3);
-                    }
-                    if(gljItem.gljParentType === 1){
-                        labourPrc.push(singlePrc);
-                    } else if(gljItem.gljParentType ===2){
-                        materialPrc.push(singlePrc);
-                    } else if(gljItem.gljParentType === 3){
-                        machinePrc.push(singlePrc);
-                    } else if(gljItem.gljParentType === 6){
-                        manageProfitConsume = scMathUtil.roundTo(manageProfitConsume + gljItem.consumeAmt, -6);
-                    } else if(gljItem.gljParentType === 7){
-                        manageProfitConsume = scMathUtil.roundTo(manageProfitConsume + gljItem.consumeAmt, -6);
-                    }
-                }
-            });
-            if(labourPrc.length > 0){
-                let sumLaP = 0;
-                for(let i=0; i<labourPrc.length; i++){
-                    sumLaP = scMathUtil.roundTo(sumLaP + labourPrc[i], -6);
-                }
-                updatePrc.labourPrice = scMathUtil.roundTo(sumLaP, -2);
-                updatePrc.manageProfitPrice = scMathUtil.roundTo(updatePrc.labourPrice * manageProfitConsume * 0.01, -2);
-                updatePrc.basePrice = scMathUtil.roundTo(updatePrc.labourPrice + updatePrc.manageProfitPrice, -2);
-            }
-            if(materialPrc.length > 0){
-                let sumMtP = 0;
-                for(let i= 0; i<materialPrc.length; i++){
-                    sumMtP = scMathUtil.roundTo(sumMtP + materialPrc[i], -6);
-                }
-                updatePrc.materialPrice = scMathUtil.roundTo(sumMtP, -2);
-                updatePrc.basePrice = scMathUtil.roundTo(updatePrc.basePrice + updatePrc.materialPrice, -2);
+// 后端用 计算定额基价
+function calcRation(gljArr, scMathUtil) {
+    let labourPrc = [],
+        materialPrc = [],
+        machinePrc = [],
+        manageProfitConsume = 0,
+        updatePrc = {labourPrice: 0, materialPrice: 0, machinePrice: 0, manageProfitPrice: 0, basePrice: 0};
+    // 临时材料费
+    let tempPrice = {gljType1: 0, gljType2: 0, gljType3: 0};
+    gljArr.forEach(function (gljItem) {
+        if (gljItem.gljParentType !== -1 &&
+            gljItem.gljParentType <= 3 &&
+            gljItem.unit !== '%') {
+            let single = scMathUtil.roundTo(gljItem.basePrice * gljItem.consumeAmt, singleDecimal);
+            tempPrice['gljType' + gljItem.gljParentType] = scMathUtil.roundTo(tempPrice['gljType' + gljItem.gljParentType] + single, processDecimal);
+        }
+    });
+    labourPrc.push(tempPrice.gljType1);
+    materialPrc.push(tempPrice.gljType2);
+    machinePrc.push(tempPrice.gljType3);
+    gljArr.forEach(function (gljItem) {
+        let singlePrc = 0;
+        if(gljItem.gljParentType !== -1){
+            if (gljItem.gljParentType <= 3 && gljItem.unit === '%') {
+                singlePrc = scMathUtil.roundTo(tempPrice['gljType' + gljItem.gljParentType] * gljItem.consumeAmt * 0.01, singleDecimal);
+            } else if (gljItem.gljParentType > 3) {
+                singlePrc = scMathUtil.roundTo(gljItem.basePrice * gljItem.consumeAmt, singleDecimal);
             }
-            if(machinePrc.length > 0){
-                let sumMaP = 0;
-                for(let i =0; i< machinePrc.length; i++){
-                    sumMaP = scMathUtil.roundTo(sumMaP + machinePrc[i], -6);
-                }
-                updatePrc.machinePrice = scMathUtil.roundTo(sumMaP, -2);
-                updatePrc.basePrice = scMathUtil.roundTo(updatePrc.basePrice + updatePrc.machinePrice, -2);
+            if(gljItem.gljParentType === 1){
+                labourPrc.push(singlePrc);
+            } else if(gljItem.gljParentType ===2){
+                materialPrc.push(singlePrc);
+            } else if(gljItem.gljParentType === 3){
+                machinePrc.push(singlePrc);
+            } else if(gljItem.gljParentType === 6){
+                manageProfitConsume = scMathUtil.roundTo(manageProfitConsume + gljItem.consumeAmt, processDecimal);
+            } else if(gljItem.gljParentType === 7){
+                manageProfitConsume = scMathUtil.roundTo(manageProfitConsume + gljItem.consumeAmt, processDecimal);
             }
-            return updatePrc;
         }
+    });
+    if(labourPrc.length > 0){
+        let sumLaP = 0;
+        for(let i=0; i<labourPrc.length; i++){
+            sumLaP = scMathUtil.roundTo(sumLaP + labourPrc[i], processDecimal);
+        }
+        updatePrc.labourPrice = scMathUtil.roundTo(sumLaP, summaryDecimal);
+        updatePrc.manageProfitPrice = scMathUtil.roundTo(updatePrc.labourPrice * manageProfitConsume * 0.01, summaryDecimal);
+        updatePrc.basePrice = scMathUtil.roundTo(updatePrc.labourPrice + updatePrc.manageProfitPrice, summaryDecimal);
+    }
+    if(materialPrc.length > 0){
+        let sumMtP = 0;
+        for(let i= 0; i<materialPrc.length; i++){
+            sumMtP = scMathUtil.roundTo(sumMtP + materialPrc[i], processDecimal);
+        }
+        updatePrc.materialPrice = scMathUtil.roundTo(sumMtP, summaryDecimal);
+        updatePrc.basePrice = scMathUtil.roundTo(updatePrc.basePrice + updatePrc.materialPrice, summaryDecimal);
+    }
+    if(machinePrc.length > 0){
+        let sumMaP = 0;
+        for(let i =0; i< machinePrc.length; i++){
+            sumMaP = scMathUtil.roundTo(sumMaP + machinePrc[i], processDecimal);
+        }
+        updatePrc.machinePrice = scMathUtil.roundTo(sumMaP, summaryDecimal);
+        updatePrc.basePrice = scMathUtil.roundTo(updatePrc.basePrice + updatePrc.machinePrice, summaryDecimal);
+    }
+    return updatePrc;
+}
+
+//计税方式
+const taxModel = {'common': 1, 'simple': 2};
+//价格属性:计税方式
+const pricePropertiesTemplate = [
+    {
+        region: '全省',
+        taxModel: taxModel.common,
+        price: {
+            dataCode: 'price1',
+            dataName: '单价-一般'
+        }
+    },
+    {
+        region: '全省',
+        taxModel: taxModel.simple,
+        price: {
+            dataCode: 'price2',
+            dataName: '单价-简易'
+        }
+    }
+];
+
+//消耗量属性:计税方式
+const consumeAmtPropertiesTemplate = [
+    {
+        region: '全省',
+        taxModel: taxModel.common,
+        consumeAmt: {
+            dataCode: 'consumeAmt1',
+            dataName: '消耗-一般',
+            refPrice: 'price1' //关联的单价字段
+        }
+    },
+    {
+        region: '全省',
+        taxModel: taxModel.simple,
+        consumeAmt: {
+            dataCode: 'consumeAmt2',
+            dataName: '消耗-简易',
+            refPrice: 'price2' //关联的单价字段
+        }
+    }
+];
+
+if(typeof module !== 'undefined'){
+    module.exports = {
+        pricePropertiesTemplate: pricePropertiesTemplate,
+        consumeAmtPropertiesTemplate: consumeAmtPropertiesTemplate,
+        calcRation: calcRation
     };
 }