Ver código fonte

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

zhongzewei 7 anos atrás
pai
commit
01c894c2e7

+ 1 - 0
modules/all_models/bills.js

@@ -64,6 +64,7 @@ let billsSchema = new Schema({
     installationKey:String,//用来记录安装增加费的关联字段
     deleteInfo: deleteSchema,
     isEstimate:{type: Number,default:0},       // 1 true 0 false 是否暂估
+    mainBills:{type:Schema.Types.Mixed,default:false},//true 是,false否,null 不确定,三个状态
     remark:String,
     engineeringContent:String,//工程内容
     serviceContent:String,//服务内容

+ 5 - 1
modules/all_models/project_glj.js

@@ -103,7 +103,11 @@ let modelSchema = {
         default: 0
     },
     ratio_data: Schema.Types.Mixed,
-    remark:String
+    remark:String,
+    originPlace:String,//产地
+    vender:String, //厂家
+    qualityGrace:String,//质量等级
+    brand:String//品牌
 };
 mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false}));
 

+ 3 - 64
modules/glj/controllers/glj_controller.js

@@ -19,7 +19,7 @@ let mongoose = require('mongoose');
 let ration = mongoose.model('ration');
 let projectModel = mongoose.model('projects');
 let _ = require('lodash');
-
+let glj_facade = require('../facade/glj_facade');
 
 const ProjectModel = require('../../pm/models/project_model').project;
 class GLJController extends BaseController {
@@ -86,7 +86,7 @@ class GLJController extends BaseController {
         try {
             // 可编辑的字段
             let editableField = ['is_evaluate', 'unit_price.market_price', 'is_adjust_price', 'mix_ratio.consumption',
-                'supply', 'supply_quantity','delivery_address','delivery','materialType','materialCoe','is_main_material','remark'];
+                'supply', 'supply_quantity','delivery_address','delivery','materialType','materialCoe','is_main_material','originPlace','vender','qualityGrace','brand','remark'];
             if (editableField.indexOf(field) < 0) {
                 throw '对应字段不能编辑';
             }
@@ -365,68 +365,7 @@ class GLJController extends BaseController {
             msg: ''
         };
         try {
-            let currentUnitPriceId = await ProjectModel.getUnitPriceFileId(projectId);
-            let unitPriceFileModel = new UnitPriceFileModel();
-
-            let insertData = null;
-            if (type > 0) {
-                let currentUnitPrice = await unitPriceFileModel.findDataByCondition({id: changeUnitPriceId});
-                if (currentUnitPrice === null) {
-                    throw '不存在对应单价文件';
-                }
-                // 获取当前项目的rootProjectId
-                let projectData = await ProjectModel.getProject(projectId);
-                let rootProjectId = projectData.property.rootProjectID !== undefined ? projectData.property.rootProjectID : 0;
-
-                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;
-            }
-            // 获取即将更改的单价文件信息
-            let targetUnitPriceFile = type === 0 ? await unitPriceFileModel.findDataByCondition({id: changeUnitPriceId}) :
-                await unitPriceFileModel.add(insertData);
-            if (targetUnitPriceFile === null) {
-                throw '没有找到对应的单价文件';
-            }
-
-            // 查找对应单价文件的项目工料机数据
-            let unitPriceModel = new UnitPriceModel();
-            if(type ===1){//从其它项目复制,则先复制一份数据。
-                let needCopyList = await unitPriceModel.findDataByCondition({unit_price_file_id: changeUnitPriceId}, null, false);
-                if(needCopyList){
-                    // 过滤mongoose格式
-                    needCopyList = JSON.stringify(needCopyList);
-                    needCopyList = JSON.parse(needCopyList);
-                    let copyList = [];
-                    for(let n of needCopyList){
-                        delete n._id;  // 删除原有id信息
-                        delete n.id;
-                        n.unit_price_file_id = targetUnitPriceFile.id;
-                        copyList.push(n);
-                    }
-                    copyList.length>0 ? await unitPriceModel.add(copyList):'';
-                }
-            }
-
-
-            let copyResult = await unitPriceModel.copyNotExist(currentUnitPriceId, targetUnitPriceFile.id,projectId);
-            // 复制成功后更改project数据
-            if (!copyResult) {
-                throw '复制数据失败';
-            }
-
-            let changeUnitPriceFileInfo = {
-                id: targetUnitPriceFile.id,
-                name: targetUnitPriceFile.name
-            };
-            let result = ProjectModel.changeUnitPriceFileInfo(projectId, changeUnitPriceFileInfo);
-            if (!result) {
-                throw '切换单价文件失败!';
-            }
-
+            responseData.unitFile = await glj_facade.changeUnitFile({projectID:projectId}, {id:changeUnitPriceId,name:newName},type,request.session.sessionUser.id);
         } catch (error) {
             console.log(error);
             responseData.err = 1;

+ 1 - 1
modules/users/controllers/sms_controller.js

@@ -6,7 +6,7 @@
  * @version
  */
 import SmsModel from "../models/sms_model";
-const SMS = require('../models/SMS');
+const SMS = require('../models/sms');
 
 class SmsController {
 

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

@@ -301,13 +301,17 @@ var sheetCommonObj = {
         }
     },
     setCheckBoxCell(row,col,sheet,val){
-        var c = new GC.Spread.Sheets.CellTypes.CheckBox();
-        c.isThreeState(false);
+        var c = this.getCheckBox();
         sheet.setCellType(row, col,c,GC.Spread.Sheets.SheetArea.viewport);
         sheet.getCell(row, col).value(val);
         sheet.getCell(row, col).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
 
     },
+    getCheckBox(threeState = false){
+        var c = new GC.Spread.Sheets.CellTypes.CheckBox();
+        c.isThreeState(threeState);
+        return c
+    },
     setComboBox(row,col,sheet,options,editorValueType){
         //let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
         let dynamicCombo = sheetCommonObj.getDynamicCombo(true);

+ 2 - 0
public/web/tree_sheet/tree_sheet_helper.js

@@ -181,6 +181,8 @@ var TREE_SHEET_HELPER = {
                 var cell = sheet.getCell(iRow, iCol, GC.Spread.Sheets.SheetArea.viewport);
                 if (colSetting.data.getText && Object.prototype.toString.apply(colSetting.data.getText) === "[object Function]") {
                     cell.value(colSetting.data.getText(node));
+                }else if(colSetting.data.field=="mainBills"&&MainTreeCol.mainBillsEnable(node)){//主要清单有三种状态,所以直接显示就好,不走最后的逻辑
+                    cell.value(node.data[colSetting.data.field]===undefined?false:node.data[colSetting.data.field]);
                 } else {
                     cell.value(getFieldText2());
                 }

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

@@ -23,6 +23,7 @@ $(function () {
         billsLibObj.refreshBillsRelaSpread();
         rationLibObj.refreshSpread();
         subObj.initGljSubTab();
+        subObj.initQDSubTab();
         refreshSubSpread();
     });
 

+ 4 - 1
web/building_saas/main/js/models/bills.js

@@ -560,12 +560,15 @@ var Bills = {
         };
         bills.prototype.isMeasure = function (node) {//判读是否属于措施项目部分
             let rootNode = this.getRootNode(node);
-            if(isFlag(rootNode.data)&&rootNode.data.flagsIndex.fixed.flag==fixedFlag.MEASURE){
+            if(this.isMeasureNode(rootNode)){
                 return true;
             }else {
                 return false;
             }
         };
+        bills.prototype.isMeasureNode=function(node){//判读是否就是措施项目节点
+            return isFlag(node.data)&&node.data.flagsIndex.fixed.flag==fixedFlag.MEASURE
+        };
         bills.prototype.hasFlags = function (node) {
             return isFlag(node.data);
         };

+ 67 - 0
web/building_saas/main/js/models/project.js

@@ -382,6 +382,73 @@ var PROJECT = {
             }
             return true;
         };
+        project.prototype.updateMainBills = function(node,newval){
+            let datas = [];
+            let data =  {
+                type:node.sourceType,
+                data:{
+                    ID:node.data.ID,
+                    mainBills:newval
+                }
+            };
+            datas.push(data);
+            setChildren(node,newval,datas);//同步设置所有子项
+            setParent(node,newval,datas);//设置父节点
+            $.bootstrapLoading.start();
+            this.updateNodes(datas,function () {
+                let nodes = [];
+                for(let d of datas){
+                    let node = projectObj.project.mainTree.findNode(d.data.ID);
+                    if(node){
+                        node.data.mainBills = d.data.mainBills;
+                        nodes.push(node)
+                    }
+                }
+                projectObj.mainController.refreshTreeNode(nodes);
+                $.bootstrapLoading.end();
+            });
+
+            function setChildren(pnode,newValue,datas) {//同步设置所有子项
+                if(pnode.children.length > 0 && pnode.children[0].sourceType == ModuleNames.bills){//设置子项不包括定额
+                    for(let c of pnode.children){
+                        let data =  {
+                            type:c.sourceType,
+                            data:{
+                                ID:c.data.ID,
+                                mainBills:newValue
+                            }
+                        };
+                        datas.push(data);
+                        setChildren(c,newValue,datas)
+                    }
+                }
+            }
+            function setParent(cnode,newValue,datas) {
+                let diferrent = false;
+                if(cnode.parent && !projectObj.project.Bills.isMeasureNode(cnode.parent)){//排除措施项目节点
+                    for(b of cnode.parent.children){
+                        if(b == cnode) continue
+                        if(b.data.mainBills!== newValue){//有兄弟节点的值和本节点不一样,则父节点设置为null
+                            diferrent = true;
+                            break;
+                        }
+                    }
+                    let pvalue = diferrent === true?null:newValue;
+                    let data =  {
+                        type:cnode.parent.sourceType,
+                        data:{
+                            ID:cnode.parent.data.ID,
+                            mainBills:pvalue
+                        }
+                    };
+                    datas.push(data);
+                    setParent(cnode.parent,pvalue,datas);
+                }
+            }
+
+        };
+
+
         project.prototype.updateNodes = function (datas,callback) {
           /*  let datas = [
                 {

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

@@ -496,6 +496,7 @@ ProjectGLJ.prototype.getRatioData=function(id,callback){
 ProjectGLJ.prototype.changeFile = function (changeData,callback) {
     $.bootstrapLoading.start();
     CommonAjax.specialPost('/glj/change-file',changeData,function (response) {
+        projectObj.project.property.unitPriceFile = response.unitFile;
         projectObj.project.projectGLJ.loadData(function () {
             if(callback){
                 callback();

+ 4 - 0
web/building_saas/main/js/views/glj_col.js

@@ -51,6 +51,10 @@ let gljCol = {
             {headerName: "三材系数", headerWidth: 70, dataCode: "materialCoe", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:'material'
             {headerName: "交货方式", headerWidth: 70, dataCode: "delivery", hAlign: "left", dataType: "String"},
             {headerName: "送达地点", headerWidth: 70, dataCode: "delivery_address", hAlign: "left", dataType: "String"},
+            {headerName: "产地", headerWidth: 80, dataCode: "originPlace", hAlign: "left", dataType: "String"},
+            {headerName: "厂家", headerWidth: 80, dataCode: "vender", hAlign: "left", dataType: "String"},
+            {headerName: "质量等级", headerWidth: 80, dataCode: "qualityGrace", hAlign: "left", dataType: "String"},
+            {headerName: "品牌", headerWidth: 80, dataCode: "brand", hAlign: "left", dataType: "String"},
             {headerName: "备注", headerWidth: 100, dataCode: "remark", hAlign: "left", dataType: "String"}
         ],
         view: {

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

@@ -354,8 +354,16 @@ let MainTreeCol = {
         commonTotalFee: function (node) {
             let readOnly = projectReadOnly || !calcBaseView.ifEdit('bills', projectObj.project.mainTree.items.indexOf(node));
             return sheetCommonObj.getCusButtonCellType(projectObj.onCommonTotalFeeButtonClick,readOnly) //projectObj.getCommonTotalFeeCellType();
+        },
+        mainBills:function (node) {
+            if(MainTreeCol.mainBillsEnable(node)) return sheetCommonObj.getCheckBox(true);
         }
     },
+    mainBillsEnable:function (node) {
+        let Bills = projectObj.project.Bills;
+        //仅“分部分项工程”或“施工技术措施项目”下的分部、分项、补项、清单可编辑
+        return ((Bills.isFBFX(node)||Bills.isTechMeasure(node))&&node.sourceType == ModuleNames.bills)
+    },
     editChecking:function(node){
         if(node.sourceType==projectObj.project.Bills.getSourceType()&&projectObj.project.isBillsLocked()&&projectObj.project.withinBillsLocked(node)){
             return true;

+ 4 - 0
web/building_saas/main/js/views/project_glj_view.js

@@ -674,6 +674,10 @@ projectGljObject={
             bgColour:'white',
             techQuantity:glj.techQuantity,
             subdivisionQuantity:glj.subdivisionQuantity,
+            originPlace:glj.originPlace,
+            vender:glj.vender,
+            qualityGrace:glj.qualityGrace,
+            brand:glj.brand,
             remark:glj.remark
         };
         gljOprObj.setGLJPrice(data,glj);

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

@@ -1735,6 +1735,8 @@ var projectObj = {
             projectObj.onIsEstimateClick(node,info);
         }else if(fieldName == "evaluationProject"){
             projectObj.onEvaluationProjectClic(node,info);
+        }else if(fieldName == "mainBills"){
+            projectObj.onMainBillsClick(node,info);
         }
 
     },
@@ -1748,7 +1750,6 @@ var projectObj = {
             projectObj.project.calcProgram.calcAndSave(node);
         })
     },
-
     onIsEstimateClick: function(node,info){
         let checkboxValue = info.sheet.getCell(info.row, info.col).value();
         let cell = info.sheet.getCell(info.row, info.col), newval = 0;
@@ -1767,6 +1768,16 @@ var projectObj = {
             projectObj.project.projectGLJ.pGljUpdate(updateData);
         }
     },
+    onMainBillsClick:function (node,info) {//清单有三种状态,true,false,null。 打勾:true, 不打勾 false 子项有打勾和不打勾的情况 null
+        let checkboxValue = info.sheet.getCell(info.row, info.col).value();
+        let cell = info.sheet.getCell(info.row, info.col), newval = true;
+        if (checkboxValue == true) {
+            newval = false;
+        } else {
+            newval = true;
+        }
+        projectObj.project.updateMainBills(node,newval);
+    },
     onSubcontractClick:function (node) {//点击分包费checkbox
         if (node.data.isSubcontract) node.data.isSubcontract = false;
         else node.data.isSubcontract = true;

+ 3 - 0
web/building_saas/main/js/views/side_tools.js

@@ -12,6 +12,7 @@ $(window).resize(function() {
     //刷新主界面与各库中间的拖动条宽度:始终保持为一个宽度(在小窗口打开一个库,再放大窗口后,该拖动条宽度会变大)
     SlideResize.setResizeWidth($('#sideResize'));
     subObj.initGljSubTab();
+    subObj.initQDSubTab();
     refreshSubSpread();
 
 });
@@ -31,6 +32,7 @@ sideResizeEles.limit = {
 SlideResize.horizontalSlide(sideResizeEles.eleObj, sideResizeEles.limit, function(){
    // MaterialController.showReplaceDiv();
     subObj.initGljSubTab();
+    subObj.initQDSubTab();
     pageCCOprObj.resizeWidth();
     //BillsElf.setColumnWidthByRate();
     projectObj.refreshMainSpread();
@@ -195,6 +197,7 @@ var sideToolsObj = {
         adaptiveTzjnrWidth();
         autoFlashHeight();
         subObj.initGljSubTab();
+        subObj.initQDSubTab();
         pageCCOprObj.resizeWidth();
         billsGuidance.refreshWorkBook();
         billsLibObj.refreshBillsSpread();

+ 7 - 0
web/users/js/login.js

@@ -130,6 +130,13 @@ $(document).ready(function () {
         cleanValidError($(this));
     });
 
+    $('#inputEmail').blur(function () {
+        let account = $("#inputEmail").val();
+        if(!/^1[3456789]\d{9}$/.test(account) && !/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(account)) {
+            $('#emailHelp').text('您输入的 邮箱/手机 格式不对');
+        }
+    });
+
     $(".form-control").on('input', function () {
         $('#hint').html('&nbsp;');
     });