Skip to content

Commit

Permalink
fix: params import xml bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kungfuboy committed Jan 3, 2023
1 parent 5ca5fe5 commit 95a4198
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,21 @@ export class ParamsImportComponent implements OnInit {
mixin: (data, base) => obj2array(merge(array2obj(base), array2obj(data)))
};

const endParse = (data, type) => {
if (['xml'].includes(type)) {
return [data.at(0)];
}
return data;
};

const { data } = res;
// * this.baseData.reverse().slice(1).reverse() for filter the last empty row
const emptyRow = this.baseData.slice(-1);
const resultData = cloneDeep(this.baseData.reverse().slice(1).reverse());
const resultData = cloneDeep(['xml'].includes(this.contentType) ? this.baseData : this.baseData.reverse().slice(1).reverse());
const result = combineFunc[type](json2Table(data), resultData);
this.baseDataChange.emit([...result, ...emptyRow]);
// * 后处理
const finalData = endParse([...result, ...emptyRow], this.contentType);
this.baseDataChange.emit(finalData);
this.handleCancel();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ export const xml2json = text => {
}),
{}
);
const result = deep(data.slice(0, 1));
return result;
return deep(data);
};
/**
* Json object 2 xml
Expand Down

0 comments on commit 95a4198

Please sign in to comment.