Browse Source

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

# Conflicts:
#	public/web/tree_sheet/tree_sheet_helper.js
zhongzewei 6 years ago
parent
commit
88de64db2e

+ 4 - 0
modules/main/facade/ration_facade.js

@@ -462,6 +462,10 @@ async function CalculateQuantity (ration,billsItemID,projectID) {
     let decimalObject =await decimal_facade.getProjectDecimal(projectID,project);
     let quantity_decimal = (decimalObject&&decimalObject.ration&&decimalObject.ration.quantity)?decimalObject.ration.quantity:3;
     let pbill = await bill_model.model.findOne({projectID:projectID,ID:billsItemID});
+    let  t_unit = ration.unit.replace(/^\d+/,"");
+    if(t_unit!=pbill.unit){//如果定额工程量的单位去除前面的数字后不等于清单单位,定额工程量保持不变
+        return ;
+    }
     let billsQuantity = pbill.quantity ? pbill.quantity : 0;
     let bill_decimal = await decimal_facade.getBillsQuantityDecimal(projectID,pbill.unit,project);
     billsQuantity=scMathUtil.roundForObj(billsQuantity,bill_decimal);

+ 67 - 1
modules/users/controllers/cld_controller.js

@@ -57,12 +57,22 @@ class CLDController {
             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 = JSON.parse(JSON.stringify(userData.upgrade_list));
+                let userUpgradeList = userData.upgrade_list;
                 for (let i in userUpgradeList) {
                     let oneCompilationIndex = await compilationList.findIndex(function (item) {
                         return item._id === userUpgradeList[i].compilationID;
@@ -77,6 +87,62 @@ class CLDController {
             response.json({error: 1, msg: err});
         }
     }
+
+    /**
+     * 设置用户编办专业版
+     *
+     * @param request
+     * @param response
+     * @return {Promise.<void>}
+     */
+    async setUsersUpgrade(request, response) {
+        let ssoID = request.body.ssoId;
+        let compilationID = request.body.cid;
+        try {
+
+            let userModel = new UserModel();
+
+            let userData = await userModel.findDataBySsoId(ssoID);
+
+            let compilationModel = new CompilationModel();
+
+            let compilationData = compilationModel.getCompilationById(compilationID);
+
+            if (compilationData === null || compilationData === undefined) {
+                throw '不存在该编办或者编办未发布';
+            }
+
+            let upgrade_list = userData.upgrade_list !== undefined ? JSON.parse(JSON.stringify(userData.upgrade_list)) : [];
+
+            let upgradeIndex = upgrade_list.findIndex(function (item) {
+                return item.compilationID === compilationID
+            });
+
+            let upgradeInfo = {
+                compilationID:compilationID,//编办ID
+                upgrade_time:new Date().getTime(),
+                isUpgrade:true,
+                remark: ''
+            };
+
+            if (upgradeIndex === -1) {
+                upgrade_list.push(upgradeInfo);
+            } else {
+                upgrade_list.splice(upgradeIndex, 1, upgradeInfo);
+            }
+
+            let condition = {ssoId: ssoID};
+            let result = await userModel.updateUser(condition, {upgrade_list: upgrade_list});
+
+            if (result) {
+                response.json({error: 0, msg: 'success'});
+            } else {
+                throw '更新失败';
+            }
+        } catch (err) {
+            response.json({error: 1, msg: err});
+        }
+    }
 }
 
 export default CLDController;

+ 3 - 1
modules/users/routes/cld_route.js

@@ -15,10 +15,12 @@ import CLDController from "../controllers/cld_controller";
 module.exports = function (app) {
     let router = express.Router();
     let cldController = new CLDController();
-    // 登录页面action
+
     router.get('/getCategoryStaff', cldController.getCategoryStaff);
 
     router.get('/getUsersAndCompilation', cldController.getUsersAndCompilationList);
 
+    router.post('/setUserUpgrade', cldController.setUsersUpgrade);
+
     app.use('/cld',router)
 };

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

@@ -502,11 +502,36 @@ var sheetCommonObj = {
             if (options.row === sheet.getActiveRowIndex() && options.col === sheet.getActiveColumnIndex() && (!forLocked || forLocked && !sheet.getCell(options.row, options.col).locked())) {
                 return GC.Spread.Sheets.CellTypes.ComboBox.prototype.getHitInfo.apply(this, arguments);
             } else {
-                return GC.Spread.Sheets.CellTypes.Base.prototype.getHitInfo.apply(this, arguments);
+                return  {
+                    x: x,
+                    y: y,
+                    row: options.row,
+                    col: options.col,
+                    cellStyle: cellStyle,
+                    cellRect: cellRect,
+                    sheetArea: options.sheetArea
+                };//GC.Spread.Sheets.CellTypes.Text.prototype.getHitInfo.apply(this, arguments);
             }
         };
         return new ComboCellForActiveCell();
     },
+    getTipsCombo:function (forLocked,tips,setting) {
+        let getTipsCombo = function () {
+
+        };
+        getTipsCombo.prototype = sheetCommonObj.getDynamicCombo(forLocked);
+        if(tips && tips !=""){
+            getTipsCombo.prototype.processMouseEnter = function(hitinfo){
+                console.log(hitinfo);
+                TREE_SHEET_HELPER.delayShowTips(hitinfo,setting,tips);
+            };
+            getTipsCombo.prototype.processMouseLeave = function (hitinfo) {
+                TREE_SHEET_HELPER.hideTipsDiv();
+            };
+        }
+        return new getTipsCombo();
+    },
+
     setDynamicCombo: function (sheet, beginRow, col, rowCount, items, itemsHeight, itemsType) {
         let me = this;
         sheet.suspendPaint();

+ 14 - 6
public/web/tree_sheet/tree_sheet_helper.js

@@ -167,9 +167,9 @@ var TREE_SHEET_HELPER = {
                         let tag ="";
                         if(node.sourceType == ModuleNames.ration){//定额的时候换算子目
                             tag = node.data.adjustState?node.data.adjustState:'';
-                        }else if(node.sourceType == ModuleNames.bills &&projectObj.ifItemCharHiden(setting)){//清单、并且项目特征列隐藏的时候悬浮提示
+                        }/*else if(node.sourceType == ModuleNames.bills &&projectObj.ifItemCharHiden(setting)){//清单、并且项目特征列隐藏的时候悬浮提示  这里改成在 计量单位那里提示
                             tag = node.data.itemCharacterText?node.data.itemCharacterText:'';
-                        }
+                        }*/
                         sheet.setTag(iRow, iCol,tag);
                     }
                     /*if(colSetting.data.field=="name"){ 2018-08-06 改成在编号列悬浮提示
@@ -187,7 +187,7 @@ var TREE_SHEET_HELPER = {
                     cell.value(getFieldText2());
                 }
                 if (colSetting.data.cellType && Object.prototype.toString.apply(colSetting.data.cellType) !== "[object String]") {
-                    cell.cellType(colSetting.data.cellType(node));
+                    cell.cellType(colSetting.data.cellType(node,setting));
                 }
                 if(colSetting.data.autoHeight == true){
                     colSetting.setAutoHeight(cell,node);
@@ -505,7 +505,7 @@ var TREE_SHEET_HELPER = {
                 if(hitinfo.sheet && hitinfo.sheet.getParent().qo){
                     setting.pos = SheetDataHelper.getObjPos(hitinfo.sheet.getParent().qo);
                 }
-                $(this._toolTipElement).html(`<span>${text}</span><div class="triangle-border tb-border"></div><div class="triangle-border tb-background"></div>`);
+                $(this._toolTipElement).html(`<span>${text}</span><div class="triangle-border tb-border_up"></div><div class="triangle-border tb-background_up"></div>`);
                 //清单指引、清单库做特殊处理
                 if($(hitinfo.sheet.getParent().qo).attr('id') === 'stdBillsSpread' || $(hitinfo.sheet.getParent().qo).attr('id') === 'billsGuidance_bills'){
                     $(this._toolTipElement).html(`<span>${text}</span>`);
@@ -519,9 +519,15 @@ var TREE_SHEET_HELPER = {
                     $(this._toolTipElement).css("top", top).css("left", setting.pos.x - divWidth);
                 } else {
                     //计算显示的初始位置
+               /*   显示在单元格上方,三角形指向下的版本
                     let top = setting.pos.y + hitinfo.cellRect.y -$(this._toolTipElement).height() -26;
                     let left =  setting.pos.x + hitinfo.cellRect.x;
+                    $(this._toolTipElement).css("top", top).css("left", left);*/
+                    //显示在下方,三角形指
+                    let top = setting.pos.y  + hitinfo.cellRect.y+26;
+                    let left =  setting.pos.x + hitinfo.cellRect.x;
                     $(this._toolTipElement).css("top", top).css("left", left);
+
                 }
                 $(this._toolTipElement).show("fast");
                 TREE_SHEET_HELPER.tipDiv = 'show';//做个标记
@@ -549,14 +555,16 @@ var TREE_SHEET_HELPER = {
             }
         },600)
     },
-    delayShowTips:function(hitinfo,setting){//延时显示
+    delayShowTips:function(hitinfo,setting,tips){//延时显示
         let delayTimes = 500; //延时时间
         let now_timeStamp = +new Date();
         TREE_SHEET_HELPER.tipTimeStamp = now_timeStamp;
         setTimeout(function () {
             if(now_timeStamp - TREE_SHEET_HELPER.tipTimeStamp == 0){//鼠标停下的时候才显示
-                let text = hitinfo.sheet.getText(hitinfo.row, hitinfo.col);
                 let tag = hitinfo.sheet.getTag(hitinfo.row, hitinfo.col);
+                if(tips && tips !=""){ //有tips的话优先显示tips
+                    tag = tips;
+                }
                 if(tag&&tag!=''){
                     TREE_SHEET_HELPER.showTipsDiv(tag,setting,hitinfo);
                 }

+ 4 - 1
web/building_saas/css/custom.css

@@ -96,7 +96,10 @@ legend.legend{
 }
 .tb-background_up {
     top:-11px;
-    border-color:transparent transparent #000 transparent;}
+    border-color:transparent transparent #000 transparent;
+}
+
+
 .elf-options:hover{
     background-color: #CCCCCC;
 }

+ 8 - 3
web/building_saas/main/js/views/main_tree_col.js

@@ -249,13 +249,18 @@ let MainTreeCol = {
         }
     },
     cellType: {
-        unit: function () {
-            let dynamicCombo = sheetCommonObj.getDynamicCombo(true);
+        unit: function (node,setting) {
+            let tips = "";
+            //在这里做要不要显示的判断
+             if(node.sourceType == ModuleNames.bills &&projectObj.ifItemCharHiden(setting)){//清单、并且项目特征列隐藏的时候悬浮提示
+                tips = node.data.itemCharacterText?node.data.itemCharacterText:'';
+             }
+             console.log(setting);
+            let dynamicCombo = sheetCommonObj.getTipsCombo(true,tips,setting);//sheetCommonObj.getDynamicCombo(true);
             dynamicCombo.itemHeight(10).items(['m', 'm2', 'm3', 'km', 't', 'kg', '台班', '工日', '昼夜', '元', '项', '处', '个', '件',
                 '根', '组', '系统', '台', '套', '株', '丛', '缸', '支', '只', '块', '座', '对', '份', '樘', '攒', '榀']).editable(true);
             return dynamicCombo;
         },
-
         units: function () {
             this.unit;
         },

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

@@ -1202,8 +1202,8 @@ $(function () {
             changeUnitPriceId = $("#self-file").val();
             if(!changeUnitPriceId){
                 alert('单价文件不可为空');
-                return;
             }
+            submitFileChange(changeUnitPriceId,type);
         } else {
             // 从其他项目中复制
             changeUnitPriceId = $("#other-file").val();
@@ -1214,14 +1214,17 @@ $(function () {
                     $("#newUnitFileID").val(changeUnitPriceId);
                     $("#newUnitFileName").val(newName);
                 }else {
-                    let data = {project_id: scUrlUtil.GetQueryString('project'), change_id: changeUnitPriceId, type: type};
-                    projectObj.project.projectGLJ.changeFile(data,function () {
-                        projectGljObject.changeFileCallback();
-                    })
+                    submitFileChange(changeUnitPriceId,type);
                 }
             });
         }
 
+        function submitFileChange(changeUnitPriceId,type)  {
+            let data = {project_id: scUrlUtil.GetQueryString('project'), change_id: changeUnitPriceId, type: type};
+            projectObj.project.projectGLJ.changeFile(data,function () {
+                projectGljObject.changeFileCallback();
+            })
+        }
     });
     // 单价文件选项切换
     $("input[name='change-type']").change(function () {

+ 13 - 12
web/building_saas/main/js/views/project_view.js

@@ -454,8 +454,7 @@ var projectObj = {
                     quantityEditObj.checkingAndUpdate(editingText,node);
                    // project.quantity_detail.editMainTreeNodeQuantity(value,node,fieldName,editingText);
                     return;
-                }
-                else if (fieldName === 'marketUnitFee' || fieldName === 'feesIndex.common.unitFee'||fieldName === 'feesIndex.common.totalFee') {
+                } else if (fieldName === 'marketUnitFee' || fieldName === 'feesIndex.common.unitFee'||fieldName === 'feesIndex.common.totalFee') {
                     if(isNaN(value)){//说明输入的是无效的字符
                         //value == null && editingText!=null && editingText!=""
                         alert("当前输入的数据类型不正确,请重新输入。");
@@ -464,15 +463,19 @@ var projectObj = {
                     }
                     if (value) {
                         if(fieldName === 'feesIndex.common.unitFee')  value = parseFloat(value).toDecimal(decimalObj.decimal("unitPrice", node));
-                        if(fieldName === 'feesIndex.common.totalFee' && node.data.quantity){//修改了综合合价后,反算综合单价,然后再由计算程序算个综合合价出来
-                           let t_quantity = scMathUtil.roundForObj(node.data.quantity,getDecimal("quantity",node));
-                            value = scMathUtil.roundForObj(value,getDecimal("unitPrice", node));
-                            let unitfee = scMathUtil.roundForObj(value/t_quantity,getDecimal("totalPrice", node));
+                        if(fieldName === 'feesIndex.common.totalFee'){//修改了综合合价后,反算综合单价,然后再由计算程序算个综合合价出来
+                            let unitfee = 0;
+                            if(node.data.quantity){//如果工程量为0或空,综合合单直接填到综合单价
+                                let t_quantity = scMathUtil.roundForObj(node.data.quantity,getDecimal("quantity",node));
+                                value = scMathUtil.roundForObj(value,getDecimal("unitPrice", node));
+                                unitfee = scMathUtil.roundForObj(value/t_quantity,getDecimal("totalPrice", node));
+                            }else {
+                                unitfee = scMathUtil.roundForObj(value,getDecimal("totalPrice", node));
+                            }
                             calcTools.setFieldValue(node, 'feesIndex.common.unitFee', unitfee);
                         }
                     }
-                }
-                else if (fieldName === 'calcBase') {
+                } else if (fieldName === 'calcBase') {
                     //zhong
                     if(value === undefined ||value === null || value.toString().trim() === ''){
                         value = '';
@@ -496,8 +499,7 @@ var projectObj = {
 
                 project.calcProgram.calcAndSave(node);
                 gljOprObj.showRationGLJSheetData();
-            }
-            else if (node.sourceType === project.Bills.getSourceType()&&fieldName === 'unit'){//修改清单单位的时候清单工程量要重新4舍5入
+            } else if (node.sourceType === project.Bills.getSourceType()&&fieldName === 'unit'){//修改清单单位的时候清单工程量要重新4舍5入
                 node.data[fieldName] = value;
                 node.changed = true;
                 if(node.data.quantity){
@@ -507,8 +509,7 @@ var projectObj = {
             } else {
                 if (node.sourceType === project.Bills.getSourceType()) {
                     project.Bills.updateField(node.source, fieldName, value, false);
-                }
-                else if (node.sourceType === project.Ration.getSourceType()) {
+                } else if (node.sourceType === project.Ration.getSourceType()) {
                     project.Ration.updateField(node.source, fieldName, value);
                 }
                 if (colSetting.data.wordWrap) {