소스 검색

Merge branch '1.0.0_online' of http://smartcost.f3322.net:3000/SmartCost/ConstructionCost into 1.0.0_online

chenshilong 6 년 전
부모
커밋
15083ad01d

+ 23 - 0
modules/all_models/compleGlj_section.js

@@ -0,0 +1,23 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Zhong
+ * @date 2018/12/13
+ * @version
+ */
+
+import mongoose from 'mongoose';
+
+const Schema = mongoose.Schema;
+const compleGljSection = new Schema({
+    userId: String,
+    compilationId: String,
+    Name: String,
+    ID: String,
+    ParentID: String,
+    NextSiblingID: String,
+});
+
+mongoose.model('complementary_glj_section', compleGljSection, 'complementary_glj_section');

+ 30 - 0
modules/all_models/compleGlj_sectionTemplate.js

@@ -0,0 +1,30 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Zhong
+ * @date 2018/12/13
+ * @version
+ */
+
+/*
+ * 我的补充人材机库章节树模板,一个费用定额有一个模板
+ * 模板的生成目前由手工生成(借助定额库编辑器的章节树编辑)
+ * 新用户第一次进入某费用定额的补充定额库时,拷贝模板给该用户
+ *
+ * */
+
+import mongoose from 'mongoose';
+
+const Schema = mongoose.Schema;
+const compleGljSectionTemp = new Schema({
+    compilationId: String,
+    Name: String,
+    ID: Number,
+    ParentID: Number,
+    NextSiblingID: Number,
+});
+
+mongoose.model('complementary_glj_section_templates', compleGljSectionTemp, 'complementary_glj_section_templates');
+

+ 3 - 0
modules/all_models/ration_coe.js

@@ -20,6 +20,9 @@ var coeListSchema = mongoose.Schema({
     ID: String,                         // 系数ID(流水号ID)
     name: String,                       // 名称
     content: String,                    // 说明
+    original_code:String,               //原人材机编码
+    option_codes:String,                //可选人材机编码
+    select_code:String,
     rationID:String,
     projectID:Number,
     coeID:Number,

+ 2 - 0
modules/all_models/stdRation_coe.js

@@ -23,6 +23,8 @@ const coeListSchema = new Schema({
     serialNo: Number,                  //编号
     name: String,                       // 名称
     content: String,                    // 说明
+    original_code:String,               //原人材机编码
+    option_codes:String,                //可选人材机编码
     coes: [coeSchema]
 }, {versionKey: false});
 

+ 5 - 6
modules/main/facade/ration_facade.js

@@ -310,6 +310,8 @@ async function addRationCoe(std,newRation,compilation) {
                 newCoe.seq = seq;
                 newCoe.name = libCoe.name;
                 newCoe.content = libCoe.content;
+                newCoe.original_code = libCoe.original_code;
+                newCoe.option_codes = libCoe.option_codes;
                 newCoe.isAdjust=0;
                 newCoe.coes = libCoe.coes;
                 newCoe.rationID = newRation.ID;
@@ -488,7 +490,7 @@ async function updateCoeAdjust(data,compilation) {
         }
     }
 
-    let cal_result = await glj_calculate_facade.calculateQuantity({projectID:data.projectID,rationID:data.rationID});
+    let cal_result = await glj_calculate_facade.calculateQuantity({projectID:data.projectID,rationID:data.rationID},null,true);
     let coe = {
         query:{ID:data.ID,projectID:data.projectID},
         doc:data.doc
@@ -499,16 +501,13 @@ async function updateCoeAdjust(data,compilation) {
     };
     let ration = {
         ID:cal_result.rationID,
-        adjustState:cal_result.adjustState
+        adjustState:cal_result.adjustState,
+        name:cal_result.rationName
     };
     return {coe:coe,ration_glj:ration_glj,ration:ration,add:data.add,delete:data.delete,replace:replace}
 
 }
 
-function addGLJByCoe(code,engineerID,rationID,projectID) {//通过单个工料机类型编号添加
-
-}
-
 
 
 async function  updateRation(std,defaultLibID,rationID,billsItemID,projectID,calQuantity) {

+ 15 - 12
modules/pm/controllers/pm_controller.js

@@ -251,20 +251,12 @@ module.exports = {
         sessionCompilation = request.session.sessionCompilation;
         //更新用户的使用过的费用定额列表
         let userData = await userModel.findOne({_id: mongoose.Types.ObjectId(request.session.sessionUser.id)}, '-_id used_list');
+        //是否第一次进入该费用定额
+        let isFirst = false;
         if (userData) {
-            let usedCompilation = _.find(userData.used_list, function (o) {
+            isFirst = !_.find(userData.used_list, function (o) {
                 return o.compilationId === compilationData._id.toString();
-            });
-            //第一次使用该费用定额
-            if (!usedCompilation) {
-                await userModel.update({_id: mongoose.Types.ObjectId(request.session.sessionUser.id)}, {$push: {used_list: {compilationId: compilationData._id}}});
-                //拷贝补充定额模板数据
-                await sectionTreeDao.copyDataFromTemplate(request.session.sessionUser.id, compilationData._id);
-                //拷贝例题数据
-                if (sessionCompilation.example && sessionCompilation.example.length > 0) {
-                   await pm_facade.copyExample(request.session.sessionUser.id, sessionCompilation._id, sessionCompilation.example);
-                }
-            }
+            });;
         }
         // 清单计价
         let billValuation = sessionCompilation.bill_valuation !== undefined ?
@@ -281,6 +273,7 @@ module.exports = {
         let absoluteUrl = compilationData.overWriteUrl ? request.app.locals.rootDir + compilationData.overWriteUrl : request.app.locals.rootDir;
         let overWriteUrl = fs.existsSync(absoluteUrl) && fs.statSync(absoluteUrl).isFile()? compilationData.overWriteUrl : null;
         let renderData = {
+            isFirst: isFirst,
             userAccount: request.session.userAccount,
             userID: request.session.sessionUser.id,
             compilationData: JSON.stringify(sessionCompilation),
@@ -295,6 +288,16 @@ module.exports = {
 
         response.render('building_saas/pm/html/project-management.html', renderData);
     },
+    //第一次进入该费用定额时准备的初始数据
+    prepareInitialData: async function(request, response) {
+        try {
+            let sessionCompilation = request.session.sessionCompilation;
+            await pm_facade.prepareInitialData(request.session.sessionUser.id, sessionCompilation._id, sessionCompilation.example);
+            callback(request, response, 0, 'success', null);
+        } catch(err) {
+            callback(request, response, 1, err, null);
+        }
+    },
     // 获取单价文件列表
     getUnitFileList: async function(request, response) {
         let data = request.body.data;

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

@@ -23,10 +23,15 @@ let rationGLJModel = mongoose.model('ration_glj');
 let rationCoeModel = mongoose.model('ration_coe');
 let rationInstallationModel = mongoose.model('ration_installation');
 let quantityDetailModel = mongoose.model('quantity_detail');
+let userModel = mongoose.model('user');
+let compleGljSectionModel = mongoose.model('complementary_glj_section');
+let compleGljSectionTModel = mongoose.model('complementary_glj_section_templates');
 
 let featureLibModel =  mongoose.model("std_project_feature_lib");
 let scMathUtil = require('../../../public/scMathUtil').getUtil();
 let counter = require('../../../public/counter/counter');
+import SectionTreeDao from '../../complementary_ration_lib/models/sectionTreeModel';
+let sectionTreeDao = new SectionTreeDao();
 import CounterModel from "../../glj/models/counter_model";
 import moment from 'moment';
 import billsFlags from '../../common/const/bills_fixed';
@@ -52,6 +57,7 @@ module.exports={
     projectType: projectType,
     getPosterityProjects: getPosterityProjects,
     isShare: isShare,
+    prepareInitialData: prepareInitialData,
 };
 
 //拷贝例题项目
@@ -878,4 +884,51 @@ async function isShare(userId, project){
         project = await projectModel.findOne({ID: project.ParentID}, '-_id shareInfo ID ParentID');
     }
     return false;
-}
+}
+
+//用户第一次进入费用定额的数据准备
+async function prepareInitialData(userId, compilation, example) {
+    let prepareTask = [
+        updateUsedList(userId, compilation),
+        copyCompleRationSection(userId, compilation),
+        copyCompleGljSection(userId, compilation)
+    ];
+    if (example && example.length > 0) {
+        prepareTask.push(copyExample(userId, compilation, example));
+    }
+    await Promise.all(prepareTask);
+}
+
+async function updateUsedList(userId, compilation) {
+    await userModel.update({_id: mongoose.Types.ObjectId(userId)}, {$push: {used_list: {compilationId: compilation}}});
+}
+
+//拷贝补充定额章节树
+async function copyCompleRationSection(userId, compilationId) {
+    await sectionTreeDao.copyDataFromTemplate(userId, compilationId);
+}
+//拷贝补充人材机分类树
+async function copyCompleGljSection(userId, compilationId) {
+    let templateData = await compleGljSectionTModel.find({compilationId: compilationId});
+    if (templateData.length > 0) {
+        let insertDatas = [],
+            uuidMapping = {};
+        //将ID替换成UUID
+        for (let temData of templateData) {
+            uuidMapping[temData.ID] = uuidV1();
+        }
+        for(let temData of templateData) {
+            let insertD = {
+                userId: userId,
+                compilationId: compilationId,
+                Name: temData.Name,
+                ID: uuidMapping[temData.ID],
+                ParentID: uuidMapping[temData.ParentID] || -1,
+                NextSiblingID: uuidMapping[temData.NextSiblingID] || -1,
+            };
+            insertDatas.push(insertD);
+        }
+        //插入数据
+        await compleGljSectionModel.insertMany(insertDatas);
+    }
+}

+ 3 - 0
modules/pm/routes/pm_route.js

@@ -24,6 +24,9 @@ module.exports = function (app) {
     /*
      req.body = {data: '{user_id}'}
      */
+
+    pmRouter.post('/prepareInitialData', pmController.prepareInitialData);
+
     pmRouter.post('/getProjects', pmController.getProjects);
     pmRouter.post('/getSummaryInfo', pmController.getSummaryInfo);
 

+ 37 - 17
modules/ration_glj/facade/glj_calculate_facade.js

@@ -66,8 +66,7 @@ async function calculateQuantity(query,noNeedCal,refreshRationName = false){
          }
          gljList = sortRationGLJ(gljList);
          for(let i =0;i<gljList.length;i++ ){
-             let isLast = i == gljList.length -1;
-             let r = await calculateQuantityPerGLJ(gljList[i],isLast,coeList,assList,adjustState,noNeedCal);
+             let r = await calculateQuantityPerGLJ(gljList[i],gljList,coeList,assList,adjustState,noNeedCal);
              result.glj_result.push(r);
          }
 
@@ -137,7 +136,7 @@ function sortRationGLJ(list) {
     return list;
 }
 
-async function calculateQuantityPerGLJ(glj,isLast,coeList,assList,adjustState,noNeedCal) {
+async function calculateQuantityPerGLJ(glj,gljList,coeList,assList,adjustState,noNeedCal) {
     let decimalObject =await decimal_facade.getProjectDecimal(glj.projectID);
     let decimal = (decimalObject&&decimalObject.glj&&decimalObject.glj.quantity)?decimalObject.glj.quantity:3;
     let quantity =  scMathUtil.roundTo(parseFloat(glj.quantity),-decimal);
@@ -155,7 +154,7 @@ async function calculateQuantityPerGLJ(glj,isLast,coeList,assList,adjustState,no
             if(!glj._doc.hasOwnProperty('customQuantity')||glj.customQuantity==null||glj.customQuantity==""){
                 quantity =scMathUtil.roundTo(parseFloat(glj.rationItemQuantity),-decimal);
                 quantity =scMathUtil.roundTo(await calculateAss(quantity,assList,glj),-decimal);
-                quantity = calculateQuantityByCoes(quantity,coeList,glj);
+                quantity = calculateQuantityByCoes(quantity,coeList,glj,gljList,decimal);
             }else {
                 quantity = glj.customQuantity;
                 result.doc.customQuantity = glj.customQuantity;
@@ -163,11 +162,12 @@ async function calculateQuantityPerGLJ(glj,isLast,coeList,assList,adjustState,no
             let customerCoe = _.last(coeList);
             if(customerCoe&&customerCoe.isAdjust==1){
                 quantity = scMathUtil.roundToString(quantity,decimal);
-                quantity = calculateQuantityByCustomerCoes(quantity,customerCoe,glj);
+                quantity = calculateQuantityByCustomerCoes(quantity,customerCoe,glj,decimal);
             }
             result.doc.quantity =scMathUtil.roundToString(quantity,decimal);
+            glj.quantity = quantity;//这里保存中间过程计算出来的消耗量,后面处理“+*”操作符时要用到
         }
-        generateAdjustState(glj,coeList,adjustState,isLast,result.doc.quantity);
+        generateAdjustState(glj,coeList,adjustState,gljList,result.doc.quantity);
         return result;
     }catch (err){
         throw err;
@@ -199,7 +199,7 @@ async function calculateAss(quantity,assList,glj) {
     return scMathUtil.roundTo(quantity,-6);
 }
 
-function generateAdjustState(glj,coeList,adjustState,isLast,quantity) {
+function generateAdjustState(glj,coeList,adjustState,gljList,quantity) {
    //替换工料机 and 添加工料机
     if(glj._doc.createType=='replace'&&glj.rcode!=glj.code){
         adjustState.push({index:stateSeq.replace,content:glj.rcode+'换'+glj.code});
@@ -214,17 +214,21 @@ function generateAdjustState(glj,coeList,adjustState,isLast,quantity) {
     // to do
 
   //标准附注条件调整 + 自定义乘系数
-    if(isLast){//最后一个工料机的时候才生成,生成一次就可以了
+    if(_.last(gljList).ID == glj.ID){//最后一个工料机的时候才生成,生成一次就可以了
         for(let i=0;i<coeList.length;i++){
             if(coeList[i].isAdjust==1){
                 if(i==coeList.length-1){
                     adjustState.push({index:stateSeq.cusCoe,content:getContent(coeList[i].coes)});//自定义乘系数要去掉倍数为1的
                 }else {
+                    if(coeList[i].select_code && coeList[i].select_code!=""){
+                        _.remove(adjustState,{'content':coeList[i].original_code+'换'+coeList[i].select_code});//去掉替换工料机自动生成的调整状态
+                        adjustState.push({index:stateSeq.coe,content:"调 : "+coeList[i].original_code+'换'+coeList[i].select_code});
+                    }
                     for(let c of coeList[i].coes){
                         if(c.coeType=='单个工料机') _.remove(adjustState,{'type':"添"+c.gljCode});//如果是单个工料机子目换算类型自动添加的,去掉前面手动生成的调整状态
                         if(c.coeType=='替换人材机') _.remove(adjustState,{'content':c.gljCode+'换'+c.replaceCode});//如果是替换人材机子目换算类型自动添加的,去掉前面手动生成的调整状态
                     }
-                    adjustState.push({index:stateSeq.coe,content:"调 : "+coeList[i].content});//coeList[i].content
+                    if(coeList[i].content) adjustState.push({index:stateSeq.coe,content:"调 : "+coeList[i].content});//coeList[i].content
                 }
             }
         }
@@ -295,28 +299,30 @@ function calculateTimes(ass){
     return scMathUtil.roundTo(times,-6);
 }
 
-function calculateQuantityByCoes(quantity,coeList,glj){
+function calculateQuantityByCoes(quantity,coeList,glj,gljList,decimal){
     let coeQuantity = quantity;
     if(coeList.length>1){
         for(let i=0;i<coeList.length-1;i++){
-            coeQuantity = everyCoe(coeQuantity,coeList[i],glj);
+            coeQuantity = everyCoe(coeQuantity,coeList[i],glj,gljList,decimal);
         }
     }
     return scMathUtil.roundTo(coeQuantity,-6);
 }
 
-function everyCoe(quantity,coe,glj) {
+function everyCoe(quantity,coe,glj,gljList,decimal) {
     let coeQuantity = quantity;
     if(coe.isAdjust==1){
         for(let i=0;i<coe.coes.length;i++){
             if(coe.coes[i].coeType=='单个工料机' &&coe.coes[i].gljCode==glj.code){//if(coe.coes[i].coeType=='单个工料机'&&coe.coes[i].gljCode==glj.code)
-                coeQuantity = getCalculateResult(coeQuantity,coe.coes[i]);
+                coeQuantity = getCalculateResult(coeQuantity,coe.coes[i],coe,gljList,decimal);
             }else if(coe.coes[i].coeType== "替换人材机" && glj.rcode == coe.coes[i].gljCode && glj.code == coe.coes[i].replaceCode){
-                coeQuantity = getCalculateResult(coeQuantity,coe.coes[i]);
+                coeQuantity = getCalculateResult(coeQuantity,coe.coes[i],coe,gljList,decimal);
+            }else if(coe.coes[i].coeType== "所选人材机" && glj.rcode == coe.original_code && glj.code == coe.select_code ){
+                coeQuantity = getCalculateResult(coeQuantity,coe.coes[i],coe,gljList,decimal);
             } else if(coe.coes[i].coeType=='定额'){
-                coeQuantity = getCalculateResult(coeQuantity,coe.coes[i]);
+                coeQuantity = getCalculateResult(coeQuantity,coe.coes[i],coe,gljList,decimal);
             }else if(coeTypeMap[coe.coes[i].coeType]==getRootGLJType(glj.type).ID){
-                coeQuantity = getCalculateResult(coeQuantity,coe.coes[i]);
+                coeQuantity = getCalculateResult(coeQuantity,coe.coes[i],coe,gljList,decimal);
             }
         }
     }
@@ -338,7 +344,15 @@ function calculateQuantityByCustomerCoes(quantify,coe,glj) {
     return quantify
 }
 
-function getCalculateResult(quantify,c) {
+function getCoeSelectedGLJ(gljList,rcode,code) {
+    if(gljList&& code && code !=""){
+        let o_glj = _.find(gljList,{'rcode':rcode,'code':code});
+        return o_glj;
+    }
+    return null;
+}
+
+function getCalculateResult(quantify,c,coe,gljList,decimal) {
     let q = quantify;
     switch (c.operator){
         case '+' :
@@ -353,6 +367,12 @@ function getCalculateResult(quantify,c) {
         case '/' :
             q = q / c.amount;
             break;
+        case '+*' :
+            let o_glj = getCoeSelectedGLJ(gljList,coe.original_code,coe.select_code);
+            if(o_glj){
+              q = q +  c.amount * scMathUtil.roundForObj(o_glj.quantity,decimal);
+            }
+            break;
         case '=' :
              q = c.amount;
             break;

+ 1 - 0
modules/users/models/user_model.js

@@ -195,6 +195,7 @@ class UserModel extends BaseModel {
             email: userData.email,
             mobile: userData.mobile,
             create_time: new Date().getTime(),
+            latest_login: new Date().getTime(),
         };
         return this.db.create(insertData);
     }

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

@@ -38,7 +38,9 @@
         let lockBills = '<%- projectData.property.lockBills %>';
         let userAccount = '<%- userAccount %>';
         let userID = '<%- userID %>';
+        console.log('<%- projectReadOnly %>');
         let projectReadOnly = JSON.parse('<%- projectReadOnly %>');
+        console.log(projectReadOnly);
         const G_SHOW_BLOCK_LIB = true;
 //        const G_SHOW_BLOCK_LIB = false;
     </script>

+ 43 - 10
web/building_saas/main/js/models/ration_coe.js

@@ -127,21 +127,25 @@ var ration_coe = {
             updateData.push(newobj);
             return updateData;
         };
-        ration_coe.prototype.adjustCoeClick = function(recode,newval){
+        ration_coe.prototype.adjustCoeClick = function(record,newval,ext){
             let me=this,codesList = [],add=[],replace=[];
+            let doc = ext?ext:{};
+            doc['isAdjust'] = newval;
             var updateData = {
-                'ID':recode.ID,
-                'projectID': recode.projectID,
-                'rationID':recode.rationID,
-                'doc':{
-                    isAdjust:newval
-                },
+                'ID':record.ID,
+                'projectID': record.projectID,
+                'rationID':record.rationID,
+                'doc':doc,
                 add:[],
                 delete:[],
                 replace:[]
             };
-            let gljList = project.ration_glj.getGLJListByRationID(recode.rationID);
-            for(let coe of recode.coes){//做单个、替换等检查
+            let gljList = project.ration_glj.getGLJListByRationID(record.rationID);
+            if(gljUtil.isDef(record.option_codes)&&record.option_codes!=""){ //说明编辑的是下拉选择编号的类型
+                this.prepareDataForOptionType(record,newval,gljList,updateData,replace,codesList,ext);
+            }
+
+            for(let coe of record.coes){//做单个、替换等检查
                 if(coe.coeType == "单个工料机"){ //单个工料机的情况
                     let glj = _.find(gljList,{"code":coe.gljCode});
                     if(newval == 1){ //单个工料机,选中时,如果能找到则不管,如果没找到,则需自动插入
@@ -175,7 +179,7 @@ var ration_coe = {
                 let gljMap = _.indexBy(gljList, 'code');
                 for(let a of add){
                     if(gljMap[a]){
-                        let tem = project.ration_glj.getAddDataByStd(gljMap[a],recode.rationID,project.mainTree.selected.data.billsItemID,recode.projectID);
+                        let tem = project.ration_glj.getAddDataByStd(gljMap[a],record.rationID,project.mainTree.selected.data.billsItemID,record.projectID);
                         updateData.add.push(tem);
                     }
                 }
@@ -194,6 +198,35 @@ var ration_coe = {
             });
 
         };
+        ration_coe.prototype.prepareDataForOptionType = function (record,newval,gljList,updateData,replace,codesList,ext) {
+            let select_code = record.select_code;
+            if(ext && gljUtil.isDef(ext.select_code)&&ext.select_code!=""){//是下拉框选择了人材机编号进来的
+                select_code = ext.select_code;
+            }
+            if(gljUtil.isDef(select_code) && select_code!=""){//有选中编号的情况下,才会做这些操作
+                let glj = _.find(gljList,{"rcode":record.original_code,'code':select_code});//两个条件都满足,则表示已找到对应的记录
+                if(newval == 1){
+                    if(!glj){//在没找到的情况下,要替换
+                        let r_glj = _.find(gljList,function (g) {
+                            return (g.code == record.original_code && (g.createType===undefined || g.createType == 'normal')) || g.rcode == record.original_code //这两个满足一个说明要替换
+                        });
+                        if(r_glj){
+                            replace.push({code:select_code,oldData:r_glj});
+                            codesList.push(select_code);
+                        }
+                    }
+                }else {
+                    updateData.doc['select_code'] = ""; //取消勾选,选中值要恢复为空
+                    if(glj){//如果找到工料机,还需要恢复成原来的
+                        replace.push({code:record.original_code,oldData:glj});
+                        codesList.push(record.original_code);
+                    }
+                }
+            }
+        };
+
+
+
 
         ration_coe.prototype.updateCustomerCoe = function (data) {
             var updateData = this.getUpdateData('ut_update',data.query,data.doc,'updateCustomerCoe');

+ 4 - 1
web/building_saas/main/js/views/project_view.js

@@ -806,12 +806,15 @@ var projectObj = {
         };
     },
     mainSpreadEditEnded: function (sender, info) {
-        console.log('enterEDEnd');
         let project = projectObj.project;
         let node = project.mainTree.items[info.row];
         project.withinBillsLocked(node);
         let colSetting = projectObj.mainController.setting.cols[info.col];
         let fieldName = projectObj.mainController.setting.cols[info.col].data.field;
+        //提前处理
+        if (fieldName === 'code' || fieldName === 'name' || fieldName === 'unit') {
+            info.editingText = info.editingText ? info.editingText.toString().replace(new RegExp(/[\r,\n]/g), '') : info.editingText;
+        }
         // 检查输入类型等
         let value = projectObj.checkSpreadEditingText(info.editingText, colSetting);
         projectObj.updateCellValue(node, value, colSetting,info.editingText);

+ 42 - 9
web/building_saas/main/js/views/zmhs_view.js

@@ -11,12 +11,22 @@ let zmhs_obj = {
         header: [
             {headerName: "调整", headerWidth: 35, dataCode: "isAdjust", dataType: "String", cellType: "checkBox"},
             {headerName: "条件", headerWidth: 250, dataCode: "name", dataType: "String", cellType: "button"},
-            {headerName: "内容", headerWidth: 160, dataCode: "content", dataType: "String", hAlign: "left"}
+            {headerName: "内容", headerWidth: 160, dataCode: "content", dataType: "String", hAlign: "left",getText:'forContent'}
         ],
         view: {
             lockColumns:[0,1,2],
             rowHeaderWidth:25
         },
+        getText:{
+            forContent:function (item) {
+               if(gljUtil.isDef(item.select_code)&&item.select_code!=""){
+                   return item.select_code;
+               }else {
+                   return item.content;
+               }
+
+            }
+        },
         autoFit:true,
         fitRow:['name']
     },
@@ -45,9 +55,12 @@ let zmhs_obj = {
         this.coeSheet.name('ration_coe');
         this.coeSheet.bind(GC.Spread.Sheets.Events.CellClick, this.onCoeCellClick);
         this.coeSpread.bind(GC.Spread.Sheets.Events.ButtonClicked, this.onButtonClick);
-        this.coeSheet.bind(GC.Spread.Sheets.Events.EditStarting, function (e,args) {
-            //args.cancel = true;
+        this.coeSheet.bind(GC.Spread.Sheets.Events.ValueChanged,this.onCoeValueChange);
+        this.coeSheet.bind(GC.Spread.Sheets.Events.SelectionChanged, function (e,args) {
+            args.sheet.repaint();
         });
+
+
         this.assSheet = this.assSpread.getSheet(0);
         sheetCommonObj.initSheet(this.assSheet, this.assSetting, 30);
         this.assSheet.bind(GC.Spread.Sheets.Events.EditEnded, this.onAssEditEnded);
@@ -68,17 +81,29 @@ let zmhs_obj = {
         }
         sheetCommonObj.showData(this.coeSheet, this.coeSetting,coeList);
         if (coeList.length > 0) {
-            var cus_index = _.findIndex(coeList, function (item) {
-                return item.coeID == -1;
-            })
-            if (cus_index != -1) {
-                this.coeSheet.getCell(cus_index, 1, GC.Spread.Sheets.SheetArea.viewport).locked(false);
-                this.coeSheet.setCellType(cus_index, 1, sheetCommonObj.getCustomerCoeCellType(this.generateHtmlString,this.bindCusEditorValue,this.updateCusCoeAfterEditor), GC.Spread.Sheets.SheetArea.viewport);
+            for(let i =0;i<coeList.length;i++ ){
+                if(gljUtil.isDef(coeList[i].option_codes)&&coeList[i].option_codes!=""){
+                    this.getComboBoxForCodes(coeList[i],i);//设置可选类型的下拉框
+                    //  sheet.setValue(row, col, val, ch);
+                } else if(coeList[i].coeID == -1){ //自定义系数列
+                    this.coeSheet.getCell(i, 1, GC.Spread.Sheets.SheetArea.viewport).locked(false);
+                    this.coeSheet.setCellType(i, 1, sheetCommonObj.getCustomerCoeCellType(this.generateHtmlString,this.bindCusEditorValue,this.updateCusCoeAfterEditor), GC.Spread.Sheets.SheetArea.viewport);
+                }
             }
         }
         this.coeSheetData = coeList;
+    },
+    getComboBoxForCodes:function (coe,i) {
+        this.coeSheet.getCell(i, 2, GC.Spread.Sheets.SheetArea.viewport).locked(false);
+        let options = coe.option_codes.split("|");
+        let combo = sheetCommonObj.getDynamicCombo(true);
+        combo.itemHeight(options.length).items(options);
+        this.coeSheet.setCellType(i, 2, combo, GC.Spread.Sheets.SheetArea.viewport);
+        this.coeSheet.setValue(i, 2, coe.select_code);
 
     },
+
+
     showAssData:function (node) {
         this.assSheet.suspendPaint();
         this.assSheet.suspendEvent();
@@ -302,6 +327,14 @@ let zmhs_obj = {
             zmhs_obj.coeSheet.startEdit();
         }
     },
+    onCoeValueChange:function (e,args) {
+        let fieldID =  zmhs_obj.coeSetting.header[args.col].dataCode;
+        let recode = zmhs_obj.coeSheetData[args.row];
+        if(gljUtil.isDef(recode.option_codes)&&recode.option_codes!=""&& fieldID == 'content'){//说明是选择了下拉框
+            projectObj.project.ration_coe.adjustCoeClick(recode, 1,{'select_code':args.newValue});
+        }
+    },
+
     onAssEditEnded:function (e,args) {
         var me = zmhs_obj;
         if (args.row >= me.assSheetData.length) {

+ 17 - 1
web/building_saas/pm/html/project-management.html

@@ -22,7 +22,7 @@
         // 这里的变量供页面调用
         var userAccount = '<%- userAccount %>';
         var userID = '<%- userID %>';
-        console.log(userID);
+        let isFirst = JSON.parse('<%- isFirst %>');
     </script>
     <style type="text/css">
         .hidden-area{
@@ -680,6 +680,22 @@
         </div>
     </div>
 </div>
+<!--弹出 新用户第一次进度条-->
+<div class="modal fade" id="progress" data-backdrop="static">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">欢迎使用纵横建筑计价</h5>
+            </div>
+            <div class="modal-body">
+                <h5 class="my-3">首次加载例题,请稍候……</h5>
+                <div class="progress mb-3">
+                    <div class="progress-bar progress-bar-striped progress-bar-animated" id="progressBar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%"></div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
 <!--弹出分享-->
 <!--<div class="modal fade" id="share" data-backdrop="static">
     <div class="modal-dialog" role="document">

+ 78 - 3
web/building_saas/pm/js/pm_newMain.js

@@ -1696,6 +1696,61 @@ function getWorkBookWidth(){
     return workBookWidth = $(window).width() - $('.pm-side').width() - 90;
 }
 
+function prepareInitialTimer() {
+    $('#progressBar').css('width', `0%`);
+    let outer = setInterval(function () {
+        let curWidth = parseInt($('#progressBar')[0].style.width.replace('%', ''));
+        curWidth = parseInt(curWidth + 2);
+        $('#progressBar').css('width', `${curWidth}%`);
+        if (curWidth >= 80) {
+            clearInterval(outer);
+        }
+    }, 100);
+    let inner = setInterval(function () {
+        let curWidth = parseFloat($('#progressBar')[0].style.width.replace('%', ''));
+        if (curWidth >= 80) {
+            curWidth = parseFloat(curWidth + 0.1);
+            $('#progressBar').css('width', `${curWidth}%`);
+            if (curWidth >= 95) {
+                clearInterval(inner);
+            }
+        }
+    }, 500);
+    return {outer, inner};
+}
+
+function initProjects(callback) {
+    GetAllProjectData(function (datas) {
+        //设置工程专业
+        for (let data of datas) {
+            if (data.projType === projectType.tender) {
+                data.feeStandardName = data.property.feeStandardName || '';
+            }
+        }
+        CommonAjax.post('/options/getOptions', [], function (rstData) {
+            projTreeObj.setting.style.selectedColor = rstData.COLOROPTS.SELECTED.backColor;
+            projTreeObj.tree = pmTree.createNew(projTreeObj.setting, datas);
+            projTreeObj.tree.selected = projTreeObj.tree.items[0];
+            projTreeObj.workBook = projTreeObj.buildSheet(projTreeObj.workBook,'projSpread',projTreeObj.setting);
+            projTreeObj.workBook.getSheet(0).frozenColumnCount(2);
+            sheetCommonObj.spreadDefaultStyle(projTreeObj.workBook);
+            projTreeObj.sumEngineeringCost();
+            projTreeObj.showTreeData(projTreeObj.tree.items, projTreeObj.setting.header, projTreeObj.workBook.getActiveSheet());
+            //初始选择
+            let initSel = projTreeObj.workBook.getSheet(0).getSelections()[0] ? projTreeObj.workBook.getSheet(0).getSelections()[0] : {row: 0, rowCount: 1};
+            projTreeObj.initSelection(initSel,null,projTreeObj.workBook.getActiveSheet());
+           // $.bootstrapLoading.end();
+            autoFlashHeight();
+            projTreeObj.workBook.refresh();
+            if (callback) {
+                callback();
+            }
+        }, function () {
+            $.bootstrapLoading.end();
+        });
+    });
+}
+
 /**
  * 初始化数据
  *
@@ -1706,8 +1761,28 @@ function init() {
     rationValuation = rationValuation.replace(/\n/g, '\\n');
     //init spread and pmTree
     socketObject.connect('pm');//socket 连接;
-    $.bootstrapLoading.start();
-    GetAllProjectData(function (datas) {
+    if (isFirst) {
+        $('#progress').modal('show');
+        let intervalTime = prepareInitialTimer();
+        CommonAjax.post('/pm/api/prepareInitialData', {user_id: userID}, function () {
+            initProjects(function () {
+                clearInterval(intervalTime.outer);
+                clearInterval(intervalTime.inner);
+                $('#progressBar').css('width', '100%');
+                setTimeout(function () {
+                    $('#progress').modal('hide');
+                }, 500);
+            });
+        });
+    } else {
+        $.bootstrapLoading.start();
+        initProjects(function () {
+            $.bootstrapLoading.end();
+        })
+    }
+    //return;
+    //$.bootstrapLoading.start();
+    /*GetAllProjectData(function (datas) {
         //设置工程专业
         for (let data of datas) {
             if (data.projType === projectType.tender) {
@@ -1730,7 +1805,7 @@ function init() {
             autoFlashHeight();
             projTreeObj.workBook.refresh();
         });
-    });
+    });*/
     engineering = engineeringList !== null && engineeringList !== undefined ? JSON.parse(engineeringList) : [];
 }