This commit is contained in:
Taric Xin
2021-12-20 15:15:13 +08:00
parent c3f31cc224
commit bce661246c
15 changed files with 272 additions and 124 deletions

View File

@ -22,23 +22,44 @@ export class CartConfigActionModalComponent implements OnInit {
};
@Input()
configType: number = 1;
@Input()
params = {};
dictKey = '';
constructor(private modal: NzModalRef, public service: SystemService) {}
ngOnInit(): void {
this.initSF(this.i);
console.log(this.configType);
}
initSF(staff: any) {
let required: any = [];
let option: any = {};
switch (this.configType) {
case 1:
required = ['phone1'];
option = {
title: '车型',
ui: {
placeholder: '请输入'
}
};
this.dictKey = 'car:model';
break;
case 2:
required = ['phone2'];
option = {
title: '车长',
ui: {
placeholder: '请输入',
addOnAfter: '米'
} as SFStringWidgetSchema
};
this.dictKey = 'car:length';
break;
case 3:
required = ['phone3'];
option = {
title: '物品名称',
ui: {
placeholder: '请输入'
}
};
this.dictKey = 'car:model';
break;
default:
@ -46,35 +67,12 @@ export class CartConfigActionModalComponent implements OnInit {
}
this.schema = {
properties: {
phone1: {
title: '车型',
itemValue: {
...option,
type: 'string',
ui: {
placeholder: '请输入',
hidden: this.configType === 2 || this.configType === 3
},
default: staff.phone1
default: staff.itemValue
},
phone2: {
title: '车长',
type: 'string',
ui: {
placeholder: '请输入',
addOnAfter: '米',
hidden: this.configType === 1 || this.configType === 3
} as SFStringWidgetSchema,
default: staff.phone2
},
phone3: {
title: '物品名称',
type: 'string',
ui: {
placeholder: '请输入',
hidden: this.configType === 1 || this.configType === 2
},
default: staff.phone3
},
roleId: {
stateLocked: {
type: 'string',
title: '状态',
enum: [
@ -87,7 +85,7 @@ export class CartConfigActionModalComponent implements OnInit {
default: staff?.roleId || 1
}
},
required: required
required: ['itemValue']
};
}
@ -95,26 +93,27 @@ export class CartConfigActionModalComponent implements OnInit {
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.params,
dictKey: this.dictKey,
itemData: this.sf.value.itemValue
};
// 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;
// });
this.service.request(this.service.$api_add_dict, params).subscribe(res => {
if (res) {
this.service.msgSrv.success('保存成功!');
this.modal.close(true);
}
});
} else {
const params: any = {
appUserId: this.i.appUserId,
staffName: this.sf.value.name,
roleId: this.sf.value.roleId,
telephone: this.i.telephone
...this.i,
...this.sf.value
};
this.service.request(this.service.$api_update_dict, params).subscribe(res => {
if (res) {
this.service.msgSrv.success('保存成功!');
this.modal.close(true);
}
});
}
}

View File

@ -25,9 +25,9 @@
<button nz-button nzType="primary" (click)="configAction()">新增</button>
</div>
</div>
<st #st [data]="url" [columns]="columns"
<st #st [data]="service.$api_get_dict_page" [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>
[loading]="service.http.loading" [scroll]="{ y: '370px' }"></st>
</nz-card>

View File

@ -33,7 +33,6 @@ export class CartConfigComponent implements OnInit {
}
];
tabType = 1;
url = `/rule?_allow_anonymous=true`;
searchSchema: SFSchema = {
properties: {
@ -77,24 +76,22 @@ export class CartConfigComponent implements OnInit {
};
columns: STColumn[] = [
{ title: '车型', index: 'no', iif: () => this.tabType === 1 },
{ title: '车长', index: 'no', iif: () => this.tabType === 2 },
{ title: '物品名称', index: 'no', iif: () => this.tabType === 3 },
{ title: '车型', index: 'itemValue', iif: () => this.tabType === 1 },
{ title: '车长', index: 'itemValue', iif: () => this.tabType === 2 },
{ title: '物品名称', index: 'itemValue', iif: () => this.tabType === 3 },
{
title: '启用状态',
className: 'text-center',
index: 'status',
index: 'stateLocked',
type: 'badge',
badge: {
0: { text: '启用', color: 'success' },
2: { text: '禁用', color: 'error' },
3: { text: '禁用', color: 'error' },
1: { text: '禁用', color: 'error' }
false: { text: '启用', color: 'success' },
true: { text: '禁用', color: 'error' }
}
},
{
title: '创建时间',
index: 'updatedAt',
index: 'modifyTime',
type: 'date'
},
{
@ -112,9 +109,24 @@ export class CartConfigComponent implements OnInit {
}
];
selectedRows: any[] = [];
get reqParams() {
let params = {};
switch (this.tabType) {
case 1:
Object.assign(params, { dictKey: 'car:model', itemValue: this.sf?.value.params1 });
break;
case 2:
Object.assign(params, { dictKey: 'car:length', itemValue: this.sf?.value.params2 });
break;
case 3:
Object.assign(params, { dictKey: 'car:model', itemValue: this.sf?.value.params3 });
break;
reqParams = { pageIndex: 1, pageSize: 10 };
default:
break;
}
return { ...params };
}
constructor(public service: SystemService, private nzModalService: NzModalService) {}
@ -133,27 +145,18 @@ export class CartConfigComponent implements OnInit {
}, 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 },
? { i: { ...item }, configType: this.tabType }
: { i: { id: 0 }, configType: this.tabType, params: { itemKey: this.st.total + 1 } },
nzFooter: null
});
modal.afterClose.subscribe(res => {
this.st.load();
if (res) {
this.st.load();
}
});
}
@ -162,7 +165,14 @@ export class CartConfigComponent implements OnInit {
nzTitle: '确认删除?',
nzClosable: false,
nzCancelText: '取消',
nzOnOk: () => {}
nzOnOk: () => {
this.service.request(this.service.$api_delete_dict_by_ids, [item.id]).subscribe(res => {
if (res) {
this.service.msgSrv.success('删除配置成功');
this.st.load();
}
});
}
});
}
/**