edit
This commit is contained in:
@ -1,3 +1,3 @@
|
|||||||
<app-dynamic-setting-h5 [tabs]="tabs" [configList]="configList" [selectedTab]="selectedTab"
|
<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>
|
</app-dynamic-setting-h5>
|
||||||
@ -13,7 +13,6 @@ export class BasicSettingComponent implements OnInit {
|
|||||||
selectedTab: any = null;
|
selectedTab: any = null;
|
||||||
|
|
||||||
configList: any = [];
|
configList: any = [];
|
||||||
|
|
||||||
constructor(public service: SystemService) {}
|
constructor(public service: SystemService) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@ -27,21 +26,24 @@ export class BasicSettingComponent implements OnInit {
|
|||||||
if (typeData) {
|
if (typeData) {
|
||||||
this.tabs = typeData.children;
|
this.tabs = typeData.children;
|
||||||
this.selectedTab = typeData.children[0];
|
this.selectedTab = typeData.children[0];
|
||||||
this.getConfigList(this.selectedTab.id);
|
this.getConfigList(this.selectedTab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getConfigList(id: string) {
|
getConfigList(selectedTab: any) {
|
||||||
this.service.request(this.service.$api_get_config_by_parent_id, { id }).subscribe((res: Array<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) {
|
if (res?.length > 0) {
|
||||||
res = res.map(item => ({
|
res = res.map(item => ({
|
||||||
...item,
|
...item,
|
||||||
remark: item.remark ? JSON.parse(item.remark) : null,
|
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;
|
this.configList = res;
|
||||||
} else {
|
} else {
|
||||||
this.configList = [];
|
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) {
|
saveAction(params: any) {
|
||||||
this.service.request(this.service.$api_update_config_batch, params).subscribe(res => {
|
console.log(params);
|
||||||
if (res) {
|
|
||||||
this.service.msgSrv.success('修改配置成功');
|
// this.service.request(this.service.$api_update_config_batch, params).subscribe(res => {
|
||||||
this.getConfigList(this.selectedTab.id);
|
// if (res) {
|
||||||
}
|
// this.service.msgSrv.success('修改配置成功');
|
||||||
});
|
// setTimeout(() => {
|
||||||
|
// this.getConfigList(this.selectedTab);
|
||||||
|
// }, 100);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,8 +24,8 @@
|
|||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container *ngSwitchCase="2">
|
<ng-container *ngSwitchCase="2">
|
||||||
<nz-radio-group [(ngModel)]="item.itemValue" class="mr-xl">
|
<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]="0" class="ml-xl">{{item.remark?.[0] || '否'}}</label>
|
||||||
<label nz-radio nzValue="1" class="ml-xl">{{item.remark?.[1] || '是'}}</label>
|
<label nz-radio [nzValue]="1" class="ml-xl">{{item.remark?.[1] || '是'}}</label>
|
||||||
</nz-radio-group>
|
</nz-radio-group>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container *ngSwitchCase="3">
|
<ng-container *ngSwitchCase="3">
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { Component, OnInit, EventEmitter, Input, Output } from '@angular/core';
|
import { Component, OnInit, EventEmitter, Input, Output } from '@angular/core';
|
||||||
import { BaseService } from '@shared';
|
import { BaseService } from '@shared';
|
||||||
|
|
||||||
|
const JSONTYPE = new Set([5]);
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dynamic-setting-h5',
|
selector: 'app-dynamic-setting-h5',
|
||||||
templateUrl: './dynamic-setting-h5.component.html',
|
templateUrl: './dynamic-setting-h5.component.html',
|
||||||
@ -39,12 +40,18 @@ export class DynamicSettingH5Component implements OnInit {
|
|||||||
if (this.configList?.length < 0) {
|
if (this.configList?.length < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const params = this.configList.map((item: any) => ({
|
|
||||||
|
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,
|
...item,
|
||||||
remark: item.remark ? JSON.stringify(item.remark) : null,
|
remark: item.remark ? JSON.stringify(item.remark) : null,
|
||||||
itemData: item.itemData ? JSON.stringify(item.itemData) : null,
|
itemData: item.itemData ? JSON.stringify(item.itemData) : null
|
||||||
itemValue: item.itemValue ? JSON.stringify(item.itemValue) : null
|
};
|
||||||
}));
|
});
|
||||||
this.saveEvent.emit(params);
|
this.saveEvent.emit(params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user