Skip to content

Commit

Permalink
feat: format form import
Browse files Browse the repository at this point in the history
  • Loading branch information
kungfuboy committed Aug 15, 2022
1 parent 25972d9 commit 931f8a7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,18 @@ export class ParamsImportComponent {
const json = {};
form2json(this.paramCode).forEach((it) => {
const { key, value } = it;
if (key == null || value == null) {
this.message.error($localize`Form format invalid`);
return;
}
json[key] = value;
});
paramCode = JSON.parse(JSON.stringify(json));
}
if (this.contentType === 'xml') {
const status = isXML(this.paramCode);
if (!status) {
this.message.error('XML格式不合法');
this.message.error($localize`XML format invalid`);
return;
}
paramCode = JSON.parse(JSON.stringify(xml2UiData(this.paramCode)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const form2json = (tmpl) =>
.map((it) => it.split(':'))
.map((it) => {
const [key, value] = it;
return { key: key.trim(), value: value.trim() };
return { key: key?.trim(), value: value?.trim() };
});

export const xml2json = (tmpl) => {
Expand Down Expand Up @@ -170,7 +170,7 @@ export const xml2UiData = (text) => {
* @returns
*/
export const json2XML: (o: object, tab?) => string = (o, tab) => {
const toXml = function(v, name, ind) {
const toXml = function (v, name, ind) {
let xml = '';
if (v instanceof Array) {
for (let i = 0, n = v.length; i < n; i++) {
Expand Down Expand Up @@ -258,7 +258,7 @@ export const text2UiData: (text: string) => uiData = (text) => {
* @param inputOptions
* @returns
*/
export const uiData2Json = function(eoapiArr: ApiEditBody[], inputOptions) {
export const uiData2Json = function (eoapiArr: ApiEditBody[], inputOptions) {
inputOptions = inputOptions || {};
const result = {};
const loopFun = (inputArr, inputObject) => {
Expand Down

0 comments on commit 931f8a7

Please sign in to comment.