Selected Organization is implemented
This commit is contained in:
parent
2fe33a4c4f
commit
a08003bf47
|
@ -5,5 +5,9 @@
|
||||||
(selected)="onSelectedOrganization($event)"
|
(selected)="onSelectedOrganization($event)"
|
||||||
></ucap-organization-tree>
|
></ucap-organization-tree>
|
||||||
</div>
|
</div>
|
||||||
<div fxFlex="50">dddd</div>
|
<div fxFlex="50" style="overflow: scroll">
|
||||||
|
<div *ngFor="let userInfo of selectedDepartmentUserInfoList$ | async">
|
||||||
|
ddddd
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -4,15 +4,18 @@ import { Observable } from 'rxjs';
|
||||||
import {
|
import {
|
||||||
DeptInfo,
|
DeptInfo,
|
||||||
QueryProtocolService,
|
QueryProtocolService,
|
||||||
DeptSearchType
|
DeptSearchType,
|
||||||
|
UserInfoSS,
|
||||||
|
DeptUserResponse
|
||||||
} from '@ucap-webmessenger/protocol-query';
|
} from '@ucap-webmessenger/protocol-query';
|
||||||
import { Store, select } from '@ngrx/store';
|
import { Store, select } from '@ngrx/store';
|
||||||
import { NGXLogger } from 'ngx-logger';
|
import { NGXLogger } from 'ngx-logger';
|
||||||
|
|
||||||
import * as AppStore from '@app/store';
|
import * as AppStore from '@app/store';
|
||||||
|
import * as QueryStore from '@app/store/messenger/query';
|
||||||
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
||||||
import { LoginInfo, KEY_LOGIN_INFO } from '@app/types';
|
import { LoginInfo, KEY_LOGIN_INFO } from '@app/types';
|
||||||
import { take, map } from 'rxjs/operators';
|
import { take, map, switchMap } from 'rxjs/operators';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-layout-chat-left-sidenav-organization',
|
selector: 'app-layout-chat-left-sidenav-organization',
|
||||||
|
@ -22,6 +25,8 @@ import { take, map } from 'rxjs/operators';
|
||||||
})
|
})
|
||||||
export class OrganizationComponent implements OnInit {
|
export class OrganizationComponent implements OnInit {
|
||||||
departmentInfoList$: Observable<DeptInfo[]>;
|
departmentInfoList$: Observable<DeptInfo[]>;
|
||||||
|
selectedDepartmentUserInfoList$: Observable<UserInfoSS[]>;
|
||||||
|
selectedDepartmentStatus$: Observable<DeptUserResponse>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private store: Store<any>,
|
private store: Store<any>,
|
||||||
|
@ -34,29 +39,37 @@ export class OrganizationComponent implements OnInit {
|
||||||
this.departmentInfoList$ = this.store.pipe(
|
this.departmentInfoList$ = this.store.pipe(
|
||||||
select(AppStore.MessengerSelector.QuerySelector.departmentInfoList)
|
select(AppStore.MessengerSelector.QuerySelector.departmentInfoList)
|
||||||
);
|
);
|
||||||
|
this.selectedDepartmentUserInfoList$ = this.store.pipe(
|
||||||
|
select(
|
||||||
|
AppStore.MessengerSelector.QuerySelector.selectedDepartmentUserInfoList
|
||||||
|
)
|
||||||
|
);
|
||||||
|
this.selectedDepartmentStatus$ = this.store.pipe(
|
||||||
|
select(AppStore.MessengerSelector.QuerySelector.selectedDepartmentStatus)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelectedOrganization(deptInfo: DeptInfo) {
|
onSelectedOrganization(deptInfo: DeptInfo) {
|
||||||
const loginInfo = this.sessionStorageService.get<LoginInfo>(KEY_LOGIN_INFO);
|
const loginInfo = this.sessionStorageService.get<LoginInfo>(KEY_LOGIN_INFO);
|
||||||
|
|
||||||
// this.store
|
this.store
|
||||||
// .pipe(
|
.pipe(
|
||||||
// take(1),
|
take(1),
|
||||||
// select(AppStore.AccountSelector.AuthenticationSelector.loginRes),
|
select(AppStore.AccountSelector.AuthenticationSelector.loginRes),
|
||||||
// map(loginRes => {
|
map(loginRes => {
|
||||||
|
this.store.dispatch(
|
||||||
// this.queryProtocolService.deptUser({
|
QueryStore.deptUser({
|
||||||
// divCd: 'ORG',
|
divCd: 'ORG',
|
||||||
// companyCode: loginInfo.companyCode,
|
companyCode: loginInfo.companyCode,
|
||||||
// seq: deptInfo.seq,
|
seq: deptInfo.seq,
|
||||||
// search: '',
|
search: '',
|
||||||
// searchRange: DeptSearchType.All,
|
searchRange: DeptSearchType.All,
|
||||||
// senderCompanyCode: loginInfo.companyCode,
|
senderCompanyCode: loginInfo.companyCode,
|
||||||
// senderEmployeeType: loginRes.
|
senderEmployeeType: loginRes.userInfo.employeeType
|
||||||
// });
|
})
|
||||||
|
);
|
||||||
// })
|
})
|
||||||
// )
|
)
|
||||||
// .subscribe();
|
.subscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,10 @@ import {
|
||||||
AuthRequest,
|
AuthRequest,
|
||||||
AuthResponse,
|
AuthResponse,
|
||||||
DeptRequest,
|
DeptRequest,
|
||||||
DeptInfo
|
DeptInfo,
|
||||||
|
DeptUserRequest,
|
||||||
|
UserInfoSS,
|
||||||
|
DeptUserResponse
|
||||||
} from '@ucap-webmessenger/protocol-query';
|
} from '@ucap-webmessenger/protocol-query';
|
||||||
|
|
||||||
export const auth = createAction(
|
export const auth = createAction(
|
||||||
|
@ -36,3 +39,18 @@ export const deptFailure = createAction(
|
||||||
'[Messenger::Query] Dept Failure',
|
'[Messenger::Query] Dept Failure',
|
||||||
props<{ error: any }>()
|
props<{ error: any }>()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const deptUser = createAction(
|
||||||
|
'[Messenger::Query] Dept User',
|
||||||
|
props<DeptUserRequest>()
|
||||||
|
);
|
||||||
|
|
||||||
|
export const deptUserSuccess = createAction(
|
||||||
|
'[Messenger::Query] Dept User Success',
|
||||||
|
props<{ userInfos: UserInfoSS[]; res: DeptUserResponse }>()
|
||||||
|
);
|
||||||
|
|
||||||
|
export const deptUserFailure = createAction(
|
||||||
|
'[Messenger::Query] Dept User Failure',
|
||||||
|
props<{ error: any }>()
|
||||||
|
);
|
||||||
|
|
|
@ -5,14 +5,26 @@ import { Actions, ofType, createEffect } from '@ngrx/effects';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
import { catchError, map, tap, switchMap } from 'rxjs/operators';
|
import { catchError, map, tap, switchMap } from 'rxjs/operators';
|
||||||
|
|
||||||
import { dept, deptSuccess, deptFailure } from './actions';
|
import {
|
||||||
|
dept,
|
||||||
|
deptSuccess,
|
||||||
|
deptFailure,
|
||||||
|
deptUser,
|
||||||
|
deptUserSuccess,
|
||||||
|
deptUserFailure
|
||||||
|
} from './actions';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
QueryProtocolService,
|
QueryProtocolService,
|
||||||
DeptInfo,
|
DeptInfo,
|
||||||
SSVC_TYPE_QUERY_DEPT_DATA,
|
SSVC_TYPE_QUERY_DEPT_DATA,
|
||||||
SSVC_TYPE_QUERY_DEPT_RES,
|
SSVC_TYPE_QUERY_DEPT_RES,
|
||||||
DeptData
|
DeptData,
|
||||||
|
UserInfoSS,
|
||||||
|
SSVC_TYPE_QUERY_DEPT_USER_DATA,
|
||||||
|
DeptUserData,
|
||||||
|
SSVC_TYPE_QUERY_DEPT_USER_RES,
|
||||||
|
DeptUserResponse
|
||||||
} from '@ucap-webmessenger/protocol-query';
|
} from '@ucap-webmessenger/protocol-query';
|
||||||
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
||||||
|
|
||||||
|
@ -53,6 +65,40 @@ export class Effects {
|
||||||
{ dispatch: false }
|
{ dispatch: false }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
deptUser$ = createEffect(
|
||||||
|
() => {
|
||||||
|
let userInfos: UserInfoSS[];
|
||||||
|
|
||||||
|
return this.actions$.pipe(
|
||||||
|
ofType(deptUser),
|
||||||
|
tap(() => {
|
||||||
|
userInfos = [];
|
||||||
|
}),
|
||||||
|
switchMap(req => {
|
||||||
|
return this.queryProtocolService.deptUser(req).pipe(
|
||||||
|
map(res => {
|
||||||
|
switch (res.Type) {
|
||||||
|
case SSVC_TYPE_QUERY_DEPT_USER_DATA:
|
||||||
|
userInfos.push(...(res as DeptUserData).userInfos);
|
||||||
|
break;
|
||||||
|
case SSVC_TYPE_QUERY_DEPT_USER_RES:
|
||||||
|
this.store.dispatch(
|
||||||
|
deptUserSuccess({
|
||||||
|
userInfos,
|
||||||
|
res: res as DeptUserResponse
|
||||||
|
})
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
catchError(error => of(deptUserFailure({ error })))
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{ dispatch: false }
|
||||||
|
);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private actions$: Actions,
|
private actions$: Actions,
|
||||||
private store: Store<any>,
|
private store: Store<any>,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { createReducer, on } from '@ngrx/store';
|
import { createReducer, on } from '@ngrx/store';
|
||||||
import { initialState } from './state';
|
import { initialState } from './state';
|
||||||
import { authSuccess, deptSuccess } from './actions';
|
import { authSuccess, deptSuccess, deptUserSuccess } from './actions';
|
||||||
|
|
||||||
export const reducer = createReducer(
|
export const reducer = createReducer(
|
||||||
initialState,
|
initialState,
|
||||||
|
@ -16,5 +16,13 @@ export const reducer = createReducer(
|
||||||
...state,
|
...state,
|
||||||
departmentInfoList: action.departmentInfoList
|
departmentInfoList: action.departmentInfoList
|
||||||
};
|
};
|
||||||
|
}),
|
||||||
|
|
||||||
|
on(deptUserSuccess, (state, action) => {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
selectedDepartmentUserInfoList: action.userInfos,
|
||||||
|
selectedDepartmentStatus: action.res
|
||||||
|
};
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,15 +1,25 @@
|
||||||
import { Selector, createSelector } from '@ngrx/store';
|
import { Selector, createSelector } from '@ngrx/store';
|
||||||
import { AuthResponse, DeptInfo } from '@ucap-webmessenger/protocol-query';
|
import {
|
||||||
|
AuthResponse,
|
||||||
|
DeptInfo,
|
||||||
|
UserInfoSS,
|
||||||
|
DeptUserResponse
|
||||||
|
} from '@ucap-webmessenger/protocol-query';
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
auth?: AuthResponse;
|
auth?: AuthResponse;
|
||||||
|
|
||||||
departmentInfoList: DeptInfo[] | null;
|
departmentInfoList: DeptInfo[] | null;
|
||||||
|
|
||||||
|
selectedDepartmentUserInfoList: UserInfoSS[] | null;
|
||||||
|
selectedDepartmentStatus: DeptUserResponse | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const initialState: State = {
|
export const initialState: State = {
|
||||||
auth: null,
|
auth: null,
|
||||||
departmentInfoList: null
|
departmentInfoList: null,
|
||||||
|
selectedDepartmentUserInfoList: null,
|
||||||
|
selectedDepartmentStatus: null
|
||||||
};
|
};
|
||||||
|
|
||||||
export function selectors<S>(selector: Selector<any, State>) {
|
export function selectors<S>(selector: Selector<any, State>) {
|
||||||
|
@ -21,6 +31,14 @@ export function selectors<S>(selector: Selector<any, State>) {
|
||||||
departmentInfoList: createSelector(
|
departmentInfoList: createSelector(
|
||||||
selector,
|
selector,
|
||||||
(state: State) => state.departmentInfoList
|
(state: State) => state.departmentInfoList
|
||||||
|
),
|
||||||
|
selectedDepartmentUserInfoList: createSelector(
|
||||||
|
selector,
|
||||||
|
(state: State) => state.selectedDepartmentUserInfoList
|
||||||
|
),
|
||||||
|
selectedDepartmentStatus: createSelector(
|
||||||
|
selector,
|
||||||
|
(state: State) => state.selectedDepartmentStatus
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user