Skip to content

Commit

Permalink
fix: query params import
Browse files Browse the repository at this point in the history
  • Loading branch information
kungfuboy committed Apr 22, 2022
1 parent 6a955d8 commit 1daf8ce
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="param_header">
<params-import [(baseData)]="model"></params-import>
<params-import [(baseData)]="model" contentType="formData" modalTitle="头部"></params-import>
</div>
<list-block-common-component [mainObject]="listConf" [(list)]="model"></list-block-common-component>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="param_header">
<params-import [(baseData)]="model"></params-import>
<params-import [(baseData)]="model" contentType="query" modalTitle="Query参数"></params-import>
</div>
<list-block-common-component [mainObject]="listConf" [(list)]="model"></list-block-common-component>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="param_header">
<params-import [(baseData)]="model"></params-import>
<params-import [(baseData)]="model" contentType="formData" modalTitle="头部"></params-import>
</div>
<list-block-common-component [mainObject]="listConf" [(list)]="model"></list-block-common-component>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="param_header">
<params-import [(baseData)]="model"></params-import>
<params-import [(baseData)]="model" contentType="query" modalTitle="Query参数"></params-import>
</div>
<list-block-common-component [mainObject]="listConf" [(list)]="model"></list-block-common-component>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<nz-modal
[(nzVisible)]="isVisible"
[nzTitle]="'导入' + contentTypeTitle"
[nzTitle]="'导入' + (modalTitle || contentTypeTitle)"
[nzStyle]="{ width: '800px' }"
(nzOnCancel)="handleCancel()"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component, Input, Output, EventEmitter } from '@angular/core';
import { NzMessageService } from 'ng-zorro-antd/message';
import { whatType } from '../../../utils';
import { flatData } from '../../../utils/tree/tree.utils';
import * as qs from 'qs';
import { form2json, parseTree, xml2UiData, isXML } from '../../../utils/data-transfer/data-transfer.utils';
@Component({
selector: 'params-import',
Expand All @@ -12,6 +13,7 @@ export class ParamsImportComponent {
@Input() rootType: 'array' | string | 'object' = 'object';
@Input() contentType = 'json';
@Input() baseData: object[] = [];
@Input() modalTitle: string = '';
@Output() baseDataChange = new EventEmitter<any>();
isVisible = false;
paramCode = '';
Expand All @@ -33,6 +35,7 @@ export class ParamsImportComponent {
get contenTypeEditor() {
switch (this.contentType) {
case 'formData':
case 'query':
return 'text';
default:
return this.contentType;
Expand All @@ -57,6 +60,10 @@ export class ParamsImportComponent {
return;
}
}
if (this.contentType === 'query') {
paramCode = qs.parse(this.paramCode.split('?')[1]);
// console.log('-->', paramCode);
}
if (this.contentType === 'formData') {
const json = {};
form2json(this.paramCode).forEach((it) => {
Expand Down

1 comment on commit 1daf8ce

@vercel
Copy link

@vercel vercel bot commented on 1daf8ce Apr 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.