浏览代码

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

TonyKang 6 年之前
父节点
当前提交
9eba7e7e77

+ 2 - 2
modules/glj/models/unit_price_file_model.js

@@ -33,8 +33,8 @@ class UnitPriceFileModel extends BaseModel {
         switch (scene) {
             // 新增数据的验证规则
             case 'add':
-                this.model.schema.path('name').required(true);
-                this.model.schema.path('project_id').required(true);
+               /* this.model.schema.path('name').required(true);
+                this.model.schema.path('project_id').required(true);*/
                 break;
         }
     }

+ 22 - 12
modules/pm/facade/pm_facade.js

@@ -678,6 +678,25 @@ function getBuildingArea(projFeature){
     return null;
 }
 
+// 根据树结构数据排序
+function getSortedDataByTree(data) {
+    // NextSiblingID-数据映射
+    const mapping = {};
+    data.forEach(item => mapping[item.NextSiblingID] = item);
+    let lastItem = data.find(item => +item.NextSiblingID === -1);
+    if (!lastItem) {
+        return data;
+    }
+    const rst = [lastItem];
+    let preItem = mapping[lastItem.ID];
+    while (preItem) {
+        rst.unshift(preItem);
+        preItem = mapping[preItem.ID];
+    }
+    // 根据树结构排序形成的新数组与旧数组项数不同,说明树结构数据有问题(断链),则返回原本数据。
+    return rst.length === data.length ? rst : data;
+}
+
 //根据单位工程ID获取汇总信息
 //@param {Number}tenderID {String}summaryType @return {Object}
 async function getSummaryInfoByTender(tenderID, summaryType) {
@@ -693,20 +712,11 @@ async function getSummaryInfoByTender(tenderID, summaryType) {
         return null;
     }
     let summaryInfo = await getSummaryInfo([project.ID]);
-    //已经没有单项工程这一层
-    if(summaryType === projectType.engineering){
-        /*parentName = engineering.name ? engineering.name : '';
-        let tenders = await projectModel.find({ParentID: engineering.ID, $or: notDeleted});
-        for(let t of tenders){
-            if(summaryInfo[t.ID]){
-                summaryInfo[t.ID]['name'] = t.name ? t.name : '';
-                summaryList.push(summaryInfo[t.ID]);
-            }
-        }*/
-    }
-    else {
+    // 汇总到建设项目层(没有单项工程层了)
+    if (summaryType === projectType.project) {
         parentName = project.name ? project.name : '';
         let tenders = await projectModel.find({ParentID: project.ID, $or: notDeleted});
+        tenders = getSortedDataByTree(tenders);
         for(let t of tenders){
             if(summaryInfo[t.ID]){
                 summaryInfo[t.ID]['name'] = t.name ? t.name : '';

+ 4 - 3
modules/users/models/log_model.js

@@ -64,7 +64,7 @@ class LogModel extends BaseModel {
         ip = ip[3] === undefined ? '' : ip[3];
 
         // let ipInfo = '127.0.0.1';//await this.getIpInfoFromApi(ip);
-       // let ipInfo = await this.getIpInfoFromApi(ip);
+        let ipInfo = await this.getIpInfoFromApi(ip);
 
         let userAgentObject = new UAParser(request.headers['user-agent']);
         let osInfo = userAgentObject.getOS();
@@ -74,7 +74,7 @@ class LogModel extends BaseModel {
             os: osInfo.name + ' ' + osInfo.version + ' ' + cpuInfo.architecture,
             browser: browserInfo.name + ' ' + browserInfo.version,
             ip: ip,
-            ip_info: ""//ipInfo
+            ip_info: ipInfo
         };
 
         return this.addLog(userId, LogType.LOGIN_LOG, message);
@@ -121,7 +121,8 @@ class LogModel extends BaseModel {
         }
         let getData = {
             url: 'http://ip.taobao.com/service/getIpInfo.php?ip=' + ip,
-            encoding: 'utf8'
+            encoding: 'utf8',
+            timeout:2000
         };
         return new Promise(function (resolve, reject) {
             try {

+ 6 - 6
modules/users/models/user_model.js

@@ -67,10 +67,10 @@ class UserModel extends BaseModel {
                 Request.post(postData, function (err, postResponse, body) {
                     if (err) {
                         console.log('111');
-                        throw '请求错误';
+                        reject('请求错误');
                     }
                     if (postResponse.statusCode !== 200) {
-                        throw '通行证验证失败!';
+                        reject('通行证验证失败!');
                     }
                     resolve(body);
                 });
@@ -103,10 +103,10 @@ class UserModel extends BaseModel {
                 Request.post(postData, function (err, postResponse, body) {
                     if (err) {
                         console.log('111');
-                        throw '请求错误';
+                        reject('请求错误');
                     }
                     if (postResponse.statusCode !== 200) {
-                        throw '通行证验证失败!';
+                        reject('通行证验证失败!');
                     }
                     resolve(body);
                 });
@@ -135,10 +135,10 @@ class UserModel extends BaseModel {
                 Request.post(postData, function (err, postResponse, body) {
                     if (err) {
                         console.log('111');
-                        throw '请求错误';
+                        reject('请求错误');
                     }
                     if (postResponse.statusCode !== 200) {
-                        throw '通行证验证失败!';
+                        reject('通行证验证失败!');
                     }
                     resolve(body);
                 });

+ 4 - 3
web/building_saas/main/js/models/bills.js

@@ -801,14 +801,15 @@ var Bills = {
                 me.tree.m_delete(idTreeNodes);
                 $.bootstrapLoading.end();
                 //重新计算
-                project.installation_fee.calcInstallationFee(function (isChange) {
+            /*    project.installation_fee.calcInstallationFee(function (isChange) { 养护没有安装增加费,同时计算安装增加费的clone 那里性能很低
                     project.calcProgram.calcAllNodesAndSave();
                     if(!isChange) {
                         project.projectGLJ.loadData();
                     }
                     gljOprObj.refreshView();
-                });
-
+                });*/
+                project.calcProgram.calcNodesAndSave(parentNodes);
+                gljOprObj.refreshView();
                 if (isDeleteChild){
                     calcTools.forceSelect(parentNode);
                 }

+ 4 - 4
web/building_saas/main/js/models/installation_fee.js

@@ -223,6 +223,10 @@ var installation_fee = {
             }
         };
        installation_fee.prototype.calcInstallationFee=function(callback){
+            if(!projectObj.project.isInstall()){//如果不是安装工程,则不用计算
+                if(callback) callback(false);
+                return;
+            }
             let project = projectObj.project,me = this;
             let engineering = projectObj.project.projectInfo.property.engineering;
             let installSetting = projectObj.project.projectInfo.property.installSetting;
@@ -235,10 +239,6 @@ var installation_fee = {
             let FBMap = {};//保存分部下对应的补项
             let usedBXMap = {};//有使用到的补项
             let startTime =  +new Date();
-            if(!projectObj.project.isInstall()){//如果不是安装工程,则不用计算
-                if(callback) callback(false);
-                return;
-            }
             for(let bx of BXs){//把补项放入映射表中
                 FBMap[bx.ParentID] = bx;
             }

+ 48 - 0
web/over_write/js/zhejiang_2005.js

@@ -0,0 +1,48 @@
+/**
+ * Created by CSL on 2019/09/11.  江西计算程序、基数 等覆盖。
+ */
+
+let isZJ2005 = true;
+
+// 一般计税取不含税市场价、不含税定额价。简易计税取含税市场价、含税定额价。打开项目时,4个价格根据计税类型只载入其二,所以这里可不作区分。
+function overwriteRationCalcBases (taxType){
+    if (typeof rationCalcBases == 'undefined') return;
+    for (let key in rationCalcBases) delete rationCalcBases[key];
+    // let isJY = taxType == '2';
+
+    rationCalcBases['人工费'] = function (node, isTender) {
+        return calcTools.rationBaseFee(node, [gljType.LABOUR], priceTypes.ptMarketPrice, isTender);
+    };
+    rationCalcBases['材料费'] = function (node, isTender) {
+        return calcTools.rationBaseFee(node, baseMaterialTypes, priceTypes.ptMarketPrice, isTender);
+    };
+    rationCalcBases['施工机械费使用费'] = function (node, isTender) {
+        return calcTools.rationBaseFee(node, baseMachineTypes, priceTypes.ptMarketPrice, isTender);
+    };
+};
+
+(function overwriteFeeTypes() {
+    if (typeof cpFeeTypes == 'undefined') return;
+    cpFeeTypes = [
+        {type: 'directWork', name: '直接工程费'},
+        {type: 'direct', name: '直接费'},
+        {type: 'marketLabour', name: '人工费'},
+        {type: 'marketMaterial', name: '材料费'},
+        {type: 'marketMachine', name: '施工机械使用费'},
+        {type: 'otherDirect', name: '其他直接费'},
+        {type: 'local', name: '现场经费'},
+        {type: 'indirect', name: '间接费'},
+        {type: 'profit', name: '计划利润'},
+        {type: 'tax', name: '税金'},
+        {type: 'composite', name: '年度经费综合费'},
+        {type: 'common', name: '养护工程费'}
+    ];
+})();
+
+
+
+
+
+
+
+