Ver código fonte

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

chenshilong 6 anos atrás
pai
commit
cba612bfcb

+ 16 - 0
lib/jquery-contextmenu/jquery.contextMenu.js

@@ -199,6 +199,21 @@
 
                 opt.$menu.css(offset);
             },
+            // 有的电脑会出现主菜单和子菜单距离比较远的情况,这里检查一下。
+            checkSubmenuPosition: function ($menu) {
+                if (!$menu) {
+                    return;
+                }
+                const parentOffsetWidth = $menu.parentElement.offsetWidth;
+                const curLeft = parseFloat(window.getComputedStyle($menu).left) || 0;
+                const maxDiff = 8;
+                const minDiff = 4;
+                const diff = parentOffsetWidth - curLeft;
+                if (diff > maxDiff || diff < minDiff) {
+                    const fixedLeft = parentOffsetWidth - 5;
+                    $menu.style.left = `${fixedLeft}px`;
+                }
+            },
             // position the sub-menu
             positionSubmenu: function ($menu) {
                 if (typeof $menu === 'undefined') {
@@ -224,6 +239,7 @@
                     };
                     $menu.css(offset);
                 }
+                defaults.checkSubmenuPosition($menu[0]);
             },
             // offset to add to zIndex
             zIndex: 1,

+ 1 - 1
modules/all_models/calc_program_model.js

@@ -37,7 +37,7 @@ let stdCalcPrograms = new Schema({
 
 let projectCalcPrograms = new Schema({
     ID: String,
-    projectID: Number,
+    projectID: {type: Number, index: true},
     name: String,
     libID: Number,
     libName: String,

+ 30 - 1
modules/all_models/material_calc.js

@@ -101,4 +101,33 @@ let originalSchema = {
     ration_gljs:[ration_glj]
 };
 
-mongoose.model("original_calc", new Schema(originalSchema, {versionKey: false, collection: "original_calc"}));
+mongoose.model("original_calc", new Schema(originalSchema, {versionKey: false, collection: "original_calc"}));
+
+
+let userfreightSchema = {
+    ID:String,
+    unit_price_file_id: Number,
+    connect_key: String,// 关联项目工料机的key 不能关联id,因为单价文件导入别的项目后项目工料机id不同
+    start:String,//起讫地点
+    conveyance:String,//运输工具
+    unitFreight:String,//单位运价
+    kmDistance:String,//km运距
+    unitLoadingFee:String,//装卸费单价
+    loadingTimes:String,//装卸次数
+    otherFee:String,//其它费用
+    freightIncreaseRate:String,//运价增加率
+    weightCoe:String,//加权系数
+    rations:[ration_schema],
+    ration_gljs:[ration_glj],
+    calcType:String,//计算方式
+    materialType:String//材料类型
+};
+
+let user_freights = {
+    ID:{type:String,index: true},
+    userID:{type:String,index: true},
+    compilationID:{type:String,index: true},
+    rootProjectID:Number,
+    freight:userfreightSchema
+};
+mongoose.model("user_freights", new Schema(user_freights, {versionKey: false, collection: "user_freights"}));

+ 1 - 1
modules/all_models/ration_glj.js

@@ -9,7 +9,7 @@ var ration_glj = new Schema({
     GLJID:Number,
     repositoryId:Number,
     projectID: {type: Number, index: true},
-    rationID:String,
+    rationID:{type: String, index: true},
     projectGLJID:Number,
     name:String,
     code:String,

+ 13 - 67
modules/glj/controllers/glj_controller.js

@@ -404,56 +404,6 @@ class GLJController extends BaseController {
         response.json(result);
     }
 
-    async addOriginalCalc(request, response){
-        let result={error:0};
-        try {
-            let data = JSON.parse(request.body.data);
-            result.data = await glj_facade.addOriginalCalc(data);
-        }catch (err){
-            logger.err(err);
-            result.error=1;
-            result.message = err.message;
-        }
-        response.json(result);
-    }
-
-    async addFreightCalc(request, response){
-        let result={error:0};
-        try {
-            let data = JSON.parse(request.body.data);
-            result.data = await glj_facade.addFreightCalc(data);
-        }catch (err){
-            logger.err(err);
-            result.error=1;
-            result.message = err.message;
-        }
-        response.json(result);
-    }
-
-    async deletePriceCalc(request, response){
-        let result={error:0};
-        try {
-            let data = JSON.parse(request.body.data);
-            result.data = await glj_facade.deletePriceCalc(data);
-        }catch (err){
-            logger.err(err);
-            result.error=1;
-            result.message = err.message;
-        }
-        response.json(result);
-    }
-    async updateOriginalCalc(request, response){
-        let result={error:0};
-        try {
-            let data = JSON.parse(request.body.data);
-            result.data = await glj_facade.updateOriginalCalc(data);
-        }catch (err){
-            logger.err(err);
-            result.error=1;
-            result.message = err.message;
-        }
-        response.json(result);
-    }
     async updateMaterialCalc(request, response){
         let result={error:0};
         try {
@@ -467,20 +417,6 @@ class GLJController extends BaseController {
         response.json(result);
     }
 
-
-    async updateFreightCalc(request, response){
-        let result={error:0};
-        try {
-            let data = JSON.parse(request.body.data);
-            result.data = await glj_facade.updateFreightCalc(data);
-        }catch (err){
-            logger.err(err);
-            result.error=1;
-            result.message = err.message;
-        }
-        response.json(result);
-    }
-
    async updateMaterialCalcTasks(request, response){
        let result={error:0};
        try {
@@ -494,12 +430,11 @@ class GLJController extends BaseController {
        response.json(result);
    }
 
-
-    async deleteFreightCalc(request, response){
+    async updateUserFreight(request, response){
         let result={error:0};
         try {
             let data = JSON.parse(request.body.data);
-            result.data = await glj_facade.deleteFreightCalc(data);
+            result.data = await glj_facade.updateUserFreight(data,request);
         }catch (err){
             logger.err(err);
             result.error=1;
@@ -884,9 +819,20 @@ class GLJController extends BaseController {
             logger.err(err);
         }
         res.json(vvTxtList);
+    }
+
+    async getUserFreights(req,res){
+        let userFreights = [];
+        try {
+            userFreights = await await glj_facade.getUserFreights(req);
+        }catch (err){
+            logger.err(err);
+        }
+        res.json(userFreights);
 
     }
 
+
     async getProjectGLJsByProjectID(projectId){
         return await getGLJListByProjectID(projectId)
     }

+ 20 - 48
modules/glj/facade/glj_facade.js

@@ -6,14 +6,10 @@ module.exports={ //先导出后require可以解决循环引用问题
     changeVvTaxFile:changeVvTaxFile,
     changeAssistProductionFeeRate:changeAssistProductionFeeRate,
     addMixRatioForNew:addMixRatioForNew,
-    addOriginalCalc:addOriginalCalc,
-    deletePriceCalc:deletePriceCalc,
-    updateOriginalCalc:updateOriginalCalc,
-    addFreightCalc:addFreightCalc,
-    deleteFreightCalc:deleteFreightCalc,
-    updateFreightCalc:updateFreightCalc,
     updateMaterialCalc:updateMaterialCalc,
-    updateMaterialCalcTasks:updateMaterialCalcTasks
+    updateMaterialCalcTasks:updateMaterialCalcTasks,
+    updateUserFreight:updateUserFreight,
+    getUserFreights:getUserFreights
 };
 
 const mongoose = require('mongoose');
@@ -27,6 +23,8 @@ let std_glj_lib_gljList_model = mongoose.model('std_glj_lib_gljList');
 let original_calc_model = mongoose.model('original_calc');
 let freight_calc_model = mongoose.model('freight_calc');
 let unit_price_model = mongoose.model('unit_price');
+let user_freights_model = mongoose.model('user_freights');
+
 
 let ration_glj = require('../../ration_glj/facade/ration_glj_facade');
 const uuidV1 = require('uuid/v1');
@@ -191,44 +189,24 @@ async function updateUnitPrice(unitPrice) {//同时支持单个或多个更新
 
 }
 
-async function addOriginalCalc(data) {
-    let datas = data.datas;
-    for(let d of datas){
-        d.ID = uuidV1();
-    }
-    let result = await original_calc_model.create(datas);
-    await updateUnitPrice(data.unitPrice);
-    return result;
-}
-
-
-
-async function addFreightCalc(data){
-    let datas = data.datas;
-    for(let d of datas){
-        d.ID = uuidV1();
+async function updateUserFreight(data,req) {
+    let datas = [];
+    if(data.action == "add"){
+        for(let f of data.freights){
+            f.ID =  uuidV1();
+            f.compilationID = req.session.sessionCompilation._id;
+            f.userID = req.session.sessionUser.id;
+            datas.push(f);
+        }
+        console.log(datas);
+       return await user_freights_model.create(datas);
+    }else if(data.action == "update"){//暂时做成只支持单个更新
+        return await user_freights_model.update({"ID":data.ID},data.doc);
     }
-    let result = await freight_calc_model.create(datas);
-    await updateUnitPrice(data.unitPrice);
-    return result;
 }
 
-async function deletePriceCalc(data){
-    let result = await original_calc_model.deleteOne({ID:data.ID});
-    await updateUnitPrice(data.unitPrice);
-    return result
-}
-
-async function updateOriginalCalc(data){
-    if(data.tasks.length > 0 ) await original_calc_model.bulkWrite(data.tasks);
-    await updateUnitPrice(data.unitPrice);
-    return{};
-}
-
-async function updateFreightCalc(data){
-    if(data.tasks.length > 0 ) await freight_calc_model.bulkWrite(data.tasks);
-    await updateUnitPrice(data.unitPrice);
-    return{};
+async function getUserFreights(req) {
+    return await user_freights_model.find({"userID":req.session.sessionUser.id,"compilationID": req.session.sessionCompilation._id}).lean();
 }
 
 async function updateMaterialCalcTasks(data) {
@@ -280,10 +258,4 @@ async function updateMaterialCalcTasks(data) {
 async function updateMaterialCalc(data) {
     if(data.tasks.length > 0) await unit_price_model.bulkWrite(data.tasks);
     return {}
-}
-
-async function deleteFreightCalc(data){
-    let result = await freight_calc_model.deleteOne({ID:data.ID});
-    await updateUnitPrice(data.unitPrice);
-    return result
 }

+ 2 - 6
modules/glj/routes/glj_router.js

@@ -31,16 +31,12 @@ router.post('/batchUpdateConsumption', gljController.init, gljController.batchUp
 router.post('/modifyKeyValue',gljController.init, gljController.modifyKeyValue);
 router.post('/changeVvTaxFile',gljController.init, gljController.changeVvTaxFile);
 router.post('/changeAssistProductionFeeRate',gljController.init, gljController.changeAssistProductionFeeRate);
-router.post('/addOriginalCalc',gljController.init, gljController.addOriginalCalc);
-router.post('/deletePriceCalc',gljController.init, gljController.deletePriceCalc);
-router.post('/updateOriginalCalc',gljController.init, gljController.updateOriginalCalc);
-router.post('/addFreightCalc',gljController.init, gljController.addFreightCalc);
-router.post('/deleteFreightCalc',gljController.init, gljController.deleteFreightCalc);
-router.post('/updateFreightCalc',gljController.init, gljController.updateFreightCalc);
 router.post('/updateMaterialCalc',gljController.init, gljController.updateMaterialCalc);
 router.post('/updateMaterialCalcTasks',gljController.init, gljController.updateMaterialCalcTasks);
+router.post('/updateUserFreight',gljController.init, gljController.updateUserFreight);
 
 router.get('/getVvTaxList', gljController.init, gljController.getVvTaxList);
+router.get('/getUserFreights', gljController.init, gljController.getUserFreights);
 router.get('/test', gljController.init, gljController.test);
 router.get('/testModify', gljController.init, gljController.testModify);
 router.get('/testDelete', gljController.init, gljController.delete);

+ 52 - 0
modules/users/controllers/cld_controller.js

@@ -161,6 +161,58 @@ class CLDController {
         const compilationList = await compilationModel.getList();
         response.json({error: 0, msg: 'success', data: compilationList});
     }
+
+    /**
+     * 获取个人和已使用编办信息
+     * @param request
+     * @param response
+     * @returns {Promise<void>}
+     */
+    async getUsersInfo(request, response) {
+        let ssoID = request.query.ssoID;
+        try {
+            //获取用户信息
+            if (ssoID === undefined) {
+                throw '传参有误';
+            }
+            let userModel = new UserModel();
+            let userData = await userModel.findDataBySsoId(ssoID);
+            if (userData === null || userData === '') {
+                throw '不存在该建筑用户';
+            }
+            userData = JSON.parse(JSON.stringify(userData));
+
+            userData.company_scale = userData.company_scale === null || userData.company_scale === undefined ? '' : userModel.companyScale[userData.company_scale] + '人';
+            userData.company_type = userData.company_type === null || userData.company_type === undefined ? '' : userModel.companyType[userData.company_type];
+            userData.province = userModel.province[userData.province];
+
+            let date = new Date(userData.create_time);
+            userData.create_time = date.getFullYear() + '年' +
+                (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '月' +
+                (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + '日';
+
+            //获取编办列表
+            let compilationModel = new CompilationModel();
+            let compilationList = JSON.parse(JSON.stringify(await compilationModel.getList()));
+            if (userData.upgrade_list !== undefined) {
+                let userUpgradeList = userData.upgrade_list;
+                for (let i in userUpgradeList) {
+                    let oneCompilationIndex = await compilationList.findIndex(function (item) {
+                        return item._id === userUpgradeList[i].compilationID;
+                    });
+                    if (oneCompilationIndex !== -1) {
+                        // compilationList[oneCompilationIndex].isUpgrade = userUpgradeList[i].isUpgrade;
+                        userData.upgrade_list[i].name = compilationList[oneCompilationIndex].name;
+                        userData.upgrade_list[i].description = compilationList[oneCompilationIndex].description;
+                        userData.upgrade_list[i].categoryID = compilationList[oneCompilationIndex].categoryID;
+                    }
+                }
+            }
+            response.json({error: 0, msg: 'success', data: { userInfo: userData }});
+        } catch (err) {
+            response.json({error: 1, msg: err});
+        }
+    }
 }
 
 export default CLDController;

+ 2 - 0
modules/users/routes/cld_route.js

@@ -24,5 +24,7 @@ module.exports = function (app) {
 
     router.post('/setUserUpgrade', cldController.setUsersUpgrade);
 
+    router.get('/getUsersInfo', cldController.getUsersInfo);
+
     app.use('/cld',router)
 };

+ 2 - 1
public/web/sheet/sheet_common.js

@@ -308,7 +308,7 @@ var sheetCommonObj = {
         sheet.getCell(row, col).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
 
     },
-    setComboBox(row,col,sheet,options,editorValueType){
+    setComboBox(row,col,sheet,options,editorValueType,editable){
         //let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
         let dynamicCombo = sheetCommonObj.getDynamicCombo(true);
         if(options){
@@ -316,6 +316,7 @@ var sheetCommonObj = {
             if(editorValueType==true){
                 dynamicCombo.editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
             }
+            if(editable) dynamicCombo.editable(true);
         }
         sheet.setCellType(row, col,dynamicCombo,GC.Spread.Sheets.SheetArea.viewport);
     },

+ 156 - 133
web/building_saas/fee_rates/fee_rate.html

@@ -1,168 +1,191 @@
 
 
-<div >
-<div class="toolsbar_feeRate px-1 ">
-    <div class="form-inline py-1">
-        <label  class="mx-2" >使用费率文件:<span id="feeRateFileName">费率1</span>(<label class="a_color" id="pop-lv">与<span id="projectCount">3</span> 个单位工程同步</label>)
-            <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>
+    <div class="toolsbar_feeRate px-1 ">
+        <div class="form-inline py-1">
+            <label  class="mx-2" >使用费率文件:<span id="feeRateFileName">费率1</span>(<label class="a_color" id="pop-lv">与<span id="projectCount">3</span> 个单位工程同步</label>)
+                <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>
     </div>
-</div>
-<div class="toolsbar_feeRate px-1">
-    <div class="row" style="margin-left: 0px">
-        <div class="col-lg-8 p-0">
-            <div class="form-inline py-1">
-                <label class="mx-2" >基于&nbsp;&nbsp;<span id="feeRateLibName">重庆渝建发[2016]35号</span></label>
-                <a class="btn btn-sm ml-1" href="#" data-toggle="modal" data-target="#set-lv" id="setNewFeeRate"><i class="fa fa-cog"></i> 重选标准</a>
+    <div class="toolsbar_feeRate px-1">
+        <div class="row" style="margin-left: 0px">
+            <div class="col-lg-8 p-0">
+                <div class="form-inline py-1">
+                    <label class="mx-2" >基于&nbsp;&nbsp;<span id="feeRateLibName">重庆渝建发[2016]35号</span></label>
+                    <a class="btn btn-sm ml-1" href="#" data-toggle="modal" data-target="#set-lv" id="setNewFeeRate"><i class="fa fa-cog"></i> 重选标准</a>
+                </div>
             </div>
+            <!--<div class="col-lg-4 p-0">
+                <div class="form-inline py-1" style="margin-top: 5px"><input type="checkbox" id="cascadeSet" checked >  <label class="mx-2" >统一设置相同参数</label></div>
+            </div>-->
         </div>
-        <!--<div class="col-lg-4 p-0">
-            <div class="form-inline py-1" style="margin-top: 5px"><input type="checkbox" id="cascadeSet" checked >  <label class="mx-2" >统一设置相同参数</label></div>
-        </div>-->
     </div>
-</div>
-<div class="container-fluid">
-    <div class="row ">
-        <div class="col-lg-8 p-0 ">
-            <div class="grid main-data-full-feeRate" id="divFee"></div>
-        </div>
-        <div class="col-lg-4 p-0">
-            <div class="grid main-data-full-feeRate" id="subRate"></div>
+    <div class="container-fluid">
+        <div class="row ">
+            <div class="col-lg-8 p-0 ">
+                <div class="grid main-data-full-feeRate" id="divFee"></div>
+            </div>
+            <div class="col-lg-4 p-0">
+                <div class="grid main-data-full-feeRate" id="subRate"></div>
+            </div>
         </div>
     </div>
-</div>
-<!--弹出更换-->
-<div class="modal fade" id="change-lv" 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 class="modal fade" id="change-lv" 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 class="custom-control custom-radio">
+                            <input id="radio1" name="chaneg-lv-Radio" type="radio" value="0" onclick="changeFRadioClick()" class="" checked>
+                            <span class="custom-control-indicator"></span>
+                            <span class="custom-control-description">从本建设项目中选择</span>
+                        </label>
+                        <label class="custom-control custom-radio">
+                            <input id="radio2" name="chaneg-lv-Radio" type="radio" value="1" onclick="changeFRadioClick()" class="">
+                            <span class="custom-control-indicator"></span>
+                            <span class="custom-control-description">从其他建设项目中复制</span>
+                        </label>
+                    </div>
+                    <!--从本建设项目中选择-->
+                    <div class="form-group" id="fromProject">
+                        <label id="currentProject"></label>
+                        <select class="form-control" id="currentOptions"></select>
+                    </div>
+                    <!--从其他建设项目中复制-->
+                    <div id="fromOther" >
+                        <div class="form-group">
+                            <label>选择建设项目</label>
+                            <select class="form-control" id="otherProject"></select>
+                        </div>
+                        <div class="form-group">
+                            <select class="form-control" id="otherFeeRateOption"></select>
+                            <small class="form-text text-muted">你选择的费率文件将复制一份至新项目,不会影响原建设项目的费率文件。</small>
+                        </div>
+                    </div>
+
+                </div>
+                <div class="modal-footer">
+                    <button type="button"  class="btn btn-primary" data-dismiss="modal" id="changeFeeRateConfirm">确定</button>
+                    <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                </div>
             </div>
-            <div class="modal-body">
-                <div class="form-group">
-                    <label class="custom-control custom-radio">
-                        <input id="radio1" name="chaneg-lv-Radio" type="radio" value="0" onclick="changeFRadioClick()" class="" checked>
-                        <span class="custom-control-indicator"></span>
-                        <span class="custom-control-description">从本建设项目中选择</span>
-                    </label>
-                    <label class="custom-control custom-radio">
-                        <input id="radio2" name="chaneg-lv-Radio" type="radio" value="1" onclick="changeFRadioClick()" class="">
-                        <span class="custom-control-indicator"></span>
-                        <span class="custom-control-description">从其他建设项目中复制</span>
-                    </label>
-                </div>
-                <!--从本建设项目中选择-->
-                <div class="form-group" id="fromProject">
-                    <label id="currentProject"></label>
-                    <select class="form-control" id="currentOptions"></select>
-                </div>
-                <!--从其他建设项目中复制-->
-                <div id="fromOther" >
+        </div>
+    </div>
+    <!--弹出设置-->
+    <div class="modal fade" id="set-lv" data-backdrop="static">
+        <div class="modal-dialog" role="document">
+            <div class="modal-content">
+                <div class="modal-header">
+                    <h5 class="modal-title"><span id="set-lv-feeRateName" style="display: none">费率1 &nbsp;</span>重选标准</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>
-                        <select class="form-control" id="otherProject"></select>
+                        <label >费率标准</label>
+                        <select class="form-control" id="standardSelect"></select>
+                        <small class="form-text text-danger">重新选择费率标准将重置当前费率文件的所有费率,正在使用当前费率文件的其他单位工程也将受影响。</small>
                     </div>
                     <div class="form-group">
-                        <select class="form-control" id="otherFeeRateOption"></select>
-                        <small class="form-text text-muted">你选择的费率文件将复制一份至新项目,不会影响原建设项目的费率文件。</small>
+                        <label>正在使用当前费率文件的单位工程有:</label>
+                        <ul class="list-unstyled" id="usageProjectList">
+
+                        </ul>
                     </div>
                 </div>
-
-            </div>
-            <div class="modal-footer">
-                <button type="button"  class="btn btn-primary" data-dismiss="modal" id="changeFeeRateConfirm">确定</button>
-                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                <div class="modal-footer">
+                    <button type="button" class="btn btn-primary" id="changeConfirm" data-dismiss="modal">确定</button>
+                    <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                </div>
             </div>
         </div>
     </div>
-</div>
-<!--弹出设置-->
-<div class="modal fade" id="set-lv" data-backdrop="static">
-    <div class="modal-dialog" role="document">
-        <div class="modal-content">
-            <div class="modal-header">
-                <h5 class="modal-title"><span id="set-lv-feeRateName" style="display: none">费率1 &nbsp;</span>重选标准</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>
-                    <select class="form-control" id="standardSelect"></select>
-                    <small class="form-text text-danger">重新选择费率标准将重置当前费率文件的所有费率,正在使用当前费率文件的其他单位工程也将受影响。</small>
-                </div>
-                <div class="form-group">
-                    <label>正在使用当前费率文件的单位工程有:</label>
-                    <ul class="list-unstyled" id="usageProjectList">
 
-                    </ul>
+    <!--弹出 另存新文件-->
+    <div class="modal fade" id="copy-lv" 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 id="valid_name" type="hidden">
+                        <input class="form-control" id="copyFeeRateName" value="">
+                        <!--默认为复制费率文件名字+副本 2字,用户修改后需判断是否在同项目下存在同名-->
+                        <small class="form-text text-danger" id="nameError" style="display: none">已存在同名费率文件。</small>
+                    </div>
+                </div>
+                <div class="modal-footer">
+                    <button type="button" class="btn btn-primary" id="saveAsConfirm">确定</button>
+                    <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                 </div>
-            </div>
-            <div class="modal-footer">
-                <button type="button" class="btn btn-primary" id="changeConfirm" data-dismiss="modal">确定</button>
-                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
             </div>
         </div>
     </div>
-</div>
 
-<!--弹出 另存新文件-->
-<div class="modal fade" id="copy-lv" 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 id="valid_name" type="hidden">
-                    <input class="form-control" id="copyFeeRateName" value="">
-                    <!--默认为复制费率文件名字+副本 2字,用户修改后需判断是否在同项目下存在同名-->
-                    <small class="form-text text-danger" id="nameError" style="display: none">已存在同名费率文件。</small>
+    <!--弹出 重命名窗口-->
+    <div class="modal fade" id="rename-lv" 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="newFeeRateID" value="" style="display: none">
+                        <input class="form-control" id="newFeeRateName" value="">
+                        <small class="form-text text-danger" id="renameError">本建设项目中已存在同名费率文件。</small>
+                    </div>
+                </div>
+                <div class="modal-footer">
+                    <button type="button" class="btn btn-primary" id="renameConfirm">确定</button>
+                    <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                 </div>
-            </div>
-            <div class="modal-footer">
-                <button type="button" class="btn btn-primary" id="saveAsConfirm">确定</button>
-                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
             </div>
         </div>
     </div>
-</div>
 
-<!--弹出 重命名窗口-->
-<div class="modal fade" id="rename-lv" 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="newFeeRateID" value="" style="display: none">
-                    <input class="form-control" id="newFeeRateName" value="">
-                    <small class="form-text text-danger" id="renameError">本建设项目中已存在同名费率文件。</small>
+    <!--弹出 乘系数窗口-->
+    <div class="modal fade" id="widthCoeDiv" 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="width_coe_value" value="">
+                    </div>
+                </div>
+                <div class="modal-footer">
+                    <button type="button" class="btn btn-primary" id="widthCoeDivConfirm">确定</button>
+                    <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                 </div>
-            </div>
-            <div class="modal-footer">
-                <button type="button" class="btn btn-primary" id="renameConfirm">确定</button>
-                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
             </div>
         </div>
     </div>
-</div>
-
 
 </div>
 

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

@@ -77,7 +77,7 @@
                                                 <div class="ovf-hidden half-h" id="freight_ration" style="display: none">
                                                     <div class="ovf-hidden full-h" id="freight_ration_sheet"></div>  <!---->
                                                     <div class="left full-h" id="freight_ration_ass" style="display: none">
-                                                        <label class="mx-2" for="freight_ass_value" style="margin-top: 10px">运距m</label><br>
+                                                        <label class="mx-2" id="freight_ass_label" for="freight_ass_value" style="margin-top: 10px">运距m</label><br>
                                                         <input type="text" class="form-control form-control-sm ration_ass_value" id="freight_ass_value">
                                                     </div>
                                                 </div>
@@ -89,7 +89,7 @@
                                                 <div class="ovf-hidden half-h" id="price_ration" >
                                                     <div class="ovf-hidden full-h" id="price_ration_sheet" ></div>
                                                     <div class="left full-h" id="price_ration_ass" style="display: none">
-                                                        <label class="mx-2" for="price_ass_value" style="margin-top: 10px">运距m</label><br>
+                                                        <label class="mx-2" id="price_ass_label" for="price_ass_value" style="margin-top: 10px">运距m</label><br>
                                                         <input type="text" class="form-control form-control-sm ration_ass_value" id="price_ass_value">
                                                     </div>
                                                 </div>

+ 43 - 14
web/building_saas/main/js/models/project_glj.js

@@ -496,12 +496,12 @@ ProjectGLJ.prototype.freightCalc= function (glj,grossWeightCoe_n,dataMap,tfreigh
         kmDistance = scMathUtil.roundForObj(kmDistance,unitPirce);
 
         let t = getPrice(unitFreight,kmDistance,conveyance,calcType,materialType,process);//单位运价×km运距
-        console.log(t);
         t = scMathUtil.roundForObj(t*freightIncreaseRate,process);//单位运价×km运距×(1+运距增加率%)
         unitLoadingFee = scMathUtil.roundForObj(unitLoadingFee,unitPirce);
         loadingTimes = scMathUtil.roundForObj(loadingTimes,unitPirce);
         let s = scMathUtil.roundForObj(unitLoadingFee*loadingTimes,process);//装卸费单价×装卸次数
         t = scMathUtil.roundForObj(t + s,process);//单位运价×km运距×(1+运距增加率%)+装卸费单价×装卸次数
+        if(calcType == "内蒙古") t = scMathUtil.roundForObj(t/1.09,process);  //内蒙古要除以税率1.09;
         otherFee = scMathUtil.roundForObj(otherFee,unitPirce);
         t = scMathUtil.roundForObj(t+otherFee,process);//单位运价×km运距×(1+运距增加率%)+装卸费单价×装卸次数+其它费用
         t = scMathUtil.roundForObj(t*grossWeightCoe_n,process); //(单位运价×km运距×(1+运距增加率%)+装卸费单价×装卸次数+其它费用)×单位毛重”。 单位毛重:毛重系数
@@ -517,9 +517,9 @@ ProjectGLJ.prototype.freightCalc= function (glj,grossWeightCoe_n,dataMap,tfreigh
 
 
     function getPrice(unitFreight,kmDistance,conveyance,calcType,materialType,process){
+        if(calcType =="内蒙古") return materialCalcObj.calNeiMengTotalFreight(kmDistance,materialType);
         //如果运输方式为自办运输,则直接返回单位运价即可;
-        let price = conveyance == "自办运输"|| calcType =="内蒙古"? scMathUtil.roundForObj(unitFreight,process):scMathUtil.roundForObj(unitFreight * kmDistance,process);//单位运价×km运距
-
+        let price = conveyance == "自办运输" ? scMathUtil.roundForObj(unitFreight,process):scMathUtil.roundForObj(unitFreight * kmDistance,process);//单位运价×km运距
         return price
     }
 
@@ -598,7 +598,6 @@ ProjectGLJ.prototype.m_updateUnitPrice = function (datas) {//批量更新
         }
         return glj;
     }
-
 };
 
 ProjectGLJ.prototype.updateUnitPrice = function(id,unitPrice){
@@ -640,10 +639,8 @@ ProjectGLJ.prototype.updateFreightCalc = async function (datas,pgljID){
     await this.updateMaterialCalcTasks(pgljID,updateMap,"update","freight");
 };
 
-
 ProjectGLJ.prototype.updateMaterialCalcTasks =async function(pgljID,dataMap,actionType,model){
-    //为了统一接口, 参数dataMap 在添加操作时是一个数组,在修改的时候是一个ID - doc 映射表,在删除的时候传入的是一个ID
-
+    //为了统一接口, 参数dataMap 在添加操作时是一个数组,在修改的时候是一个ID - doc 映射表;
     try {
         let actionMap={};
         let calMap = {};
@@ -660,12 +657,8 @@ ProjectGLJ.prototype.updateMaterialCalcTasks =async function(pgljID,dataMap,acti
             } else {
                 sumMap[model] = actionMap;
             }
-        }else if(actionType == "delete"){
-            let IDMap = {};
-            IDMap[dataMap] = true;
-            sumMap[model] = {"delete":IDMap};
         }else {
-            sumMap[model] = actionMap
+            sumMap[model] = actionMap;
         }
         sumMap["unitPrice"] = unitPrices;
 
@@ -678,9 +671,41 @@ ProjectGLJ.prototype.updateMaterialCalcTasks =async function(pgljID,dataMap,acti
     }finally {
         $.bootstrapLoading.end();
     }
+};
 
+ProjectGLJ.prototype.updateUserFreight =async function (data) {
+    try {
+        $.bootstrapLoading.start();
+        let result = await ajaxPost('/glj/updateUserFreight',data);
+        if(data.action == "add"){
+            for(let f of data.freights){
+                materialCalcObj.userFreightList.push(f);
+            }
+        }
+        if(data.action == "update"){
+            for(let u of materialCalcObj.userFreightList){
+                if(u.ID == data.ID){
+                    gljUtil.updateProperty(u,data.doc);
+                }
+            }
+        }
+        materialCalcObj.showFreightDatas();
+    }catch (e){
+        console.log(e)
+    }finally {
+        $.bootstrapLoading.end();
+    }
 };
 
+ProjectGLJ.prototype.getUserFreights = async function () {//初始化车船税选择
+    try {
+        let result =  await ajaxGet("/glj/getUserFreights");
+        console.log(result);
+        return result;
+    }catch (e){
+        console.log(e)
+    }
+};
 
 
 ProjectGLJ.prototype.refreshMaterialCalcCache = function (updateMap){
@@ -928,7 +953,7 @@ ProjectGLJ.prototype.calcMaterialAssQuantity = function (parent,ration,newAssLis
     }
 
     function calculateTimes(ass){
-        if(ass.name != "运距m") return 0;//只计算运距;
+        if(ass.name.indexOf("运距") == -1) return 0;//只计算运距;
         let times =(ass.actualValue-ass.stdValue)/ass.stepValue;
         let r = false;
         if(times<0){
@@ -964,11 +989,15 @@ ProjectGLJ.prototype.calcMaterialRation = function(ID,type){//计算带定额的
 };
 
 ProjectGLJ.prototype.deletePriceCalc = async function (ID,pgljID) {
+    let map = {};
+    map[ID] = true;
     await this.updateMaterialCalcTasks(pgljID,ID,"delete","price");
 };
 
 ProjectGLJ.prototype.deleteFreightCalc = async function (ID,pgljID) {
-    await this.updateMaterialCalcTasks(pgljID,ID,"delete","freight");
+    let map = {};
+    map[ID] = true;
+    await this.updateMaterialCalcTasks(pgljID,map,"delete","freight");
 };
 
 ProjectGLJ.prototype.updatePrice = function (recode, updateField, newval,from,cb) {

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

@@ -492,9 +492,9 @@ let ration_glj = {
                     }
                 }
                 projectObj.project.projectGLJ.loadData(function () {//等项目工料机加载完成后再给用户编辑
-                    gljOprObj.refreshView();
                     me.refreshTreeNodeIfNeeded(recode);//刷新造价书上的树节点(如果需要)
                     me.reCalcWhenGLJChange(recode);//触发计算定额以及父节点
+                    gljOprObj.refreshView();
                     $.bootstrapLoading.end();
                     installationFeeObj.calcInstallationFee();
                 });

+ 3 - 2
web/building_saas/main/js/views/fee_rate_view.js

@@ -555,7 +555,7 @@ var feeRateObject={
             subRateObject.initSubRateSpread(me.mainFeeRateData[row]);
         }
     },
-    setRateFromSub:function (subRate,value,subList,editText) {//editText  下拉框选择的值,对于如“19.00”这样下拉选择项,value会变成19,所以在valueMap里找的时候要用editText去查找
+    setRateFromSub:function (subRate,value,subList,editText,feeRateCoe) {//editText  下拉框选择的值,对于如“19.00”这样下拉选择项,value会变成19,所以在valueMap里找的时候要用editText去查找
          let me = feeRateObject,feeRate =  projectObj.project.FeeRate;
          let rates = feeRate.getActivateFeeRate().rates;
          let updateDatas = [];
@@ -609,7 +609,7 @@ var feeRateObject={
                             }
                          }
                          if(gljUtil.isDef(ltRate)&&gljUtil.isDef(gtRate)){//已经找到前后的值了
-                             let step = scMathUtil.roundForObj(gtRate.value - ltRate.value,getDecimal("process"))
+                             let step = scMathUtil.roundForObj(gtRate.value - ltRate.value,getDecimal("process"));
                              let total =  parseFloat(gtRate.ID) - parseFloat(ltRate.ID)
                              doc.rate =getRateByStep(ltRate.value,total,parseFloat(value) - parseFloat(ltRate.ID),step);
                          }else if(gljUtil.isDef(ltRate)&&gtRate == null){//说明是超出了选项的最大值
@@ -621,6 +621,7 @@ var feeRateObject={
                          }
                      }
                      if(isDef(doc.rate)){
+                         if(feeRateCoe) doc.rate = scMathUtil.roundForObj(doc.rate * feeRateCoe,getDecimal("feeRate"));    //如果是从乘系数过来的,乘以系数。
                          updateDatas.push({rateID:r.ID,doc:doc});
                          me.sumParentRate(r.ID,doc.rate,updateDatas);
                      }

+ 192 - 32
web/building_saas/main/js/views/material_calc_view.js

@@ -32,6 +32,7 @@ materialCalcObj = {
     freightSheet:null,
     freightDatas:[],
     conveyanceOptions:["自办运输","汽车","火车","船舶","马车","手推车","拖拉机"],
+    userFreightList:[],
     freightSetting:{
         header:[
             {headerName: "起讫地点", headerWidth: 80, dataCode: "start", dataType: "String"},
@@ -44,8 +45,8 @@ materialCalcObj = {
             {headerName: "运价增\n加率(%)", headerWidth: 60, dataCode: "freightIncreaseRate", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"
             {headerName: "加权\n系数", headerWidth: 60, dataCode: "weightCoe", hAlign: "right", dataType: "Number",validator:"number"},
             {headerName: "计算式", headerWidth: 170, dataCode: "exp", hAlign: "left", dataType: "Number",getText:'forExp'},//,decimalField:"glj.unitPrice"
-            {headerName: "计算方式", headerWidth: 80, dataCode: "calcType", dataType: "String",cellType:"comboBox",options:["全国","内蒙古"]},
-            {headerName: "材料类型", headerWidth: 80, dataCode: "materialType", dataType: "String",cellType:"comboBox",options:["地方材料","外购材料","沥青、燃料等"]}
+            {headerName: "计算方式", headerWidth: 80, dataCode: "calcType",visible: false, dataType: "String",cellType:"comboBox",options:["全国","内蒙古"]},
+            {headerName: "材料类型", headerWidth: 80, dataCode: "materialType", visible: false,dataType: "String",cellType:"comboBox",options:["","地方材料","外购材料","沥青、燃料等"]}
         ],
         view: {
             lockColumns: ["exp"],
@@ -54,8 +55,12 @@ materialCalcObj = {
         getText:{
             forExp:function (item) {
                 let material = materialCalcObj.getMaterialSelected();
+                if(gljUtil.isDef(item.materialType)&&item.materialType != ""){
+                  let uString = materialCalcObj.getNeiMengUnitFreightString(item.kmDistance,item.materialType);
+                  return `((${uString}x(1+${item.freightIncreaseRate}%)+${item.unitLoadingFee}x${item.loadingTimes})/1.09+${item.otherFee})x${material.grossWeightCoe_n}x${item.weightCoe}`;
+                }
                 //(单位运价×(1+运距增加率%)+装卸费单价×装卸次数+其它费用)×单位毛重×加权系数
-                if(item.conveyance == "自办运输" || item.calcType == "内蒙古") return `(${item.unitFreight}x(1+${item.freightIncreaseRate}%)+${item.unitLoadingFee}x${item.loadingTimes}+${item.otherFee})x${material.grossWeightCoe_n}x${item.weightCoe}`;
+                if(item.conveyance == "自办运输") return `(${item.unitFreight}x(1+${item.freightIncreaseRate}%)+${item.unitLoadingFee}x${item.loadingTimes}+${item.otherFee})x${material.grossWeightCoe_n}x${item.weightCoe}`;
 
                 //(单位运价×km运距×(1+运距增加率%)+装卸费单价×装卸次数+其它费用)×单位毛重×加权系数
                 return `(${item.unitFreight}x${item.kmDistance}x(1+${item.freightIncreaseRate}%)+${item.unitLoadingFee}x${item.loadingTimes}+${item.otherFee})x${material.grossWeightCoe_n}x${item.weightCoe}`;
@@ -111,7 +116,7 @@ materialCalcObj = {
             this.initRightClick("materialCalcSheet",this.materialSpread)
         }
     },
-    initFreightSpread:function(){
+    initFreightSpread:async function(){
         this.freightSpread = SheetDataHelper.createNewSpread($("#freightSheet")[0]);
         sheetCommonObj.spreadDefaultStyle(this.freightSpread);
         this.freightSheet = this.freightSpread.getSheet(0);
@@ -125,6 +130,7 @@ materialCalcObj = {
         }else {
             this.initRightClick("freightSheet",this.freightSpread)
         }
+        this.userFreightList = await projectObj.project.projectGLJ.getUserFreights();
     },
     initFreightRationSpread:function () {
         this.freightRationSpread = SheetDataHelper.createNewSpread($("#freight_ration_sheet")[0]);
@@ -157,7 +163,7 @@ materialCalcObj = {
             this.initRightClick("price_ration_sheet",this.priceRationSpread);
         }
     },
-    initPriceSpread:function(){
+    initPriceSpread:async function(){
         this.priceSpread = SheetDataHelper.createNewSpread($("#priceSheet")[0]);
         sheetCommonObj.spreadDefaultStyle(this.priceSpread);
         this.priceSheet = this.priceSpread.getSheet(0);
@@ -182,10 +188,20 @@ materialCalcObj = {
         this.freightSheet.setRowCount(this.freightDatas+20);
         let convCol = _.findIndex(this.freightSetting.header,{'dataCode':'conveyance'});
         sheetCommonObj.setComboBox(-1,convCol,this.freightSheet,this.conveyanceOptions,false);
+        let startCol = _.findIndex(this.freightSetting.header,{'dataCode':'start'});
+        let startOptions = this.getUserFreightOptions();
+        sheetCommonObj.setComboBox(-1,startCol,this.freightSheet,startOptions,false,true);
         sel.row =  oldData?_.findIndex(this.freightDatas,{'ID':oldData.ID}):sel.row ;
         this.freightSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
         this.refreshRationView();
     },
+    getUserFreightOptions :function () {
+        let options = [];
+        for(let uf of this.userFreightList){
+            options.push(uf.freight.start);
+        }
+        return options;
+    },
     showFreightRationDatas:function (freight) {
         let sel = this.freightRationSheet.getSelections()[0];
         let oldData = sel.row<this.freightRations.length?this.freightRations[sel.row]:"";
@@ -231,10 +247,10 @@ materialCalcObj = {
         this.priceSheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
         this.showPriceRationDatas();
     },
-    showDatas:function(){
+    showDatas:async function(){
         if(!$('#materialCalcSheet').is(':visible')) return;
         if(!this.materialSpread) this.initMaterialSpread();
-        if(!this.freightSpread) this.initFreightSpread();
+        if(!this.freightSpread)await this.initFreightSpread();
         if(!this.priceSpread) this.initPriceSpread();
         if(!this.freightRationSpread) this.initFreightRationSpread();
         if(!this.priceRationSpread) this.initPriceRationSpread();
@@ -319,6 +335,12 @@ materialCalcObj = {
         let me = materialCalcObj;
         if(!me.getMaterialSelected()){
             args.cancel = true;
+        }else {
+            let price = me.priceDatas[args.row];
+            let dataCode = me.priceSetting.header[args.col].dataCode;
+            if(dataCode == "supplyPrice"){
+                if(price.rations && price.rations.length > 0) args.cancel = true;
+            }
         }
     },
     onFreightEditStarting:function(sender,args){
@@ -328,10 +350,10 @@ materialCalcObj = {
         }else {
             let freigth = me.freightDatas[args.row];
             let dataCode = me.freightSetting.header[args.col].dataCode;
-            if(dataCode == "calcType" || dataCode=="materialType"){
+            if(dataCode=="materialType"){
                 if(!freigth){
                     args.cancel = true;
-                }else if(dataCode == "materialType" && freigth.calcType !="内蒙古"){//不是内蒙古的情况下,下拉框不可编辑
+                }else if(freigth.conveyance !="汽车"){//只有在汽车的情况下,材料类型列才能编辑
                     args.cancel = true;
                 }
             }
@@ -341,7 +363,7 @@ materialCalcObj = {
                 }
                 if(dataCode == "unitFreight"){
                     if(freigth.rations && freigth.rations.length > 0) args.cancel = true;
-                    if(freigth.calcType == "内蒙古") args.cancel = true;
+                    if(gljUtil.isDef(freigth.materialType) && freigth.materialType != "") args.cancel = true;//当材料类型有值时,说明是内蒙古计算,运费是能过运距算出来的,不能编辑
                 }
             }
         }
@@ -408,10 +430,41 @@ materialCalcObj = {
              freightIncreaseRate:'0',//运价增加率
              weightCoe:'1',//加权系数
              connect_key:gljUtil.getIndex(material),
+             materialType:"",
              unit_price_file_id:material.unit_price.unit_price_file_id
-         }
+         };
         return newData;
     },
+    getSavedFreight:function (start,material) {
+        let t = null;
+        for(let f of this.userFreightList){
+            if(f.freight.start == start){
+                t = newDatas(f.freight,material);
+                break;
+            }
+        }
+        return t;
+        function newDatas(freight,material) {
+            let doc = {};
+            for(let key in freight){
+                doc[key] = freight[key];
+                if(key == "ID") doc[key] = uuid.v1();
+                if(key == "connect_key") doc[key] = gljUtil.getIndex(material);
+                if(key == "unit_price_file_id") doc[key] = material.unit_price.unit_price_file_id;
+            }
+            return doc;
+        }
+    },
+    checkSavedFreight:function (start) {
+        let t = null;
+        for(let f of this.userFreightList){
+            if(f.freight.start == start){
+                t = f;
+                break;
+            }
+        }
+        return t;
+    },
     onFreightValueChange:function (sender,args) {
         let me = materialCalcObj;
         let dataCode = me.freightSetting.header[args.col].dataCode;
@@ -426,10 +479,17 @@ materialCalcObj = {
             value = value?scMathUtil.roundForObj(value,getDecimal("glj.unitPrice"))+'':'0'//4舍五入加默认为0
         }
         if(args.row >= me.freightDatas.length){//新增
-            let newData = me.getNewFreightData(material);
-            newData[dataCode] = value;
-            newData.calcType = me.getDefualtCalcType();
-            if(newData.calcType == "内蒙古") newData.materialType = "地方材料";
+            let newData = {};
+            let tempFreight = null;
+            if(dataCode == "start"){
+                tempFreight = me.getSavedFreight(value,material);
+            }
+            if(tempFreight){
+                newData = tempFreight;
+            }else {
+                newData = me.getNewFreightData(material);
+                newData[dataCode] = value;
+            }
             projectObj.project.projectGLJ.addFreightCalc([newData],material.id);
         }else {//修改
             let recode = me.freightDatas[args.row];
@@ -447,42 +507,78 @@ materialCalcObj = {
                     doc["loadingTimes"] = '0';
                     doc["freightIncreaseRate"] = '0';
                 }
+                if(args.oldValue =="汽车") doc["materialType"] = "";//当运输方式从汽车切换成其它方式时,清空材料类型
+
             }
-            if(dataCode == "calcType"){
+          /*  if(dataCode == "calcType"){
                 if(value == "全国") doc["materialType"] = "";
                 if(value == "内蒙古"){
                     doc["materialType"] = "地方材料";
                     doc["unitFreight"] = me.calcNeiMengUnitFreight(recode.kmDistance,"地方材料");
                 }
-            }
-            if(recode.calcType == "内蒙古"){
-                if(dataCode == "materialType") doc["unitFreight"] = me.calcNeiMengUnitFreight(recode.kmDistance,value);
-                if(dataCode == "kmDistance") doc["unitFreight"] = me.calcNeiMengUnitFreight(value,recode.materialType);
+            }*/
+
+            if(dataCode == "materialType" && value!="") doc["unitFreight"] = me.calcNeiMengUnitFreight(recode.kmDistance,value);
+            if(dataCode == "kmDistance" && gljUtil.isDef(recode.materialType)&&recode.materialType!="") doc["unitFreight"] = me.calcNeiMengUnitFreight(value,recode.materialType);
+
+            if(dataCode == "start"){
+               let t_f = me.getSavedFreight(value,material);
+               if(t_f) doc = t_f;
+
             }
             projectObj.project.projectGLJ.updateFreightCalc([{ID:recode.ID,doc:doc}],material.id);
         }
     },
-    calcNeiMengUnitFreight:function (kmDistance,materialType) {
-        if(!kmDistance||kmDistance == '0') return "0";
+    calcNeiMengUnitFreight:function (tkmDistance,tmaterialType) {
+        if(!tkmDistance||tkmDistance == '0') return "0";
+        let decimal = getDecimal("glj.unitPrice");
+        tkmDistance =  scMathUtil.roundForObj(tkmDistance,decimal);
+        return scMathUtil.roundForObj(this.calNeiMengTotalFreight(tkmDistance,tmaterialType)/tkmDistance,decimal);
+    },
+    calNeiMengTotalFreight:function (kmDistance,materialType) {
+        if(!kmDistance||kmDistance == '0') return 0;
         let decimal = getDecimal("glj.unitPrice");
         let baseMap = {"地方材料":6,"外购材料":13,"沥青、燃料等":19};//"地方材料","外购材料","沥青、燃料等"
         let baseFreight = baseMap[materialType];
         kmDistance =  scMathUtil.roundForObj(kmDistance,decimal);
         //用截取的方式,一段段取值
         let less = kmDistance - 5;//kmDistance <= 5 这段
-        if(less <= 0) return baseFreight+"" ;  //kmDistance <= 5 的时候直接取baseFreight
+        if(less <= 0) return baseFreight ;  //kmDistance <= 5 的时候直接取baseFreight
 
-         //5< kmDistance <= 15  每增运1km 则增加0.6
+        //5< kmDistance <= 15  每增运1km 则增加0.6
         less = less - 10;
-        if(less <=0)  return scMathUtil.roundForObj(baseFreight + scMathUtil.roundForObj((less + 10) * 0.6,6),decimal)+"";//baseFreight + (less + 10) * 0.6;
+        if(less <=0)  return scMathUtil.roundForObj(baseFreight + scMathUtil.roundForObj((less + 10) * 0.6,6),decimal);//baseFreight + (less + 10) * 0.6;
         baseFreight = baseFreight + 10 * 0.6; //累加5到15这一段的运费;
 
-         //15< kmDistance <= 100  每增运1km 则增加0.45
+        //15< kmDistance <= 100  每增运1km 则增加0.45
         less = less - 85;
-        if(less <=0) return scMathUtil.roundForObj(baseFreight + scMathUtil.roundForObj((less + 85)*0.45,6),decimal)+"";//baseFreight + (less + 85)*0.45;
+        if(less <=0) return scMathUtil.roundForObj(baseFreight + scMathUtil.roundForObj((less + 85)*0.45,6),decimal);//baseFreight + (less + 85)*0.45;
         baseFreight = scMathUtil.roundForObj(baseFreight + scMathUtil.roundForObj(85*0.45,6),6) ;  //累加15到100这一段的运费;
-        return scMathUtil.roundForObj(baseFreight + scMathUtil.roundForObj(less * 0.35,6),decimal)+""; // >100 的所有部分每增运1km 则增加0.35  baseFreight + less * 0.35
+        return scMathUtil.roundForObj(baseFreight + scMathUtil.roundForObj(less * 0.35,6),decimal); // >100 的所有部分每增运1km 则增加0.35  baseFreight + less * 0.35
+    },
+
+    getNeiMengUnitFreightString:function (kmDistance,materialType) {
+        if(!kmDistance||kmDistance == '0') return "0";
+        let decimal = getDecimal("glj.unitPrice");
+        let baseMap = {"地方材料":6,"外购材料":13,"沥青、燃料等":19};//"地方材料","外购材料","沥青、燃料等"
+        let baseFreight = baseMap[materialType];
+        kmDistance =  scMathUtil.roundForObj(kmDistance,decimal);
+        let resultString = baseFreight+"";
+        //用截取的方式,一段段取值
+        let less = kmDistance - 5;//kmDistance <= 5 这段
+        if(less <= 0) return resultString ; //kmDistance <= 5 的时候直接取baseFreight
+
+        //5< kmDistance <= 15  每增运1km 则增加0.6
+        less = less - 10;
+        if(less <=0)  return `(${resultString}+0.6x${less + 10})`;//baseFreight + (less + 10) * 0.6;
+        resultString =  `${resultString}+0.6x10`;
+        //15< kmDistance <= 100  每增运1km 则增加0.45
+        less = less - 85;
+        if(less <=0) return `(${resultString}+0.45x${less + 85})`; //baseFreight + (less + 85)*0.45;
+        resultString = `${resultString}+0.45x85`;
+        return `(${resultString}+0.35x${less})`;// >100 的所有部分每增运1km 则增加0.35  baseFreight + less * 0.35
     },
+
     onFreightRationValueChange:function (sender,args) {
         materialCalcObj.onRationValueChange(sender,args,"freight");
     },
@@ -592,6 +688,51 @@ materialCalcObj = {
         projectObj.project.projectGLJ.updateMaterialRation(datas);
 
     },
+    saveFreight:function (row) {
+        let me = this;
+        let record = this.freightDatas[row];
+        if(record){
+            let exist = this.checkSavedFreight(record.start);
+            if(exist){//已存在的情况,更新
+                let info =`起讫地点“${record.start}”已存在,是否覆盖?`;
+                //to do 检查是否已经存在,存在给出是否覆盖提示
+                hintBox.infoBox('操作确认', info, 2, function () {
+                    me.updateUserFreight(record,exist)
+                }, function () {
+                    //
+                },['确定','取消'],false);
+                return true;
+            }
+            let user_freight = {rootProjectID:projectObj.project.projectInfo.property.rootProjectID};
+            let f = {};
+            for(let key in record){
+                f[key] = record[key];
+                if(key =="ration" || key == "ration_gljs")f[key] = [];//下面的定额和工料机不用保存
+            }
+            user_freight.freight = f;
+            projectObj.project.projectGLJ.updateUserFreight({freights:[user_freight],action:"add"});
+        }
+    },
+
+    updateUserFreight:function (record,userFreight) {
+        let t  = {};
+        for(let t_key in userFreight){
+            if(t_key == "ID") continue;
+            t[t_key] = userFreight[t_key];
+        }
+
+        t.rootProjectID = projectObj.project.projectInfo.property.rootProjectID;
+        let f = {};
+        for(let key in record){
+            f[key] = record[key];
+            if(key =="ration" || key == "ration_gljs")f[key] = [];//下面的定额和工料机不用保存
+        }
+        t.freight = f;
+        projectObj.project.projectGLJ.updateUserFreight({ID:userFreight.ID,doc:t,action:"update"});
+
+    },
+
+
     getSideResize: function () {
         let rg_sideResizeEles = {};
         rg_sideResizeEles.eleObj = {
@@ -621,7 +762,7 @@ materialCalcObj = {
                     name: "内蒙古计算",
                     icon: 'fa-sign-in',
                     visible:function () {
-                        return id == "freightSheet";
+                        return false;//2019-11-17 改成不需要右键插入功能    id == "freightSheet";
                     },
                     disabled: function (){
                        let material = me.getMaterialSelected();
@@ -632,7 +773,22 @@ materialCalcObj = {
                     }
 
                 },
+                "saveFreight":{
+                    name: "保存运输起讫地点",
+                    icon: 'fa-sign-in',
+                    visible:function () {
+                        return id == "freightSheet";
+                    },
+                    disabled: function (){
+                        if(id == "freightSheet") return me.rightClickTarget.row >= me.freightDatas.length;
+                        return me.rightClickTarget.row === undefined;
+                    },
+                    callback:function () {
+                        let row = me.rightClickTarget.row;
+                        me.saveFreight(row);
+                    }
 
+                },
                 "delete": {
                     name: "删除",
                     icon: 'fa-trash-o',
@@ -691,7 +847,7 @@ materialCalcObj = {
         let stats = $(`#${preString}_ration_ass`).is(':visible');
         if(ration && ration.rationAssList){
             for(let r of ration.rationAssList){
-                if(r.name == "运距m"){//辅助定额只处理运距的情况,其它的都忽略
+                if(r.name.indexOf("运距")!= -1){//辅助定额只处理运距的情况,其它的都忽略  模糊匹配
                     show = true;
                     ass = r;
                 }
@@ -701,6 +857,7 @@ materialCalcObj = {
             $(`#${preString}_ration_sheet`).addClass("material-ration-left");
             $(`#${preString}_ration_ass`).addClass("material-ass");
             $(`#${preString}_ass_value`).val(ass.actualValue);
+            $(`#${preString}_ass_label`).text(ass.name);
             $(`#${preString}_ration_ass`).show();
         }else {
             $(`#${preString}_ration_sheet`).removeClass("material-ration-left");
@@ -714,11 +871,14 @@ materialCalcObj = {
         let replaceList = [];
         if(value && !number_util.isNum(value)){
             alert("输入的数据类型不对,请重新输入!");
-            let a = _.find(ration.rationAssList,{'name':"运距m"});
+            let a = _.find(ration.rationAssList,function (item) {
+                return item.name.indexOf("运距") != -1;
+            });
             if(a)ele.val(a.actualValue);
+            return;
         }
         for(let ass of ration.rationAssList){
-            if(ass.name == "运距m"){
+            if(ass.name.indexOf("运距")!= -1){
                 ass.actualValue = value?scMathUtil.roundForObj(value,2):ass.stdValue;
             }
             replaceList.push(value);

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

@@ -1525,8 +1525,8 @@ var projectObj = {
                             return true;
                         }
                     },
-                    visible:function(key, opt){//2018-11-15 新需求隐藏右键“造价计算”。
-                        return false;
+                    visible:function(key, opt){//2019-11-11 新需求重新开放右键“造价计算”。
+                        return true;
                     }
                 },
                 "spr4":'--------',

+ 54 - 6
web/building_saas/main/js/views/sub_fee_rate_views.js

@@ -54,12 +54,14 @@ var subRateObject={
         }
         //subRateObject.valueMap=projectObj.project.FeeRate.getValueMap(item);
         subRateObject.showSubRateData();
-        disableRightMenu("subRate",this.subRateSpread);
         if(projectReadOnly){
             if(this.subRateSetting.view.lockColumns){
                 this.subRateSetting.view.lockColumns = null;
             }
             disableSpread(this.subRateSpread);
+            disableRightMenu("subRate",this.subRateSpread);
+        }else {
+            this.initRightClick("subRate",this.subRateSpread)
         }
     },
     showSubRateData:function () {
@@ -124,7 +126,7 @@ var subRateObject={
         if($.bootstrapLoading.isLoading())  info.cancel = true;
     },
 
-    onSubRateValueChange:function (e,info) {
+    onSubRateValueChange:function (e,info,feeRateCoe) {
         let me = subRateObject, subList=null;
         let value = info.newValue;
         let subRate = me.datas[info.row];
@@ -158,15 +160,15 @@ var subRateObject={
         }
         if(me.timeStamp = null){
             me.timeStamp =  +new Date()
-            feeRateObject.setRateFromSub(subRate,value,subList,info.newValue);
+            feeRateObject.setRateFromSub(subRate,value,subList,info.newValue,feeRateCoe);
         }else {
             let now = +new Date();
             if(now - me.timeStamp < 500){
                 setTimeout(function () {
-                    feeRateObject.setRateFromSub(subRate,value,subList,info.newValue);
+                    feeRateObject.setRateFromSub(subRate,value,subList,info.newValue,feeRateCoe);
                 },500)
             }else {
-                feeRateObject.setRateFromSub(subRate,value,subList,info.newValue);
+                feeRateObject.setRateFromSub(subRate,value,subList,info.newValue,feeRateCoe);
             }
             me.timeStamp = now;
         }
@@ -179,5 +181,51 @@ var subRateObject={
         }
         subRateObject.datas=null;
         subRateObject.valueMap=null;
+    },
+    initRightClick:function (id,spread) {
+        let me = this;
+        $.contextMenu({
+            selector: '#'+id,
+            build: function ($trigger, e) {
+                me.rightClickTarget = SheetDataHelper.safeRightClickSelection($trigger, e, spread);
+                return me.rightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.viewport ||
+                    me.rightClickTarget.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
+            },
+            items: {
+                "widthCoe":{
+                    name: "乘系数",
+                    icon: 'fa-sign-in',
+                    visible:function () {
+                        return true;//2019-11-17 改成不需要右键插入功能    id == "freightSheet";
+                    },
+                    disabled: function (){
+                        let subRate = subRateObject.datas[me.rightClickTarget.row];
+                        if(subRate && subRate.isSub) return true;
+                        return me.rightClickTarget.row === undefined;
+                    },
+                    callback:function () {
+                        $("#width_coe_value").val(1);
+                        $("#widthCoeDiv").modal("show");
+                    }
+
+                }
+            }
+        });
     }
-}
+};
+
+$(function(){
+    $("#widthCoeDivConfirm").click(function () {
+        let feeRateCoe = $("#width_coe_value").val();
+        if(!number_util.isNum(feeRateCoe)){
+            alert("乘系数类型不对,请重新输入!");
+            return ;
+        }
+        feeRateCoe = scMathUtil.roundForObj(feeRateCoe,getDecimal("feeRate"));
+        let sub = subRateObject.subRateSheet.getSelections()[0];
+        let value =subRateObject.subRateSheet.getCell(sub.row,1).value();
+        let info = {col:1,row:sub.row,newValue:value,oldValue:value};
+        subRateObject.onSubRateValueChange({},info,feeRateCoe);
+        $("#widthCoeDiv").modal("hide");
+    })
+});

+ 2 - 3
web/over_write/js/neimeng_2019.js

@@ -251,7 +251,6 @@ if (typeof baseFigureTemplate !== 'undefined' && baseFigureTemplate.budget) {
 if(typeof materialCalcObj !== 'undefined' && materialCalcObj.rationSetting){
     let h =_.find(materialCalcObj.rationSetting.header,{"dataCode":"feeType"});
     if(h) h.visible = true;
-    materialCalcObj.getDefualtCalcType = function () {
-        return "内蒙古";
-    }
+    let mt = _.find(materialCalcObj.freightSetting.header,{"dataCode":"materialType"});
+    if(mt) mt.visible = true;
 }