diff --git a/src/workbench/browser/src/app/shared/components/params-import/params-import.component.ts b/src/workbench/browser/src/app/shared/components/params-import/params-import.component.ts index 5fd68154..9e5973ed 100644 --- a/src/workbench/browser/src/app/shared/components/params-import/params-import.component.ts +++ b/src/workbench/browser/src/app/shared/components/params-import/params-import.component.ts @@ -3,7 +3,7 @@ import { EoMessageService } from 'eo/workbench/browser/src/app/eoui/message/eo-m import { whatType } from '../../../utils'; import { flatData } from '../../../utils/tree/tree.utils'; import qs from 'qs'; -import { form2json, parseTree, xml2UiData, isXML } from '../../../utils/data-transfer/data-transfer.utils'; +import { form2json, parseTree, xml2UiData, xml2json, isXML } from '../../../utils/data-transfer/data-transfer.utils'; @Component({ selector: 'params-import', templateUrl: './params-import.component.html', @@ -13,7 +13,7 @@ export class ParamsImportComponent { @Input() rootType: 'array' | string | 'object' = 'object'; @Input() contentType = 'json'; @Input() baseData: object[] = []; - @Input() modalTitle: string = ''; + @Input() modalTitle = ''; @Output() baseDataChange = new EventEmitter(); @Output() beforeHandleImport = new EventEmitter(); isVisible = false; @@ -98,6 +98,7 @@ export class ParamsImportComponent { return; } paramCode = JSON.parse(JSON.stringify(xml2UiData(this.paramCode))); + console.log(paramCode); // console.log('-->', paramCode); } if (this.contentType === 'raw') { @@ -119,7 +120,7 @@ export class ParamsImportComponent { paramCode = data || {}; } // * tree to array for table render - const cacheData = flatData(Object.keys(paramCode).map((it) => parseTree(it, paramCode[it]))); + const cacheData = flatData(Object.entries(paramCode).map(([key, value]) => parseTree(key, value))); // TODO delete useless attribute in cacheData switch (type) { diff --git a/src/workbench/browser/src/app/utils/data-transfer/data-transfer.utils.ts b/src/workbench/browser/src/app/utils/data-transfer/data-transfer.utils.ts index 1a0f15d7..0877d3f5 100644 --- a/src/workbench/browser/src/app/utils/data-transfer/data-transfer.utils.ts +++ b/src/workbench/browser/src/app/utils/data-transfer/data-transfer.utils.ts @@ -61,7 +61,7 @@ export const parseTree = (key, value, level = 0) => { description: '', type: whatType(value), required: true, - example: value || '', + example: value == null ? '' : value.toString(), listDepth: level, }; }; @@ -166,7 +166,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++) { @@ -252,7 +252,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) => {