瀏覽代碼

批量导入

zhongzewei 7 年之前
父節點
當前提交
6253412c87

+ 110 - 94
modules/main/controllers/bills_controller.js

@@ -200,12 +200,12 @@ module.exports = {
         }
 
     },
-
+    //导入清单
     upload: async function(req, res){
         let responseData = {
             err: 0,
             msg: '',
-            data: null
+            data: []
         };
         const allowHeader = ['application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'];
         const uploadOption = {
@@ -230,79 +230,50 @@ module.exports = {
                 }
                 //导入表类型(09表lj、广联达gld)
                 const fileType = fields.fileType !== undefined && fields.fileType.length > 0 ? fields.fileType[0] : uploadType.lj;
-                //广联达表始终插入到分部分项,将文件名重命名为分部分项触发导入到分部分项部分
-                if(fileType === uploadType.gld){
-                    file.originalFilename = '广联达分部分项工程';
-                }
                 // 重命名文件名
                 uploadFullName = uploadOption.uploadDir + '/' + file.originalFilename;
                 fs.renameSync(file.path, uploadFullName);
 
-                const sheet = excel.parse(uploadFullName);
-                if (sheet[0] === undefined || sheet[0].data === undefined) {
+                const sheets = excel.parse(uploadFullName);
+                if (sheets[0] === undefined || sheets[0].data === undefined) {
                     throw 'excel没有对应数据';
                 }
-                //获取表的列设置确定导入的格式是否合法(09、广联达)
-               //console.log(sheet[0].data);
-                let colMapping = getColMapping(sheet[0].data);
-                console.log(fileType);
-                console.log(`colMapping`);
-                console.log(colMapping);
-                console.log(`sheet[0].data`);
-                console.log(sheet[0].data);
-                if(!isValidSheet(colMapping, fileType)){
-                    throw `excel数据格式错误`;
-                }
-
-                //导入的数据是否含有固定行(分部分项、施工技术措施项目、施工组织措施项目,通过文件名判断)、确定导入位置
-                let flag = getImportFlag(file.originalFilename);
-                if(!flag){
-                    throw 'excel数据错误';
-                }
-                let fixedBill = await billsData.model.findOne({projectID: projectID, 'flags.flag': flag, deleteInfo: null});
-                let insertFixedBill = null;
-
-                let vData = getValidImportData(colMapping, sheet[0].data, fixedBill);
-                console.log(`vData`);
-                console.log(vData);
-                for(let rData of vData){
-                    let t = {};
-                    t.serialNo = rData[colMapping.serialNo];
-                    t.code = rData[colMapping.code];
-                    t.name = rData[colMapping.name];
-                    t.itemCharacterText = rData[colMapping.itemCharacterText];
-                    t.unit = rData[colMapping.unit];
-                    t.quantity = rData[colMapping.quantity];
-                    console.log(t);
-                }
-               // throw 'test';
-                //导入xx措施项目,若不存在此固定清单,则先插入相关固定清单
-                if(!fixedBill){
-                    //分部分项工程(不可删除)应存在
-                    if(flag === fixedFlag.SUB_ENGINERRING){
-                        throw '项目不存在分部分项工程'
+                //出现错误的表表名,前端提示用
+                let invalidSheets = [];
+                let validSheets = {fbfx: [], jscsxm: [], zzcsxm: []};
+                //获得选择的导入的表及导入位置
+                const uploadWorkBook = fields.uploadWorkBook !== undefined && fields.uploadWorkBook.length > 0 ? JSON.parse(fields.uploadWorkBook[0]) : [];
+                //识别非法和合法表,sheetInfo存储前端勾选的表的位置索引以及选择的导入位置
+                for(let sheetInfo of uploadWorkBook){
+                    let sheet = sheets[sheetInfo.sheetIdx];
+                    if(sheet.data === undefined){
+                        invalidSheets.push(sheet.name);
+                        continue;
                     }
-                    //措施项目是否存在
-                    let csxm = await billsData.model.findOne({projectID: projectID, 'flags.flag': fixedFlag.MEASURE, deleteInfo: null});
-                    if(!csxm){
-                        throw '项目不存在措施项目'
+                    //获取表的列设置确定导入的格式是否合法(09、广联达)
+                    let colMapping = getColMapping(sheet.data);
+                    if(!isValidSheet(colMapping, fileType)){
+                        invalidSheets.push(sheet.name);
+                        continue;
                     }
-                    //插入清单固定行(施工技术措施项目、施工组织措施项目可删除)
-                    insertFixedBill = {projectID: projectID, name: flag === fixedFlag.CONSTRUCTION_TECH ? '施工技术措施项目' : '施工组织措施项目', code: '1',
-                        ID: uuidV1(), NextSiblingID: -1, ParentID: csxm.ID, flags: [{fieldName: 'fixed', flag: flag}], type: billType.BILL};
-                    //更新前节点
-                    let preDatas = await billsData.model.find({projectID: projectID, ParentID: csxm.ID, deleteInfo: null});
-                    for(let preData of preDatas){
-                        if(preData.NextSiblingID == -1){
-                            await billsData.model.update({ID: preData.ID}, {$set: {NextSiblingID: insertFixedBill.ID}});
-                            break;
-                        }
+                    //合法的表
+                    sheet.colMapping = colMapping;
+                    //将合法的表按导入位置分类当做一个表来处理
+                    if(validSheets[sheetInfo.position] !== undefined){
+                        validSheets[sheetInfo.position].push(sheet)
+                    }
+                }
+                //合并同类表并提取表的有效数据
+                let toImportSheets = [];
+                for(let uploadPosition in validSheets){
+                    let validExcelData = [];
+                    for(let uSheet of validSheets[uploadPosition]){
+                        validExcelData = validExcelData.concat(getValidImportData(uSheet.colMapping, uSheet.data))
+                    }
+                    if(validSheets[uploadPosition].length > 0){
+                        toImportSheets.push({position: uploadPosition, colMapping: validSheets[uploadPosition][0].colMapping, validExcelData: validExcelData});
                     }
-                    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 = [];
@@ -311,22 +282,21 @@ module.exports = {
                     stdJobs = await stdBillJobsModel.find({billsLibId: billsLibId, deleted: false});
                     stdCharacters = await stdBillCharacterModel.find({billsLibId: billsLibId, deleted: false});
                 }
-                //将excel数据转换成清单树结构数据
-                let insertDatas = parseToBillData(getValidImportData(colMapping, sheet[0].data, fixedBill), colMapping, fixedBill, projectID, {stdBills: stdBills, stdJobs: stdJobs, stdCharacters: stdCharacters});
-                console.log(`insertDatas`);
-                console.log(insertDatas);
-                if(insertDatas.length === 0){
+                let stdData = {stdBills: stdBills, stdJobs: stdJobs, stdCharacters: stdCharacters};
+                //导入表
+                for(let importData of toImportSheets){
+                    let updateFrontData = await importSheet(importData, req.session.sessionUser.id, projectID, stdData);
+                    if(updateFrontData){
+                        responseData.data.push(updateFrontData);
+                    }
+                }
+                if(responseData.data.length === 0){
                     throw 'excel无有效数据';
                 }
-                //删除相关数据
-                let deleteDatas = await billsData.deepDeleteBill([fixedBill], req.session.sessionUser.id);
-                //新增清单数据
-                await billsData.importBills(insertDatas);
-                //返回数据以更新前端
-                if(insertFixedBill){
-                    insertDatas.push(insertFixedBill);
+                if(invalidSheets.length > 0){
+                    let msg = invalidSheets.join('、');
+                    responseData.msg = `${msg},导入失败`;
                 }
-                responseData.data = {fixedBill: fixedBill, insert: {bill: insertDatas, ration: []}, remove: {bill: deleteDatas.bill, ration: deleteDatas.ration}};
                 //删除暂存文件
                 fs.unlink(uploadFullName);
                 res.json(responseData);
@@ -343,13 +313,63 @@ module.exports = {
 
         });
     }
-
 };
 
+//
+async function importSheet(importData, userID, projectID, stdData){
+        //导入位置的有固定行
+        let flag = getImportFlag(importData.position);
+        if(!flag){
+            throw 'excel数据错误';
+        }
+        let fixedBill = await billsData.model.findOne({projectID: projectID, 'flags.flag': flag, deleteInfo: null});
+        let insertFixedBill = null;
+        //导入xx措施项目,若不存在此固定清单,则先插入相关固定清单
+        if(!fixedBill){
+            //分部分项工程(不可删除)应存在
+            if(flag === fixedFlag.SUB_ENGINERRING){
+                throw '项目不存在分部分项工程'
+            }
+            //措施项目是否存在
+            let csxm = await billsData.model.findOne({projectID: projectID, 'flags.flag': fixedFlag.MEASURE, deleteInfo: null});
+            if(!csxm){
+                throw '项目不存在措施项目'
+            }
+            //插入清单固定行(施工技术措施项目、施工组织措施项目可删除)
+            insertFixedBill = {projectID: projectID, name: flag === fixedFlag.CONSTRUCTION_TECH ? '施工技术措施项目' : '施工组织措施项目', code: '1',
+                ID: uuidV1(), NextSiblingID: -1, ParentID: csxm.ID, flags: [{fieldName: 'fixed', flag: flag}], type: billType.BILL};
+            //更新前节点
+            let preDatas = await billsData.model.find({projectID: projectID, ParentID: csxm.ID, deleteInfo: null});
+            for(let preData of preDatas){
+                if(preData.NextSiblingID == -1){
+                    await billsData.model.update({ID: preData.ID}, {$set: {NextSiblingID: insertFixedBill.ID}});
+                    break;
+                }
+            }
+            await billsData.model.create(insertFixedBill);
+            fixedBill = insertFixedBill;
+        }
+        //将excel数据转换成清单树结构数据
+        let insertDatas = parseToBillData(importData.validExcelData, importData.colMapping, fixedBill, projectID, stdData);
+        /*if(insertDatas.length === 0){
+            throw 'excel无有效数据';
+        }*/
+        if(insertDatas.length === 0){
+            return null;
+        }
+        //删除相关数据
+        let deleteDatas = await billsData.deepDeleteBill([fixedBill], userID);
+        //新增清单数据
+        await billsData.importBills(insertDatas);
+        //返回数据以更新前端
+        if(insertFixedBill){
+            insertDatas.push(insertFixedBill);
+        }
+        return {fixedBill: fixedBill, insert: {bill: insertDatas, ration: []}, remove: {bill: deleteDatas.bill, ration: deleteDatas.ration}};
+}
+
 //是否是有效的表头列格式,只要含有各表需要的列就行,不严格控制多少列
 function isValidSheet(colMapping, fileType){
-    //09表:序号、项目编码、项目名称、项目特征、计量单位、工程量、金额
-    let isValid = true;
     function hasField(field, all){
         for(let i of all){
             if(field === i){
@@ -360,9 +380,11 @@ function isValidSheet(colMapping, fileType){
     }
     let needFields;
     if(fileType === uploadType.lj){
+        //09表:序号、项目编码、项目名称、项目特征、计量单位、工程量、金额
         needFields = ['serialNo', 'code', 'name', 'money'];
     }
     else {
+        //广联达表:序号、项目编码、项目名称、项目特征、计量单位、工程量、工程量明细、费用明细
         needFields = ['serialNo', 'code', 'name', 'itemCharacterText', 'unit', 'quantity', 'quantityDetail', 'feeDetail'];
     }
     let hasFieldCount = 0;
@@ -372,7 +394,6 @@ function isValidSheet(colMapping, fileType){
         }
     }
     return hasFieldCount === needFields.length;
-    //广联达表:序号、项目编码、项目名称、项目特征、计量单位、工程量、工程量明细、费用明细
 }
 
 //提取excel表头列对应数据
@@ -390,9 +411,9 @@ function getColMapping(sheetData){
         }
         return [];
     }
-    let headRow = getHeadRow(sheetData);
     //获取需要的表头列与列号对应关系
     let colMapping = {};
+    let headRow = getHeadRow(sheetData);
     for(let c = 0; c < headRow.length; c++){
         if(headRow[c]){
             headRow[c] = headRow[c].toString().replace(/\s/g, '');
@@ -438,7 +459,7 @@ function rowExistData(rowData){
     return false;
 }
 //提取excel表数据中的有效数据(去表头表尾,提取其中的excel数据)(根据fixedBill获取栏头占行数)
-function getValidImportData(colMapping, sheetData, fixedBill){
+function getValidImportData(colMapping, sheetData){
     let withingD = false;
     let validData = [];
     function isHead(rData){
@@ -459,9 +480,9 @@ function getValidImportData(colMapping, sheetData, fixedBill){
         let rData = sheetData[r];
         if(isHead(rData)){
             withingD = true;
-            if(fixedBill.name !== '施工组织措施项目'){
+          /*  if(fixedBill.name !== '施工组织措施项目'){
                 r++;
-            }
+            }*/
             continue;
         }
         else if(isTail(rData)){
@@ -493,14 +514,9 @@ function getValidImportData(colMapping, sheetData, fixedBill){
     return validData;
 }
 
-function getImportFlag(sheetName){
-    const fixedItem = {'分部分项': fixedFlag.SUB_ENGINERRING, '施工技术措施项目': fixedFlag.CONSTRUCTION_TECH, '施工组织措施项目': fixedFlag.CONSTRUCTION_ORGANIZATION};
-    for(let flag in fixedItem){
-        if(sheetName.includes(flag)){
-            return fixedItem[flag];
-        }
-    }
-    return null;
+function getImportFlag(position){
+    const fixedItem = {'fbfx': fixedFlag.SUB_ENGINERRING, 'jscsxm': fixedFlag.CONSTRUCTION_TECH, 'zzcsxm': fixedFlag.CONSTRUCTION_ORGANIZATION};
+    return fixedItem[position] ? fixedItem[position] : null;
 }
 function isDef(data){
     return typeof data !== 'undefined' && data !== null && data !== '';

+ 1 - 1
public/web/PerfectLoad.js

@@ -27,7 +27,7 @@ jQuery.bootstrapLoading = {
             //提示颜色
             delayTime: 500,
             //页面加载完成后,加载页面渐出速度
-            zindex: 999,
+            zindex: 2000,
             //loading页面层次
             sleep: 0
             //设置挂起,等于0时则无需挂起

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

@@ -1214,6 +1214,8 @@
                         广东XXXX项目清单.xlsx 准备导入上传
                     </div>
                     <button style="margin-top: 2px;" type="button" class="btn btn-primary" id="uploadExample">示例</button>
+                   <!-- <div id="uploadSheets" style="display: none; border-top: 1px solid #CED4DA;border-left: 1px solid #CED4DA;border-radius: 5px;margin-top: 5px;"></div>-->
+                    <div id="uploadSheets"></div>
                 </div>
                 <div class="modal-footer">
                     <a href="javascript:void(0);" class="btn btn-primary" id="uploadConfirm">确定导入</a>
@@ -1269,6 +1271,7 @@
         <!--<script src="/lib/spreadjs/views/common/gc.spread.common.10.0.0.min.js" type="text/javascript"></script>-->
         <script src="/lib/spreadjs/views/plugins/gc.spread.views.gridlayout.10.0.0.min.js" type="text/javascript"></script>
         <script>GC.Spread.Views.LicenseKey = "559432293813965#A0y3iTOzEDOzkjMyMDN9UTNiojIklkI1pjIEJCLi4TPB9mM5AFNTd4cvZ7SaJUVy3CWKtWYXx4VVhjMpp7dYNGdx2ia9sEVlZGOTh7NRlTUwkWR9wEV4gmbjBDZ4ElR8N7cGdHVvEWVBtCOwIGW0ZmeYVWVr3mI0IyUiwCMzETN8kzNzYTM0IicfJye&Qf35VfiEzRwEkI0IyQiwiIwEjL6ByUKBCZhVmcwNlI0IiTis7W0ICZyBlIsIyNyMzM5ADI5ADNwcTMwIjI0ICdyNkIsIibj9SbvNmL4N7bjRnch56ciojIz5GRiwiI8+Y9sWY9QmZ0Jyp96uL9v6L0wap9biY9qiq95q197Wr9g+89iojIh94Wiqi";</script>
+        <script src="/lib/js-xlsx/xlsx.core.min.js"></script>
         <!-- inject:js -->
         <!--<script type="text/javascript" src="/test/tmp_data/test_ration_calc/ration_calc_base.js"></script>-->
         <script type="text/javascript" src="/web/building_saas/main/js/models/main_consts.js"></script>

+ 163 - 67
web/building_saas/main/js/views/project_view.js

@@ -1972,6 +1972,59 @@ $('#uploadGld').click(function () {
    fileType = uploadType.gld;
 });
 
+//设置导入表内容
+function setUploadSheets(sheetNames){
+    let sheetArea = $('#uploadSheets');
+    $('#uploadSheets').height('');
+    sheetArea.empty();
+    for(let sheetName of sheetNames){
+        let sheetDiv = $(`<div style="margin-left: 5px;margin-top: 5px;" class="input-group form-check"><label class="form-check-label" style="width:270px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis">
+                           <input class="form-check-input" type="checkbox">${sheetName}</label></div>`);
+        sheetDiv.find('input[type="checkbox"]').click(function () {
+            if($('#uploadAlert').is(':visible')){
+                $('#uploadAlert').hide();
+            }
+        });
+        let sel = $(`<select style="margin-left: 5px; border-radius: .20rem;"><option value="fbfx">分部分项工程</option><option value="zzcsxm">施工组织措施项目</option><option value="jscsxm">施工技术措施项目</option></select>`);
+        if(sheetName.includes('分部分项工程项目清单计价表')){
+            sheetDiv.find('input[type="checkbox"]').prop('checked', true);
+            sel.find('option:eq(0)').prop('selected', true);
+        }
+        else if(sheetName.includes('施工组织措施项目清单计价表')){
+            sheetDiv.find('input[type="checkbox"]').prop('checked', true);
+            sel.find('option:eq(1)').prop('selected', true);
+        }
+        else if(sheetName.includes('施工技术措施项目清单计价表')){
+            sheetDiv.find('input[type="checkbox"]').prop('checked', true);
+            sel.find('option:eq(2)').prop('selected', true);
+        }
+        sheetDiv.append(sel);
+        sheetArea.append(sheetDiv);
+
+    }
+    if(sheetNames.length > 0){
+        sheetArea.show();
+    }
+    if($('#uploadSheets').height() > 250){
+        console.log('aa');
+        sheetArea.css('overflow', 'auto');
+        sheetArea.height(250);
+    }
+    else {
+        sheetArea.css('overflow', 'hidden');
+    }
+}
+//获得选择导入的表信息(表索引及导入位置)
+function getUploadSheets(){
+    let rst = [];
+    let sheetArea = $('#uploadSheets');
+    let checkedInputs = sheetArea.find('input:checked');
+    for(let checked of checkedInputs){
+        rst.push({sheetIdx: $(checked).parent().parent().index(), position: $(checked).parent().next().select().val()})
+    }
+    return rst;
+}
+
 //选择要导入的excel文件
 $('#customFile').change(function () {
     let file = $(this)[0];
@@ -1979,6 +2032,31 @@ $('#customFile').change(function () {
         $('.custom-file-label').text(`${file.files[0].name} 准备导入上传`);
         $('#uploadAlert').hide();
         console.log(file.files);
+        //读取各个表及表名
+        $.bootstrapLoading.start();
+        let fileReader = new FileReader();
+        fileReader.onload = function(ev) {
+            console.log('enter');
+            try {
+                let data = ev.target.result;
+                // 以二进制流方式读取得到整份excel表格对象
+                let workbook = XLSX.read(data, {type: 'binary'});
+                // 遍历每张表读取
+                let sheetNames = [];
+                for (let sheetName in workbook.Sheets) {
+                    sheetNames.push(sheetName);
+                }
+                setUploadSheets(sheetNames);
+                $.bootstrapLoading.end();
+            } catch (e) {
+                console.log(e);
+                $.bootstrapLoading.end();
+                alert('文件类型不正确');
+                return;
+            }
+        };
+        // 以二进制方式打开文件
+        fileReader.readAsBinaryString(file.files[0]);
     }
     else{
         $('.custom-file-label').text(`请选择上传文件`);
@@ -2001,6 +2079,12 @@ $('#uploadConfirm').click(function () {
         }
         //导入表类型(09lj、广联达gld)
         formData.append('fileType', fileType);
+        //选择的表及导入位置
+        let uploadWorkBook = getUploadSheets();
+        if(uploadWorkBook.length === 0){
+            throw '请选择要导入的表';
+        }
+        formData.append('uploadWorkBook', JSON.stringify(uploadWorkBook));
         formData.append('projectID', projectID);
         //要去匹配的清单库(第一个)
         let matchBillLibId = projectInfoObj.projectInfo.engineeringInfo.bill_lib.length > 0 ? projectInfoObj.projectInfo.engineeringInfo.bill_lib[0].id : null;
@@ -2060,75 +2144,81 @@ function showUploadAlert(success, msg){
     $('#uploadAlert').text(msg);
     $('#uploadAlert').show();
 }
+//导入清单到一个固定行位置后,更新数据
+function doAfterImportPosition(positionData){
+    let nodes = projectObj.project.mainTree.nodes;
+    let bills_datas = projectObj.project.Bills.datas;
+    let ration_datas = projectObj.project.Ration.datas;
+    let quantity_detail_datas = projectObj.project.quantity_detail.datas;
+    let ration_glj_datas = projectObj.project.ration_glj.datas;
+    let ration_coe_datas = projectObj.project.ration_coe.datas;
+    let ration_install_datas = projectObj.project.ration_installation.datas;
+    let delNodes = [];
+    for(let billID of positionData.remove.bill){
+        if(nodes['id_' + billID]){
+            delNodes.push(nodes['id_' + billID]);
+        }
+        //清除清单数据
+        _.remove(bills_datas, {ID: billID});
+        //清除清单工程量明细数据
+        _.remove(quantity_detail_datas, {billID: billID});
+    }
+    for(let rationID of positionData.remove.ration){
+        //清除定额数据
+        _.remove(ration_datas, {ID: rationID});
+        //清除定额下的相关数据
+        _.remove(ration_glj_datas, {rationID: rationID});
+        _.remove(ration_coe_datas, {rationID: rationID});
+        _.remove(ration_install_datas, {rationID: rationID});
+        _.remove(quantity_detail_datas, {rationID: rationID});
+
+    }
+    //删除节点
+    if(delNodes.length > 0){
+        //通过固定清单获得删除节点的起始行索引
+        let beginRow = null;
+        if(positionData.fixedBill){
+            let fixedNode = nodes['id_' + positionData.fixedBill.ID];
+            if(fixedNode){
+                beginRow = projectObj.project.mainTree.items.indexOf(fixedNode) + 1;
+            }
+        }
+        //删除主树节点
+        projectObj.mainController.m_delete(delNodes, beginRow);
+        //删除清单树节点
+        let delIdNodes = [];
+        for(let delNode of delNodes){
+            delIdNodes.push(delNode.source);
+        }
+        projectObj.project.Bills.tree.m_delete(delIdNodes);
+    }
+    if(positionData.insert.bill.length > 0){
+        //设置flagsIndex
+        for(let insertBill of positionData.insert.bill){
+            insertBill.flagsIndex = {};
+            if (insertBill.flags) {
+                insertBill.flags.forEach(function (flag) {
+                    insertBill.flagsIndex[flag.fieldName] = flag;
+                });
+            }
+        }
+        //插入清单节点
+        projectObj.project.Bills.tree.insertByDatas(positionData.insert.bill);
+        //插入主树节点
+        let newNodes = projectObj.project.mainTree.insertByDatas(positionData.insert.bill);
+        for(let node of newNodes){
+            node.source = projectObj.project.Bills.tree.nodes['id_' + node.getID()];
+            node.data = node.source.data;
+            node.sourceType = projectObj.project.Bills.getSourceType();
+        }
+        ProjectController.syncDisplayNewNodes(projectObj.mainController, newNodes);
+    }
+}
 //导入后更新操作
 function doAfterImport(resData){
-    if(resData){
-        let nodes = projectObj.project.mainTree.nodes;
-        let bills_datas = projectObj.project.Bills.datas;
-        let ration_datas = projectObj.project.Ration.datas;
-        let quantity_detail_datas = projectObj.project.quantity_detail.datas;
-        let ration_glj_datas = projectObj.project.ration_glj.datas;
-        let ration_coe_datas = projectObj.project.ration_coe.datas;
-        let ration_install_datas = projectObj.project.ration_installation.datas;
-        let delNodes = [];
-        for(let billID of resData.remove.bill){
-            if(nodes['id_' + billID]){
-                delNodes.push(nodes['id_' + billID]);
-            }
-            //清除清单数据
-            _.remove(bills_datas, {ID: billID});
-            //清除清单工程量明细数据
-            _.remove(quantity_detail_datas, {billID: billID});
-        }
-        for(let rationID of resData.remove.ration){
-            //清除定额数据
-            _.remove(ration_datas, {ID: rationID});
-            //清除定额下的相关数据
-            _.remove(ration_glj_datas, {rationID: rationID});
-            _.remove(ration_coe_datas, {rationID: rationID});
-            _.remove(ration_install_datas, {rationID: rationID});
-            _.remove(quantity_detail_datas, {rationID: rationID});
-
-        }
-        //删除节点
-        if(delNodes.length > 0){
-            //通过固定清单获得删除节点的起始行索引
-            let beginRow = null;
-            if(resData.fixedBill){
-                let fixedNode = nodes['id_' + resData.fixedBill.ID];
-                if(fixedNode){
-                    beginRow = projectObj.project.mainTree.items.indexOf(fixedNode) + 1;
-                }
-            }
-            //删除主树节点
-            projectObj.mainController.m_delete(delNodes, beginRow);
-            //删除清单树节点
-            let delIdNodes = [];
-            for(let delNode of delNodes){
-                delIdNodes.push(delNode.source);
-            }
-            projectObj.project.Bills.tree.m_delete(delIdNodes);
-        }
-        if(resData.insert.bill.length > 0){
-            //设置flagsIndex
-            for(let insertBill of resData.insert.bill){
-                insertBill.flagsIndex = {};
-                if (insertBill.flags) {
-                    insertBill.flags.forEach(function (flag) {
-                        insertBill.flagsIndex[flag.fieldName] = flag;
-                    });
-                }
-            }
-            //插入清单节点
-            projectObj.project.Bills.tree.insertByDatas(resData.insert.bill);
-            //插入主树节点
-            let newNodes = projectObj.project.mainTree.insertByDatas(resData.insert.bill);
-            for(let node of newNodes){
-                node.source = projectObj.project.Bills.tree.nodes['id_' + node.getID()];
-                node.data = node.source.data;
-                node.sourceType = projectObj.project.Bills.getSourceType();
-            }
-            ProjectController.syncDisplayNewNodes(projectObj.mainController, newNodes);
+    if(resData && resData.length > 0){
+        for(let positionData of resData){
+            doAfterImportPosition(positionData);
         }
         //如果清单未锁定,导入后锁定清单
         if(!projectInfoObj.projectInfo.property.lockBills){
@@ -2156,6 +2246,12 @@ $(function () {
         $('.custom-file-label').text(`请选择上传文件`);
     });
 
+    $('#import').on('hidden.bs.modal', function () {
+        //恢复选择表高度
+        $('#uploadSheets').height('');
+        $('#uploadSheets').hide();
+    });
+
     $("#billsSpread").mouseover(function(){
         spreadAutoFocus(projectObj.mainSpread,subSpread);
     });