This commit is contained in:
Park Byung Eun 2022-08-20 07:24:32 +00:00
parent 3300c6d579
commit e6a0c6e988
2 changed files with 53 additions and 33 deletions

View File

@ -125,21 +125,6 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
this.__addBtnConfirmConfig();
this.__removeBtnConfirmConfig();
this._memberReffererService.listMemberReferrers().then((result) => {
const list = result.getMemberReferrersList();
this.removePartnerStoreDataSource.data = result.getMemberReferrersList();
/* this.registPartnerStoreDataSource.data */
const partnerStores = this.listMembers.filter(
(m) =>
m.getMemberClass()?.getId() === 'e11cac11-3825-4f4e-9cd5-39367f23f973'
);
this.registPartnerStoreDataSource.data = partnerStores;
// Mark for check
this._changeDetectorRef.markForCheck();
});
// Get the products
this._activatedRoute.data.subscribe((data) => {
let listMemberResult: ListMembersResponse.Result =
@ -147,22 +132,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
this.listMembers = listMemberResult.getMembersList();
/* this.registPartnerStoreDataSource.data = listMemberResult
.getMembersList()
.filter(
(v: MemberModel) =>
v.getMemberClass()?.getId() ===
'e11cac11-3825-4f4e-9cd5-39367f23f973' &&
);
this.removePartnerStoreDataSource.data = listMemberResult
.getMembersList()
.filter(
(v: MemberModel) =>
v.getMemberClass()?.getId() ===
'e11cac11-3825-4f4e-9cd5-39367f23f973'
); */
/* console.log('dddd', listMemberResult.getMembersList()); */
this.__generationRefererList();
// Mark for check
this._changeDetectorRef.markForCheck();
@ -374,8 +344,12 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
dialogRef.afterClosed().subscribe((result) => {
if (result === 'confirmed') {
if (!!this.registSelection.hasValue()) {
/* const mrArr = this.removePartnerStoreDataSource.data; */
this.registSelection.selected.forEach((m: MemberModel) => {
this._memberReffererService.createMemberReferrer(m.getId());
this._memberReffererService
.createMemberReferrer(m.getId())
.then(() => this.__generationRefererList());
});
}
}
@ -390,6 +364,15 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
// Subscribe to afterClosed from the dialog reference
dialogRef.afterClosed().subscribe((result) => {
if (result === 'confirmed') {
if (!!this.removeSelection.hasValue()) {
/* const mrArr = this.removePartnerStoreDataSource.data; */
this.removeSelection.selected.forEach((m: MemberReferrerModel) => {
this._memberReffererService
.deleteMemberReferrer(m.getId())
.then(() => this.__generationRefererList());
});
}
}
});
}
@ -406,4 +389,37 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
console.log(info.getMember()?.getUsername());
return '매장';
}
__generationRefererList(): void {
this._memberReffererService.listMemberReferrers().then((result) => {
const list = result.getMemberReferrersList();
this.removePartnerStoreDataSource.data = result.getMemberReferrersList();
/* this.registPartnerStoreDataSource.data */
const registArr: MemberModel[] = [];
const partnerStores = this.listMembers.filter(
(m) =>
m.getMemberClass()?.getId() === 'e11cac11-3825-4f4e-9cd5-39367f23f973'
);
list.forEach((rm) => {
if (partnerStores.length > 0) {
partnerStores.forEach((ps) => {
if (rm.getMember()?.getId() === ps.getId() && !rm.getCanUse()) {
registArr.push(ps);
}
});
}
});
this.registPartnerStoreDataSource.data = partnerStores;
this.removePartnerStoreDataSource.data = list.filter(
(v) => !!v.getCanUse()
);
// Mark for check
this._changeDetectorRef.markForCheck();
});
}
}

View File

@ -134,11 +134,15 @@ export class MemberReferrerService {
);
}
deleteMemberReferrer(): Promise<DeleteMemberReferrerResponse.Result> {
deleteMemberReferrer(
id: string
): Promise<DeleteMemberReferrerResponse.Result> {
return new Promise<DeleteMemberReferrerResponse.Result>(
(resolve, reject) => {
let req = new DeleteMemberReferrerRequest();
req.setId(id);
this.__natsService
.request<DeleteMemberReferrerResponse.Result>(
SUBJECT_DELETE_MEMBER_REFERRER,