|
|
@@ -48,7 +48,7 @@ const importBills = (function(){
|
|
|
}
|
|
|
function isGCLHead(dataRow) {
|
|
|
let cell = dataRow[0];
|
|
|
- return cell.value === '工程量清单';
|
|
|
+ return cell && cell.value === '工程量清单';
|
|
|
}
|
|
|
//分析文件,1、工程量清单 2、清单示例表
|
|
|
function getFileType(sheetData) {
|
|
|
@@ -93,6 +93,7 @@ const importBills = (function(){
|
|
|
continue;
|
|
|
}
|
|
|
//表格内的数据
|
|
|
+ code = String(code);
|
|
|
let depth = getDepth(code);
|
|
|
let data = {
|
|
|
ID: uuid.v1(),
|
|
|
@@ -160,10 +161,13 @@ const importBills = (function(){
|
|
|
let rst = [];
|
|
|
let curRoot = null;
|
|
|
for (let row = 0; row < rowCount; row++) {
|
|
|
- let code = dataTable[row][colMapping.code] ? dataTable[row][colMapping.code].value : null,
|
|
|
+ let code = dataTable[row][colMapping.code] && dataTable[row][colMapping.code].value ? String(dataTable[row][colMapping.code].value) : null,
|
|
|
name = dataTable[row][colMapping.name] ? dataTable[row][colMapping.name].value : null,
|
|
|
unit = dataTable[row][colMapping.unit] ? dataTable[row][colMapping.unit].value : null,
|
|
|
quantity = dataTable[row][colMapping.quantity] ? dataTable[row][colMapping.quantity].value : null;
|
|
|
+ if (code === '602') {
|
|
|
+ debugger;
|
|
|
+ }
|
|
|
if (!code) { //没有编号的数据,名称必须为:清单 第xx章,认为新的表根节点
|
|
|
if (name && /清单 第\d+章/.test(name)) {
|
|
|
curRoot = {code: null, name: name, ID: uuid.v1(), ParentID: -1, NextSiblingID: -1, parent: null};
|
|
|
@@ -209,9 +213,14 @@ const importBills = (function(){
|
|
|
|
|
|
function extactDatas(sheets) {
|
|
|
let rst = [];
|
|
|
+ let curSheetType = null;
|
|
|
for (let sheetName in sheets) {
|
|
|
let sheetData = sheets[sheetName];
|
|
|
let sheetType = getFileType(sheetData);
|
|
|
+ if (curSheetType !== null && sheetType !== curSheetType) {
|
|
|
+ throw 'excel文件中存在不同格式的表格。';
|
|
|
+ }
|
|
|
+ curSheetType = sheetType;
|
|
|
let colMapping = getColMapping(sheetType);
|
|
|
let datas = sheetType === fileType.gcl ? extractGCLDatas(sheetData, colMapping) : extractSLDatas(sheetData, colMapping);
|
|
|
rst = rst.concat(datas);
|