Просмотр исходного кода

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

zhongzewei 6 лет назад
Родитель
Сommit
ce9fe92f8c

+ 2 - 2
modules/all_models/bills.js

@@ -6,10 +6,10 @@ let subSchema = require("../all_schemas/bills_sub_schemas");
 let deleteSchema = require('../all_schemas/delete_schema');
 let Schema = mongoose.Schema;
 let billsSchema = new Schema({
-    ID: String,
+    ID: {type: String, index: true},
     ParentID: String,
     NextSiblingID: String,
-    projectID: Number,
+    projectID: {type: Number, index: true} ,
     serialNo: Number,
     chapterID: Number,
     billsLibId: Number,

+ 3 - 3
modules/all_models/fee_rates.js

@@ -38,7 +38,7 @@ let ratesSchema = new Schema({
 },{versionKey:false,_id: false});
 
 let feeRatesSchema = new Schema({
-    ID: String,
+    ID:  {type: String, index: true},
     rates: [ratesSchema],
     deleteInfo: deleteSchema
 },{versionKey:false});
@@ -47,7 +47,7 @@ mongoose.model('fee_rates', feeRatesSchema, 'fee_rates');
 
 
 let feeRateFileSchema = new Schema({
-    ID: String,
+    ID:  {type: String, index: true},
     rootProjectID:Number,//顶层项目ID
     userID:String,
     name:String,
@@ -62,7 +62,7 @@ mongoose.model('fee_rate_file', feeRateFileSchema, 'fee_rate_file');
 
 
 let feeRatesLibSchema = new Schema({
-    ID: String,
+    ID:  {type: String, index: true},
     region: String,                     // 工程所在地
     libName: String,
     rates: [ratesSchema]

+ 1 - 1
modules/all_models/mix_ratio.js

@@ -23,7 +23,7 @@ let modelSchema = {
         index: true
     },
     // 单价文件表id (因为选择单价文件后配合比数据也需要同步,所以记录单价文件id)
-    unit_price_file_id: Number,
+    unit_price_file_id: {type: Number, index: true},
     // 关联项目工料机的key 不能关联id,因为单价文件导入别的项目后项目工料机id不同
     connect_key: {
         type: String,

+ 7 - 4
modules/all_models/project_glj.js

@@ -18,21 +18,24 @@ let modelSchema = {
     // 工料机总库ID
     glj_id: Number,
     // 标段ID
-    project_id: Number,
+    project_id: {
+        type: Number,
+        index: true
+    },
     // 编码
     code: {
         type: String,
-        index: true
+        index: false
     },
     //原始的编码
     original_code: {
         type: String,
-        index: true
+        index: false
     },
     // 名称
     name: {
         type: String,
-        index: true,
+        index: false,
         default: ''
     },
     // 是否暂估 (0为否 1为是)

+ 1 - 1
modules/all_models/projects.js

@@ -14,7 +14,7 @@ const shareSchema = new Schema({
     shareDate: String,
 }, {versionKey: false, _id: false});
 const ProjectSchema = new Schema({
-    "ID": Number,
+    "ID": {type: Number, index: true},
     "ParentID": Number,
     "NextSiblingID": Number,
     "userID": String,

+ 2 - 2
modules/all_models/ration.js

@@ -23,8 +23,8 @@ var rationAssItemSchema = mongoose.Schema({
 // 定额、量价、工料机定额 合并存储
 let rationSchema = new Schema({
     // 公用属性部分
-    ID: String,
-    projectID: Number,
+    ID: {type: String, index: true},
+    projectID: {type: Number, index: true},
     billsItemID: String,
     serialNo: Number,
     code: String,

+ 2 - 2
modules/all_models/ration_coe.js

@@ -24,8 +24,8 @@ var coeListSchema = mongoose.Schema({
     option_codes:String,                //可选人材机编码
     option_list:[Schema.Types.Mixed],//下拉列表选项
     select_code:String,
-    rationID:String,
-    projectID:Number,
+    rationID:{type: String, index: true},
+    projectID:{type: Number, index: true},
     coeID:Number,
     isAdjust:Number, //0不调整,1调整
     seq:Number,//序数,排序用

+ 1 - 1
modules/all_models/std_glj.js

@@ -20,7 +20,7 @@ const std_gljComponent = new Schema(
 
 const std_glj = new Schema({
     deleted: Boolean,
-    repositoryId: Number,
+    repositoryId: {type: Number,index: true},
     ID: Number,
     code: String,
     name: String,

+ 1 - 1
modules/all_models/unit_price.js

@@ -43,7 +43,7 @@ let modelSchema = {
     // 类型简称
     short_name: String,
     // 单价文件表id
-    unit_price_file_id: Number,
+    unit_price_file_id: {type: Number, index: true},
     // 对应标准库工料机id
     glj_id: Number,
     //是否新增1为是,0为否

+ 13 - 4
modules/main/controllers/ration_controller.js

@@ -27,7 +27,12 @@ let controller = {
             data = JSON.stringify(data);
         }
         data = JSON.parse(data);
-        return await ration_facade.addNewRation(data,req.session.sessionCompilation);
+        let result = await ration_facade.addNewRation(data,req.session.sessionCompilation);
+        //合并取项目工料机数据的情求,用于刷新项目工料机数据,当有添加、替换项目工料机的情况,才需要刷新
+        if(result.ration_gljs && result.ration_gljs.length > 0 && data.newData){
+            result.projectGLJDatas =  await getProjectGLJData(data.newData.projectID);
+        }
+        return result;
     },
     addMultiRation: async function (req) {
         let data = req.body.data;
@@ -83,14 +88,18 @@ let controller = {
         let result = await ration_facade.updateCoeAdjust(data,req.session.sessionCompilation);
         //合并取项目工料机数据的情求,用于刷新项目工料机数据,当有添加、替换项目工料机的情况,才需要刷新
         if(result.add.length > 0 || result.replace.length > 0){
-            let gljController = new GLJController();
-            let responseData = await gljController.getProjectGLJsByProjectID(data.projectID);
-            result.projectGLJDatas = responseData.data;
+            result.projectGLJDatas =  await getProjectGLJData(data.projectID);
         }
         return result;
     }
 };
 
+async function getProjectGLJData(projectID) {
+    let gljController = new GLJController();
+    let responseData = await gljController.getProjectGLJsByProjectID(projectID);
+    return responseData.data;
+}
+
 function prepareUpdateNodes(datas,nodes,type) {
     for(let d of datas){
         nodes.push({type:type,data:d});

+ 10 - 1
modules/main/routes/main_route.js

@@ -7,6 +7,8 @@ import BaseController from "../../common/base/base_controller";
 const projectModel = require("../../pm/models/project_model");
 const pmFacade = require('../../pm/facade/pm_facade');
 let config = require("../../../config/config.js");
+import OptionsDao from '../../options/models/optionsModel';
+import optionSetting from '../../options/models/optionTypes';
 module.exports =function (app) {
     const baseController = new BaseController();
     app.get('/main', baseController.init, function(req, res) {
@@ -28,6 +30,12 @@ module.exports =function (app) {
                 if (constructProject && constructProject.property && constructProject.property.fileKind) {
                     fileKind = constructProject.property.fileKind;
                 }
+                let optionsDao = new OptionsDao();
+                let options = await optionsDao.getOptions(req.session.sessionUser.id, req.session.sessionCompilation._id);
+                if(options){
+                    options = await optionsDao.saveOptions(req.session.sessionUser.id, req.session.sessionCompilation._id, optionSetting);
+                }
+
                 res.render('building_saas/main/html/main.html',
                     {
                         userAccount: req.session.userAccount,
@@ -39,7 +47,8 @@ module.exports =function (app) {
                         projectCooperate: projectCooperate,
                         LicenseKey:config.getLicenseKey(process.env.NODE_ENV),
                         overWriteUrl:req.session.sessionCompilation.overWriteUrl,
-                        fileKind: fileKind
+                        fileKind: fileKind,
+                        options:JSON.stringify(options)
                     });
             } else {
                 res.redirect('/pm');

+ 13 - 5
modules/ration_glj/facade/glj_calculate_facade.js

@@ -46,9 +46,9 @@ async function calculateQuantity(query,noNeedCal,refreshRationName = false){
              glj_result:[],
              rationID:query.rationID
          };
-         let impactRation = await ration.findOne({ID:query.rationID,projectID:query.projectID});
+         let impactRation = await ration.findOne({ID:query.rationID});
          let gljList = await ration_glj.find(query);//{projectID:query.projectID,rationID:query.rationID}
-         let coeList = await ration_coe.find({projectID:query.projectID,rationID:query.rationID}).sort('seq').exec();
+         let coeList = await ration_coe.find({rationID:query.rationID}).sort('seq').exec();
          let assList=[];
          let assRation = null;
          let adjustState=[];
@@ -68,10 +68,10 @@ async function calculateQuantity(query,noNeedCal,refreshRationName = false){
          gljList = sortRationGLJ(gljList);
          for(let i =0;i<gljList.length;i++ ){
              let r = await calculateQuantityPerGLJ(gljList[i],gljList,coeList,assList,adjustState,noNeedCal);
-             result.glj_result.push(r);
+             if(quantityUpdateCheck(gljList[i],r) == true) result.glj_result.push(r);
          }
 
-         if(noNeedCal==null){
+         if(noNeedCal==null && result.glj_result.length > 0){
             await ration_glj.bulkWrite(generateUpdateTasks(result.glj_result));
          }
          adjustState= _.sortByOrder(adjustState, ['index'], ['asc']);
@@ -83,7 +83,7 @@ async function calculateQuantity(query,noNeedCal,refreshRationName = false){
              setData.name = newName;
              result.rationName = newName;
          }
-         await ration.update({projectID:query.projectID,ID:query.rationID,deleteInfo: null},setData);
+         await ration.update({ID:query.rationID},setData);
          result.adjustState=adjustStateString;
          return result;
     }catch (err){
@@ -92,6 +92,14 @@ async function calculateQuantity(query,noNeedCal,refreshRationName = false){
     }
 }
 
+function quantityUpdateCheck(glj,r) {//检查,有改变的才更新
+    for(let key in r.doc){
+        if(glj._doc[key] != r.doc[key]) return true
+    }
+    return false
+}
+
+
 function generateRationName(ration,gljList) {
     let caption = ration.caption ? ration.caption:ration.name;
     if(ration.rationAssList && ration.rationAssList.length > 0){

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

@@ -41,6 +41,7 @@
         let userID = '<%- userID %>';
         let projectReadOnly = JSON.parse('<%- projectReadOnly %>');
         let projectCooperate = JSON.parse('<%- projectCooperate %>');
+        let projectOptins =  JSON.parse('<%- options %>');
         console.log(projectCooperate);
         const G_SHOW_BLOCK_LIB = true;
 //        const G_SHOW_BLOCK_LIB = false;

+ 1 - 1
web/building_saas/main/js/models/project.js

@@ -56,7 +56,7 @@ var PROJECT = {
                     me.modules[module].setMaxID(counter[module]);
                 }
             }
-
+            projectInfoObj.showProjectInfo(me._project.projectInfo);
             me._project.loadMainTree();
             //me.test(result[0].data[0]);
             if (callback) {

+ 10 - 10
web/building_saas/main/js/models/ration.js

@@ -614,17 +614,17 @@ var Ration = {
                         syncNodeOper(data);
                         if(callback) callback(newNode);
                     }else {
-                        project.projectGLJ.loadData(function () {
-                            syncNodeOper(data);
-                            project.calcProgram.calcAndSave(newNode,function () {
-                                if(project.Bills.isFBFX(newNode)) { //判断是否属于分部分项工程 ,是的话才需要做计取安装费计算
-                                    installationFeeObj.calcInstallationFee();
-                                }
-                            });
-                            //如果添加规则中,添加内容为定额子目,则更新相关清单
-                            updateBillsOprRation();
-                            if(callback) callback(newNode);
+                        if(data.projectGLJDatas) projectObj.project.projectGLJ.refreshByDatas(data.projectGLJDatas);
+                        syncNodeOper(data);
+                        project.calcProgram.calcAndSave(newNode,function () {
+                            if(project.Bills.isFBFX(newNode)) { //判断是否属于分部分项工程 ,是的话才需要做计取安装费计算
+                                installationFeeObj.calcInstallationFee();
+                            }
                         });
+                        //如果添加规则中,添加内容为定额子目,则更新相关清单
+                        updateBillsOprRation();
+                        if(callback) callback(newNode);
+
                     }
                     $.bootstrapLoading.end();
                 })

+ 6 - 8
web/building_saas/main/js/views/options_view.js

@@ -8,15 +8,13 @@ let optionsOprObj = {
     rationQuanACToRationUnit: $('#generalOpts2'),
     getOptions: function () {
         let me = this;
-        CommonAjax.post('/options/getOptions', [], function (rstData) {
-            me.options = rstData;
-            let gOpts = me.options[me.optionsTypes.GENERALOPTS];
-            if(isDef(gOpts)){
-                for(let attr in gOpts){
-                    me[attr].prop('checked', gOpts[attr]);
-                }
+        me.options = projectOptins;
+        let gOpts = me.options[me.optionsTypes.GENERALOPTS];
+        if(isDef(gOpts)){
+            for(let attr in gOpts){
+                me[attr].prop('checked', gOpts[attr]);
             }
-        });
+        }
     },
     saveOptions: function (type, opts) {
         let optSettingType = 'options.' + type;

+ 11 - 2
web/building_saas/main/js/views/project_view.js

@@ -904,7 +904,6 @@ var projectObj = {
         this.project.loadDatas(function (err) {
             let mTime = +new Date();
             console.log(`get data时间——${mTime - startTime}`);
-            projectInfoObj.showProjectInfo(that.project.projectInfo);
             //快速列设置
             if(!colSettingObj.getVisible('itemCharacterText')){
                 switchTznrHtml(true);
@@ -1449,7 +1448,17 @@ var projectObj = {
                             return true;
                         }
                         return false;
-                    }
+                    },
+                    disabled: function () {
+                        let selected = project.mainTree.selected;
+                        if (projectReadOnly) {
+                            return true;
+                        }
+                        if(selected && selected.data.type != rationType.ration){
+                            return true;
+                        }
+                        return false;
+                    },
                 },
                 "delete": {
                     name: '删除',