Prechádzať zdrojové kódy

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

chenshilong 6 rokov pred
rodič
commit
767e6da790

+ 2 - 1
config/gulpConfig.js

@@ -29,7 +29,8 @@ module.exports = {
     ],
     login_jspaths:[
         'public/web/url_util.js',
-        'web/users/js/login.js'
+        'web/users/js/login.js',
+        'public/web/headerOpr.js'
     ],
     pm_css:[
         'lib/ztree/css/zTreeStyle.css',

+ 8 - 0
modules/main/controllers/ration_controller.js

@@ -73,8 +73,16 @@ let controller = {
         let data = req.body.data;
         data = JSON.parse(data);
         return ration_ass_facade.updateRationAss(data);
+    },
+    //勾选定额调整系数
+    updateCoeAdjust:async function(req){
+        let data = req.body.data;
+        data = JSON.parse(data);
+        return await ration_facade.updateCoeAdjust(data,req.session.sessionCompilation);
+
     }
 
+
 };
 
 function prepareUpdateNodes(datas,nodes,type) {

+ 33 - 1
modules/main/facade/ration_facade.js

@@ -5,6 +5,7 @@ let mongoose = require('mongoose');
 import SearchDao from '../../complementary_ration_lib/models/searchModel';
 const scMathUtil = require('../../../public/scMathUtil').getUtil();
 let ration_glj_facade = require("../../ration_glj/facade/ration_glj_facade");
+let glj_calculate_facade = require("../../ration_glj/facade/glj_calculate_facade");
 let quantity_detail = require("../facade/quantity_detail_facade");
 let ration_glj = mongoose.model('ration_glj');
 let ration_coe = mongoose.model('ration_coe');
@@ -22,6 +23,7 @@ let complementaryRationModel = mongoose.model('complementary_ration_items');
 
 let coeMolde = mongoose.model('std_ration_lib_coe_list');
 let compleCoeModel = mongoose.model('complementary_ration_coe_list');
+
 let _= require('lodash');
 const projectDao = require('../../pm/models/project_model').project;
 let projectModel = mongoose.model('projects');
@@ -34,7 +36,8 @@ module.exports = {
     getSameSectionRations:getSameSectionRations,
     getExtendData:getExtendData,
     getDefaultProgramID:getDefaultProgramID,
-    deleteSubListByQuery:deleteSubListByQuery
+    deleteSubListByQuery:deleteSubListByQuery,
+    updateCoeAdjust:updateCoeAdjust
 };
 async function addNewRation(data,compilation) {
     let query = data.itemQuery;
@@ -471,6 +474,35 @@ async function deleteSubListByQuery(delete_query) {
     await rationTemplateModel.deleteMany(delete_query);//删除模板关联子目
 }
 
+async function updateCoeAdjust(data,compilation) {
+    let newGLJs = [];
+    await ration_coe.update({ID:data.ID},data.doc);
+    //添加单个工料机的情况
+    if (data.add.length > 0) newGLJs = await ration_glj_facade.insertAddTypeGLJ(data.add,compilation);
+    if(data.delete.length > 0) await ration_glj_facade.deleteGLJ(data.delete);
+
+    let cal_result = await glj_calculate_facade.calculateQuantity({projectID:data.projectID,rationID:data.rationID});
+    let coe = {
+        query:{ID:data.ID,projectID:data.projectID},
+        doc:data.doc
+    }
+    let ration_glj ={
+        quantityRefresh:true,
+        glj_result:cal_result.glj_result
+    };
+    let ration = {
+        ID:cal_result.rationID,
+        adjustState:cal_result.adjustState
+    };
+    return {coe:coe,ration_glj:ration_glj,ration:ration,add:data.add,delete:data.delete}
+
+}
+
+function addGLJByCoe(code,engineerID,rationID,projectID) {//通过单个工料机类型编号添加
+
+}
+
+
 
 async function  updateRation(std,defaultLibID,rationID,billsItemID,projectID,calQuantity) {
     // insertNewRation

+ 1 - 0
modules/main/routes/ration_route.js

@@ -17,5 +17,6 @@ module.exports = function (app) {
     rationRouter.post('/getDefaultProgramID', rationController.action);
     rationRouter.post('/applyTemplate', rationController.action);
     rationRouter.post('/updateRationAss', rationController.action);
+    rationRouter.post('/updateCoeAdjust', rationController.action);
     app.use('/ration', rationRouter);
 };

+ 5 - 4
modules/pm/facade/pm_facade.js

@@ -180,7 +180,6 @@ async function copyProject(userID, compilationID,data,newProjectID = null) {
     projectMap['copy'].document.userID = userID;
     projectMap['copy'].document.compilation = compilationID;
     projectMap['copy'].document.createDateTime = new Date();
-
     //清单、定额ID生成任务
     let IDtasks = [
         createIDsAndReturn(originalID,billsModel),
@@ -188,7 +187,6 @@ async function copyProject(userID, compilationID,data,newProjectID = null) {
         getProjectGLJIDAndReturn(originalID,newProjectID)
     ];
     let [billMap,rationMap,projectGLJMap] = await Promise.all(IDtasks);
-
     //所有复制任务异步处理,提升效率  复制清单,定额,4个文件,项目工料机, 定额工料机,人工系数,工程量明细,定额安装增加费,安装增加费
     let copyTasks = [
         createProject(projectMap),
@@ -235,8 +233,11 @@ async function getProjectGLJIDAndReturn(originalID,newProjectID) {
     let IDMap = {};
     let datas = [];
     let result = await gljListModel.find({project_id:originalID}, '-_id');
-    for(let d of result){
-        let newID = await getCounterID("glj_list");
+    let gljCount = await counter.counterDAO.getIDAfterCountSync(counter.moduleName.glj_list, result.length);
+    for(let i = 0; i < result.length; i++){
+        let d = result[i];
+        let newID = gljCount.sequence_value - (result.length - 1) + i;
+        //let newID = await getCounterID("glj_list");
         IDMap[d.id] = newID;
         d._doc.project_id = newProjectID;
         d._doc.id = newID;

+ 13 - 11
modules/pm/models/project_model.js

@@ -697,18 +697,20 @@ ProjectsDAO.prototype.getProjectProperty = async function (projectId) {
 
 ProjectsDAO.prototype.getExtendData = function(property,compilation) {
     let ext = {};
-    let region = property.region;
-    let taxType = property.taxType;
-    if(compilation.priceProperties && compilation.priceProperties.length > 0){//如果是具有多单价的编办,取单价对应的字段
-        let priceProperty  = _.find(compilation.priceProperties,{region:region,taxModel:parseInt(taxType)});
-        if(priceProperty){
-            ext['priceField'] =  priceProperty.price.dataCode;
+    if(property){
+        let region = property.region;
+        let taxType = property.taxType;
+        if(compilation.priceProperties && compilation.priceProperties.length > 0){//如果是具有多单价的编办,取单价对应的字段
+            let priceProperty  = _.find(compilation.priceProperties,{region:region,taxModel:parseInt(taxType)});
+            if(priceProperty){
+                ext['priceField'] =  priceProperty.price.dataCode;
+            }
         }
-    }
-    if(compilation.consumeAmtProperties && compilation.consumeAmtProperties.length > 0){
-        let  consumeAmt =   _.find(compilation.consumeAmtProperties,{region:region,taxModel:parseInt(taxType)});
-        if(consumeAmt){
-            ext['quantityField'] =  consumeAmt.consumeAmt.dataCode;
+        if(compilation.consumeAmtProperties && compilation.consumeAmtProperties.length > 0){
+            let  consumeAmt =   _.find(compilation.consumeAmtProperties,{region:region,taxModel:parseInt(taxType)});
+            if(consumeAmt){
+                ext['quantityField'] =  consumeAmt.consumeAmt.dataCode;
+            }
         }
     }
     return _.isEmpty(ext)?null:ext;

+ 19 - 0
modules/ration_glj/controllers/ration_glj_controller.js

@@ -10,6 +10,7 @@ module.exports={
     createRationGLJ:createRationGLJ,
     testGetQuantify:testGetQuantify,
     getGLJData:getGLJData,
+    getGLJDataByCodes:getGLJDataByCodes,
     addGLJ:addGLJ,
     replaceGLJ:replaceGLJ,
     mReplaceGLJ:mReplaceGLJ,
@@ -38,6 +39,24 @@ async function testGetQuantify() {
     }
 }
 
+async function getGLJDataByCodes(req,res){
+    let result={
+        error:0
+    }
+    try {
+        let data = req.body.data;
+        data = JSON.parse(data);
+        let datas= await ration_glj_facade.getGLJDataByCodes(data,req.session.sessionCompilation);
+        result.data=datas;
+    }catch (err){
+        logger.err(err);
+        result.error=1;
+        result.message = err.message;
+    }
+    res.json(result);
+}
+
+
 async function getGLJData(req, res) {
     let result={
         error:0

+ 57 - 17
modules/ration_glj/facade/ration_glj_facade.js

@@ -35,7 +35,10 @@ module.exports = {
     getQuantityByProjectGLJ: getQuantityByProjectGLJ,
     getLibInfo: getLibInfo,
     getGLJData: getGLJData,
+    getGLJDataByCodes:getGLJDataByCodes,
     addGLJ: addGLJ,
+    deleteGLJ:deleteGLJ,
+    insertAddTypeGLJ:insertAddTypeGLJ,
     replaceGLJ: replaceGLJ,
     mReplaceGLJ: mReplaceGLJ,
     updateRationGLJByEdit: updateRationGLJByEdit,
@@ -45,7 +48,8 @@ module.exports = {
     getInfoFromProjectGLJ:getInfoFromProjectGLJ,
     createNewRecord:createNewRecord,
     getGLJSearchInfo:getGLJSearchInfo,
-    updateRationGLJFromDoc:updateRationGLJFromDoc
+    updateRationGLJFromDoc:updateRationGLJFromDoc,
+    getGLJLibByEngineerID:getGLJLibByEngineerID
 }
 
 let operationMap = {
@@ -383,6 +387,9 @@ function deleteByID(datas, callback) {
         }
     })
 }
+async function deleteGLJ(IDs) {
+    await ration_glj.deleteMany({'ID': {$in: IDs}});
+}
 
 async function deleteAndUpdateState(datas) {
     let result = {
@@ -506,12 +513,10 @@ function save(user_id, datas, callback) {
 }
 
 async function getLibInfo(req) {
-    let gljLibId = null, engineerID, sessionCompilation = req.session.sessionCompilation,
-        engineeringLibModel = new EngineeringLibModel() ;
+    let gljLibId = null, engineerID, sessionCompilation = req.session.sessionCompilation;
     engineerID = req.params.engineerID;
     if(engineerID){
-        let engineeringInfo = await engineeringLibModel.findDataByCondition({'_id': engineerID});
-        gljLibId = engineeringInfo.glj_lib.length > 0 && typeof engineeringInfo.glj_lib !== 'undefined' ? engineeringInfo.glj_lib[0].id : null;
+        gljLibId = await getGLJLibByEngineerID(engineerID);
     }else {
         throw new Error("工程专业ID为空!");
     }
@@ -524,6 +529,14 @@ async function getLibInfo(req) {
     return data;
 }
 
+async function getGLJLibByEngineerID  (engineerID) {
+    let engineeringLibModel = new EngineeringLibModel() ;
+    let engineeringInfo = await engineeringLibModel.findDataByCondition({'_id': engineerID});
+    let gljLibId = engineeringInfo.glj_lib.length > 0 && typeof engineeringInfo.glj_lib !== 'undefined' ? engineeringInfo.glj_lib[0].id : null;
+    return gljLibId
+}
+
+
 function getGLJData(info, callback) {
     let gljDao = new GljDao();
     let datas = {};
@@ -603,8 +616,22 @@ async function prepareExtData(projectID,compilation) {
 
 
 async function addGLJ(rgList,compilation) {
-    let newRecodes = [];
     if (rgList.length <= 0) return {};
+    let newRecodes = await insertAddTypeGLJ(rgList,compilation);
+    let stateResult = await glj_calculate_facade.calculateQuantity({
+        projectID: rgList[0].projectID,
+        rationID: rgList[0].rationID
+    });
+    let result = {
+        newRecodes: newRecodes,
+        showData: rgList,
+        adjustState: stateResult.adjustState
+    };
+    return result;
+}
+
+async function insertAddTypeGLJ(rgList,compilation) {
+    let newRecodes = [];
     let [unitFileId,ext] = await  prepareExtData(rgList[0].projectID,compilation);
     for (let g of rgList) {
         let projectGljModel = new GLJListModel();
@@ -625,19 +652,10 @@ async function addGLJ(rgList,compilation) {
         newRecodes.push(createNewRecord(g));
     }
     await ration_glj.insertMany(newRecodes);
-
-    let stateResult = await glj_calculate_facade.calculateQuantity({
-        projectID: rgList[0].projectID,
-        rationID: rgList[0].rationID
-    });
-    let result = {
-        newRecodes: newRecodes,
-        showData: rgList,
-        adjustState: stateResult.adjustState
-    }
-    return result;
+    return newRecodes;
 }
 
+
 async function replaceGLJ(data,compilation) {
     let rdata = {};
     let projectGljModel = new GLJListModel();
@@ -835,6 +853,28 @@ async function changAdjustState(data, rationList) {
     return stateList;
 }
 
+async function getGLJDataByCodes(data,compilation) {
+  let  gljLibId = await getGLJLibByEngineerID(data.engineerID);
+  let gljDatas = [];
+  if(gljLibId){
+     let stdList =   await  std_glj_lib_gljList_model.find({'repositoryId':gljLibId,code:{'$in':data.codes}});
+     if(stdList.length > 0){
+         let property = await projectDao.getProjectProperty(data.projectID);
+         let ext = projectDao.getExtendData(property,compilation);//多单价处理
+         for(let s of stdList){
+             let tem = JSON.parse(JSON.stringify(s));
+             if(ext && ext.priceField && tem && tem.priceProperty){
+                 tem.basePrice =  tem.priceProperty[ext.priceField];
+             }
+             gljDatas.push(tem);
+
+         }
+     }
+  }
+    return gljDatas
+}
+
+
 async function testError() {
     throw  new Error('test Error');
 }

+ 1 - 0
modules/ration_glj/routes/ration_glj_route.js

@@ -9,6 +9,7 @@ module.exports = function (app) {
 
     var rgRouter = express.Router();
     rgRouter.get('/getGLJData/:engineerID', rgController.getGLJData);
+    rgRouter.post('/getGLJDataByCodes',rgController.getGLJDataByCodes);
     rgRouter.post('/addGLJ',rgController.addGLJ);
     rgRouter.post('/replaceGLJ',rgController.replaceGLJ);
     rgRouter.post('/mReplaceGLJ',rgController.mReplaceGLJ);

+ 2 - 1
public/counter/counter.js

@@ -20,7 +20,8 @@ const COUNTER_MODULE_NAME = {
     template_bills: 'temp_bills',
     billsLib: 'billsLib',
     coeList: 'coeList',
-    complementaryCoeList: 'complementary_coe_list'
+    complementaryCoeList: 'complementary_coe_list',
+    glj_list: 'glj_list'
 }
 /*const PROJECT_COUNTER = 'projects', USER_COUNTER = 'users', BILL_COUNTER = 'bills', RATION_COUNTER = 'rations',
     REPORT_COUNTER = 'rptTemplates', FEE_COUNTER = 'fees'*/

+ 21 - 1
public/web/headerOpr.js

@@ -58,9 +58,29 @@ const CommonHeader = (function () {
             getCategoryList(-1, '联系客服');
         });
     }
-    return {getCategoryList, addEventListener}
+    //取消浏览器自带右键
+    //@return {void}
+    function banNavigatorContextMenu() {
+        document.oncontextmenu = function(event) {
+            if (window.event) {
+                event = window.event;
+            }
+            try {
+                var the = event.srcElement;
+                if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
+                    return false;
+                }
+                return true;
+            } catch (e) {
+                return false;
+            }
+        }
+    }
+    return {getCategoryList, addEventListener, banNavigatorContextMenu};
 })();
 
+CommonHeader.banNavigatorContextMenu();
+
 $(document).ready(function(){
     CommonHeader.addEventListener();
 });

+ 18 - 18
web/building_saas/main/html/main.html

@@ -157,6 +157,7 @@
                               <a class="nav-link px-1 right-nav-link" href="javascript:void(0)" id="stdRationTab"
                                  relaPanel="#de">定额库</a>
                           </li>
+
                           <li class="nav-item dropdown">
                               <!--<a class="nav-link dropdown-toggle more" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">更多</a>-->
                               <div class="dropdown-menu">
@@ -1760,7 +1761,7 @@
         </div>
     </div>
     <!--弹出 生成组价模板-->
-    <div class="modal fade" id="div_createBlocks" data-backdrop="static">
+    <div class="modal fade" id="zujiamb" data-backdrop="static">
         <div class="modal-dialog" role="document">
             <div class="modal-content">
                 <div class="modal-header">
@@ -1777,7 +1778,7 @@
                     <div class="form-group">
                         <div class="form-check form-check-inline">
                             <input class="form-check-input" type="checkbox" name="inlineRadioOptions" id="ckb_block_exist_cover" value="option1">
-                            <label class="form-check-label" for="ckb_block_exist_cover">当存在同名模板时覆盖</label>
+                            <label class="form-check-label" for="ckb_block_exist_cover">当存在同名模板时,提示是否覆盖</label>
                         </div>
                     </div>
                 </div>
@@ -1789,7 +1790,7 @@
         </div>
     </div>
     <!--弹出 匹配原则-->
-    <div class="modal fade" id="div_cloneOptions" data-backdrop="static">
+    <div class="modal fade" id="blockAdjustOptions" data-backdrop="static">
         <div class="modal-dialog" role="document">
             <div class="modal-content">
                 <div class="modal-header">
@@ -1803,16 +1804,16 @@
                         <label>选择匹配模式:</label>
                         <div>
                             <div class="form-check form-check-inline">
-                                <input class="form-check-input" type="checkbox" id="clone_option_code" value="option1" checked>
-                                <label class="form-check-label" for="clone_option_code">项目编码(前9位)</label>
+                                <input class="form-check-input" type="checkbox" name="inlineRadioOptions" id="inlinecheckbox1" value="option1" checked>
+                                <label class="form-check-label" for="inlinecheckbox1">项目编码(前9位)</label>
                             </div>
                             <div class="form-check form-check-inline">
-                                <input class="form-check-input" type="checkbox" id="clone_option_name" value="option2">
-                                <label class="form-check-label" for="clone_option_name">项目名称</label>
+                                <input class="form-check-input" type="checkbox" name="inlineRadioOptions" id="inlinecheckbox2" value="option2">
+                                <label class="form-check-label" for="inlinecheckbox2">项目名称</label>
                             </div>
                             <div class="form-check form-check-inline">
-                                <input class="form-check-input" type="checkbox" id="clone_option_unit" value="option3" checked>
-                                <label class="form-check-label" for="clone_option_unit">单位</label>
+                                <input class="form-check-input" type="checkbox" name="inlineRadioOptions" id="inlinecheckbox3" value="option3" checked>
+                                <label class="form-check-label" for="inlinecheckbox3">单位</label>
                             </div>
                         </div>
                     </div>
@@ -1820,12 +1821,12 @@
                         <label for="exampleInputPassword1">插入为选定节点的:</label>
                         <div>
                             <div class="form-check form-check-inline">
-                                <input class="form-check-input" type="radio" name="rationQuantity" id="clone_option_quantity" value="option1" checked>
-                                <label class="form-check-label" for="clone_option_quantity">根据含量计算定额工程量</label>
+                                <input class="form-check-input" type="radio" name="rationQuantity" id="inlineRadio21" value="option1" checked>
+                                <label class="form-check-label" for="inlineRadio21">根据含量计算定额工程量</label>
                             </div>
                             <div class="form-check form-check-inline">
-                                <input class="form-check-input" type="radio" name="rationQuantity" id="clone_option_zeroQuantity" value="option2">
-                                <label class="form-check-label" for="clone_option_zeroQuantity">含量和定额工程量为零</label>
+                                <input class="form-check-input" type="radio" name="rationQuantity" id="inlineRadio22" value="option2">
+                                <label class="form-check-label" for="inlineRadio22">含量和定额工程量为零</label>
                             </div>
                         </div>
                     </div>
@@ -1833,12 +1834,12 @@
                         <label for="exampleInputPassword1">清单下有定额时:</label>
                         <div>
                             <div class="form-check form-check-inline">
-                                <input class="form-check-input" type="radio" name="rationCover" id="clone_option_noCover" value="option3" checked>
-                                <label class="form-check-label" for="clone_option_noCover">跳过不覆盖</label>
+                                <input class="form-check-input" type="radio" name="rationCover" id="inlineRadio33" value="option3" checked>
+                                <label class="form-check-label" for="inlineRadio33">跳过不覆盖</label>
                             </div>
                             <div class="form-check form-check-inline">
-                                <input class="form-check-input" type="radio" name="rationCover" id="clone_option_overwriteRations" value="option2">
-                                <label class="form-check-label" for="clone_option_overwriteRations">直接覆盖</label>
+                                <input class="form-check-input" type="radio" name="rationCover" id="inlineRadio32" value="option2">
+                                <label class="form-check-label" for="inlineRadio32">直接覆盖</label>
                             </div>
                         </div>
                     </div>
@@ -2035,7 +2036,6 @@
                 $("#checkCount").text(checkCount);
 
             }
-
             /*$(document).ready(function(){
                 document.addEventListener('visibilitychange', function() {
                     if(document.hidden){ //页面不可见状态

+ 1 - 3
web/building_saas/main/js/models/ration_ass.js

@@ -120,10 +120,8 @@ var ration_ass = {
             $.bootstrapLoading.start();
             CommonAjax.post("/ration/updateRationAss",updateData[0],function (result) {
                 $.bootstrapLoading.end();
-                let nodes = project.updateNodesCache([{type:ModuleNames.ration,data:result.ration}]);
+                zmhs_obj.refreshAfterUpdate(result);
                 zmhs_obj.showAssData();
-                projectObj.mainController.refreshTreeNode(nodes, false);
-                project.ration_glj.refreshAfterUpdate(result.ration_glj);
             })
            // project.pushNow('updateRationAss',[this.getSourceType()],updateData);
 

+ 51 - 7
web/building_saas/main/js/models/ration_coe.js

@@ -128,16 +128,60 @@ var ration_coe = {
             return updateData;
         };
         ration_coe.prototype.adjustCoeClick = function(recode,newval){
-            var query = {
+            let me=this,codesList = [],add=[],replace=[];
+            var updateData = {
                 'ID':recode.ID,
                 'projectID': recode.projectID,
-                'rationID':recode.rationID
+                'rationID':recode.rationID,
+                'doc':{
+                    isAdjust:newval
+                },
+                add:[],
+                delete:[],
+                replace:[]
             };
-            var doc ={
-                isAdjust:newval,
-            };
-            var updateData = this.getUpdateData('ut_update',query,doc,'adjustUpdate');
-            project.pushNow('updateRationCOE',[this.getSourceType()],updateData);
+            let gljList = project.ration_glj.getGLJListByRationID(recode.rationID);
+            for(let coe of recode.coes){//做单个、替换等检查
+                if(coe.coeType == "单个工料机"){ //单个工料机的情况
+                    let glj = _.find(gljList,{"code":coe.gljCode});
+                    if(newval == 1){ //单个工料机,选中时,如果能找到则不管,如果没找到,则需自动插入
+                        if(glj) continue;
+                        add.push(coe.gljCode);
+                        codesList.push(coe.gljCode);
+                    }else {//取消勾选时,要删除添加的工料机记录
+                       if(glj && glj.createType == "add") updateData.delete.push(glj.ID);
+                    }
+
+                }
+                //替换工料机的情况
+            }
+            project.ration_glj.getGLJDataByCodes(codesList,function (gljList) {//统一从后端按编号查找标准工料机信息
+                let gljMap = _.indexBy(gljList, 'code');
+                console.log(gljMap);
+                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);
+                        updateData.add.push(tem);
+                    }
+                }
+                $.bootstrapLoading.start();
+                CommonAjax.post("/ration/updateCoeAdjust",updateData,function (result) {
+                    $.bootstrapLoading.end();
+                    me.refreshAfterUpdate(result.coe);
+                    zmhs_obj.refreshAfterUpdate(result,true)
+                })
+            });
+
+
+
+
+
+           /* ;*/
+
+
+
+            //var updateData = this.getUpdateData('ut_update',query,doc,'adjustUpdate');
+           // project.pushNow('updateRationCOE',[this.getSourceType()],updateData);
         };
 
         ration_coe.prototype.updateCustomerCoe = function (data) {

+ 63 - 34
web/building_saas/main/js/models/ration_glj.js

@@ -61,6 +61,11 @@ let ration_glj = {
             }
         };
 
+        ration_glj.prototype.getGLJListByRationID = function (rationID) {
+           return  _.filter(this.datas, {'rationID': rationID})
+        };
+
+
         ration_glj.prototype.getGatherGljArrByRations = function (rations, needOneBill, billQuantity) {
             let result = [];
             let clone = function (obj) {
@@ -230,17 +235,25 @@ let ration_glj = {
 
         ration_glj.prototype.refreshAfterUpdate = function (data) {
             let me = this;
+            let rationID= me.updateCacheAfterAdjust(data);
+            gljOprObj.showRationGLJSheetData(true);
+            this.reCalcWhenGLJChange({rationID:rationID});
+        };
+
+        ration_glj.prototype.updateCacheAfterAdjust=function (data) {
+            let me = this;
             let rationID=null;
             if (data.quantityRefresh) {
                 data.glj_result.forEach(function (item) {
-                   rationID = me.refreshEachItme(item.doc, item.query);
+                    rationID = me.refreshEachItme(item.doc, item.query);
                 })
             } else {
                 rationID =  me.refreshEachItme(data.doc, data.query);
             }
-            gljOprObj.showRationGLJSheetData(true);
-            this.reCalcWhenGLJChange({rationID:rationID});
+            return rationID;
         };
+
+
         ration_glj.prototype.refreshEachItme = function (doc, query) {
             let glj = this.refreshByID(query.ID,doc);
             return glj.rationID;
@@ -603,10 +616,55 @@ let ration_glj = {
                 $.bootstrapLoading.end();
             });
 
+        };
+        ration_glj.prototype.getGLJDataByCodes = function (codes,callback) {
+            if(!gljUtil.isDef(codes)||codes.length ==0) {
+                if(callback) callback([]);
+                return
+            }
+            $.bootstrapLoading.start();
+            CommonAjax.post("/rationGlj/getGLJDataByCodes", { 'engineerID':projectInfoObj.projectInfo.property.engineering_id,projectID:projectObj.project.ID(),codes:codes}, function (result) {
+                $.bootstrapLoading.end();
+                callback(result)
+            });
+        };
 
+        ration_glj.prototype.getAddDataByStd = function (glj,rationID,billsItemID,projectID) {//生成添加类型的定额工料机数据
+            let ration_glj = {
+                projectID: projectID,
+                GLJID: glj.ID,
+                rationID: rationID,
+                billsItemID: billsItemID,
+                rationItemQuantity: 0,
+                quantity: 0,
+                name: glj.name,
+                code: glj.code,
+                original_code: glj.code,
+                unit: glj.unit,
+                specs: glj.specs,
+                basePrice: glj.basePrice,
+                marketPrice:glj.basePrice,
+                shortName: glj.shortName,
+                type: glj.gljType,
+                model:glj.model,
+                adjCoe: glj.adjCoe,
+                createType: 'add',
+                materialType:glj.materialType,
+                materialCoe:glj.materialCoe,
+                repositoryId: glj.repositoryId
+            };
+            if (glj.hasOwnProperty("compilationId")) {
+                ration_glj.from = "cpt";
+                if (glj.code.indexOf('-') != -1) {//这条工料机是用户通过修改名称、规格、型号等保存到补充工料机库的
+                    ration_glj.original_code = glj.code.split('-')[0];//取-前的编号作为原始编号
+                }
+            }
+            return ration_glj;
         };
+
+
         ration_glj.prototype.addGLJByLib = function (GLJSelection, ration, callback) {
-            let gljList = [];
+            let me=this,gljList = [];
             let allGLJ = gljOprObj.AllRecode;
             GLJSelection.sort();
             _.forEach(GLJSelection, function (g) {
@@ -614,36 +672,7 @@ let ration_glj = {
                     let i_key = gljOprObj.getIndex(item, gljLibKeyArray);
                     return i_key == g;
                 });
-                let ration_glj = {
-                    projectID: ration.projectID,
-                    GLJID: glj.ID,
-                    rationID: ration.ID,
-                    billsItemID: ration.billsItemID,
-                    rationItemQuantity: 0,
-                    quantity: 0,
-                    name: glj.name,
-                    code: glj.code,
-                    original_code: glj.code,
-                    unit: glj.unit,
-                    specs: glj.specs,
-                    basePrice: glj.basePrice,
-                    marketPrice:glj.basePrice,
-                    shortName: glj.shortName,
-                    type: glj.gljType,
-                    model:glj.model,
-                    adjCoe: glj.adjCoe,
-                    createType: 'add',
-                    materialType:glj.materialType,
-                    materialCoe:glj.materialCoe,
-                    repositoryId: glj.repositoryId
-                }
-                if (glj.hasOwnProperty("compilationId")) {
-                    ration_glj.from = "cpt";
-                    if (glj.code.indexOf('-') != -1) {//这条工料机是用户通过修改名称、规格、型号等保存到补充工料机库的
-                        ration_glj.original_code = glj.code.split('-')[0];//取-前的编号作为原始编号
-                    }
-                }
-
+                let ration_glj = me.getAddDataByStd(glj,ration.ID,ration.billsItemID,ration.projectID);
                 gljList.push(ration_glj);
             });
             $.bootstrapLoading.start();

+ 3 - 3
web/building_saas/main/js/views/billsElf.js

@@ -168,7 +168,7 @@ const BillsElf = (function() {
             workBookWidth = ($(window).width() - $('.main').find('.main-nav').width() - $('.main-side').width()) * 5 / 6,
             headers = elfItem.headers;
         if(workBook){
-            workBookWidth -= 60;
+            workBookWidth -= 55;
             const sheet = workBook.getActiveSheet();
             sheet.suspendEvent();
             sheet.suspendPaint();
@@ -461,9 +461,9 @@ const BillsElf = (function() {
             }
             let height = cellRect.height;
             let options = getOptions(node.data, bills.selected.elf.datas);
-            top = options.length - 2 > 4 ? top - 4 * height : top - (options.length - 2) * height - 5;
+            top = options.length - 2 > 4 ? top - 4 * height : top - (options.length - 2) * height;
             let $editInput = $(`<div style="height: ${height}px; background: ${cellStyle.backColor};overflow: hidden; white-space: nowrap; text-overflow: ellipsis">${node.data.options}</div>`),
-                $optDiv = $(`<div style="position: fixed; width: ${cellRect.width}px; top: ${top}px;background: ${cellStyle.backColor};border: 1px solid; overflow: auto; height: ${options.length > 6 ? height*6 : height*options.length+5}px; font-size: 0.9rem;"></div>`);
+                $optDiv = $(`<div style="position: fixed; width: ${cellRect.width}px; top: ${top}px;background: ${cellStyle.backColor};border: 1px solid; overflow: auto; height: ${options.length > 6 ? height*6+5 : height*options.length+5}px; font-size: 0.9rem;"></div>`);
             for(let opt of options){
                 let $opt = $(`<div title="${opt.name ? opt.name : ''}" class="elf-options" style="height: ${height}px;overflow: hidden; white-space: nowrap; text-overflow: ellipsis"></div>`),
                     $optInput = $(`<input rank="${opt.rank}" value="${opt.ID}" style="margin-left: 5px; vertical-align: middle" type="checkbox" 

+ 1 - 0
web/building_saas/main/js/views/main_tree_col.js

@@ -306,6 +306,7 @@ let MainTreeCol = {
             ) {
                 // var names = new GC.Spread.Sheets.CellTypes.ComboBox();
                 var names = sheetCommonObj.getDynamicCombo();
+                names._maxDropDownItems = 10;
                 names.items(projectObj.project.calcProgram.compiledTemplateNames);
                 return names;
             }

+ 40 - 0
web/building_saas/main/js/views/std_ration_lib.js

@@ -188,8 +188,48 @@ var rationLibObj = {
             SheetDataHelper.loadSheetData(setting, rationLibObj.sectionRationsSpread.getActiveSheet(), datas);
             rationLibObj.setTagForHint(rationSheet, datas);
         };
+        //定额名称的处理:
+        /*
+         * 1、从定额库提取的名称,是否含有空格:
+         * 1.1、无,则不处理。
+         * 1.2、有,则取第一个空格前的文本,与定额所属节点名称(去掉前面和后面的编号、括号、空格,保留中间的中文及符号)比较是否相同:
+         * 1.2.1、不同,则不处理。
+         * 1.2.2、相同,则将定额名称显示为去除第一个空格及空格之前的文本。
+         */
+        //@param {String}sectionName(章节名称) {Array}datas(定额数据)
+        function simplifyName(sectionName, datas){
+            if (!sectionName || !datas || datas.length === 0) {
+                return;
+            }
+            //提取需要匹配的章节名称
+            //去掉前缀
+            let toMatchArr = sectionName.split(' '),
+                toMatchStr = toMatchArr[toMatchArr.length - 1];
+            //去掉后缀
+            let sectionReg = /\(\w{9,}\)/g,
+                regMatch = toMatchStr.match(sectionReg);
+            if (regMatch) {
+                toMatchStr = toMatchStr.replace(regMatch[regMatch.length - 1], '');
+            }
+            //简化匹配到的定额名称
+            for (let data of datas) {
+                //第一个空格前的字符串去进行匹配,没有则不匹配
+                let nameArr = data.name.split(' ');
+                if (nameArr.length <= 1) {
+                    continue;
+                }
+                let matchName = nameArr[0];
+                if (matchName === toMatchStr) {
+                    nameArr.shift();
+                    data.name = nameArr.join(' ');
+                }
+            }
+        }
         if (sectionID) {
             CommonAjax.post('/complementaryRation/api/getRationGljItemsBySection', {user_Id: userID, sectionId: sectionID, type: me.curLibType}, function (datas) {
+                let chapterSheet = me.rationChapterSpread.getActiveSheet();
+                let sectionName = chapterSheet.getText(chapterSheet.getActiveRowIndex(), chapterSheet.getActiveColumnIndex());
+                simplifyName(sectionName, datas);
                 showDatas(datas, rationLibObj.sectionRationsSetting);
                 if(me.doAfterLoadGetRations){
                     me.doAfterLoadGetRations(datas);

+ 47 - 0
web/building_saas/main/js/views/zmhs_view.js

@@ -92,6 +92,53 @@ let zmhs_obj = {
         this.assSheet.resumeEvent();
 
     },
+    refreshAfterUpdate:function(result,reload){
+        let ration_glj = projectObj.project.ration_glj;
+        let calcInstall = false;//是否记录安装增加费
+        let nodes = projectObj.project.updateNodesCache([{type:ModuleNames.ration,data:result.ration}]);
+        projectObj.mainController.refreshTreeNode(nodes, false);
+        if(result.add && result.add.length > 0){//需添加定额工料机的情况
+            ration_glj.datas = ration_glj.datas.concat(result.add);
+            gljOprObj.sheetData = gljOprObj.sheetData.concat(result.add);
+        }
+        if(result.delete && result.delete.length > 0 && this.deleteGLJs(result.delete)) calcInstall = true; //这样保证delete返回值是true的时候才改变变量类型
+
+        let rationID= ration_glj.updateCacheAfterAdjust(result.ration_glj);
+        if(reload == true){//有添加、替换、工料机等需重新加载的情况
+            $.bootstrapLoading.start();
+            projectObj.project.projectGLJ.loadData(function () {
+                $.bootstrapLoading.end();
+                if(result.add && result.add.length > 0) ration_glj.addToMainTree(result.add);
+                ration_glj.reCalcWhenGLJChange({rationID:rationID});
+                if(result.delete && result.delete.length > 0 && calcInstall) installationFeeObj.calcInstallationFee();//如果是删除节点的话,
+            });
+        }else {
+            ration_glj.reCalcWhenGLJChange({rationID:rationID});
+        }
+        gljOprObj.showRationGLJSheetData(true);
+    },
+
+    deleteGLJs:function (IDs) {
+        let ration_glj = projectObj.project.ration_glj;
+        let glj_list = ration_glj.datas;
+        let calcInstall = false;
+        let oldData = _.remove(glj_list, function (o) {
+            return _.includes(IDs,o.ID);
+        });
+        _.remove(gljOprObj.sheetData, function (o) {
+            return _.includes(IDs,o.ID);
+        });
+        for (let o of oldData) {
+            if (ration_glj.needShowToTree(o)) {
+                let node = ration_glj.findGLJNodeByID(o.ID);  //找到对应的树节点
+                projectObj.mainController.deleteNode(node, null);
+                calcInstall = true;
+            }
+        }
+        return calcInstall;
+    },
+
+
     refresh:function () {
         this.coeSpread?this.coeSpread.refresh():'';
         this.assSpread?this.assSpread.refresh():'';

+ 2 - 2
web/building_saas/report/html/rpt_main.html

@@ -15,7 +15,7 @@
             </div>
         </div>
         <div class="col-lg-9 p-0">
-            <div class="toolsbar">
+            <div class="toolsbar-f d-flex justify-content-between">
                 <div class="print-toolsbar">
                     <div class="panel">
                         <div class="panel-body" id="print_div">
@@ -88,7 +88,7 @@
                     </div>
                 </div>
             </div>
-            <div class="print-view poj-list">
+            <div class="print-view  form-view">
                 <div class="pageContainer">
                     <canvas id="rptCanvas" height="820" width="920"></canvas>
                 </div>

+ 1 - 0
web/users/html/login.html

@@ -111,6 +111,7 @@
     <script src="/lib/bootstrap/bootstrap.min.js"></script>
     <script src="/web/building_saas/js/global.js"></script>
     <script type="text/javascript" src="/web/users/js/login.js"></script>
+    <script src="/public/web/headerOpr.js"></script>
     <!-- endinject -->
 </body>