edit
This commit is contained in:
@ -0,0 +1,3 @@
|
||||
<app-dynamic-setting-h5 [tabs]="tabs" [configList]="configList" [selectedTab]="selectedTab"
|
||||
(selectedEvent)="changeType($event)" (saveEvent)="saveAction($event)" [tabSpan]="6" [labelWidth]="200" >
|
||||
</app-dynamic-setting-h5>
|
||||
@ -0,0 +1,91 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { ModalHelper } from '@delon/theme';
|
||||
import { NzModalRef } from 'ng-zorro-antd/modal';
|
||||
import { BaseService } from 'src/app/shared/services';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dynamic-setting-modal',
|
||||
templateUrl: './dynamic-setting-modal.component.html',
|
||||
styleUrls: ['./dynamic-setting-modal.component.less']
|
||||
})
|
||||
export class DynamicSettingModalComponent implements OnInit {
|
||||
tabs: any[] = [];
|
||||
selectedTab: any = null;
|
||||
|
||||
configList: any = [];
|
||||
|
||||
@Input()
|
||||
extendType!: string;
|
||||
@Input()
|
||||
businessId!: string;
|
||||
|
||||
constructor(public service: BaseService, private modalHelp: NzModalRef) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.getTypeList();
|
||||
}
|
||||
|
||||
getTypeList() {
|
||||
this.service
|
||||
.request('/api/mdc/pbc/sysConfigItemExtend/getSysConfigExtend', {
|
||||
configFullKey: 'sys.config',
|
||||
extendType: this.extendType,
|
||||
businessId: this.businessId
|
||||
})
|
||||
.subscribe((res: Array<any>) => {
|
||||
if (res?.length > 0) {
|
||||
const typeData = res.find(config => config.configFullKey === 'sys.config');
|
||||
if (typeData) {
|
||||
this.tabs = typeData.children;
|
||||
this.selectedTab = typeData.children[0];
|
||||
|
||||
this.configList = this.formatItems(this.selectedTab.items);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
changeType(type: any): void {
|
||||
this.selectedTab = type;
|
||||
this.configList = this.formatItems(type.items);
|
||||
}
|
||||
|
||||
saveAction(params: Array<any>) {
|
||||
const p = params.map(config => ({
|
||||
businessId: this.businessId,
|
||||
configId: config.configId,
|
||||
extendType: this.extendType,
|
||||
id: config.extendId,
|
||||
configItemId: config.id,
|
||||
parentId: config.parentId,
|
||||
itemData: config.itemData,
|
||||
itemValue: config.itemValue,
|
||||
remark: config.remark
|
||||
}));
|
||||
this.service.request('/api/mdc/pbc/sysConfigItemExtend/saveBatch', p).subscribe(res => {
|
||||
if (res) {
|
||||
this.service.msgSrv.success('修改配置成功');
|
||||
this.modalHelp.destroy();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private formatItems(items: Array<any>): Array<any> {
|
||||
if (items?.length > 0) {
|
||||
return items
|
||||
.map(item => ({
|
||||
...item,
|
||||
itemData: item.extendItemData || item.itemData,
|
||||
itemValue: item.extendItemValue || item.itemValue
|
||||
}))
|
||||
.map(item => ({
|
||||
...item,
|
||||
remark: item.remark ? JSON.parse(item.remark) : null,
|
||||
extend: item.extend ? JSON.parse(item.extend) : [],
|
||||
// itemData: item.itemData ? JSON.parse(item.itemData) : item.itemData,
|
||||
itemValue: item.itemValue ? JSON.parse(item.itemValue) : item.itemValue
|
||||
}));
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user