This commit is contained in:
Taric Xin
2022-02-21 20:39:34 +08:00
parent 2c70028eb3
commit 901a5f0cdb
16 changed files with 500 additions and 298 deletions

View File

@ -100,8 +100,8 @@
<nz-switch [(ngModel)]="item.itemValue"></nz-switch>
</ng-container>
<!-- 开关选项 -->
<ng-container *ngSwitchCase="99">
<nz-switch [(ngModel)]="item.itemValue"></nz-switch>
<ng-container *ngSwitchCase="999">
<ng-content select="custom-element"></ng-content>
</ng-container>
</ng-container>
</se>
@ -112,7 +112,7 @@
<div class="mb-md save-btn">
<button class="ml-lg" nz-button nzSize="large" nzType="primary" (click)="saveAction()"
*ngIf="selectedTab?.configKey!=='freight'">保存</button>
*ngIf="selectedTab?.configKey!=='freight' && labelWidth!==0">保存</button>
</div>
</div>
</div>

View File

@ -1,3 +1,16 @@
<app-dynamic-setting-h5 [tabs]="tabs" [configList]="configList" [selectedTab]="selectedTab"
(selectedEvent)="changeType($event)" (saveEvent)="saveAction($event)" [tabSpan]="6" [labelWidth]="200" >
(selectedEvent)="changeType($event)" (saveEvent)="saveAction($event)" [tabSpan]="6" [labelWidth]="labelWidth">
<custom-element>
<ng-container [ngSwitch]="selectedTab?.configType">
<ng-container *ngSwitchCase="1">
权限配置
</ng-container>
<ng-container *ngSwitchCase="2">
</ng-container>
<ng-container *ngSwitchDefault>
费率变更记录
</ng-container>
</ng-container>
</custom-element>
</app-dynamic-setting-h5>

View File

@ -1,5 +1,5 @@
/*
* @Description :
* @Description :
* @Version : 1.0
* @Author : Shiming
* @Date : 2022-01-10 16:06:17
@ -8,9 +8,12 @@
* @FilePath : \\tms-obc-web\\src\\app\\shared\\components\\dynamic-setting\\dynamic-setting-modal\\dynamic-setting-modal.component.ts
* Copyright (C) 2022 huzhenhong. All rights reserved.
*/
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/compiler';
import { Component, Input, OnInit } from '@angular/core';
import { ModalHelper } from '@delon/theme';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { BaseService } from 'src/app/shared/services';
@Component({
@ -21,41 +24,58 @@ import { BaseService } from 'src/app/shared/services';
export class DynamicSettingModalComponent implements OnInit {
tabs: any[] = [];
selectedTab: any = null;
configFullKey = 'sys.config'
configFullKey = 'sys.config';
configList: any = [];
// 配置类型数组重组函数
@Input()
formatTypeList = (item: any[]) => {
return [...item];
};
@Input()
extendType!: string;
@Input()
businessId!: string;
@Input()
configvalue!: string;
@Input()
labelWidth = 200;
constructor(public service: BaseService, private modalHelp: NzModalRef) {}
ngOnInit() {
if(this.configvalue) {
this.configFullKey = this.configvalue
if (this.configvalue) {
this.configFullKey = this.configvalue;
}
this.getTypeList();
}
getTypeList() {
this.service
.request('/api/mdc/pbc/sysConfigItemExtend/getSysConfigExtend', {
configFullKey: this.configFullKey,
extendType: this.extendType,
businessId: this.businessId
})
.subscribe((res: Array<any>) => {
if (res?.length > 0) {
const typeData = res.find(config => config.configFullKey === this.configFullKey);
if (typeData) {
this.tabs = typeData.children;
this.selectedTab = typeData.children[0];
this.configList = this.formatItems(this.selectedTab.items);
.pipe(
map((res: Array<any>) => {
if (res?.length > 0) {
const typeData = res.find(config => config.configFullKey === this.configFullKey);
if (typeData) {
return typeData.children || [];
}
}
return [];
}),
map(this.formatTypeList)
)
.subscribe((res: Array<any>) => {
this.tabs = res;
if (res?.length > 0) {
this.selectedTab = res[0];
this.configList = this.formatItems(this.selectedTab.items);
const hiddenType = this.configList.find((item: any) => item.itemType === 7 || item.itemType === 999);
this.labelWidth = hiddenType ? 0 : 200;
}
});
}
@ -63,6 +83,8 @@ export class DynamicSettingModalComponent implements OnInit {
changeType(type: any): void {
this.selectedTab = type;
this.configList = this.formatItems(type.items);
const hiddenType = this.configList.find((item: any) => item.itemType === 7 || item.itemType === 999);
this.labelWidth = hiddenType ? 0 : 200;
}
saveAction(params: Array<any>) {
@ -93,13 +115,12 @@ export class DynamicSettingModalComponent implements OnInit {
itemData: item.extendItemData || item.itemData,
itemValue: item.extendItemValue || item.itemValue
}))
.map(item => (
{
.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 ? item?.itemType !== 8? JSON.parse(item?.itemValue) : item?.itemValue : item?.itemValue
itemValue: item?.itemValue ? (item?.itemType !== 8 ? JSON.parse(item?.itemValue) : item?.itemValue) : item?.itemValue
}));
}
return [];

View File

@ -17,10 +17,12 @@ import { FormsModule } from '@angular/forms';
import { DynamicSettingModalComponent } from './dynamic-setting-modal/dynamic-setting-modal.component';
import { FreightTableComponent } from './freight-table/freight-table.component';
import { SEModule } from '@delon/abc/se';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
const COMPONENTS = [DynamicSettingH5Component, DynamicSettingModalComponent, FreightTableComponent];
@NgModule({
declarations: [...COMPONENTS],
imports: [CommonModule, FormsModule, SHARED_ZORRO_MODULES, SEModule],
exports: [...COMPONENTS]
exports: [...COMPONENTS],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class DynamicSettingModule {}

View File

@ -45,7 +45,6 @@ export class ShipperBaseService extends BaseService {
* @returns
*/
getEnterpriseProject(params?: any) {
console.log(params)
return this.request(this.$api_get_enterprise_project, params).pipe(
map((res: any) => {
if (!res) {