This commit is contained in:
Taric Xin
2021-11-30 19:42:42 +08:00
parent 3c753a3b4f
commit 8aca1f7b83
33 changed files with 1588 additions and 12 deletions

View File

@ -0,0 +1,11 @@
<div class="modal-header">
<div class="modal-title">{{ i.id === 0 ? '新增配置' : '编辑配置' }}</div>
</div>
<div>
<sf #sf [compact]="true" [ui]="ui" [schema]="schema" [button]="'none'">
</sf>
</div>
<div class="modal-footer">
<button nz-button type="button" (click)="close()">取消</button>
<button nz-button type="button" nzType="primary" (click)="sure()" [disabled]="!sf.valid">保存</button>
</div>

View File

@ -0,0 +1,123 @@
import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { SFComponent, SFRadioWidgetSchema, SFSchema, SFUISchema } from '@delon/form';
import { NzMessageService } from 'ng-zorro-antd/message';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { SystemService } from '../../../services/system.service';
@Component({
selector: 'app-cart-config-action-modal',
templateUrl: './cart-config-action-modal.component.html',
styleUrls: ['./cart-config-action-modal.component.less']
})
export class CartConfigActionModalComponent implements OnInit {
@ViewChild('sf', { static: false })
sf!: SFComponent;
i: any;
schema!: SFSchema;
ui: SFUISchema = {
'*': {
spanLabelFixed: 120,
grid: { span: 24 }
}
};
@Input()
configType: number = 1;
constructor(private modal: NzModalRef, public service: SystemService) {}
ngOnInit(): void {
this.initSF(this.i);
console.log(this.configType);
}
initSF(staff: any) {
let required: any = [];
switch (this.configType) {
case 1:
required = ['phone1'];
break;
case 2:
required = ['phone2'];
break;
case 3:
required = ['phone3'];
break;
default:
break;
}
this.schema = {
properties: {
phone1: {
title: '车型',
type: 'string',
ui: {
placeholder: '请输入',
hidden: this.configType === 2 || this.configType === 3
},
default: staff.phone1
},
phone2: {
title: '车长',
type: 'string',
ui: {
placeholder: '请输入',
hidden: this.configType === 1 || this.configType === 3
},
default: staff.phone2
},
phone3: {
title: '物品名称',
type: 'string',
ui: {
placeholder: '请输入',
hidden: this.configType === 1 || this.configType === 2
},
default: staff.phone3
},
roleId: {
type: 'string',
title: '状态',
enum: [
{ label: '启用', value: 1 },
{ label: '停用', value: 0 }
],
ui: {
widget: 'radio'
} as SFRadioWidgetSchema,
default: staff?.roleId || 1
}
},
required: required
};
}
sure() {
if (this.i.id === 0) {
const params: any = {
...this.sf.value,
roleId: this.sf.value.roleId,
telephone: this.sf.value.phone,
staffName: this.sf.value.name
};
// this.service.request(this.service.$api_addStaff, params).subscribe((res) => {
// console.log(res);
// if (res) {
// this.service.msgSrv.success('保存成功!');
// this.modal.close(true);
// }
// // this.showInviteFlag = true;
// // this.inviteCode = res.inviteCode;
// });
} else {
const params: any = {
appUserId: this.i.appUserId,
staffName: this.sf.value.name,
roleId: this.sf.value.roleId,
telephone: this.i.telephone
};
}
}
close() {
this.modal.destroy();
}
}

View File

@ -0,0 +1,33 @@
<page-header-wrapper [title]="'车型车长配置'" [content]="content">
<ng-template #content>
<nz-tabset class="tabs-wrap">
<nz-tab *ngFor="let tab of tabs" [nzTitle]="tab.name" (nzSelect)="changeTab(tab)"> </nz-tab>
</nz-tabset>
</ng-template>
</page-header-wrapper>
<nz-card class="search-box">
<div nz-row nzGutter="8">
<div nz-col [nzSpan]="6">
<sf #sf [schema]="searchSchema" [ui]="{ '*': { spanLabelFixed: 90,grid: { span: 24 } }}" [compact]="true"
[button]="'none'"></sf>
</div>
<div nz-col [nzSpan]="8" nzOffset="1">
<button nz-button nzType="primary" [nzLoading]="service.http.loading" (click)="st?.load(1)">查询</button>
<button nz-button (click)="resetSF()">重置</button>
</div>
</div>
</nz-card>
<nz-card>
<div class="d-flex justify-content-end mb-sm">
<div>
<button nz-button nzType="primary" (click)="configAction()">新增</button>
</div>
</div>
<st #st [data]="url" [columns]="columns"
[req]="{ method: 'POST', allInBody: true, reName: { pi: 'pageIndex', ps: 'pageSize' }, params: reqParams }"
[res]="{ reName: { list: 'data.records', total: 'data.total' } }"
[page]="{ show: true, showSize: true, pageSizes: [10, 20, 30, 50, 100, 200, 300, 500, 1000] }"
[loading]="service.http.loading" [scroll]="{ y: '370px' }" (change)="stChange($event)"></st>
</nz-card>

View File

@ -0,0 +1,21 @@
:host::ng-deep {
.search-box {
.ant-card-body {
padding-bottom: 18px;
}
}
.content-box {
.ant-card-body {
padding-top: 14px;
}
}
.tabs-wrap>.ant-tabs-nav {
margin-bottom: 0;
}
h1 {
margin: 0;
}
}

View File

@ -0,0 +1,174 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { STComponent, STColumn, STChange } from '@delon/abc/st';
import { SFComponent, SFSchema } from '@delon/form';
import { NzModalService } from 'ng-zorro-antd/modal';
import { SystemService } from '../../services/system.service';
import { CartConfigActionModalComponent } from './cart-config-action-modal/cart-config-action-modal.component';
@Component({
selector: 'app-cart-config',
templateUrl: './cart-config.component.html',
styleUrls: ['./cart-config.component.less']
})
export class CartConfigComponent implements OnInit {
@ViewChild('st', { static: true })
st!: STComponent;
@ViewChild('sf', { static: false })
sf!: SFComponent;
tabs = [
{
name: '车型配置',
type: 1,
isActived: false
},
{
name: '车长配置',
type: 2,
isActived: false
},
{
name: '禁限物品名单',
type: 3,
isActived: false
}
];
tabType = 1;
url = `/rule?_allow_anonymous=true`;
searchSchema: SFSchema = {
properties: {
tabType: {
type: 'number',
ui: {
hidden: true
}
},
params1: {
title: '车型',
type: 'string',
ui: {
placeholder: '请输入',
visibleIf: {
tabType: (value: number) => this.tabType === 1
}
}
},
params2: {
title: '车长',
type: 'string',
ui: {
placeholder: '请输入',
visibleIf: {
tabType: (value: number) => this.tabType === 2
}
}
},
params3: {
title: '物品名称',
type: 'string',
ui: {
placeholder: '请输入',
visibleIf: {
tabType: (value: number) => this.tabType === 3
}
}
}
}
};
columns: STColumn[] = [
{ title: '车型', index: 'no', iif: () => this.tabType === 1 },
{ title: '车长', index: 'no', iif: () => this.tabType === 2 },
{ title: '物品名称', index: 'no', iif: () => this.tabType === 3 },
{
title: '启用状态',
className: 'text-center',
index: 'status',
type: 'badge',
badge: {
0: { text: '启用', color: 'success' },
2: { text: '禁用', color: 'error' },
3: { text: '禁用', color: 'error' },
1: { text: '禁用', color: 'error' }
}
},
{
title: '创建时间',
index: 'updatedAt',
type: 'date'
},
{
title: '操作',
buttons: [
{
text: '编辑',
click: item => this.configAction(item)
},
{
text: '删除',
click: item => this.deleteAction(item)
}
]
}
];
selectedRows: any[] = [];
reqParams = { pageIndex: 1, pageSize: 10 };
constructor(public service: SystemService, private nzModalService: NzModalService) {}
ngOnInit(): void {}
// 切换Tab
changeTab(item: any) {
this.tabType = item.type;
this.sf?.setValue('/tabType', item.type);
this.sf?.reset();
setTimeout(() => {
this.tabs.forEach(i => (i.isActived = false));
item.isActived = !item.isActived;
this.st.load(1);
this.st.resetColumns();
}, 500);
}
stChange(e: STChange): void {
switch (e.type) {
case 'checkbox':
this.selectedRows = e.checkbox!;
break;
case 'filter':
this.st.load();
break;
}
}
configAction(item?: any) {
const modal = this.nzModalService.create({
nzContent: CartConfigActionModalComponent,
nzComponentParams: item
? { i: { ...item, roleId: 1, phone1: '车辆审核', phone2: '车辆审核', phone3: '车辆审核' }, configType: this.tabType }
: { i: { id: 0 }, configType: this.tabType },
nzFooter: null
});
modal.afterClose.subscribe(res => {
this.st.load();
});
}
deleteAction(item?: any) {
this.nzModalService.error({
nzTitle: '确认删除?',
nzClosable: false,
nzCancelText: '取消',
nzOnOk: () => {}
});
}
/**
* 重置表单
*/
resetSF() {
this.sf.reset();
}
}