Browse Source

feat: 审核对比表设置

zhangweicheng 4 năm trước cách đây
mục cha
commit
7b8c4cb6c2

+ 1 - 0
config/gulpConfig.js

@@ -143,6 +143,7 @@ module.exports = {
         'web/building_saas/main/js/views/project_property_projFeature.js',
         'web/building_saas/main/js/views/project_property_indicativeInfo.js',
         'web/building_saas/main/js/views/project_property_display_view.js',
+        'web/building_saas/main/js/views/project_property_compare.js',
         'web/building_saas/main/js/main_ajax.js',
         'web/building_saas/main/js/main.js',
         'web/building_saas/main/js/controllers/project_controller.js',

+ 2 - 1
modules/all_models/projects.js

@@ -41,7 +41,8 @@ const ProjectSchema = new Schema({
     "changeMark":String,// 更新标记  feeRate:费率文件发生了改变,unitFile 单件文件发生了改变
     "remark":String, // 备注
     "fileVer": String,  // 创建时程序版本号
-    "lastFileVer": String  // 最新打开并计算时的程序版本号
+    "lastFileVer": String,  // 最新打开并计算时的程序版本号
+    "compareID":Number
 });
 
 mongoose.model(collectionName, ProjectSchema, collectionName);

+ 15 - 1
modules/main/controllers/project_controller.js

@@ -251,5 +251,19 @@ module.exports = {
         } finally {
             res.json(responseData);
         }
-    }
+    },
+    getCompareProjects:async function(req,res){
+        let result={
+            error:0
+        };
+        try {
+
+            result = await project_facade.getCompareProjects(req.session.sessionUser.id, req.session.sessionCompilation._id);
+        } catch (err) {
+            console.log(err.stack);
+            result.error=1;
+            result.message = err.message;
+        }
+        res.json(result);
+    },
 };

+ 0 - 1
modules/main/facade/info_price_facade.js

@@ -50,7 +50,6 @@ async function getOptions(data,compilation){//data 是预留对象,暂时不
 }
 
 async function getClassByAreaID(data,compilation){
-  console.log(data);
   //要先知道根据期数和编办查找库ID
   let newList = [];
   let lib = await infoLibModel.findOne({compilationID:compilation._id,period:data.period})

+ 14 - 1
modules/main/facade/project_facade.js

@@ -16,7 +16,8 @@ module.exports = {
     loadSEIProjectData:loadSEIProjectData,
     setSEILibData:setSEILibData,
     getIndexReportData:getIndexReportData,
-    setDefaultItemIncrease:setDefaultItemIncrease
+    setDefaultItemIncrease:setDefaultItemIncrease,
+    getCompareProjects:getCompareProjects,
 };
 
 let mongoose = require('mongoose');
@@ -692,4 +693,16 @@ async function calcProjectGLJQuantity(projectID,projectGLJDatas,property){
     let rationGLJDatas = await ration_glj_model.find({'projectID':projectID});
     let rationDatas = await ration_model.model.find({'projectID':projectID});
     gljUtil.calcProjectGLJQuantity(projectGLJDatas,rationGLJDatas,rationDatas,[],q_decimal)
+}
+
+
+async function getCompareProjects(userID, compilationID){
+    let projects = await projectsModel.find({
+        '$or': [{
+            'userID': userID,
+            'compilation': compilationID,
+            'deleteInfo': null
+        }, {'userID': userID, 'compilation': compilationID, 'deleteInfo.deleted': {'$in': [null, false]}}]
+    }, 'ID ParentID NextSiblingID name projType compareID', {lean: true});
+   return projects;
 }

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

@@ -21,6 +21,7 @@ module.exports = function (app) {
     projectRouter.post('/loadSEIProjectData', projectController.loadSEIProjectData);
     projectRouter.post('/getDecodedData', projectController.getDecodedData);
     projectRouter.post('/getEncodedData', projectController.getEncodedData);
+    projectRouter.get('/getCompareProjects', projectController.getCompareProjects);
     app.use('/project',projectRouter);
 };
 

+ 47 - 1
public/web/common_util.js

@@ -90,4 +90,50 @@ function deletePropNames(object, namesArr) {
     for (let name of namesArr){
         if (object[name]) delete object[name];
     };
-};
+};
+
+
+function sortTreeChildren(lists) {//树结构排序
+    let IDMap ={},nextMap = {}, firstNode = null,newList=[];
+    for(let l of lists){
+        if(l.children&&l.children.length > 0) l.children = sortChildren(l.children);//递规排序
+        IDMap[l.ID] = l;
+        if(l.NextSiblingID!=-1) nextMap[l.NextSiblingID] = l;
+    }
+    for(let t of lists){
+        if(!nextMap[t.ID]){ //如果在下一节点映射没找到,则是第一个节点
+            firstNode = t;
+            break;
+        }
+    }
+    if(firstNode){
+        newList.push(firstNode);
+        delete IDMap[firstNode.ID];
+        setNext(firstNode,newList);
+    }
+    //容错处理,如果链断了的情况,直接添加到后面
+    for(let key in IDMap){
+        if(IDMap[key]) newList.push(IDMap[key])
+    }
+    return newList;
+
+    function setNext(node,array) {
+        if(node.NextSiblingID != -1){
+            let next = IDMap[node.NextSiblingID];
+            if(next){
+                array.push(next);
+                delete IDMap[next.ID];
+                setNext(next,array);
+            }
+        }
+    }
+} 
+
+function setTreeChildern(children,list,parentMap){//按顺序设置树节点
+    for(let c of children){
+      list.push(c);
+      if(parentMap[c.ID]){
+        getChildern(parentMap[c.ID],list,parentMap)
+      }
+    }
+  }

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

@@ -1163,7 +1163,7 @@ var sheetCommonObj = {
         return new TreeNodeCellType()
 
         function getTreeLevel(item,data) {
-            if(item.ParentID && item.ParentID!=-1){
+            if(item && item.ParentID && item.ParentID!=-1){
                 let pitem =  _.find(data,{'ID':item.ParentID});
                 return  getTreeLevel(pitem,data) + 1;
             }else {

+ 12 - 0
web/building_saas/main/html/main.html

@@ -1006,6 +1006,8 @@
                     role="tab" id="tab_poj-settings-basicInfo">基本信息</a></li>
                 <li class="nav-item ml-3"><a class="nav-link" data-toggle="pill" href="#compilationIllustrationP"
                     role="tab" id="tab_compilation_illustration_p">编制说明</a></li>
+                 <li class="nav-item ml-3"><a class="nav-link" data-toggle="pill" href="#auditCompareTab"
+                      role="tab" id="tab_compare">审核对比</a></li>
                 <li class="nav-item"><a class="nav-link disabled">单位工程信息</a></li>
                 <li class="nav-item ml-3"><a class="nav-link" data-toggle="pill" href="#poj-settings-projFeature"
                     id="tab_poj-settings-projFeature" role="tab">工程特征</a></li>
@@ -1042,6 +1044,15 @@
                     <textarea class="form-control" rows="15"></textarea>
                   </div>
                 </div>
+                <!--审核对比-->
+                <div class="tab-pane fade" id="auditCompareTab" role="tabpanel">
+                  <div class="modal-auto-height">
+                    <P>选择送审的项目:</P>
+                    <select class="form-control form-control-sm" style="width: 100%; font-size: .875rem" id="audiCompareID">
+                    </select>
+                    <div style="overflow: hidden;height: 330px;" id="compareProjectSpread"></div>
+                  </div>
+                </div>
                 <!--工程特征-->
                 <div class="tab-pane fade" id="poj-settings-projFeature" role="tabpanel">
                   <div class="modal-auto-height" style="overflow: hidden" id="projFeatureSpread">
@@ -2855,6 +2866,7 @@
   <script type="text/javascript" src="/web/building_saas/main/js/views/project_property_projFeature.js"></script>
   <script type="text/javascript" src="/web/building_saas/main/js/views/project_property_indicativeInfo.js"></script>
   <script type="text/javascript" src="/web/building_saas/main/js/views/project_property_display_view.js"></script>
+  <script type="text/javascript" src="/web/building_saas/main/js/views/project_property_compare.js"></script>
   <script type="text/javascript" src="/web/building_saas/main/js/main_ajax.js"></script>
   <script type="text/javascript" src="/web/building_saas/main/js/main.js"></script>
   <script type="text/javascript" src="/web/building_saas/main/js/controllers/project_controller.js"></script>

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

@@ -599,7 +599,7 @@ var PROJECT = {
                         }
                     }
                 }else if(d.type == ModuleNames.project){
-                    temObj = this;
+                    temObj = d.isInfo?this.projectInfo:this;
                 }else if (d.type == ModuleNames.ration_glj && d.action == "add"){
                     this[d.type].datas.push(d.data);
                     if(d.projectGLJ) this.projectGLJ.loadNewProjectGLJToCache(d.projectGLJ);

+ 123 - 0
web/building_saas/main/js/views/project_property_compare.js

@@ -0,0 +1,123 @@
+let compareObject = {
+    setting:{
+        header: [
+            {headerName: "审定", headerWidth: 240, dataCode: "name", dataType: "String"},
+            {headerName: "送审", headerWidth: 240, dataCode: "compare", dataType: "String"}
+        ],
+        view:{ lockColumns: ["name","compare"]}
+    },
+    initSpread:function(){
+        if(!this.spread){
+            this.spread = SheetDataHelper.createNewSpread($("#compareProjectSpread")[0]);
+            sheetCommonObj.spreadDefaultStyle(this.spread);
+            let sheet = this.spread.getSheet(0);
+            sheetCommonObj.initSheet(sheet,this.setting,0);
+        }else{
+            this.spread.repaint();
+        }
+    },
+    showDatas:function(){
+        this.getCompareDatas();
+        sheetCommonObj.showTreeData(this.spread.getSheet(0), this.setting,this.datas);
+    },
+    datas:[],
+    getCompareDatas:function(){
+        let datas = [];
+        let me = compareObject;
+        let compareID = projectObj.project.projectInfo.compareID;
+        let rootProjectID = projectObj.project.property.rootProjectID;
+        if(gljUtil.isNotEmpty(compareID)){
+            let rootProject = _.find(me.projects,{'ID':rootProjectID});
+            let compareProject = _.find(me.projects,{'ID':compareID});
+            rootProject.compare = compareProject.name;
+            rootProject.matchID = compareID; 
+            rootProject.collapsed = false;
+            datas.push(rootProject);
+
+            setDatas(rootProjectID,compareID,datas);
+        }
+        this.datas = datas;
+        function setDatas(nID,cID,mdatas){
+            let nameMap = {};
+            if(cID && me.parentMap[cID]){
+                for(let c of me.parentMap[cID]){
+                    nameMap[c.name] = c;
+                }
+            }
+            if(me.parentMap[nID]){
+                for(let n of me.parentMap[nID]){
+                    if(nameMap[n.name]){//找到同名的项目时,匹配上
+                       n.compare = n.name;
+                       n.matchID = nameMap[n.name].ID             
+                    }
+                    n.collapsed = false;
+                    mdatas.push(n);
+                    setDatas(n.ID,n.matchID,mdatas)
+                }
+            }
+        }
+    },
+    initProjectDatas:async function(){
+        let projects = await ajaxGet("/project/getCompareProjects");
+        let parentMap=_.groupBy(projects, 'ParentID');
+        for(let key in parentMap){
+            parentMap[key] = sortTreeChildren(parentMap[key]);
+        }
+        compareObject.parentMap = parentMap;
+        compareObject.projects = projects;
+        let rootParjects = parentMap['-1'];
+        let options = [];
+        for(let r of rootParjects){
+            [newPath,project] =  setProjectPath(r,parentMap,"");
+            if(newPath && project)options.push({path:newPath,ID:project.ID})
+        }   
+        compareObject.options = options;
+        let rootProject  = _.find(projects,{'ID':projectObj.project.property.rootProjectID});
+        projectObj.project.projectInfo.compareID = rootProject.compareID;
+
+        function setProjectPath(project,parentMap,namePath){
+            let newPath = project.ParentID == -1?project.name:`${namePath}/${project.name}`;
+            if(project.projType === commonConstants.projectType.Project) return [newPath,project];
+            
+            if(parentMap[project.ID]){
+                for(let c of parentMap[project.ID]){
+                   return setProjectPath(c,parentMap,newPath)
+                }
+            }
+        }
+    },
+    getCompareID:async function(){
+        if(!this.parentMap){
+           await this.initProjectDatas();
+        }
+        this.getCompareDatas();
+        for(let d of this.datas){
+            if(d.ID == projectObj.project.ID()) return d.matchID;
+        }
+        return null;
+    } 
+}
+
+$(document).ready(function () {
+    $('#tab_compare').on('shown.bs.tab', async function () {
+        await compareObject.initProjectDatas();
+        let optionString = `<option value=""></option>`;
+        for(let o of compareObject.options){
+            if(o.ID === projectObj.project.property.rootProjectID) continue;
+            optionString += `<option value="${o.ID}">${o.path}</option>`
+        }
+        $("#audiCompareID").html(optionString);
+        $("#audiCompareID").val(projectObj.project.projectInfo.compareID);
+        compareObject.initSpread();
+        compareObject.showDatas();
+    });
+    $("#audiCompareID").change(async function(){
+        //compareID 保存在建设项目上,为方便使用,获取后挂在projectInfo上
+        let updateData = {type:ModuleNames.project,isInfo:true,data:{'ID' : projectObj.project.property.rootProjectID,compareID:parseInt(this.value)}};//,'property.locateSetting':outstd
+        $.bootstrapLoading.start();
+        await projectObj.project.syncUpdateNodesAndRefresh([updateData]);
+        compareObject.showDatas();
+        $.bootstrapLoading.end();
+    })
+
+})