Browse Source

导入清单bug

zhongzewei 7 years ago
parent
commit
915fd08e56

+ 2 - 1
modules/common/base/base_controller.js

@@ -60,11 +60,12 @@ class BaseController {
         // 获取当前用户消息数量
         let userMessageModel = new UserMessageModel();
         // 消息处理
+        console.log(`sessionUser`);
+        console.log(sessionUser);
         await userMessageModel.initMessage(sessionUser.id);
         // 获取未读数据
         let messageUnreadCount = await userMessageModel.count({user_id: sessionUser.id, is_read: 0, is_delete: 0});
         response.locals.unreadCount = messageUnreadCount;
-
         next();
     }
 }

+ 2 - 0
modules/complementary_ration_lib/models/compleRationModel.js

@@ -141,6 +141,7 @@ class CompleRatoinDao {
     //造价书定额库
     async getRationGljItemsBySection(userId, sectionId, callback){
         try{
+            const perHintHeight = 17.2;
             let stdRations = await stdRationModel.find({sectionId: sectionId, $or: [{isDeleted: null}, {isDeleted: false}]});
             for(let ration of stdRations){
                 ration._doc.type = 'std';
@@ -176,6 +177,7 @@ class CompleRatoinDao {
                     }
                 }
                 ration._doc.hint = hint;
+                ration._doc.hintHeight = ration.rationGljList.length * perHintHeight;//控制定额库悬浮提示位置
             }
             callback(0, rations);
         }

+ 28 - 8
modules/main/controllers/bills_controller.js

@@ -200,7 +200,7 @@ module.exports = {
                 if (sheet[0] === undefined || sheet[0].data === undefined) {
                     throw 'excel没有对应数据';
                 }
-                //导入的数据是否含有固定行(分部分项、施工技术措施项目、施工组织措施项目)
+                //导入的数据是否含有固定行(分部分项、施工技术措施项目、施工组织措施项目,通过文件名判断)
                 let flag = getImportFlag(file.originalFilename);
                 if(!flag){
                     throw 'excel数据错误';
@@ -232,6 +232,8 @@ module.exports = {
                     await billsData.model.create(insertFixedBill);
                     fixedBill = insertFixedBill;
                 }
+                console.log(`fixedBill--------------`);
+                console.log(fixedBill);
                 //匹配的清单库
                 const billsLibId = fields.billsLibId !== undefined && fields.billsLibId.length > 0 && fields.billsLibId[0]? parseInt(fields.billsLibId[0]) : null;
                 let stdBills = [], stdJobs = [], stdCharacters = [];
@@ -241,7 +243,7 @@ module.exports = {
                     stdCharacters = await stdBillCharacterModel.find({billsLibId: billsLibId, deleted: false});
                 }
                 //将excel数据转换成清单树结构数据
-                let insertDatas = parseToBillData(getValidImportData(sheet[0].data), getColMapping(sheet[0].data), fixedBill, projectID, {stdBills: stdBills, stdJobs: stdJobs, stdCharacters: stdCharacters});
+                let insertDatas = parseToBillData(getValidImportData(sheet[0].data, fixedBill), getColMapping(sheet[0].data), fixedBill, projectID, {stdBills: stdBills, stdJobs: stdJobs, stdCharacters: stdCharacters});
                 //删除相关数据
                 let deleteDatas = await billsData.deepDeleteBill([fixedBill], req.session.sessionUser.id);
                 //新增清单数据
@@ -305,8 +307,10 @@ function rowExistData(rowData){
     }
     return false;
 }
-//提取excel表数据中的有效数据(去表头表尾,提取其中的excel数据)
-function getValidImportData(sheetData){
+//提取excel表数据中的有效数据(去表头表尾,提取其中的excel数据)(根据fixedBill获取栏头占行数)
+function getValidImportData(sheetData, fixedBill){
+    console.log(`sheetData`);
+    console.log(sheetData);
     let withingD = false;
     let validData = [];
     for(let r = 0; r < sheetData.length; r++){
@@ -317,7 +321,9 @@ function getValidImportData(sheetData){
             //表头
             if(rData[0] === '序号'){
                 withingD = true;
-                r++;
+                if(fixedBill.name !== '施工组织措施项目'){
+                    r++;
+                }
                 continue;
             }
             //表尾
@@ -325,10 +331,16 @@ function getValidImportData(sheetData){
                 withingD = false;
             }
         }
+        /*console.log(`rData`);
+        console.log(rData);
+        console.log(withingD);
+        console.log(rowExistData(rData));*/
         if(withingD && rowExistData(rData)){
             validData.push(rData);
         }
     }
+    /*console.log(`validData`);
+    console.log(validData);*/
     return validData;
 }
 
@@ -358,7 +370,7 @@ function parseToBillData(validData, colMapping, fixedBill, projectID, stdData){
     }
     //续数据,上一行数据是有效节点且无序号
     function isExtend(preData, rData){
-        return preData && (isRoot(preData) || isLeaf(preData)) && (rData[colMapping.serialNo] === undefined || rData[colMapping.serialNo] === '');
+        return preData && (isRoot(preData) || isLeaf(preData)) &&  !isRoot(rData) && (rData[colMapping.serialNo] === undefined || rData[colMapping.serialNo] === '');
     }
     function getBillType(rData, flag){
         if(flag === fixedFlag.CONSTRUCTION_TECH || flag === fixedFlag.CONSTRUCTION_ORGANIZATION){
@@ -371,12 +383,14 @@ function parseToBillData(validData, colMapping, fixedBill, projectID, stdData){
     }
     //excel数据与标准库数据匹配,根据清单前九位编码匹配,匹配成功则获取标准清单对应的工程专业、特征及内容
     function matchStdBill(excelBill, stdData){
+        let isMatch = false;
         let regExp = /^\d{12}$/g;
         if(regExp.test(excelBill.code)){
             let nineCode = excelBill.code.substr(0, 9);
             for(let stdBill of stdData.stdBills){
                 //set programID
                 if(nineCode == stdBill.code){
+                    isMatch = true;
                     excelBill.programID = stdBill.engineering ? stdBill.engineering : null;
                     //set jobContent and itemCharacter
                     let tempJob = [], tempCharacter = [];
@@ -403,6 +417,9 @@ function parseToBillData(validData, colMapping, fixedBill, projectID, stdData){
                 }
             }
         }
+        if(!isMatch && excelBill.type === billType.FX){//分项在标准清单中不匹配,则识别为补项
+                excelBill.type = billType.BX;
+        }
     }
     for(let r = 0; r < validData.length; r++){
         let preData = validData[r-1],
@@ -450,8 +467,9 @@ function parseToBillData(validData, colMapping, fixedBill, projectID, stdData){
                 programID: null,
                 unit: rData[colMapping.unit] ? rData[colMapping.unit] : '',
                 quantity: rData[colMapping.quantity] ? rData[colMapping.quantity] : '',
-                flags: fixedBill.flags[0].flag === fixedFlag.CONSTRUCTION_ORGANIZATION && rData[colMapping.name] === '安全文明施工专项费用' ?
-                    [{fieldName: 'fixed', flag: fixedBill.flags[0].flag}] : [],
+                //安全文明
+                flags: fixedBill.flags[0].flag === fixedFlag.CONSTRUCTION_ORGANIZATION && (rData[colMapping.name] === '安全文明施工专项费用' || rData[colMapping.name] === '安全文明施工费') ?
+                    [{fieldName: 'fixed', flag: fixedFlag.SAFETY_CONSTRUCTION}] : [],
                 fees: [],
                 projectID: projectID,
                 type: getBillType(rData, fixedBill.flags[0].flag)};
@@ -470,6 +488,8 @@ function parseToBillData(validData, colMapping, fixedBill, projectID, stdData){
     for(let i in billIdx){
         rst.push(billIdx[i]);
     }
+    console.log('rst');
+    console.log(rst);
     return rst;
 }
 

+ 0 - 1
modules/pm/controllers/pm_controller.js

@@ -195,7 +195,6 @@ module.exports = {
         let rationValuation = sessionCompilation.ration_valuation !== undefined ?
             sessionCompilation.ration_valuation : [];
         rationValuation = await engineeringLibModel.getLib(rationValuation);
-
         let renderData = {
             userAccount: request.session.userAccount,
             userID: request.session.sessionUser.id,

+ 13 - 1
public/web/sheet/sheet_data_helper.js

@@ -118,6 +118,7 @@ var SheetDataHelper = {
     loadSheetData: function (setting, sheet, datas) {
         SheetDataHelper.protectdSheet(sheet);
 
+
         let TipCellType = function () {};
         TipCellType.prototype = new GC.Spread.Sheets.CellTypes.Text();
         TipCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
@@ -135,6 +136,9 @@ var SheetDataHelper = {
         TipCellType.prototype.processMouseEnter = function (hitinfo) {
             let text = hitinfo.sheet.getText(hitinfo.row, hitinfo.col);
             let tag = hitinfo.sheet.getTag(hitinfo.row, hitinfo.col);
+            let hintHeight = datas[hitinfo.row] ?
+                                datas[hitinfo.row].hintHeight ? datas[hitinfo.row].hintHeight : null
+                            : null; //定额库定额悬浮提示位置相关
             if(tag !== undefined && tag){
                 text = tag;
             }
@@ -154,8 +158,15 @@ var SheetDataHelper = {
                         document.body.insertBefore(div, null);
                     }
                     this._toolTipElement = div;
-                    $(this._toolTipElement).html(text).css("top", setting.pos.y + hitinfo.y + 15).css("left", setting.pos.x + hitinfo.x + 15);
+                    $(this._toolTipElement).html(text);
+                    if(hintHeight){
+                        $(this._toolTipElement).css("top", setting.pos.y  + hitinfo.y - hintHeight).css("left", setting.pos.x + hitinfo.x + 15);
+                    }
+                    else{
+                        $(this._toolTipElement).css("top", setting.pos.y + hitinfo.y +15).css("left", setting.pos.x + hitinfo.x + 15);
+                    }
                     $(this._toolTipElement).show("fast");
+                    TREE_SHEET_HELPER.tipDiv = 'show';//做个标记
                 }
             }
         };
@@ -164,6 +175,7 @@ var SheetDataHelper = {
                 $(this._toolTipElement).hide();
                 this._toolTipElement = null;
             }
+            TREE_SHEET_HELPER.tipDivCheck();//延时检查:当tips正在show的时候,就调用了hide方法,会导致tips一直存在,所以设置一个超时处理
         }
 
         sheet.suspendPaint();

+ 3 - 1
web/building_saas/main/js/controllers/project_controller.js

@@ -30,8 +30,10 @@ ProjectController = {
             });
             for(let newNode of newNodes){
                 sc.sheet.addRows(newNode.serialNo(), 1);
-               // TREE_SHEET_HELPER.refreshTreeNodeData(sc.setting, sc.sheet, [newNode], false);
+            }
+            for(let newNode of newNodes){
                 sc.setTreeSelected(newNode);
+                TREE_SHEET_HELPER.refreshTreeNodeData(sc.setting, sc.sheet, [newNode], false);
                 sc.sheet.setSelection(newNode.serialNo(), sels[0].col, 1, 1);
                 sc.sheet.showRow(newNode.serialNo(), GC.Spread.Sheets.VerticalPosition.center);
             }

+ 2 - 2
web/building_saas/pm/html/project-management.html

@@ -124,7 +124,7 @@
 
                         <legend>单价文件</legend>
                         <table class="table table-bordered table-hover table-sm" id="summary-project-unit-price-table">
-                            <thead><th></th><th>名称</th><th width="50">使用</th></thead>
+                            <thead><th style="width: 25px;"></th><th style="width: 330px;">名称</th><th style="width:40px;">使用</th></thead>
                             <tbody>
                             <tr><td>1</td><td>A单价文件</td></tr>
                             <tr><td>2</td><td>B单价文件</td></tr>
@@ -135,7 +135,7 @@
 
                         <legend>费率文件</legend>
                         <table class="table table-bordered table-hover table-sm" id="summary-project-fee-table">
-                            <thead><th></th><th>名称</th><th width="50">使用</th></thead>
+                            <thead><th style="width: 25px;"></th><th style="width: 330px;">名称</th><th style="width:40px;">使用</th></thead>
                             <tbody>
                             <tr><td>1</td><td>A费率文件</td></tr>
                             <tr><td>2</td><td>B费率文件</td></tr>

+ 0 - 1
web/building_saas/pm/js/pm_newMain.js

@@ -107,7 +107,6 @@ const projTreeObj = {
                 allowResizeRows: true,
                 allowResizeColumns: true
             };
-            sheet.setColumnCount(headers.length);
             sheet.setRowHeight(0, 40, GC.Spread.Sheets.SheetArea.colHeader);
             for(let i = 0, len = headers.length; i < len; i++){
                 sheet.setValue(0, i, headers[i].name, GC.Spread.Sheets.SheetArea.colHeader);