zhangweicheng %!s(int64=7) %!d(string=hai) anos
pai
achega
c51f75aa8f

+ 1 - 1
modules/fee_rates/controllers/fee_rates_controller.js

@@ -140,7 +140,7 @@ async function getChangeInfo(req, res) {
     }
     try {
         let data = req.body.data;
-        let info= await feeRateFacde.getChangeInfo(data);
+        let info= await feeRateFacde.getChangeInfo(data,req.session.sessionCompilation._id);
         result.data= info;
     }catch (err){
         console.log(err);

+ 2 - 2
modules/fee_rates/facade/fee_rates_facade.js

@@ -322,7 +322,7 @@ async function checkFeeRateName(jdata) {
     return false;
 }
 
-async function getChangeInfo(jdata){
+async function getChangeInfo(jdata,compilation){
     let data = JSON.parse(jdata);
     //{ rootProjectID: 99, user_id: '76075' }
     let result={};
@@ -332,7 +332,7 @@ async function getChangeInfo(jdata){
     }
     //根据用户ID 找除了当前项目的其它建设项目;
     let others =await projectsModel.find({'$and': [
-            {'$or':[{'userID': data.user_id,'projType':'Project', 'deleteInfo': null}, {'userID': data.user_id,'projType':'Project', 'deleteInfo.deleted': {'$in': [null, false]}}]},
+            {'$or':[{'userID': data.user_id,'compilation': compilation,'projType':'Project', 'deleteInfo': null}, {'userID': data.user_id,'compilation': compilation,'projType':'Project', 'deleteInfo.deleted': {'$in': [null, false]}}]},
             { 'ID':{'$nin':[data.rootProjectID]}}
         ]},['ID','name']);
     for(let o of others){

+ 27 - 1
modules/glj/controllers/glj_controller.js

@@ -249,7 +249,7 @@ class GLJController extends BaseController {
         try {
             let sessionUserData = request.session.sessionUser;
             // 获取对应用户所有的建设项目数据
-            let projectList = await ProjectModel.getUserProjectData(sessionUserData.id);
+            let projectList = await ProjectModel.getUserProjectData(sessionUserData.id,request.session.sessionCompilation._id);
             if (projectList === null) {
                 throw '没有找到对应的项目数据';
             }
@@ -295,6 +295,7 @@ class GLJController extends BaseController {
     async changeUnitPriceFile(request, response) {
         let projectId = request.body.project_id;
         let changeUnitPriceId = request.body.change_id;
+        let newName = request.body.newName;
         let type = request.body.type;
         type = parseInt(type);
         let responseData = {
@@ -317,6 +318,7 @@ class GLJController extends BaseController {
 
                 insertData = JSON.parse(JSON.stringify(currentUnitPrice));
                 insertData.root_project_id = rootProjectId;
+                newName?insertData.name = newName:'';
                 insertData.user_id = insertData.user_id === undefined ? request.session.sessionUser.id : insertData.user_id;
                 delete insertData._id;
                 delete insertData.ID;
@@ -372,6 +374,30 @@ class GLJController extends BaseController {
         response.json(responseData);
     }
 
+    async checkUnitFileName(request, response){
+        let result={
+            error:0
+        }
+        try {
+            let data = request.body.data;
+            let nameExist = false;
+            data = JSON.parse(data);
+            let unitPriceFileModel = new UnitPriceFileModel();
+            let count = await unitPriceFileModel.model.count({root_project_id:data.rootProjectID,name:data.name,deleteInfo:null});
+            if(count>0){
+                nameExist = true;
+            }else {
+                nameExist = false;
+            }
+            result.data= nameExist;
+        }catch (err){
+            console.log(err);
+            result.error=1;
+            result.message = err.message;
+        }
+        response.json(result);
+    }
+
     /**
      * 单价文件另存为
      *

+ 1 - 0
modules/glj/routes/glj_router.js

@@ -19,6 +19,7 @@ router.post('/get-ratio', gljController.init, gljController.getRatio);
 router.post('/delete-ratio', gljController.init, gljController.deleteMixRatio);
 router.post('/get-project-info', gljController.init, gljController.getProjectInfo);
 router.post('/change-file', gljController.init, gljController.changeUnitPriceFile);
+router.post('/checkUnitFileName', gljController.init, gljController.checkUnitFileName);
 router.post('/save-as', gljController.init, gljController.unitPriceSaveAs);
 router.post('/get-composition', gljController.init, gljController.getComposition);
 router.post('/updatePrice', gljController.init, gljController.updateUnitPrice);

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

@@ -638,11 +638,11 @@ ProjectsDAO.prototype.getUnitPriceFileId = async function (projectId) {
  * @paraconsolem {Number} userId
  * @return {Promise}
  */
-ProjectsDAO.prototype.getUserProjectData = async function (userId) {
+ProjectsDAO.prototype.getUserProjectData = async function (userId,compilation) {
     let projectList = await Projects.find({
         '$or': [
-            {'userID': userId, 'deleteInfo': null, projType: 'Project'},
-            {'userID': userId, 'deleteInfo.deleted': {'$in': [null, false]}, projType: 'Project'}
+            {'userID': userId, 'compilation': compilation, 'deleteInfo': null, projType: 'Project'},
+            {'userID': userId, 'compilation': compilation,'deleteInfo.deleted': {'$in': [null, false]}, projType: 'Project'}
         ]
     }, {_id: 0, name: 1, ID: 1});
 

+ 14 - 8
modules/ration_glj/facade/ration_glj_facade.js

@@ -658,21 +658,27 @@ async function mReplaceGLJ(data) {
     let projectGljModel = new GLJListModel();
     let result = await projectGljModel.addList(getGLJSearchInfo(data.doc));
     let typeString = result.type+'';
-    data.doc.projectGLJID = result.id;
+    let newDoc = {};
+    newDoc.projectGLJID = result.id;
     let rationList = await ration_glj.distinct('rationID', data.query);
-    let updateResult = await ration_glj.update(data.query, data.doc, {multi: true});
+    for(let t of data.tasks){
+        t.updateOne.update.projectGLJID = result.id;//更新项目工料机ID
+    }
+    await ration_glj.bulkWrite(data.tasks);
+    //let updateResult = await ration_glj.update(data.query, data.doc, {multi: true});
 
-    data.doc.marketPrice = result.unit_price.market_price;
-    data.doc.adjustPrice = result.unit_price.base_price;
-    data.doc.basePrice = result.unit_price.base_price;
-    data.doc.isAdd = result.unit_price.is_add;
+    newDoc.marketPrice = result.unit_price.market_price;
+    newDoc.adjustPrice = result.unit_price.base_price;
+    newDoc.basePrice = result.unit_price.base_price;
+    newDoc.isAdd = result.unit_price.is_add;
     if (typeString.startsWith("2")||typeString=='4'||typeString=='5') {//只有材料类型才显示是否暂估
-        data.doc.isEstimate = result.is_evaluate;
+        newDoc.isEstimate = result.is_evaluate;
     }
     if (result.hasOwnProperty('subList') && result.subList.length > 0) {
-        data.doc.subList = getMixRatioShowDatas(result.subList);
+        newDoc.subList = getMixRatioShowDatas(result.subList);
     }
     let stateList = await changAdjustState(data, rationList);
+    data.doc = newDoc;
     mresult.data = data;
     mresult.stateList = stateList;
     return mresult

+ 1 - 1
web/building_saas/fee_rates/fee_rate.html

@@ -3,7 +3,7 @@
 <div >
 <div class="toolsbar_feeRate px-1 ">
     <div class="form-inline py-1">
-        <label class="mx-2" >当前使用:<span id="feeRateFileName">费率1</span>(<a href="#" id="pop-lv"><span id="projectCount">3</span> 单位工程使用</a>)
+        <label class="mx-2" >当前使用:<span id="feeRateFileName">费率1</span>(<a href="#" id="pop-lv"><span id="projectCount">3</span> 单位工程使用</a>)
             <a class="btn btn-sm ml-1" href="#" data-toggle="modal" data-target="#change-lv" id="changFeeRateFile"><i class="fa fa-exchange"></i> 选择其他</a>
             <a class="btn btn-sm ml-1" href="#" data-toggle="modal" id="saveAs" data-target="#copy-lv"><i class="fa fa-files-o"></i> 另存单独用</a></label>
     </div>

+ 1 - 1
web/building_saas/glj/html/glj_index.html

@@ -5,7 +5,7 @@
 </style>
 <div class="toolsbar px-1">
     <div class="form-inline py-1">
-        <label class="mx-2">当前使用:<span id="used-name"></span>(<a href="#" id="pop-dj" data-original-title="" title=""><span id="used-count">0</span> 单位工程使用</a>)
+        <label class="mx-2">当前使用:<span id="used-name"></span>(<a href="#" id="pop-dj" data-original-title="" title=""><span id="used-count">0</span> 单位工程使用</a>)
             <a class="btn btn-sm ml-1" href="#" data-toggle="modal" data-target="#change-dj"><i class="fa fa-exchange"></i> 选择其他</a>
             <a class="btn btn-sm ml-1" href="#" data-toggle="modal" data-target="#file-save-as-dialog"><i class="fa fa-files-o"></i> 另存单独用</a></label>
     </div>

+ 29 - 2
web/building_saas/glj/html/project_glj.html

@@ -5,7 +5,7 @@
 </style>
 <div class="toolsbar px-1">
     <div class="form-inline py-1">
-        <label class="mx-2">当前使用:<span id="current-name"></span>(<a href="#" id="pop-used-list" data-original-title="" title=""><span id="used-project-count">0</span> 单位工程使用</a>)
+        <label class="mx-2">当前使用:<span id="current-name"></span>(<a href="#" id="pop-used-list" data-original-title="" title=""><span id="used-project-count">0</span> 单位工程使用</a>)
             <a class="btn btn-sm ml-1" href="#" data-toggle="modal" data-target="#change-unitFile"><i class="fa fa-exchange"></i> 选择其他</a>
             <a class="btn btn-sm ml-1" href="#" data-toggle="modal" data-target="#unitFile-save-as"><i class="fa fa-files-o"></i> 另存单独用</a></label>
     </div>
@@ -130,7 +130,34 @@
             </div>
             <div class="modal-footer">
                 <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
-                <a href="javascript:void(0);" class="btn btn-primary" id="save-as-confirm">确定</a>
+                <button type="button" class="btn btn-primary" id="save-as-confirm">确定</button>
+            </div>
+        </div>
+    </div>
+</div>
+
+
+<!--弹出 重命名窗口-->
+<div class="modal fade" id="rename-unitFile" data-backdrop="static">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">重命名</h5>
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">&times;</span>
+                </button>
+            </div>
+            <div class="modal-body">
+                <div class="form-group">
+                    <label>单价文件名称</label>
+                    <input class="form-control" id="newUnitFileID" value="" style="display: none">
+                    <input class="form-control" id="newUnitFileName" value="">
+                    <small class="form-text text-danger" id="renameError_unitFile">本建设项目中已存在同名单价文件。</small>
+                </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                <button type="button" class="btn btn-primary" data-dismiss="modal" id="renameUnitFileConfirm" disabled>确定</button>
             </div>
         </div>
     </div>

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

@@ -889,8 +889,8 @@
                 </div>
                 <div class="modal-footer" style="justify-content: center">
                     <button type="button" class="btn btn-primary"  data-dismiss="modal" id="deleteY" >是</button>
-                    <button type="button" class="btn btn-primary"  data-dismiss="modal" id="deleteN" >否</button>
-                    <button type="button" class="btn btn-secondary" data-dismiss="modal" id="deleteCancel">取消</button>
+                    <button type="button" class="btn btn-primary"  data-dismiss="modal" id="deleteN" style="display: none" >否</button>
+                    <button type="button" class="btn btn-secondary" data-dismiss="modal" id="deleteCancel">否</button><!--实际是取消-->
                 </div>
             </div>
         </div>

+ 12 - 6
web/building_saas/main/js/models/installation_fee.js

@@ -592,12 +592,18 @@ var installation_fee = {
                     labourQuantity = scMathUtil.roundForObj(parseFloat(project.Ration.getLabourTotalFee(ration))*parseFloat(labour),gljDecimal);
                     materialQuantity = scMathUtil.roundForObj(parseFloat(project.Ration.getMaterialTotalFee(ration))*parseFloat(material),gljDecimal);
                     machineQuantity = scMathUtil.roundForObj(parseFloat(project.Ration.getMachineTotalFee(ration))*parseFloat(machine),gljDecimal);
-                }else if(rule.base=='人工'){
-                    labourQuantity = scMathUtil.roundForObj(parseFloat(project.Ration.getLabourTotalFee(ration))*parseFloat(feeRate)*parseFloat(labour),gljDecimal);
-                }else if(rule.base=='材料'){
-                    materialQuantity = scMathUtil.roundForObj(parseFloat(project.Ration.getMaterialTotalFee(ration))*parseFloat(feeRate)*parseFloat(material),gljDecimal);
-                }else if(rule.base=='机械'){
-                    machineQuantity = scMathUtil.roundForObj(parseFloat(project.Ration.getMachineTotalFee(ration))*parseFloat(feeRate)*parseFloat(machine),gljDecimal);
+                }else {
+                    let base = 0;
+                    if(rule.base=='人工'){
+                        base = parseFloat(project.Ration.getLabourTotalFee(ration))*parseFloat(feeRate);
+                    }else if(rule.base=='材料'){
+                        base = parseFloat(project.Ration.getMaterialTotalFee(ration))*parseFloat(feeRate);
+                    }else if(rule.base=='机械'){
+                        base = parseFloat(project.Ration.getMachineTotalFee(ration))*parseFloat(feeRate);
+                    }
+                    labourQuantity = scMathUtil.roundForObj(base*parseFloat(labour),gljDecimal);
+                    materialQuantity = scMathUtil.roundForObj(base*parseFloat(material),gljDecimal);
+                    machineQuantity = scMathUtil.roundForObj(base*parseFloat(machine),gljDecimal);
                 }
                 return [labourQuantity,materialQuantity,machineQuantity];
             }

+ 11 - 0
web/building_saas/main/js/models/project_glj.js

@@ -412,6 +412,17 @@ ProjectGLJ.prototype.changeFile = function (changeData,callback) {
     });
 };
 
+ProjectGLJ.prototype.checkUnitFileName = function(newVal,callback){
+    let property = projectInfoObj.projectInfo.property;
+    let data = {
+        name:newVal,
+        rootProjectID:property.rootProjectID
+    }
+    CommonAjax.post('/glj/checkUnitFileName', data, function (data) {
+        callback(data);
+    });
+};
+
 ProjectGLJ.prototype.saveAs = function (saveData,callback) {
     $.bootstrapLoading.start();
     CommonAjax.specialPost('/glj/save-as',saveData,function () {

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

@@ -640,7 +640,7 @@ var ration_glj = {
             if (selectCode == gljOprObj.getIndex(oldData, gljKeyArray)) {
                 return callback(null);
             }
-            if (oldData.createType != 'replace') {
+            if (oldData.createType == 'normal') {//只有是定额下带的工料机才需把类型改成替换,其它的保持不变
                 oldData.rcode = oldData.code;
                 oldData.createType = 'replace';
             }
@@ -669,15 +669,16 @@ var ration_glj = {
         };
 
         ration_glj.prototype.mReplaceGLJ = function (selectCode, oldData, callback) {
-            var allGLJ = gljOprObj.AllRecode;
-            var glj = _.find(allGLJ, function (item) {
-                var i_key = gljOprObj.getIndex(item, gljLibKeyArray);
+            let allGLJ = gljOprObj.AllRecode,tasks = [],updateMap={};
+            let oldIndex = gljOprObj.getIndex(oldData, gljKeyArray);
+            let glj = _.find(allGLJ, function (item) {
+                let i_key = gljOprObj.getIndex(item, gljLibKeyArray);
                 return i_key == selectCode;
             });
-            if (selectCode == gljOprObj.getIndex(oldData, gljKeyArray)) {
+            if (selectCode == oldIndex) {
                 return callback(null);
             }
-            var query = {
+            let query = {
                 projectID: oldData.projectID,
                 code: oldData.code,
                 name: oldData.name,
@@ -687,7 +688,7 @@ var ration_glj = {
             if (oldData.specs && oldData.specs != '') {
                 query.specs = oldData.specs;
             }
-            var doc = {
+            let doc = {
                 GLJID: glj.ID,
                 createType: 'replace',
                 rationItemQuantity: 0,
@@ -702,12 +703,7 @@ var ration_glj = {
                 materialType: glj.materialType,   //三材类别
                 materialCoe: glj.materialCoe,
                 projectID: oldData.projectID
-            }
-            if (oldData.createType == 'replace') {
-                doc.rcode = oldData.rcode;
-            } else {
-                doc.rcode = oldData.code;
-            }
+            };
             if (glj.hasOwnProperty("compilationId")) {
                 doc.from = "cpt";
                 if (glj.code.indexOf('-') != -1) {//这条工料机是用户通过修改包称、规格、型号等保存到补充工料机库的
@@ -716,8 +712,32 @@ var ration_glj = {
             } else {
                 doc.from = "std";
             }
+            for(let d of this.datas){//查询出所有需替换的工料机
+                let tem_index = gljOprObj.getIndex(d, gljKeyArray);
+                if(tem_index == oldIndex){
+                    let tem_doc = _.cloneDeep(doc);
+                    if(d.createType == 'replace'){
+                        tem_doc.rcode = d.rcode;
+                    }else if(d.createType == 'add'){//对于添加的类型,替换后还是添加类型
+                        tem_doc.createType = 'add';
+                    }else {
+                        tem_doc.rcode = d.code
+                    }
+                    let task = {
+                        updateOne:{
+                            filter : {ID:d.ID},
+                            update : tem_doc
+                        }
+                    };
+                    tasks.push(task);
+                    updateMap[d.ID] = tem_doc;
+                }
+            }
+
             $.bootstrapLoading.start();
-            CommonAjax.post("/rationGlj/mReplaceGLJ", {query: query, doc: doc}, callback, function () {
+            CommonAjax.post("/rationGlj/mReplaceGLJ", {query: query, doc: doc,tasks:tasks}, function (result) {
+                callback(result,updateMap);
+            }, function () {
                 $.bootstrapLoading.end();
             });
         };

+ 15 - 11
web/building_saas/main/js/views/glj_view.js

@@ -1149,20 +1149,24 @@ var gljOprObj = {
         })
     },
     doMReplaceGLJ: function () {
-        var me = this;
-        var oldData = me.sheetData[gljContextMenu.selectedRow];
-        var project = projectObj.project;
-        var selectCode = me.GLJSelection[0];
+        let me = this;
+        let oldData = me.sheetData[gljContextMenu.selectedRow];
+        let project = projectObj.project;
+        let selectCode = me.GLJSelection[0];
         $("#glj_tree_div").modal('hide');
-        project.ration_glj.mReplaceGLJ(selectCode, oldData, function (result) {
-            var data = result.data;
-            var stateList = result.stateList;
-            var n_index = me.getIndex(data.query, gljKeyArray);
-            var nodes = [];
+        project.ration_glj.mReplaceGLJ(selectCode, oldData, function (result,updateMap) {
+            if(result == null){
+                return;
+            }
+            let data = result.data;
+            let stateList = result.stateList;
+            //let n_index = me.getIndex(data.query, gljKeyArray);
+            let nodes = [];
             _.forEach(project.ration_glj.datas, function (t) {
-                var t_index = me.getIndex(t, gljKeyArray);
-                if (n_index == t_index) {
+           //     let t_index = me.getIndex(t, gljKeyArray);
+                if (updateMap[t.ID]) {
                     me.updateProperty(t, data.doc);
+                    me.updateProperty(t, updateMap[t.ID]);
                     if (project.ration_glj.needShowToTree(t)) {//如果是造价书中的树节点,则也须刷新
                         project.ration_glj.transferToNodeData(t);
                         var node = project.ration_glj.findGLJNodeByID(t.ID);

+ 6 - 1
web/building_saas/main/js/views/installation_fee_view.js

@@ -1247,6 +1247,9 @@ let installationFeeObj={
                 projectObj.project.calcProgram.calcRationsAndSave(rations);
             }
             installationFeeObj.showRationInstallationData(projectObj.project.mainTree.selected);
+            if(callback){
+                callback();
+            }
         });
     },
     initSettingRadio:function () {
@@ -1366,7 +1369,9 @@ $(function () {
         if(canChange==false){
             return;
         }
-        me.calcInstallationFee();
+        me.calcInstallationFee(function () {
+
+        });
     });
     $('#btn_reset_to_default').click(function (){
         let ifModel =  projectObj.project.installation_fee;

+ 2 - 2
web/building_saas/main/js/views/main_tree_col.js

@@ -335,7 +335,7 @@ let MainTreeCol = {
                 case 6:
                     return '0.000000';
                 default:
-                    return '0.00';
+                    return '0';
             }
             ;
         }
@@ -354,7 +354,7 @@ let MainTreeCol = {
                 case 6:
                     return '0.######';
                 default:
-                    return '0.##';
+                    return '0';
             }
             ;
         }

+ 94 - 8
web/building_saas/main/js/views/project_glj_view.js

@@ -40,6 +40,7 @@ projectGljObject={
         header:[
             {headerName: "编码", headerWidth: 120, dataCode: "code", dataType: "String"},
             {headerName: "名称", headerWidth: 120, dataCode: "name", dataType: "String"},
+            {headerName: "规格型号", headerWidth: 120, dataCode: "specs", dataType: "String"},
             {headerName: "单位", headerWidth: 120, dataCode: "unit", hAlign: "center", dataType: "String"},
             {headerName: "类型", headerWidth: 120, dataCode: "short_name", hAlign: "center", dataType: "String"},
             {headerName: "定额价", headerWidth: 120, dataCode: "basePrice", hAlign: "right", dataType: "Number",decimalField:'glj.unitPrice',validator:"number"},
@@ -48,7 +49,7 @@ projectGljObject={
             {headerName: "消耗量", headerWidth: 120, dataCode: "consumption", hAlign: "right", dataType: "Number",decimalField:"glj.quantity",validator:"number"}
         ],
         view: {
-            lockColumns: [0,1,2,3,4,5,6]
+            lockColumns: [0,1,2,3,4,5,6,7]
         }
     },
     materialTreeSetting:{
@@ -293,6 +294,7 @@ projectGljObject={
     showProjectGljData:function () {
         this.projectGljSpread.setActiveSheetIndex(0);
         let sel = this.projectGljSheet.getSelections()[0];
+        let oldData = sel.row<this.projectGljSheetData.length?this.projectGljSheetData[sel.row]:'';
         let projectGljSheetData = [];
         let gljList = projectObj.project.projectGLJ.datas.gljList;
         gljList = this.filterProjectGLJ(gljList);
@@ -304,15 +306,19 @@ projectGljObject={
         this.projectGljSheet.setRowCount(0);
         sheetCommonObj.showData(this.projectGljSheet, this.projectGljSetting,this.projectGljSheetData);
         this.projectGljSheet.setRowCount(this.projectGljSheetData.length);
+        sel.row = _.findIndex(this.projectGljSheetData,{'id':oldData.id});
         this.projectGljSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
     },
     showMaterialTreeData:function () {
         this.projectGljSpread.setActiveSheetIndex(1);
         let sel = this.materialTreeSheet.getSelections()[0];
+        let oldNodeID = this.materialTree.selected.data.id;
         let gljList = projectObj.project.projectGLJ.datas.gljList;
         gljList = _.sortByAll(gljList, [ 'code']);
         this.createMaterialTree(gljList);
         this.materialTreeController.showTreeData();
+        let newNode = this.materialTree.getNodeByID(oldNodeID);
+        sel.row = newNode.serialNo();
         this.materialTreeSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
         this.materialTreeController.setTreeSelected(this.materialTree.items[sel.row==-1?0:sel.row]);
     },
@@ -571,11 +577,14 @@ projectGljObject={
         let parantData = null;
         if(sheet.name() == 'projectGljSheet'){
             me.showProjectGljData();// me.refreshProjectGljRow(row)  这里原来是分开刷新的,现在整个统一刷新,先留着
-            parantData = me.projectGljSheetData[row];
+            //parantData = _.find();  //me.projectGljSheetData[row];
         }else {
             me.showMaterialTreeData();
-            parantData = me.materialTree.items[row].data;
+            //parantData = me.materialTree.items[row].data;
         }
+        let pglj =  _.find(projectObj.project.projectGLJ.datas.gljList,{'id':pid});
+        parantData = pglj?me.getSheetDataByGLJ(pglj):null;
+        //projectObj.project.projectGLJ.datas.gljList
 
         // 更新组成物缓存
         projectObj.project.composition.loadData();
@@ -593,7 +602,7 @@ projectGljObject={
         for(let r of rations){
             let r_node = projectObj.project.mainTree.getNodeByID(r.ID);
             if(r_node){
-                r_node.data.marketUnitFee =  parantData.marketPrice;//parentMarketPrice;//这里用显示的价格
+                r_node.data.marketUnitFee = parantData?parantData.marketPrice:'';//parentMarketPrice;//这里用显示的价格
                 updateNodes.push(r_node);
             }
         }
@@ -767,6 +776,17 @@ projectGljObject={
                         me.deleteMixRatio(row);
                     }
                 },
+                "addMixRatio":{
+                    name: '添加',
+                    icon: 'fa-sign-in',
+                    disabled: function () {
+                        return me.rightClickTarget.row === undefined;
+                    },
+                    callback: function (key, opt) {
+                        let row = me.rightClickTarget.row;
+                        console.log(row);
+                    }
+                }
             }
         });
     },
@@ -795,6 +815,21 @@ projectGljObject={
                   });
               }
         }
+    },
+    checkUnitFileName:function (name,callback) {
+        let projectGLJ = projectObj.project.projectGLJ;
+        projectGLJ.checkUnitFileName(name,function (data) {
+            if(data){
+                $("#save-as-tips").text('已存在同名单价文件').show();
+                $('#save-as-confirm').attr("disabled","disabled");
+            }else {
+                $("#save-as-tips").hide();
+                $('#save-as-confirm').removeAttr("disabled");
+                if(callback){
+                    callback();
+                }
+            }
+        });
     }
 };
 
@@ -879,6 +914,7 @@ $(function () {
                     return false;
                 }
                 let data = response.data;
+                projectGljObject.changeInfo = data;
                 $("#current-project-name").text(data.currentProjectName);
                 // 本项目中的单价文件
                 if (data.self.length > 0) {
@@ -915,14 +951,24 @@ $(function () {
         let type = $("input[name='change-type']:checked").val();
         type = parseInt(type);
         let changeUnitPriceId = 0;
+        $('#change-unitFile').modal("hide");
         if (type === 0) {
             // 从本项目中选择
             changeUnitPriceId = $("#self-file").val();
         } else {
             // 从其他项目中复制
             changeUnitPriceId = $("#other-file").val();
+            let newName = $("#other-file").children("option:selected").text();
+            let currentOption = _.find(projectGljObject.changeInfo.self,{name:newName});
+            if(currentOption){ //存在则说明有重名的文件
+                //rename-unitFile
+                $("#rename-unitFile").modal({show:true});
+                $("#newUnitFileID").val(changeUnitPriceId);
+                $("#newUnitFileName").val(newName);
+                return;
+            }
+
         }
-        $('#change-unitFile').modal("hide");
         let data = {project_id: scUrlUtil.GetQueryString('project'), change_id: changeUnitPriceId, type: type};
         projectObj.project.projectGLJ.changeFile(data,function () {
             projectGljObject.changeFileCallback();
@@ -942,6 +988,7 @@ $(function () {
     $("#unitFile-save-as").on('shown.bs.modal', function () {
         // 获取当前建设项数据
         $("#save-as-name").val(projectGljObject.usedUnitPriceInfo.name + '副本');
+        projectGljObject.checkUnitFileName(projectGljObject.usedUnitPriceInfo.name + '副本');
     });
 
     // 从其他建设项目中复制 选择建设项目
@@ -957,17 +1004,56 @@ $(function () {
         $("#other-file").html(otherFileHtml);
     });
 
+    $('#save-as-name').change(function () {
+        projectGljObject.checkUnitFileName(this.value);
+    });
+
+    $('#newUnitFileName').change(function () {
+        let projectGLJ = projectObj.project.projectGLJ;
+        projectGLJ.checkUnitFileName(this.value,function (data) {
+            if(data){
+                $("#renameError_unitFile").text('已存在同名单价文件').show();
+                $('#renameUnitFileConfirm').attr("disabled","disabled");
+            }else {
+                $("#renameError_unitFile").hide();
+                $('#renameUnitFileConfirm').removeAttr("disabled");
+            }
+        });
+
+    });
+    $("#renameUnitFileConfirm").click(function () {
+        let projectGLJ = projectObj.project.projectGLJ;
+        let newName = $('#newUnitFileName').val();
+        let changeUnitPriceId = $('#newUnitFileID').val();
+        projectGLJ.checkUnitFileName(newName,function (data) {
+            if(data){
+                $("#renameError_unitFile").text('已存在同名单价文件').show();
+                $('#renameUnitFileConfirm').attr("disabled","disabled");
+            }else {
+                $("#renameError_unitFile").hide();
+                $('#renameUnitFileConfirm').removeAttr("disabled");
+                let data = {project_id: scUrlUtil.GetQueryString('project'), change_id: changeUnitPriceId, type: 1,newName:newName};
+                projectObj.project.projectGLJ.changeFile(data,function () {
+                    projectGljObject.changeFileCallback();
+                })
+            }
+        });
+    });
+
     // 单价文件另存为操作
     $("#save-as-confirm").click(function () {
+        let projectGLJ = projectObj.project.projectGLJ;
         let name = $("#save-as-name").val();
         if (name === '') {
             $("#save-as-tips").text('请填写单价文件名称').show();
             return false;
         }
         let saveData = {name: name, project_id: scUrlUtil.GetQueryString('project')};
-        projectObj.project.projectGLJ.saveAs(saveData,function () {
-             projectGljObject.changeFileCallback();
-            $("#unitFile-save-as").modal("hide");
+        projectGljObject.checkUnitFileName(name,function () {
+            projectGLJ.saveAs(saveData,function () {
+                projectGljObject.changeFileCallback();
+                $("#unitFile-save-as").modal("hide");
+            });
         });
     });
 

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

@@ -37,6 +37,7 @@ var projectInfoObj = {
                 basicInfoView.orgDatas = data.property.basicInformation ? basicInfoView.toViewDatas(data.property.basicInformation) : [];
                 projFeatureView.orgDatas = data.property.projectFeature ? projFeatureView.toViewDatas(data.property.projectFeature) : [];
                 $('#fullpath').html(that.getFullPathHtml(that.projectInfo));
+
             }
         });
     }

+ 6 - 6
web/building_saas/main/js/views/project_view.js

@@ -75,11 +75,11 @@ var projectObj = {
             if(node.sourceType !== that.project.Bills.getSourceType()){//焦点行是定额/量价/工料机,灰显。
                 return false;
             }else {
-                if(node.data.type == billType.FX){//是分项,灰显。
+                if(node.data.type == billType.FX || node.data.type == billType.BX){//是分项,或者补项灰显。
                     return false;
                 }
                 if(node.data.type == billType.FB&&node.nextSibling&&node.children.length>0){//焦点行是分部有后兄弟,有子项.
-                     if(node.children[0].data.type==billType.FX){ //焦点行子项是分项
+                     if(node.children[0].data.type==billType.FX || node.children[0].data.type==billType.BX){ //焦点行子项是分项
                          return false;
                      }
                 }
@@ -107,7 +107,7 @@ var projectObj = {
             if(node.sourceType !== that.project.Bills.getSourceType()) {//焦点行是定额/量价/工料机,灰显。
                 return false;
             }else {
-                if(node.data.type == billType.FX){//是分项,灰显。
+                if(node.data.type == billType.FX || node.data.type == billType.BX){//是分项,灰显。
                     return false;
                 }
                 if(!node.preSibling){//无前兄弟,灰显
@@ -116,7 +116,7 @@ var projectObj = {
                     return false
                 }
                 if(node.preSibling.children.length>0){//前兄弟有子项,子项是分项,灰显。
-                    if(node.data.type==billType.FB&&node.preSibling.children[0].data.type==billType.FX){//焦点行是分部前兄弟有子项,子项是分项,灰显。
+                    if(node.data.type==billType.FB&&(node.preSibling.children[0].data.type==billType.FX||node.preSibling.children[0].data.type==billType.BX)){//焦点行是分部前兄弟有子项,子项是分项,灰显。
                         return false;
                     }
                     if(node.data.type==billType.BILL&&node.preSibling.children[0].sourceType !== that.project.Bills.getSourceType()){//焦点行是清单,子项不是清单
@@ -638,9 +638,9 @@ var projectObj = {
                     // 综合单价、综合合价,小数部分应补0对齐。  CSLAAAAA
                     // if (col.data.field.hasSubStr("common")){
                         if (col.data.field.hasSubStr(".totalFee"))
-                            col.data.formatter = MainTreeCol.getNumberFormatter(decimalObj.ration.totalPrice, true)
+                            col.data.formatter = MainTreeCol.getNumberFormatter(decimalObj.ration.totalPrice, true);
                         else if (col.data.field.hasSubStr(".unitFee"))
-                            col.data.formatter = MainTreeCol.getNumberFormatter(decimalObj.ration.unitPrice, true)
+                            col.data.formatter = MainTreeCol.getNumberFormatter(decimalObj.ration.unitPrice, true);
                     // }
 
                 });