Browse Source

Merge branch 'master' of http://192.168.1.41:3000/SmartCost/YangHuCost

chenshilong 4 years ago
parent
commit
34b8ac583b

+ 1 - 1
modules/main/controllers/ration_controller.js

@@ -191,7 +191,7 @@ module.exports = {
             let functionName = req.url.replace(/\//g,"");
             result.data = controller[functionName]?await controller[functionName](req):"";
         }catch (err){
-            logger.err(err);
+            logger.err(err.stack);
             if(typeof err == "string"){
                 result.error=2;
                 result.message = err;

+ 3 - 3
modules/main/facade/ration_facade.js

@@ -762,6 +762,7 @@ async function getProjectGLJinfo(projectID,t_newRationGLJList,gljKeyMap,gljCodes
         unitPrice.base_price = ration_glj.basePrice;
         unitPrice.market_price = ration_glj.marketPrice;
       }
+      await setIDfromCounter("unit_price",[unitPrice])
       await unitPriceModel.insertMany([unitPrice]);
       p.unit_price =unitPrice
     }
@@ -804,7 +805,7 @@ function newPriceDataFromPGlj(np,unitPriceFileId){
 async function getUnitPriceData(newProjectGLJList,gljCodes,unitPriceFileId){
   let unitPriceMap = {};
   let newUnitPriceList = [];
-  let unitPriceList = await unitPriceModel.find({unit_price_file_id: unitPriceFileId,'code':{'$in':gljCodes}}).lean();
+  let unitPriceList = await unitPriceModel.find({unit_price_file_id: unitPriceFileId}).lean();
   for(let u of unitPriceList){
     unitPriceMap[getIndex(u)]=u;
   }
@@ -842,7 +843,6 @@ async function getUnitPriceData(newProjectGLJList,gljCodes,unitPriceFileId){
     unitPriceMap[pkey] = insertData;
   }
 
-
   if(newUnitPriceList.length > 0){
     await setIDfromCounter("unit_price",newUnitPriceList);
     await unitPriceModel.insertMany(newUnitPriceList);
@@ -863,7 +863,7 @@ async function getMixRatioInfo(projectID,projectGLJMap,newProjectGLJList,mixRati
 
   // 1. 先检查现在的组成物表中,是否有相关信息 - 生成映射记录
   if(connectKeyList.length > 0){//有组成物的话从数据库中取出组成物信息
-    let mixRatioList = await mixRatioModel.find({'unit_price_file_id': unitPriceFileId,'connect_key': {'$in':connectKeyList}}).lean();
+    let mixRatioList = await mixRatioModel.find({'unit_price_file_id': unitPriceFileId}).lean();
     for(let m of mixRatioList){
         //组成物信息分组,查看哪些是已经存在的
        existMixRatioMap[m.connect_key]?existMixRatioMap[m.connect_key].push(m):existMixRatioMap[m.connect_key]=[m];

+ 17 - 0
modules/pm/controllers/pm_controller.js

@@ -13,6 +13,7 @@ let projType = require('../models/project_model').projType;
 let fileType = require('../models/project_model').fileType;
 const engineering = require("../../common/const/engineering");
 let EngineeringLibModel = require("../../users/models/engineering_lib_model");
+const engineeringModel = mongoose.model('engineering_lib');
 let fee_rate_facade = require("../../fee_rates/facade/fee_rates_facade");
 let billsModel = require('../../main/models/bills').model;
 let rationsModel = require('../../main/models/ration').model;
@@ -128,6 +129,22 @@ module.exports = {
                 }
                 delete datas.properties['property.basicInformation'];
             }
+            // 工程特征特殊处理
+            if (datas.properties['property.projectFeature']) {
+                const engineeringItem = _.find(datas.properties['property.projectFeature'], { key: 'engineering' });
+                const feeStandardItem = _.find(datas.properties['property.projectFeature'], { key: 'feeStandard' });
+                if (engineeringItem && engineeringItem.value && feeStandardItem && feeStandardItem.value) {
+                    const project = await projectModel.findOne({ ID: datas.projectID }, { 'property.valuation': 1 }).lean();
+                    if (project) {
+                        const engineering = await engineeringModel.findOne({ valuationID: project.property.valuation, name: engineeringItem.value, feeName: feeStandardItem.value }, { _id: 1 }).lean();
+                        if (engineering) {
+                            datas.properties['property.engineeringName'] = engineeringItem.value;
+                            datas.properties['property.feeStandardName'] = feeStandardItem.value;
+                            datas.properties['property.engineering_id'] = engineering._id.toString();
+                        }
+                    }
+                }
+            }
             functions.push(updateFunc(projectModel, { ID: datas.projectID }, datas.properties));
         };
 

+ 29 - 1
modules/pm/facade/pm_facade.js

@@ -1462,7 +1462,7 @@ async function getFullPath(projectID) {
 }
 
 //@param {String}libID(工程特征库ID) {Object}assign(需要赋值的key-value)
-async function getProjectFeature(libID, assign) {
+async function getProjectFeature(libID, valuationID, assign) {
     let lib = await featureLibModel.findOne({'ID':libID});
     if (lib) {
         for (let key in assign) {
@@ -1471,6 +1471,34 @@ async function getProjectFeature(libID, assign) {
                 obj.value = assign[key];
             }
         }
+        // 特殊处理养护类别和费用标准
+        const engineeringItem = _.find(lib.feature, { key: 'engineering' });
+        const feeStandardItem = _.find(lib.feature, { key: 'feeStandard' });
+        if ((!engineeringItem || engineeringItem.readOnly === 'true') && (!feeStandardItem || feeStandardItem.readOnly === 'true')) {
+            return lib.feature;
+        }
+        const engs = await engineeringModel.find({ valuationID }, { name: 1, feeName: 1 }).lean();
+        const engOptions = [];
+        const feeStandardOptions = {};
+        engs.forEach(item => {
+            const name = item.name ? item.name : '';
+            const feeName = item.feeName ? item.feeName : '';
+            if (!engOptions.includes(name)) {
+                engOptions.push(name);
+            }
+            if (!feeStandardOptions[name]) {
+                feeStandardOptions[name] = [];
+            }
+            if (!feeStandardOptions[name].includes(feeName)) {
+                feeStandardOptions[name].push(feeName);
+            }
+        });
+        if (engineeringItem && engineeringItem.readOnly === 'false') {
+            engineeringItem.options = engOptions.join('@');
+        }
+        if (feeStandardItem && feeStandardItem.readOnly === 'false') {
+            feeStandardItem.relatedOptions = JSON.stringify(feeStandardOptions);
+        }
         return lib.feature;
 
     } else {

+ 1 - 1
modules/pm/models/project_model.js

@@ -207,7 +207,7 @@ ProjectsDAO.prototype.updateUserProjects = async function (userId, compilationId
                             // 新建分段文件时,默认将“工程特征”-“单项工程名称”填写建设项目名称
                             singleProjName: constructionProjectName,
                         };
-                        data.updateData.property.projectFeature = await pmFacade.getProjectFeature(data.updateData.property.featureLibID, assign);
+                        data.updateData.property.projectFeature = await pmFacade.getProjectFeature(data.updateData.property.featureLibID, data.updateData.property.valuation, assign);
                     }
                     /*projectFeature[0]['value'] = data.updateData.property.engineeringName || '';
                     data.updateData.property.projectFeature = projectFeature;*/

+ 12 - 0
web/building_saas/js/global.js

@@ -163,6 +163,18 @@ function replaceAll(FindText, RepText,str) {
     return str.replace(regExp, RepText);
 };
 
+//求余处理成百分号,即乘以0.01
+function handlePercent(text){
+    let arr = text.match(/[\d^%]+%/g);
+    if(arr){
+        for(let str of arr){
+            let tem = str.replace("%"," * 0.01");
+            text = text.replace(str,`${(tem)}`)
+        }
+    }
+    return text
+}   
+
 function setTimeoutSync(handle, time) {
     return new Promise(function(resolve, reject) {
         setTimeout(function () {

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

@@ -1738,6 +1738,7 @@
                             <button class="btn btn-secondary btn-sm" >/</button>
                             <button class="btn btn-secondary btn-sm" >(</button>
                             <button class="btn btn-secondary btn-sm" >)</button>
+                            <button class="btn btn-secondary btn-sm">%</button>
                         </p>
                     </div>
                     <div class="row" >

+ 56 - 4
web/building_saas/main/js/views/project_property_projFeature.js

@@ -108,8 +108,7 @@ let projFeatureView = {
             me.initTree(sheet, true, datas);
             sheet.setFormatter(-1, 1, '@');
             //兼容旧数据
-            let compatLockedKeys = ['engineering'],
-                compatNumKeys = [
+            let compatNumKeys = [
                     'buildingArea',
                     'basementBuildingArea',
                     'totalFloors',
@@ -122,8 +121,20 @@ let projFeatureView = {
                     'standardFloorHeight'
                 ];
             for(let row = 0;row < datas.length ; row ++){
+                console.log(datas[row]);
                 if(datas[row].cellType == 'comboBox'){
-                    let options = datas[row].options?datas[row].options.split("@"):[];
+                    let options = [];
+                    if (datas[row].options) {
+                        options = datas[row].options.split("@")
+                    } else if (datas[row].relatedOptions) {
+                        const eng = datas.find(item => item.key === 'engineering');
+                        const engValue = eng.value || '';
+                        const relatedOptions = JSON.parse(datas[row].relatedOptions);
+                        options = relatedOptions[engValue] || [];
+                    } else {
+                        options = [];
+                    }
+                    // let options = datas[row].options?datas[row].options.split("@"):[];
                     me.setCombo(sheet, row, options);
                 } else if(datas[row].cellType == 'number' || compatNumKeys.includes(datas[row].key)){
                     me.setting.numRows.push(row);
@@ -131,7 +142,7 @@ let projFeatureView = {
                     me.setting.dateRows.push(row);
                 }
                 let readOnly = typeof datas[row].readOnly === 'string' ? JSON.parse(datas[row].readOnly) : datas[row].readOnly;
-                if (readOnly || datas[row].items || compatLockedKeys.includes(datas[row].key)) {
+                if (readOnly || datas[row].items) {
                     me.setting.locked.rows.push(row);
                 }
                 for(let col = 0;col < cols.length;col++){
@@ -177,6 +188,19 @@ let projFeatureView = {
                     }
                 }
             }
+            // 特殊处理养护类别和费用标准
+            const item = me.datas[args.row];
+            if (item.key === 'engineering') {
+                const feeStandardItem = me.datas.find(d => d.key === 'feeStandard');
+                if (feeStandardItem && feeStandardItem.cellType === 'comboBox' && feeStandardItem.relatedOptions) {
+                    const relatedOptions = JSON.parse(feeStandardItem.relatedOptions);
+                    const options = relatedOptions[v];
+                    const feeStandardRow = me.datas.indexOf(feeStandardItem);
+                    me.setCombo(args.sheet, feeStandardRow, options);
+                    args.sheet.setValue(feeStandardRow, args.col, options[0]);
+                    feeStandardItem.value = options[0];
+                }
+            }
             me.datas[args.row].value = v;
         }
     },
@@ -197,6 +221,13 @@ let projFeatureView = {
         if(items.length === 0){
             return;
         }
+        let relatedOptions;
+        const feeStandardItem = me.datas.find(d => d.key === 'feeStandard');
+        if (feeStandardItem && feeStandardItem.cellType === 'comboBox' && feeStandardItem.relatedOptions) {
+            relatedOptions = JSON.parse(feeStandardItem.relatedOptions);
+        }
+        const engineeringItem = me.datas.find(d => d.key === 'engineering');
+        let engineeringVal = engineeringItem && engineeringItem.value || '';
         for(let i = 0, len = items.length; i < len; i++){
             let row = i + args.cellRange.row;
             let comboItems = me.getComboItemsByRow(row);
@@ -207,6 +238,27 @@ let projFeatureView = {
             else if (required && !items[i].value) {
                 recRows.push(row);
             }
+            // 特殊处理养护类别和费用标准
+            else if (me.datas[row].key === 'engineering') {
+                if (comboItems && !comboItems.includes(items[i].value)) {
+                    recRows.push(row);
+                } else {
+                    engineeringVal = items[i].value;
+                    if (relatedOptions) {
+                        const options = relatedOptions[items[i].value];
+                        const feeStandardRow = me.datas.indexOf(feeStandardItem);
+                        me.setCombo(args.sheet, feeStandardRow, options);
+                        args.sheet.setValue(feeStandardRow, args.cellRange.col, options[0]);
+                        feeStandardItem.value = options[0];
+                    }
+                }
+            }
+            else if (me.datas[row].key === 'feeStandard') {
+                const options = relatedOptions[engineeringVal];
+                if (!options.includes(items[i].value)) {
+                    args.sheet.setValue(row, args.cellRange.col, options[0]);
+                }
+            }
             //粘贴下拉框数据过滤
             else if(comboItems && !comboItems.includes(items[i].value)){
                 recRows.push(row);

+ 5 - 1
web/building_saas/main/js/views/quantity_edit_view.js

@@ -149,8 +149,10 @@ let quantityEditObj = {
             return true;
         }*/
         quantityEXP = quantityEXP?quantityEXP.toUpperCase():'';//非空判断
-        quantityEXP =replaceAll('(','(',quantityEXP);//转换中文左右符号
+        quantityEXP =replaceAll('(','(',quantityEXP);//转换中文左右符号与。、
         quantityEXP =replaceAll(')',')',quantityEXP);
+        quantityEXP =replaceAll('。','.',quantityEXP);
+        quantityEXP =replaceAll('、','/',quantityEXP);
         quantityEXP = quantityEXP.replace(/[\s\r\n]/g, "")//去掉空格回车换行等字符
         let value = me.evalQuantityExp(quantityEXP,node);
         if(value!=='evalError'){
@@ -172,6 +174,8 @@ let quantityEditObj = {
     },
     evalQuantityExp(quantityEXP,node){
         let evalString = quantityEXP;
+        //求余% 换成 * 0.01 再计算
+         evalString =handlePercent(evalString);
         if( node.sourceType == ModuleNames.ration && quantityEXP.indexOf('QDL')!=-1){
             let billNode = node.parent;
             let bQuantity = 0;