This commit is contained in:
Taric Xin
2022-01-13 20:29:23 +08:00
parent 274af8abd9
commit 2061944237
4 changed files with 34 additions and 26 deletions

View File

@ -1,3 +1,3 @@
<app-dynamic-setting-h5 [tabs]="tabs" [configList]="configList" [selectedTab]="selectedTab"
(selectedEvent)="getConfigList($event?.id)" (saveEvent)="saveAction($event)">
(selectedEvent)="getConfigList($event)" (saveEvent)="saveAction($event)">
</app-dynamic-setting-h5>

View File

@ -13,7 +13,6 @@ export class BasicSettingComponent implements OnInit {
selectedTab: any = null;
configList: any = [];
constructor(public service: SystemService) {}
ngOnInit() {
@ -27,21 +26,24 @@ export class BasicSettingComponent implements OnInit {
if (typeData) {
this.tabs = typeData.children;
this.selectedTab = typeData.children[0];
this.getConfigList(this.selectedTab.id);
this.getConfigList(this.selectedTab);
}
}
});
}
getConfigList(id: string) {
this.service.request(this.service.$api_get_config_by_parent_id, { id }).subscribe((res: Array<any>) => {
getConfigList(selectedTab: any) {
this.selectedTab = selectedTab;
this.service.request(this.service.$api_get_config_by_parent_id, { id: selectedTab.id }).subscribe((res: Array<any>) => {
if (res?.length > 0) {
res = res.map(item => ({
...item,
remark: item.remark ? JSON.parse(item.remark) : null,
extend: item.extend ? JSON.parse(item.extend) : [],
itemValue: item.itemValue ? JSON.parse(item.itemValue) : item.itemValue
itemValue: item.itemValue ? JSON.parse(item.itemValue) : item.itemValue,
itemData: item.itemData ? JSON.parse(item.itemData) : item.itemData
}));
console.log(res);
this.configList = res;
} else {
this.configList = [];
@ -49,17 +51,16 @@ export class BasicSettingComponent implements OnInit {
});
}
changeType(type: any): void {
this.selectedTab = type;
this.getConfigList(this.selectedTab.id);
}
saveAction(params: any) {
this.service.request(this.service.$api_update_config_batch, params).subscribe(res => {
if (res) {
this.service.msgSrv.success('修改配置成功');
this.getConfigList(this.selectedTab.id);
}
});
console.log(params);
// this.service.request(this.service.$api_update_config_batch, params).subscribe(res => {
// if (res) {
// this.service.msgSrv.success('修改配置成功');
// setTimeout(() => {
// this.getConfigList(this.selectedTab);
// }, 100);
// }
// });
}
}

View File

@ -24,8 +24,8 @@
</ng-container>
<ng-container *ngSwitchCase="2">
<nz-radio-group [(ngModel)]="item.itemValue" class="mr-xl">
<label nz-radio nzValue="0" class="ml-xl">{{item.remark?.[0] || '否'}}</label>
<label nz-radio nzValue="1" class="ml-xl">{{item.remark?.[1] || '是'}}</label>
<label nz-radio [nzValue]="0" class="ml-xl">{{item.remark?.[0] || '否'}}</label>
<label nz-radio [nzValue]="1" class="ml-xl">{{item.remark?.[1] || '是'}}</label>
</nz-radio-group>
</ng-container>
<ng-container *ngSwitchCase="3">

View File

@ -1,6 +1,7 @@
import { Component, OnInit, EventEmitter, Input, Output } from '@angular/core';
import { BaseService } from '@shared';
const JSONTYPE = new Set([5]);
@Component({
selector: 'app-dynamic-setting-h5',
templateUrl: './dynamic-setting-h5.component.html',
@ -39,12 +40,18 @@ export class DynamicSettingH5Component implements OnInit {
if (this.configList?.length < 0) {
return;
}
const params = this.configList.map((item: any) => ({
...item,
remark: item.remark ? JSON.stringify(item.remark) : null,
itemData: item.itemData ? JSON.stringify(item.itemData) : null,
itemValue: item.itemValue ? JSON.stringify(item.itemValue) : null
}));
let params = [...this.configList];
params = params.map((item: any) => {
if (JSONTYPE.has(item.itemType)) {
item.itemValue = item.itemValue ? JSON.stringify(item.itemValue) : null;
}
return {
...item,
remark: item.remark ? JSON.stringify(item.remark) : null,
itemData: item.itemData ? JSON.stringify(item.itemData) : null
};
});
this.saveEvent.emit(params);
}
}