tnx-shared 5.3.253 → 5.3.255

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15490,6 +15490,7 @@ class DataFormBase extends ComponentBaseWithButton {
15490
15490
  this.setValidateForm = true;
15491
15491
  this.haveEntityMetadataAPI = true;
15492
15492
  this.isBaseModel = true;
15493
+ this.autoGenerateId = true;
15493
15494
  this.__isFormView = false;
15494
15495
  const moduleConfigService = _injector.get(ModuleConfigService);
15495
15496
  this.environment = moduleConfigService.getConfig().environment;
@@ -15952,8 +15953,10 @@ class DataFormBase extends ComponentBaseWithButton {
15952
15953
  onAfterSave(response) {
15953
15954
  }
15954
15955
  _onAfterSave() {
15955
- if (!this.isCloseForm) {
15956
- this.model.data.id = this._commonService.guid();
15956
+ var _a;
15957
+ var _b;
15958
+ if (!this.isCloseForm && this.autoGenerateId) {
15959
+ (_a = (_b = this.model.data).id) !== null && _a !== void 0 ? _a : (_b.id = this._commonService.guid());
15957
15960
  }
15958
15961
  }
15959
15962
  onAfterGetDetail(data) {
@@ -16176,6 +16179,253 @@ DataFormBase.propDecorators = {
16176
16179
  onDataBinded: [{ type: Output }]
16177
16180
  };
16178
16181
 
16182
+ class CauHinhWorkflowService extends BaseService {
16183
+ constructor(http, injector, _moduleConfigService) {
16184
+ super(http, injector, `${_moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint}/${_moduleConfigService.getConfig().environment.apiVersion}/CauHinhWorkflow`);
16185
+ this._moduleConfigService = _moduleConfigService;
16186
+ this.serviceCode = 'congviec';
16187
+ this.entityName = 'CauHinhWorkflow';
16188
+ this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint;
16189
+ }
16190
+ }
16191
+ CauHinhWorkflowService.ɵprov = i0.ɵɵdefineInjectable({ factory: function CauHinhWorkflowService_Factory() { return new CauHinhWorkflowService(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(ModuleConfigService)); }, token: CauHinhWorkflowService, providedIn: "root" });
16192
+ CauHinhWorkflowService.decorators = [
16193
+ { type: Injectable, args: [{
16194
+ providedIn: 'root'
16195
+ },] }
16196
+ ];
16197
+ CauHinhWorkflowService.ctorParameters = () => [
16198
+ { type: HttpClient },
16199
+ { type: Injector },
16200
+ { type: ModuleConfigService }
16201
+ ];
16202
+
16203
+ class StateMachinesService extends BaseService {
16204
+ constructor(http, injector, _moduleConfigService) {
16205
+ super(http, injector, `${_moduleConfigService.getConfig().environment.apiDomain.workflowEndpoint}/${_moduleConfigService.getConfig().environment.apiVersion}/StateMachines`);
16206
+ this._moduleConfigService = _moduleConfigService;
16207
+ this.entityName = 'StateMachines';
16208
+ this.serviceCode = 'workflow';
16209
+ this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.workflowEndpoint;
16210
+ }
16211
+ changeState(itemWorkflowHistory) {
16212
+ return this.defaultPost(`${this.serviceUri}/ChangeState`, itemWorkflowHistory);
16213
+ }
16214
+ rollback(rowData) {
16215
+ return this.defaultPost(`${this.serviceUri}/Rollback/${rowData.__workflowCode}/${rowData.id}`, {});
16216
+ }
16217
+ getUserInProcessForm(workflowCode, stateCode, actionCode, itemId) {
16218
+ return this.defaultPost(`${this.serviceUri}/GetUserInProcessForm/${workflowCode}/${stateCode}/${actionCode}/${itemId}`, {});
16219
+ }
16220
+ }
16221
+ StateMachinesService.ɵprov = i0.ɵɵdefineInjectable({ factory: function StateMachinesService_Factory() { return new StateMachinesService(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(ModuleConfigService)); }, token: StateMachinesService, providedIn: "root" });
16222
+ StateMachinesService.decorators = [
16223
+ { type: Injectable, args: [{
16224
+ providedIn: 'root'
16225
+ },] }
16226
+ ];
16227
+ StateMachinesService.ctorParameters = () => [
16228
+ { type: HttpClient },
16229
+ { type: Injector },
16230
+ { type: ModuleConfigService }
16231
+ ];
16232
+
16233
+ class DmLoaiCongViecService extends BaseService {
16234
+ constructor(http, injector, _moduleConfigService) {
16235
+ super(http, injector, `${_moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint}/${_moduleConfigService.getConfig().environment.apiVersion}/DM_LoaiCongViec`);
16236
+ this._moduleConfigService = _moduleConfigService;
16237
+ this.serviceCode = 'congviec';
16238
+ this.entityName = 'DM_LoaiCongViec';
16239
+ this.dicLoaiCongViec = {};
16240
+ this.keyIdLoaiCongViecRoot = 'root';
16241
+ this.getWorkflowSettingByIdLoaiCongViec = (idLoaiCongViec) => __awaiter(this, void 0, void 0, function* () {
16242
+ if (!this.dicWorkflowByLoaiCongViec) {
16243
+ yield this.getDatasourceWorkflowCongViec();
16244
+ }
16245
+ if (!idLoaiCongViec) {
16246
+ return this.dicWorkflowByLoaiCongViec[this.keyIdLoaiCongViecRoot];
16247
+ }
16248
+ let result = this.dicWorkflowByLoaiCongViec[idLoaiCongViec];
16249
+ if (result)
16250
+ return result;
16251
+ const idLoaiCongViecs = yield this.getIdLoaiCongViecs(idLoaiCongViec);
16252
+ if (!Array.isArray(idLoaiCongViecs))
16253
+ return null;
16254
+ if (idLoaiCongViecs.length > 1) {
16255
+ for (let i = idLoaiCongViecs.length - 2; i >= 0; i--) {
16256
+ result = this.dicWorkflowByLoaiCongViec[idLoaiCongViecs[i]];
16257
+ if (result)
16258
+ return result;
16259
+ }
16260
+ }
16261
+ if (!result) {
16262
+ result = this.dicWorkflowByLoaiCongViec[this.keyIdLoaiCongViecRoot];
16263
+ }
16264
+ return result;
16265
+ });
16266
+ this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint;
16267
+ }
16268
+ getDatasourceWorkflowCongViec() {
16269
+ return __awaiter(this, void 0, void 0, function* () {
16270
+ if (!this.dicWorkflowByLoaiCongViec) {
16271
+ this.dicWorkflowByLoaiCongViec = {};
16272
+ }
16273
+ const cauHinhWorkflowService = this._injector.get(CauHinhWorkflowService);
16274
+ const cauHinhWorkflows = (yield cauHinhWorkflowService.getAll([], 'idLoaiCongViec,workflowCodes,workflowCode')).data;
16275
+ const notifierService = this._injector.get(NotifierService);
16276
+ if (cauHinhWorkflows == null) {
16277
+ notifierService.showWarning('Dịch vụ workflow không phản hồi');
16278
+ return [];
16279
+ }
16280
+ const workflowCodes = [];
16281
+ cauHinhWorkflows.forEach(itemWorkflowSetting => {
16282
+ if (itemWorkflowSetting.workflowCodes && !Array.isArray(itemWorkflowSetting.workflowCodes)) {
16283
+ itemWorkflowSetting.workflowCodes = itemWorkflowSetting.workflowCodes.split(',');
16284
+ }
16285
+ else {
16286
+ itemWorkflowSetting.workflowCodes = [];
16287
+ }
16288
+ itemWorkflowSetting.workflowCodes.forEach(workflowCode => {
16289
+ if (workflowCodes.indexOf(workflowCode) == -1) {
16290
+ workflowCodes.push(workflowCode);
16291
+ }
16292
+ });
16293
+ });
16294
+ const stateMachinesService = this._injector.get(StateMachinesService);
16295
+ const workflows = (yield stateMachinesService.getDataDropdownByFilter([
16296
+ this.newFilter('code', Operator.in, workflowCodes)
16297
+ ], new DropdownOptions({
16298
+ valueField: 'code',
16299
+ displayField: 'title',
16300
+ fieldPlus: 'data'
16301
+ })));
16302
+ workflows.forEach(item => {
16303
+ item.data = JSON.parse(item.data);
16304
+ const stateMachineData = item.data;
16305
+ stateMachineData.actions = {};
16306
+ stateMachineData.machines.forEach(machine => {
16307
+ stateMachineData.actions[machine.code] = [];
16308
+ stateMachineData.connections.forEach(conn => {
16309
+ if (conn.source == machine.id) {
16310
+ stateMachineData.actions[machine.code].push(conn);
16311
+ }
16312
+ });
16313
+ });
16314
+ });
16315
+ cauHinhWorkflows.forEach(itemWorkflowSetting => {
16316
+ itemWorkflowSetting.workflows = workflows.filter(q => itemWorkflowSetting.workflowCodes.indexOf(q.code) > -1);
16317
+ if (!itemWorkflowSetting.idLoaiCongViec) {
16318
+ this.dicWorkflowByLoaiCongViec[this.keyIdLoaiCongViecRoot] = itemWorkflowSetting;
16319
+ }
16320
+ else {
16321
+ this.dicWorkflowByLoaiCongViec[itemWorkflowSetting.idLoaiCongViec] = itemWorkflowSetting;
16322
+ }
16323
+ });
16324
+ return workflows;
16325
+ });
16326
+ }
16327
+ getIdLoaiCongViecs(idLoaiCongViec) {
16328
+ return __awaiter(this, void 0, void 0, function* () {
16329
+ const notifierService = this._injector.get(NotifierService);
16330
+ const itemLoaiCongViec = yield this.getItemLoaiCongViec(idLoaiCongViec);
16331
+ if (itemLoaiCongViec == null) {
16332
+ notifierService.showWarning('Loại công việc không tồn tại');
16333
+ return null;
16334
+ }
16335
+ const idLoaiCongViecs = itemLoaiCongViec.idDuongDan.split(';').filter(q => !!q);
16336
+ return idLoaiCongViecs;
16337
+ });
16338
+ }
16339
+ getItemLoaiCongViec(idLoaiCongViec) {
16340
+ return __awaiter(this, void 0, void 0, function* () {
16341
+ if (!this.dicLoaiCongViec[idLoaiCongViec]) {
16342
+ this.dicLoaiCongViec[idLoaiCongViec] = (yield this.getDetail(idLoaiCongViec)).data;
16343
+ }
16344
+ return this.dicLoaiCongViec[idLoaiCongViec];
16345
+ });
16346
+ }
16347
+ }
16348
+ DmLoaiCongViecService.ɵprov = i0.ɵɵdefineInjectable({ factory: function DmLoaiCongViecService_Factory() { return new DmLoaiCongViecService(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(ModuleConfigService)); }, token: DmLoaiCongViecService, providedIn: "root" });
16349
+ DmLoaiCongViecService.decorators = [
16350
+ { type: Injectable, args: [{
16351
+ providedIn: 'root'
16352
+ },] }
16353
+ ];
16354
+ DmLoaiCongViecService.ctorParameters = () => [
16355
+ { type: HttpClient },
16356
+ { type: Injector },
16357
+ { type: ModuleConfigService }
16358
+ ];
16359
+
16360
+ class CongViecService extends BaseService {
16361
+ constructor(http, injector, _moduleConfigService, _dmLoaiCongViecService) {
16362
+ super(http, injector, `${_moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint}/${_moduleConfigService.getConfig().environment.apiVersion}/CongViec_Chinh`);
16363
+ this._dmLoaiCongViecService = _dmLoaiCongViecService;
16364
+ this.serviceCode = 'congviec';
16365
+ this.entityName = 'CongViec_Chinh';
16366
+ this.objectName = 'công việc';
16367
+ this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint;
16368
+ this._moduleConfig = _moduleConfigService.getConfig();
16369
+ }
16370
+ adjustSettingWorkflowForCrudList(setting) {
16371
+ this.useWorkflow = true;
16372
+ setting.isWorkflowTree = true;
16373
+ setting.baseService = this;
16374
+ setting.displayField = (item) => item.ten;
16375
+ setting.baseService.useWorkflow = true;
16376
+ setting.workflowConfigAdvance = {
16377
+ getWorkflowSetting: this.getWorkflowConfig.bind(this)
16378
+ };
16379
+ }
16380
+ getWorkflowConfig(rowData) {
16381
+ return __awaiter(this, void 0, void 0, function* () {
16382
+ return yield this._dmLoaiCongViecService.getWorkflowSettingByIdLoaiCongViec(rowData.idLoaiCongViec);
16383
+ });
16384
+ }
16385
+ countByMenuState(data) {
16386
+ return this.defaultPost(`${this.serviceUri}/CountByMenuState`, data);
16387
+ }
16388
+ getDicIdByMenuState(data, tuNgay, denNgay) {
16389
+ return this.defaultPost(`${this.serviceUri}/GetDicIdByMenuState`, {
16390
+ lstTrangThai: data,
16391
+ tuNgay,
16392
+ denNgay
16393
+ });
16394
+ }
16395
+ updateBulkIdCha(model) {
16396
+ const url = `${this.serviceUri}/UpdateBulkIdCha`;
16397
+ return this.defaultPost(url, model);
16398
+ }
16399
+ deleteBulkCongViecCon(ids) {
16400
+ const url = `${this.serviceUri}/DeleteBulkCongViecCon`;
16401
+ return this.defaultPost(url, ids);
16402
+ }
16403
+ getDataDashboardCaNhan(inputData) {
16404
+ const url = `${this.serviceUri}/GetDataDashboardCaNhan`;
16405
+ return this.defaultPost(url, inputData);
16406
+ }
16407
+ getDataDashboardByDonVi(inputData) {
16408
+ const url = `${this.serviceUri}/GetDataDashboardByDonVi`;
16409
+ return this.defaultPost(url, inputData);
16410
+ }
16411
+ getListTasksDashboard(dataFilter) {
16412
+ const url = `${this.serviceUri}/getListTasksDashboard`;
16413
+ return this.defaultPost(url, dataFilter);
16414
+ }
16415
+ }
16416
+ CongViecService.ɵprov = i0.ɵɵdefineInjectable({ factory: function CongViecService_Factory() { return new CongViecService(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(ModuleConfigService), i0.ɵɵinject(DmLoaiCongViecService)); }, token: CongViecService, providedIn: "root" });
16417
+ CongViecService.decorators = [
16418
+ { type: Injectable, args: [{
16419
+ providedIn: 'root'
16420
+ },] }
16421
+ ];
16422
+ CongViecService.ctorParameters = () => [
16423
+ { type: HttpClient },
16424
+ { type: Injector },
16425
+ { type: ModuleConfigService },
16426
+ { type: DmLoaiCongViecService }
16427
+ ];
16428
+
16179
16429
  class SearchInfo {
16180
16430
  constructor(init) {
16181
16431
  this.fieldSearchText = [];
@@ -16443,752 +16693,160 @@ TnCustomScrollbarComponent.propDecorators = {
16443
16693
  scrollXReachStart: [{ type: Output }]
16444
16694
  };
16445
16695
 
16446
- const EXCEL_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8';
16447
- const EXCEL_EXTENSION = '.xlsx';
16448
- class ExportService {
16449
- constructor(_http, _injector, _commonService, _moduleConfigService) {
16450
- this._http = _http;
16451
- this._injector = _injector;
16452
- this._commonService = _commonService;
16453
- this._moduleConfig = _moduleConfigService.getConfig();
16454
- this.environment = this._moduleConfig.environment;
16455
- this.serviceUri = `${this._moduleConfig.environment.apiDomain.templateEndpoint}/Export`;
16456
- }
16457
- objectToExcel(data, fileName, numOfHeaderRow) {
16458
- return this._http
16459
- .post(`${this.serviceUri}/ObjectToExcel?numOfHeaderRow=${numOfHeaderRow}`, data, { responseType: 'blob' })
16460
- .pipe(catchError((err) => this._commonService.handleError(err, this._injector)))
16461
- .subscribe(res => {
16462
- this.saveAsExcelFile(res, fileName);
16463
- });
16464
- }
16465
- saveAsExcelFile(buffer, fileName) {
16466
- const data = new Blob([buffer], {
16467
- type: EXCEL_TYPE
16468
- });
16469
- FileSaver__default.saveAs(data, fileName + '_' + new Date().getTime() + EXCEL_EXTENSION);
16696
+ class BasePermissionService extends BaseService {
16697
+ constructor(http, injector, _moduleConfigService) {
16698
+ super(http, injector, `${_moduleConfigService.getConfig().environment.apiDomain.authorizationEndpoint}/${_moduleConfigService.getConfig().environment.apiVersion}/BasePermission`);
16699
+ this._moduleConfigService = _moduleConfigService;
16700
+ this.entityName = 'BasePermission';
16701
+ this.serviceCode = 'Authorization';
16702
+ this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.authorizationEndpoint;
16470
16703
  }
16471
- saveSpreadSheet(buffer, fileName) {
16472
- const data = new Blob([buffer], {
16473
- type: EXCEL_TYPE
16474
- });
16475
- FileSaver__default.saveAs(data, new Date().getTime() + '_' + fileName);
16704
+ getPermissionByCode(code) {
16705
+ return this.defaultGet(`${this.serviceUri}/GetPermissionByCode?code=${code}`);
16476
16706
  }
16477
16707
  }
16478
- ExportService.ɵprov = i0.ɵɵdefineInjectable({ factory: function ExportService_Factory() { return new ExportService(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(CommonService), i0.ɵɵinject(ModuleConfigService)); }, token: ExportService, providedIn: "root" });
16479
- ExportService.decorators = [
16708
+ BasePermissionService.ɵprov = i0.ɵɵdefineInjectable({ factory: function BasePermissionService_Factory() { return new BasePermissionService(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(ModuleConfigService)); }, token: BasePermissionService, providedIn: "root" });
16709
+ BasePermissionService.decorators = [
16480
16710
  { type: Injectable, args: [{
16481
16711
  providedIn: 'root'
16482
16712
  },] }
16483
16713
  ];
16484
- ExportService.ctorParameters = () => [
16714
+ BasePermissionService.ctorParameters = () => [
16485
16715
  { type: HttpClient },
16486
16716
  { type: Injector },
16487
- { type: CommonService },
16488
16717
  { type: ModuleConfigService }
16489
16718
  ];
16490
16719
 
16491
- class PhanQuyenModel {
16492
- constructor(init) {
16493
- this.addRoleIds = [];
16494
- this.removeRoleIds = [];
16495
- this.addPermissionIds = [];
16496
- this.removePermissionIds = [];
16497
- for (const key in init) {
16498
- this[key] = init[key];
16720
+ class CoCauToChucService extends BaseService {
16721
+ constructor(http, injector, _moduleConfigService) {
16722
+ super(http, injector, `${_moduleConfigService.getConfig().environment.apiDomain.userOrgEndpoint}/${_moduleConfigService.getConfig().environment.apiVersion}/organization`);
16723
+ this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.userOrgEndpoint;
16724
+ this.environment = _moduleConfigService.getConfig().environment;
16725
+ if (this.isUseOldOrganization()) {
16726
+ this.serviceUri = `${this.environment.apiDomain.organizationEndpoint}/organization`;
16727
+ }
16728
+ }
16729
+ createDropdownTree(field = 'idDonViQuanLy') {
16730
+ return new DropdownControlSchema({
16731
+ field,
16732
+ placeholder: 'Chọn đơn vị',
16733
+ baseService: this,
16734
+ sortField: 'idDuongDan',
16735
+ fieldPlus: 'idDuongDan',
16736
+ isTree: true,
16737
+ fieldTree: 'idCha',
16738
+ valueParentRoot: this._commonService.guidEmpty(),
16739
+ // isServerLoad: true, Option này đang không chạy được trong case này
16740
+ loadOnInit: true,
16741
+ maxItemDisplay: 9999
16742
+ // funcGetLabel: (item) => {
16743
+ // let level = item.idDuongDan.split(';').length - 2;
16744
+ // let prefix = '';
16745
+ // if (level < 2)
16746
+ // level = 1;
16747
+ // else
16748
+ // prefix = '|';
16749
+ // return `${prefix}${'---'.repeat(level - 1)} ${item.ten}`;
16750
+ // }
16751
+ });
16752
+ }
16753
+ isUseOldOrganization() {
16754
+ const useOldOrganization = this.environment.useOldOrganization;
16755
+ if (useOldOrganization) {
16756
+ return true;
16757
+ }
16758
+ return false;
16759
+ }
16760
+ getByParentCode(organizationCode) {
16761
+ let apiUrl = `${this.serviceUri}/GetByParentCode`;
16762
+ if (organizationCode) {
16763
+ apiUrl = `${apiUrl}?parentCode=${organizationCode}`;
16764
+ }
16765
+ return this.defaultGet(apiUrl);
16766
+ }
16767
+ getByCanBoId(canBoId) {
16768
+ const apiUrl = `${this.serviceUri}/GetByCanBoId/${canBoId}`;
16769
+ return this.defaultGet(apiUrl);
16770
+ }
16771
+ getCoCauToChucTreeTable(isIgnoreClientCache = false) {
16772
+ const apiUrl = `${this.serviceUri}/GetTreeTable`;
16773
+ if (isIgnoreClientCache) {
16774
+ return this.getIgnoreClientCache(apiUrl);
16499
16775
  }
16776
+ return this.defaultGet(apiUrl);
16777
+ }
16778
+ updateMaPhanCap(idCha) {
16779
+ return this.defaultPost(`${this.serviceUri}/UpdateMaPhanCap/${idCha}`, {});
16500
16780
  }
16501
16781
  }
16502
- class PermissionService extends BaseService {
16503
- constructor(http, injector, _moduleConfigService, _userService, _oauthService, _appContext) {
16504
- super(http, injector, `${_moduleConfigService.getConfig().environment.apiDomain.authorizationEndpoint}/${_moduleConfigService.getConfig().environment.apiVersion}/permission`);
16782
+ CoCauToChucService.ɵprov = i0.ɵɵdefineInjectable({ factory: function CoCauToChucService_Factory() { return new CoCauToChucService(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(ModuleConfigService)); }, token: CoCauToChucService, providedIn: "root" });
16783
+ CoCauToChucService.decorators = [
16784
+ { type: Injectable, args: [{
16785
+ providedIn: 'root'
16786
+ },] }
16787
+ ];
16788
+ CoCauToChucService.ctorParameters = () => [
16789
+ { type: HttpClient },
16790
+ { type: Injector },
16791
+ { type: ModuleConfigService }
16792
+ ];
16793
+
16794
+ class CanBo_HoSo_CoCauToChucService extends BaseService {
16795
+ constructor(http, injector, _moduleConfigService) {
16796
+ super(http, injector, `${_moduleConfigService.getConfig().environment.apiDomain.canboEndpoint}/${_moduleConfigService.getConfig().environment.apiVersion}/CanBo_HoSo_CoCauToChuc`);
16505
16797
  this._moduleConfigService = _moduleConfigService;
16506
- this._userService = _userService;
16507
- this._oauthService = _oauthService;
16508
- this._appContext = _appContext;
16509
- this.storage = sessionStorage;
16510
- this.ignoreAdmin = false;
16511
- this.delayCheckPermissions = [];
16512
- this.appCode = null;
16513
- this._config = this._moduleConfigService.getConfig();
16514
- this.endPoint = this._config.environment.apiDomain.authorizationEndpoint;
16515
- this.ignoreAdmin = this._config.environment.isIgnoreAdmin;
16516
- this.appCode = this._config.appCode;
16798
+ this.entityName = 'CanBo_HoSo_CoCauToChuc';
16799
+ this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.canboEndpoint;
16517
16800
  }
16518
- clearPermissionCacheAll() {
16519
- var _a, _b, _c;
16520
- const lstAppCodes = (_c = (_b = (_a = this._config.environment.appMetadata) === null || _a === void 0 ? void 0 : _a.appSwitcher) === null || _b === void 0 ? void 0 : _b.map(app => app.code)) !== null && _c !== void 0 ? _c : [];
16521
- const lstApiEndpoint = [];
16522
- const apiDomain = this._config.environment.apiDomain;
16523
- for (const domainName in apiDomain) {
16524
- if (domainName.startsWith('-') || domainName.startsWith('1') || domainName == 'gateway')
16525
- continue;
16526
- const realDomainName = domainName.split('Endpoint') ? domainName.split('Endpoint')[0] : domainName;
16527
- lstApiEndpoint.push(realDomainName.toUpperCase());
16528
- }
16529
- return this.clearPermissionCache([...lstAppCodes, ...lstApiEndpoint]);
16801
+ sapNhapCoCauToChuc(model) {
16802
+ return this.defaultPost(`${this.serviceUri}/SapNhapCoCauToChuc`, model);
16530
16803
  }
16531
- clearPermissionCache(lstModule) {
16532
- const url = `${this.serviceUri}/ClearPermissionCache`;
16533
- return this.defaultPost(url, lstModule);
16804
+ getIdsDonViByCanBoLogin() {
16805
+ return this.defaultGet(`${this.serviceUri}/GetIdsDonViByCanBoLogin`);
16534
16806
  }
16535
- getCurrentUserPermission() {
16536
- const url = `${this.serviceUri}/GetCurrentUserPermission`;
16537
- return this.defaultGet(url);
16807
+ getDonViChucVuCapCaoNhatByIdsCanBo(idsCanBo = []) {
16808
+ return this.defaultPost(`${this.serviceUri}/GetDonViChucVuCapCaoNhatByIdsCanBo`, idsCanBo);
16538
16809
  }
16539
- getAllBasePermission(userId) {
16540
- var _a, _b, _c;
16810
+ unshiftColumnKhoaVienBoMon(modelSchemas, cols) {
16811
+ modelSchemas.unshift(...[new ModelSchema({
16812
+ field: 'donVi',
16813
+ name: 'Khoa viện/ đơn vị',
16814
+ fullName: 'Khoa viện/ đơn vị',
16815
+ description: 'Khoa viện/ đơn vị'
16816
+ }),
16817
+ new ModelSchema({
16818
+ field: 'boMon',
16819
+ name: 'Bộ môn/ văn phòng khoa',
16820
+ fullName: 'Bộ môn/ văn phòng khoa',
16821
+ description: 'Bộ môn/ văn phòng khoa'
16822
+ })]);
16823
+ cols.unshift(...[new ColumnSchemaBase({
16824
+ field: 'donVi',
16825
+ dataType: 'html',
16826
+ width: '200px',
16827
+ allowFilter: false,
16828
+ sort: false
16829
+ }),
16830
+ new ColumnSchemaBase({
16831
+ field: 'boMon',
16832
+ dataType: 'html',
16833
+ width: '200px',
16834
+ allowFilter: false,
16835
+ sort: false
16836
+ })]);
16837
+ }
16838
+ getsDonViTheoCap(dataSource = []) {
16839
+ return this.defaultPost(`${this.serviceUri}/GetsDonViTheoCap`, dataSource);
16840
+ }
16841
+ getKhoaVienBoMonAfterGetData(dataSource) {
16541
16842
  return __awaiter(this, void 0, void 0, function* () {
16542
- const url = `${this.serviceUri}/GetAllBasePermission`;
16543
- // return sớm đây là trường hợp lấy permission theo Id của User
16544
- // ko set local storage vì sẽ làm hỏng quyền của người dùng hiện tại
16545
- if (userId && userId != '' && userId != this._commonService.guidEmpty()) {
16546
- return this.defaultGet(url + `?userId=${userId}`);
16547
- }
16548
- if (isDevMode()) {
16549
- return;
16550
- }
16551
- const user = this._userService.getCurrentUser();
16552
- if (user
16553
- && (user.issuperuser && user.issuperuser.toLowerCase() == 'true')
16554
- || (user.isadmin && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin)) {
16555
- return;
16556
- }
16557
- const res = yield this.defaultGet(url);
16558
- const lstAppCodes = (_c = (_b = (_a = this._config.environment.appMetadata) === null || _a === void 0 ? void 0 : _a.appSwitcher) === null || _b === void 0 ? void 0 : _b.map(app => app.code)) !== null && _c !== void 0 ? _c : [];
16559
- // Nếu Có error lấy dữ liệu quyền tổng hợp thì quay về lấy dữ liệu quyền dựa vào từng module
16560
- if (!res || !res.success || res.data == null) {
16561
- const promiseArr = [];
16562
- for (const code of lstAppCodes) {
16563
- promiseArr.push(this.getServicePermission(code, true));
16564
- }
16565
- yield Promise.all(promiseArr);
16566
- return;
16567
- }
16568
- // Set local storage cho permission của người dùng
16569
- for (const service of lstAppCodes) {
16570
- let permissions = [];
16571
- const serviceCode = service.toUpperCase();
16572
- for (const key in res.data) {
16573
- if (key.toUpperCase() != serviceCode) {
16574
- continue;
16575
- }
16576
- permissions = res.data[key];
16577
- break;
16578
- }
16579
- const key = `AUTHORIZATION.${serviceCode}`;
16580
- const storageItem = this.storage.getItem(key);
16581
- if (storageItem != null) {
16582
- this.storage.removeItem(key);
16583
- }
16584
- this.storage.setItem(key, JSON.stringify(permissions));
16585
- }
16586
- });
16587
- }
16588
- /**
16589
- * Truyền vào danh sách permision cần check
16590
- * @param lstPermissionCode những perrmision code cần check => nên dùng trong trường hợp check các button trong code
16591
- * @returns trả ra các perrmisionCode có quyền
16592
- */
16593
- getPermissionAuthorized(lstPermissionCode) {
16594
- return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
16595
- const user = (yield this._userService.getCurrentUser());
16596
- if (user && user.issuperuser.toLowerCase() == 'true') {
16597
- resolve(lstPermissionCode);
16598
- return;
16599
- }
16600
- if (user && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin) {
16601
- resolve(lstPermissionCode);
16602
- return;
16603
- }
16604
- const result = [];
16605
- for (const item of lstPermissionCode) {
16606
- if (yield this.isAuthorizedPermission(item)) {
16607
- result.push(item);
16608
- }
16609
- }
16610
- resolve(result);
16611
- }));
16612
- }
16613
- isAuthorizedPermission(permission) {
16614
- return __awaiter(this, void 0, void 0, function* () {
16615
- let retryCount = 0;
16616
- while (!this._oauthService.hasValidAccessToken()) {
16617
- yield this._commonService.delay(100);
16618
- retryCount++;
16619
- if (retryCount > 50) {
16620
- break;
16621
- }
16622
- }
16623
- return yield this.checkPermission(this.appCode, permission);
16624
- });
16625
- }
16626
- isAuthorized(service, permission, checForMenu = false) {
16627
- return __awaiter(this, void 0, void 0, function* () {
16628
- this.root = this._appContext.getRootContext();
16629
- let retryCount = 0;
16630
- while (!this._oauthService.hasValidAccessToken()) {
16631
- yield this._commonService.delay(100);
16632
- retryCount++;
16633
- if (retryCount > 50) {
16634
- break;
16635
- }
16636
- }
16637
- return yield this.checkPermission(service, permission, checForMenu);
16638
- });
16639
- }
16640
- checkPermission(service, permissionToCheck, checkForMenu = false) {
16641
- return __awaiter(this, void 0, void 0, function* () {
16642
- try {
16643
- const user = this._userService.getCurrentUser();
16644
- const valueIsDevMode = true;
16645
- if (isDevMode() && valueIsDevMode) {
16646
- return true;
16647
- }
16648
- if (user && user.issuperuser && user.issuperuser.toLowerCase() == 'true' && valueIsDevMode) {
16649
- return true;
16650
- }
16651
- if (user && user.isadmin && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin && valueIsDevMode) {
16652
- return true;
16653
- }
16654
- const userPermissions = yield this.getServicePermission(service);
16655
- if (userPermissions && userPermissions.length > 0) {
16656
- return checkForMenu
16657
- ? userPermissions.includes(permissionToCheck)
16658
- : this._checkPermission(userPermissions, permissionToCheck);
16659
- }
16660
- else {
16661
- // console.log(`Không có quyền với phân hệ [${service}]`);
16662
- return false;
16663
- }
16664
- }
16665
- catch (_a) {
16666
- return false;
16667
- }
16668
- });
16669
- }
16670
- _checkPermission(userPermissions, permissionToCheck) {
16671
- let isAuthorized = false;
16672
- // check permission của người dùng
16673
- // duyệt qua từng permission của người dùng
16674
- for (const userPermission of userPermissions) {
16675
- // biến để break khỏi vòng khi người dùng được authorized
16676
- let breakOuterLoop = false;
16677
- // pointer permission của người dùng
16678
- let userPermissionPointer = 0;
16679
- // pointer permission đang check
16680
- let permissionToCheckPointer = 0;
16681
- // mark co the check query param
16682
- let aboutToCheckQueryParam = false;
16683
- // check từng char của 2 mảng
16684
- for (; permissionToCheckPointer < permissionToCheck.length;) {
16685
- // nếu char là ký tự bắt đầu template => tịnh tiến pointer của 2 mảng
16686
- let needRecheck = false;
16687
- if (userPermission[userPermissionPointer] == '{') {
16688
- // cho đến khi tìm được ký tự '/' tiếp theo thì dừng lại
16689
- for (; userPermissionPointer < userPermission.length; userPermissionPointer++) {
16690
- if (userPermissionPointer == userPermission.length - 1) {
16691
- break;
16692
- }
16693
- if (userPermission[userPermissionPointer] != '}') {
16694
- continue;
16695
- }
16696
- if (userPermission[userPermissionPointer] === '?') {
16697
- aboutToCheckQueryParam = true;
16698
- }
16699
- ++userPermissionPointer; // tiến tiến đến ký tự sau kết thúc template
16700
- // check trường hợp trường hợp chuỗi template có dạng "{template}acsekjf"
16701
- // => cần check các ký tự sau template và trước ký tự '/'
16702
- if (userPermission[userPermissionPointer] != '/' && (aboutToCheckQueryParam && userPermission[userPermissionPointer] != '&')) {
16703
- needRecheck = true;
16704
- for (; userPermissionPointer < userPermission.length; userPermissionPointer++) {
16705
- if (userPermissionPointer == userPermission.length - 1) {
16706
- break;
16707
- }
16708
- if (userPermission[userPermissionPointer] != '/') {
16709
- continue;
16710
- }
16711
- break;
16712
- }
16713
- }
16714
- break;
16715
- }
16716
- for (; permissionToCheckPointer < permissionToCheck.length; permissionToCheckPointer++) {
16717
- if (permissionToCheckPointer == permissionToCheck.length - 1) {
16718
- break;
16719
- }
16720
- if (permissionToCheck[permissionToCheckPointer] == '/' || (aboutToCheckQueryParam && permissionToCheck[permissionToCheckPointer] == '&')) {
16721
- break;
16722
- }
16723
- }
16724
- }
16725
- let breakInnerLoop = false;
16726
- if (needRecheck) {
16727
- // check lại cho trường hợp chuỗi template có dạng "{template}acslekfj"
16728
- // duyệt ngược lại cho đến khi gặp ký tự kết thúc template
16729
- let tempUserPointer = userPermissionPointer;
16730
- let tempToCheckPointer = permissionToCheckPointer;
16731
- while (userPermission[tempUserPointer] != '}') {
16732
- // ký tự khác nhau => break khỏi vòng kiểm tra trong
16733
- if (userPermission[tempUserPointer].toLowerCase() != permissionToCheck[tempToCheckPointer].toLowerCase()) {
16734
- breakInnerLoop = true;
16735
- break;
16736
- }
16737
- tempUserPointer--;
16738
- tempToCheckPointer--;
16739
- }
16740
- }
16741
- if (breakInnerLoop) {
16742
- break;
16743
- }
16744
- const userChar = userPermission[userPermissionPointer].toLowerCase();
16745
- const toCheckChar = permissionToCheck[permissionToCheckPointer].toLowerCase();
16746
- // nếu userPermission đang ở index cuối
16747
- if (userPermissionPointer == userPermission.length - 1) {
16748
- // check char cuối của 2 mảng (trừ khi là ký tự kết thúc template)
16749
- // và cũng phải là char cuối của mảng permission cần check
16750
- // => người dùng authorized và break khỏi vòng lặp ngoài cùng
16751
- if ((userChar == '}' || userChar == toCheckChar)
16752
- && permissionToCheckPointer == permissionToCheck.length - 1) {
16753
- breakOuterLoop = true;
16754
- isAuthorized = true;
16755
- }
16756
- break;
16757
- }
16758
- // check char có giống nhau không, không giống thì break khỏi vòng check
16759
- if (userChar != toCheckChar) {
16760
- break;
16761
- }
16762
- // nếu char giống nhau thì tiếp tục vòng lăp
16763
- permissionToCheckPointer++;
16764
- userPermissionPointer++;
16765
- }
16766
- if (breakOuterLoop) {
16767
- break;
16768
- }
16769
- }
16770
- return isAuthorized;
16771
- }
16772
- _checkPermissionOld(userPermissions, permissionToCheck) {
16773
- let isAuthorized = false;
16774
- // check quyền theo cách cũ nếu trường họp là phân quyền module
16775
- if (permissionToCheck.includes('MODULE')) {
16776
- return userPermissions.includes(permissionToCheck);
16777
- }
16778
- for (const userPermission of userPermissions) {
16779
- // Cắt chuỗi permission thành mảng để xem mỗi fragement có khớp nhau không
16780
- const userPermissionFragments = userPermission.split('/');
16781
- const permissionFragments = permissionToCheck.split('/');
16782
- // Mảng khác độ dài thì thoát sớm
16783
- if (userPermissionFragments.length != permissionFragments.length) {
16784
- continue;
16785
- }
16786
- // biến flag ra hiệu người dùng authorized và out vòng
16787
- let breakLoop = false;
16788
- // nếu tất cả phần tử khớp nhau => permission này trùng và người dùng được authorized
16789
- for (let index = 0; index < permissionFragments.length; index++) {
16790
- const userFragement = userPermissionFragments[index];
16791
- const permissionFragment = permissionFragments[index];
16792
- // skip qua các phần tử có ký tự bắt đầu là '{'
16793
- if (userFragement[0] == '{') {
16794
- if (index == permissionFragments.length - 1) {
16795
- isAuthorized = true;
16796
- breakLoop = true;
16797
- }
16798
- continue;
16799
- }
16800
- if (userFragement.toLowerCase() != permissionFragment.toLowerCase()) {
16801
- break;
16802
- }
16803
- if (index == permissionFragments.length - 1) {
16804
- isAuthorized = true;
16805
- breakLoop = true;
16806
- }
16807
- }
16808
- if (breakLoop) {
16809
- break;
16810
- }
16811
- }
16812
- return isAuthorized;
16813
- }
16814
- isAuthorizedByPermissions(permissions, operator = 'OR', ignoreAdmin = false) {
16815
- return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
16816
- const user = (yield this._userService.getCurrentUser());
16817
- if (user && user.issuperuser.toLowerCase() == 'true') {
16818
- resolve(true);
16819
- return;
16820
- }
16821
- if (user && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin) {
16822
- resolve(true);
16823
- return;
16824
- }
16825
- let isAuthorized = true;
16826
- if (operator.toUpperCase() == 'OR') {
16827
- isAuthorized = false;
16828
- }
16829
- permissions.forEach(item => {
16830
- this.getServicePermission(item.service).then(permissionResult => {
16831
- if (operator.toUpperCase() == 'OR') {
16832
- if (permissionResult.includes(item.permission)) {
16833
- isAuthorized = true;
16834
- return;
16835
- }
16836
- }
16837
- else {
16838
- if (!permissionResult.includes(item.permission)) {
16839
- isAuthorized = false;
16840
- return;
16841
- }
16842
- }
16843
- }, error => {
16844
- reject(false);
16845
- });
16846
- });
16847
- resolve(isAuthorized);
16848
- }));
16849
- }
16850
- getServicePermission(service, overrideLocalStorage = false) {
16851
- return __awaiter(this, void 0, void 0, function* () {
16852
- const key = `AUTHORIZATION.${service.toUpperCase()}`;
16853
- if (!overrideLocalStorage) {
16854
- const storageItem = this.storage.getItem(key);
16855
- if (storageItem && storageItem !== 'null') {
16856
- const result = JSON.parse(storageItem);
16857
- return result;
16858
- }
16859
- }
16860
- const url = `${this.serviceUri}/GetPermissionsByService?service=${service}`;
16861
- const response = yield this.defaultGet(url);
16862
- if (!response || !response.success) {
16863
- return [];
16864
- }
16865
- if (overrideLocalStorage) {
16866
- this.storage.removeItem(key);
16867
- }
16868
- this.storage.setItem(key, JSON.stringify(response.data));
16869
- return response.data;
16870
- });
16871
- }
16872
- getPermissionIdsByModule(moduleCode, userId) {
16873
- const url = `${this.serviceUri}/GetPermissionIdsByModule/${moduleCode}/${userId}`;
16874
- return this.defaultGet(url);
16875
- }
16876
- phanQuyenNguoiDung(model) {
16877
- const url = `${this.serviceUri}/PhanQuyenNguoiDung`;
16878
- return this.defaultPost(url, model);
16879
- }
16880
- }
16881
- PermissionService.ɵprov = i0.ɵɵdefineInjectable({ factory: function PermissionService_Factory() { return new PermissionService(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(ModuleConfigService), i0.ɵɵinject(UserService), i0.ɵɵinject(i4.OAuthService), i0.ɵɵinject(ApplicationContextService)); }, token: PermissionService, providedIn: "root" });
16882
- PermissionService.decorators = [
16883
- { type: Injectable, args: [{
16884
- providedIn: 'root'
16885
- },] }
16886
- ];
16887
- PermissionService.ctorParameters = () => [
16888
- { type: HttpClient },
16889
- { type: Injector },
16890
- { type: ModuleConfigService },
16891
- { type: UserService },
16892
- { type: OAuthService },
16893
- { type: ApplicationContextService }
16894
- ];
16895
-
16896
- var sort_by;
16897
- (function () {
16898
- const defaultCompareFunc = function (a, b) {
16899
- if (a == b)
16900
- return 0;
16901
- return a < b ? -1 : 1;
16902
- };
16903
- const getCompareFunc = function (primer, reverse) {
16904
- const defaultCompare = defaultCompareFunc;
16905
- let compare = defaultCompareFunc;
16906
- if (primer) {
16907
- compare = function (a, b) {
16908
- return defaultCompare(primer(a), primer(b));
16909
- };
16910
- }
16911
- if (reverse) {
16912
- return function (a, b) {
16913
- return -1 * compare(a, b);
16914
- };
16915
- }
16916
- return compare;
16917
- };
16918
- sort_by = function (...args) {
16919
- const fields = [], n_fields = args.length;
16920
- let field, name, cmp;
16921
- // preprocess sorting options
16922
- for (let i = 0; i < n_fields; i++) {
16923
- field = args[i];
16924
- if (typeof field === 'string') {
16925
- name = field;
16926
- cmp = defaultCompareFunc;
16927
- }
16928
- else {
16929
- name = field.name;
16930
- cmp = getCompareFunc(field.primer, field.reverse);
16931
- }
16932
- fields.push({
16933
- name: name,
16934
- cmp: cmp
16935
- });
16936
- }
16937
- // final comparison function
16938
- return function (A, B) {
16939
- let name, result;
16940
- for (let i = 0; i < n_fields; i++) {
16941
- result = 0;
16942
- field = fields[i];
16943
- name = field.name;
16944
- result = field.cmp(A[name], B[name]);
16945
- if (result !== 0)
16946
- break;
16947
- }
16948
- return result;
16949
- };
16950
- };
16951
- }());
16952
- // multipleSort('idTinhThanh', 'idQuanHuyen')
16953
- // multipleSort({name: 'idTinhThanh', reverse: true}, 'idQuanHuyen')
16954
- // multipleSort({name: 'soThuTu', primer: parseInt}, 'idQuanHuyen') // parseInt là function
16955
- const multipleSort = sort_by;
16956
-
16957
- const moduleMap = {};
16958
- function loadRemoteEntry(remoteEntry) {
16959
- return new Promise((resolve, reject) => {
16960
- if (moduleMap[remoteEntry]) {
16961
- resolve();
16962
- return;
16963
- }
16964
- const script = document.createElement('script');
16965
- script.src = remoteEntry;
16966
- script.onerror = reject;
16967
- script.onload = () => {
16968
- moduleMap[remoteEntry] = true;
16969
- resolve(); // window is the global namespace
16970
- };
16971
- document.body.append(script);
16972
- });
16973
- }
16974
- function lookupExposedModule(remoteName, exposedModule) {
16975
- return __awaiter(this, void 0, void 0, function* () {
16976
- // Initializes the share scope. This fills it with known provided modules from this build and all remotes
16977
- yield __webpack_init_sharing__('default');
16978
- const container = window[remoteName]; // or get the container somewhere else
16979
- // Initialize the container, it may provide shared modules
16980
- yield container.init(__webpack_share_scopes__.default);
16981
- const factory = yield container.get(exposedModule);
16982
- const Module = factory();
16983
- return Module;
16984
- });
16985
- }
16986
- function loadRemoteModule(options) {
16987
- return __awaiter(this, void 0, void 0, function* () {
16988
- yield loadRemoteEntry(options.remoteEntry);
16989
- return yield lookupExposedModule(options.remoteName, options.exposedModule);
16990
- });
16991
- }
16992
- function loadRemotePageModule(remoteName, module, environment) {
16993
- return __awaiter(this, void 0, void 0, function* () {
16994
- let remoteEntry = `${environment.clientDomain.appDomain}/${remoteName}/remoteEntry.js`;
16995
- if (!environment.production) {
16996
- remoteEntry = `${environment.clientDomain[remoteName]}/remoteEntry.js`;
16997
- }
16998
- const options = {
16999
- remoteName: remoteName,
17000
- remoteEntry: remoteEntry,
17001
- exposedModule: module,
17002
- };
17003
- return yield loadRemoteModule(options);
17004
- });
17005
- }
17006
-
17007
- class FederationService {
17008
- constructor(resolver, _moduleConfigService) {
17009
- this.resolver = resolver;
17010
- this._moduleConfigService = _moduleConfigService;
17011
- this.environment = _moduleConfigService.getConfig().environment;
17012
- }
17013
- loadRemoteComponent(remoteName, componentName, viewContainerRef) {
17014
- return __awaiter(this, void 0, void 0, function* () {
17015
- let remoteEntry = `${this.environment.clientDomain.appDomain}/${remoteName}/remoteEntry.js`;
17016
- if (!this.environment.production) {
17017
- remoteEntry = `${this.environment.clientDomain[remoteName]}/remoteEntry.js`;
17018
- }
17019
- const options = {
17020
- remoteName: remoteName,
17021
- remoteEntry: remoteEntry,
17022
- exposedModule: componentName,
17023
- };
17024
- const component = yield loadRemoteModule(options);
17025
- const componentFactory = this.resolver.resolveComponentFactory(component[componentName]);
17026
- const viewContainer = viewContainerRef.viewContainerRef;
17027
- viewContainer.clear();
17028
- const compRef = viewContainer.createComponent(componentFactory);
17029
- return compRef;
17030
- });
17031
- }
17032
- loadRemoteNewComponent(remoteName, componentName, viewContainerRef) {
17033
- return __awaiter(this, void 0, void 0, function* () {
17034
- let remoteEntry = `${this.environment.clientDomain.appDomain}/${remoteName}/remoteEntry.js`;
17035
- if (!this.environment.production) {
17036
- remoteEntry = `${this.environment.clientDomain[remoteName]}/remoteEntry.js`;
17037
- }
17038
- const options = {
17039
- remoteName: remoteName,
17040
- remoteEntry: remoteEntry,
17041
- exposedModule: componentName,
17042
- };
17043
- const component = yield loadRemoteModule(options);
17044
- const componentFactory = this.resolver.resolveComponentFactory(component[componentName]);
17045
- viewContainerRef.clear();
17046
- const compRef = viewContainerRef.createComponent(componentFactory);
17047
- return compRef;
17048
- });
17049
- }
17050
- }
17051
- FederationService.ɵprov = i0.ɵɵdefineInjectable({ factory: function FederationService_Factory() { return new FederationService(i0.ɵɵinject(i0.ComponentFactoryResolver), i0.ɵɵinject(ModuleConfigService)); }, token: FederationService, providedIn: "root" });
17052
- FederationService.decorators = [
17053
- { type: Injectable, args: [{
17054
- providedIn: 'root'
17055
- },] }
17056
- ];
17057
- FederationService.ctorParameters = () => [
17058
- { type: ComponentFactoryResolver },
17059
- { type: ModuleConfigService }
17060
- ];
17061
-
17062
- class CoCauToChucService extends BaseService {
17063
- constructor(http, injector, _moduleConfigService) {
17064
- super(http, injector, `${_moduleConfigService.getConfig().environment.apiDomain.userOrgEndpoint}/${_moduleConfigService.getConfig().environment.apiVersion}/organization`);
17065
- this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.userOrgEndpoint;
17066
- this.environment = _moduleConfigService.getConfig().environment;
17067
- if (this.isUseOldOrganization()) {
17068
- this.serviceUri = `${this.environment.apiDomain.organizationEndpoint}/organization`;
17069
- }
17070
- }
17071
- createDropdownTree(field = 'idDonViQuanLy') {
17072
- return new DropdownControlSchema({
17073
- field,
17074
- placeholder: 'Chọn đơn vị',
17075
- baseService: this,
17076
- sortField: 'idDuongDan',
17077
- fieldPlus: 'idDuongDan',
17078
- isTree: true,
17079
- fieldTree: 'idCha',
17080
- valueParentRoot: this._commonService.guidEmpty(),
17081
- // isServerLoad: true, Option này đang không chạy được trong case này
17082
- loadOnInit: true,
17083
- maxItemDisplay: 9999
17084
- // funcGetLabel: (item) => {
17085
- // let level = item.idDuongDan.split(';').length - 2;
17086
- // let prefix = '';
17087
- // if (level < 2)
17088
- // level = 1;
17089
- // else
17090
- // prefix = '|';
17091
- // return `${prefix}${'---'.repeat(level - 1)} ${item.ten}`;
17092
- // }
17093
- });
17094
- }
17095
- isUseOldOrganization() {
17096
- const useOldOrganization = this.environment.useOldOrganization;
17097
- if (useOldOrganization) {
17098
- return true;
17099
- }
17100
- return false;
17101
- }
17102
- getByParentCode(organizationCode) {
17103
- let apiUrl = `${this.serviceUri}/GetByParentCode`;
17104
- if (organizationCode) {
17105
- apiUrl = `${apiUrl}?parentCode=${organizationCode}`;
17106
- }
17107
- return this.defaultGet(apiUrl);
17108
- }
17109
- getByCanBoId(canBoId) {
17110
- const apiUrl = `${this.serviceUri}/GetByCanBoId/${canBoId}`;
17111
- return this.defaultGet(apiUrl);
17112
- }
17113
- getCoCauToChucTreeTable(isIgnoreClientCache = false) {
17114
- const apiUrl = `${this.serviceUri}/GetTreeTable`;
17115
- if (isIgnoreClientCache) {
17116
- return this.getIgnoreClientCache(apiUrl);
17117
- }
17118
- return this.defaultGet(apiUrl);
17119
- }
17120
- updateMaPhanCap(idCha) {
17121
- return this.defaultPost(`${this.serviceUri}/UpdateMaPhanCap/${idCha}`, {});
17122
- }
17123
- }
17124
- CoCauToChucService.ɵprov = i0.ɵɵdefineInjectable({ factory: function CoCauToChucService_Factory() { return new CoCauToChucService(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(ModuleConfigService)); }, token: CoCauToChucService, providedIn: "root" });
17125
- CoCauToChucService.decorators = [
17126
- { type: Injectable, args: [{
17127
- providedIn: 'root'
17128
- },] }
17129
- ];
17130
- CoCauToChucService.ctorParameters = () => [
17131
- { type: HttpClient },
17132
- { type: Injector },
17133
- { type: ModuleConfigService }
17134
- ];
17135
-
17136
- class CanBo_HoSo_CoCauToChucService extends BaseService {
17137
- constructor(http, injector, _moduleConfigService) {
17138
- super(http, injector, `${_moduleConfigService.getConfig().environment.apiDomain.canboEndpoint}/${_moduleConfigService.getConfig().environment.apiVersion}/CanBo_HoSo_CoCauToChuc`);
17139
- this._moduleConfigService = _moduleConfigService;
17140
- this.entityName = 'CanBo_HoSo_CoCauToChuc';
17141
- this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.canboEndpoint;
17142
- }
17143
- sapNhapCoCauToChuc(model) {
17144
- return this.defaultPost(`${this.serviceUri}/SapNhapCoCauToChuc`, model);
17145
- }
17146
- getIdsDonViByCanBoLogin() {
17147
- return this.defaultGet(`${this.serviceUri}/GetIdsDonViByCanBoLogin`);
17148
- }
17149
- getDonViChucVuCapCaoNhatByIdsCanBo(idsCanBo = []) {
17150
- return this.defaultPost(`${this.serviceUri}/GetDonViChucVuCapCaoNhatByIdsCanBo`, idsCanBo);
17151
- }
17152
- unshiftColumnKhoaVienBoMon(modelSchemas, cols) {
17153
- modelSchemas.unshift(...[new ModelSchema({
17154
- field: 'donVi',
17155
- name: 'Khoa viện/ đơn vị',
17156
- fullName: 'Khoa viện/ đơn vị',
17157
- description: 'Khoa viện/ đơn vị'
17158
- }),
17159
- new ModelSchema({
17160
- field: 'boMon',
17161
- name: 'Bộ môn/ văn phòng khoa',
17162
- fullName: 'Bộ môn/ văn phòng khoa',
17163
- description: 'Bộ môn/ văn phòng khoa'
17164
- })]);
17165
- cols.unshift(...[new ColumnSchemaBase({
17166
- field: 'donVi',
17167
- dataType: 'html',
17168
- width: '200px',
17169
- allowFilter: false,
17170
- sort: false
17171
- }),
17172
- new ColumnSchemaBase({
17173
- field: 'boMon',
17174
- dataType: 'html',
17175
- width: '200px',
17176
- allowFilter: false,
17177
- sort: false
17178
- })]);
17179
- }
17180
- getsDonViTheoCap(dataSource = []) {
17181
- return this.defaultPost(`${this.serviceUri}/GetsDonViTheoCap`, dataSource);
17182
- }
17183
- getKhoaVienBoMonAfterGetData(dataSource) {
17184
- return __awaiter(this, void 0, void 0, function* () {
17185
- const items = dataSource.map(x => ({ idCanBo: x.idCanBo }));
17186
- const lstDonViTheoCap = (yield this.getsDonViTheoCap(items)).data;
17187
- if (lstDonViTheoCap.length == dataSource.length) {
17188
- dataSource.forEach((element, index) => {
17189
- element.donVi = lstDonViTheoCap[index].lstDonViCap2.join('<br/>');
17190
- element.boMon = lstDonViTheoCap[index].lstDonViCap3.join('<br/>');
17191
- });
16843
+ const items = dataSource.map(x => ({ idCanBo: x.idCanBo }));
16844
+ const lstDonViTheoCap = (yield this.getsDonViTheoCap(items)).data;
16845
+ if (lstDonViTheoCap.length == dataSource.length) {
16846
+ dataSource.forEach((element, index) => {
16847
+ element.donVi = lstDonViTheoCap[index].lstDonViCap2.join('<br/>');
16848
+ element.boMon = lstDonViTheoCap[index].lstDonViCap3.join('<br/>');
16849
+ });
17192
16850
  }
17193
16851
  });
17194
16852
  }
@@ -17906,300 +17564,662 @@ CanBoHoSoService.ctorParameters = () => [
17906
17564
  { type: CrudService }
17907
17565
  ];
17908
17566
 
17909
- class StateMachinesService extends BaseService {
17567
+ class EntityWorkflowHistoryService extends BaseService {
17910
17568
  constructor(http, injector, _moduleConfigService) {
17911
- super(http, injector, `${_moduleConfigService.getConfig().environment.apiDomain.workflowEndpoint}/${_moduleConfigService.getConfig().environment.apiVersion}/StateMachines`);
17912
- this._moduleConfigService = _moduleConfigService;
17913
- this.entityName = 'StateMachines';
17914
- this.serviceCode = 'workflow';
17915
- this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.workflowEndpoint;
17569
+ super(http, injector, `${_moduleConfigService.getConfig().environment.apiDomain.userOrgEndpoint}/${_moduleConfigService.getConfig().environment.apiVersion}/EntityWorkflowHistory`);
17570
+ this.entityName = 'EntityWorkflowHistory';
17571
+ this.serviceManagers = {};
17572
+ this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.userOrgEndpoint;
17573
+ this._moduleConfig = _moduleConfigService.getConfig();
17916
17574
  }
17917
- changeState(itemWorkflowHistory) {
17918
- return this.defaultPost(`${this.serviceUri}/ChangeState`, itemWorkflowHistory);
17575
+ registerService(entityName, service) {
17576
+ this.serviceManagers[entityName] = service;
17919
17577
  }
17920
- rollback(rowData) {
17921
- return this.defaultPost(`${this.serviceUri}/Rollback/${rowData.__workflowCode}/${rowData.id}`, {});
17578
+ getEndpointByService(service) {
17579
+ return `${service.endPoint}/${this._moduleConfig.environment.apiVersion}`;
17922
17580
  }
17923
- getUserInProcessForm(workflowCode, stateCode, actionCode, itemId) {
17924
- return this.defaultPost(`${this.serviceUri}/GetUserInProcessForm/${workflowCode}/${stateCode}/${actionCode}/${itemId}`, {});
17581
+ setCurrentServiceUri(tableName) {
17582
+ const service = this.serviceManagers[tableName];
17583
+ if (service == undefined) {
17584
+ (this._injector.get(NotifierService)).showWarning('Bạn chưa đăng ký base service cho entity workflow history');
17585
+ }
17586
+ this.serviceUri = `${this.getEndpointByService(service)}/EntityWorkflowHistory`;
17587
+ }
17588
+ getLastHistory(tableName, filters = []) {
17589
+ const service = this.serviceManagers[tableName];
17590
+ if (service == undefined) {
17591
+ (this._injector.get(NotifierService)).showWarning('Bạn chưa đăng ký base service cho entity workflow history');
17592
+ }
17593
+ const url = `${this.getEndpointByService(service)}/EntityWorkflowHistory/GetLastByFilter`;
17594
+ const gridInfo = {
17595
+ pageInfo: {
17596
+ page: 1,
17597
+ pageSize: 1
17598
+ },
17599
+ filters,
17600
+ sorts: [
17601
+ new Sort({ field: 'created', dir: 1 })
17602
+ ]
17603
+ };
17604
+ return this.defaultPost(url, gridInfo);
17605
+ }
17606
+ }
17607
+ EntityWorkflowHistoryService.ɵprov = i0.ɵɵdefineInjectable({ factory: function EntityWorkflowHistoryService_Factory() { return new EntityWorkflowHistoryService(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(ModuleConfigService)); }, token: EntityWorkflowHistoryService, providedIn: "root" });
17608
+ EntityWorkflowHistoryService.decorators = [
17609
+ { type: Injectable, args: [{
17610
+ providedIn: 'root'
17611
+ },] }
17612
+ ];
17613
+ EntityWorkflowHistoryService.ctorParameters = () => [
17614
+ { type: HttpClient },
17615
+ { type: Injector },
17616
+ { type: ModuleConfigService }
17617
+ ];
17618
+
17619
+ const EXCEL_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8';
17620
+ const EXCEL_EXTENSION = '.xlsx';
17621
+ class ExportService {
17622
+ constructor(_http, _injector, _commonService, _moduleConfigService) {
17623
+ this._http = _http;
17624
+ this._injector = _injector;
17625
+ this._commonService = _commonService;
17626
+ this._moduleConfig = _moduleConfigService.getConfig();
17627
+ this.environment = this._moduleConfig.environment;
17628
+ this.serviceUri = `${this._moduleConfig.environment.apiDomain.templateEndpoint}/Export`;
17629
+ }
17630
+ objectToExcel(data, fileName, numOfHeaderRow) {
17631
+ return this._http
17632
+ .post(`${this.serviceUri}/ObjectToExcel?numOfHeaderRow=${numOfHeaderRow}`, data, { responseType: 'blob' })
17633
+ .pipe(catchError((err) => this._commonService.handleError(err, this._injector)))
17634
+ .subscribe(res => {
17635
+ this.saveAsExcelFile(res, fileName);
17636
+ });
17637
+ }
17638
+ saveAsExcelFile(buffer, fileName) {
17639
+ const data = new Blob([buffer], {
17640
+ type: EXCEL_TYPE
17641
+ });
17642
+ FileSaver__default.saveAs(data, fileName + '_' + new Date().getTime() + EXCEL_EXTENSION);
17643
+ }
17644
+ saveSpreadSheet(buffer, fileName) {
17645
+ const data = new Blob([buffer], {
17646
+ type: EXCEL_TYPE
17647
+ });
17648
+ FileSaver__default.saveAs(data, new Date().getTime() + '_' + fileName);
17649
+ }
17650
+ }
17651
+ ExportService.ɵprov = i0.ɵɵdefineInjectable({ factory: function ExportService_Factory() { return new ExportService(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(CommonService), i0.ɵɵinject(ModuleConfigService)); }, token: ExportService, providedIn: "root" });
17652
+ ExportService.decorators = [
17653
+ { type: Injectable, args: [{
17654
+ providedIn: 'root'
17655
+ },] }
17656
+ ];
17657
+ ExportService.ctorParameters = () => [
17658
+ { type: HttpClient },
17659
+ { type: Injector },
17660
+ { type: CommonService },
17661
+ { type: ModuleConfigService }
17662
+ ];
17663
+
17664
+ const moduleMap = {};
17665
+ function loadRemoteEntry(remoteEntry) {
17666
+ return new Promise((resolve, reject) => {
17667
+ if (moduleMap[remoteEntry]) {
17668
+ resolve();
17669
+ return;
17670
+ }
17671
+ const script = document.createElement('script');
17672
+ script.src = remoteEntry;
17673
+ script.onerror = reject;
17674
+ script.onload = () => {
17675
+ moduleMap[remoteEntry] = true;
17676
+ resolve(); // window is the global namespace
17677
+ };
17678
+ document.body.append(script);
17679
+ });
17680
+ }
17681
+ function lookupExposedModule(remoteName, exposedModule) {
17682
+ return __awaiter(this, void 0, void 0, function* () {
17683
+ // Initializes the share scope. This fills it with known provided modules from this build and all remotes
17684
+ yield __webpack_init_sharing__('default');
17685
+ const container = window[remoteName]; // or get the container somewhere else
17686
+ // Initialize the container, it may provide shared modules
17687
+ yield container.init(__webpack_share_scopes__.default);
17688
+ const factory = yield container.get(exposedModule);
17689
+ const Module = factory();
17690
+ return Module;
17691
+ });
17692
+ }
17693
+ function loadRemoteModule(options) {
17694
+ return __awaiter(this, void 0, void 0, function* () {
17695
+ yield loadRemoteEntry(options.remoteEntry);
17696
+ return yield lookupExposedModule(options.remoteName, options.exposedModule);
17697
+ });
17698
+ }
17699
+ function loadRemotePageModule(remoteName, module, environment) {
17700
+ return __awaiter(this, void 0, void 0, function* () {
17701
+ let remoteEntry = `${environment.clientDomain.appDomain}/${remoteName}/remoteEntry.js`;
17702
+ if (!environment.production) {
17703
+ remoteEntry = `${environment.clientDomain[remoteName]}/remoteEntry.js`;
17704
+ }
17705
+ const options = {
17706
+ remoteName: remoteName,
17707
+ remoteEntry: remoteEntry,
17708
+ exposedModule: module,
17709
+ };
17710
+ return yield loadRemoteModule(options);
17711
+ });
17712
+ }
17713
+
17714
+ class FederationService {
17715
+ constructor(resolver, _moduleConfigService) {
17716
+ this.resolver = resolver;
17717
+ this._moduleConfigService = _moduleConfigService;
17718
+ this.environment = _moduleConfigService.getConfig().environment;
17719
+ }
17720
+ loadRemoteComponent(remoteName, componentName, viewContainerRef) {
17721
+ return __awaiter(this, void 0, void 0, function* () {
17722
+ let remoteEntry = `${this.environment.clientDomain.appDomain}/${remoteName}/remoteEntry.js`;
17723
+ if (!this.environment.production) {
17724
+ remoteEntry = `${this.environment.clientDomain[remoteName]}/remoteEntry.js`;
17725
+ }
17726
+ const options = {
17727
+ remoteName: remoteName,
17728
+ remoteEntry: remoteEntry,
17729
+ exposedModule: componentName,
17730
+ };
17731
+ const component = yield loadRemoteModule(options);
17732
+ const componentFactory = this.resolver.resolveComponentFactory(component[componentName]);
17733
+ const viewContainer = viewContainerRef.viewContainerRef;
17734
+ viewContainer.clear();
17735
+ const compRef = viewContainer.createComponent(componentFactory);
17736
+ return compRef;
17737
+ });
17738
+ }
17739
+ loadRemoteNewComponent(remoteName, componentName, viewContainerRef) {
17740
+ return __awaiter(this, void 0, void 0, function* () {
17741
+ let remoteEntry = `${this.environment.clientDomain.appDomain}/${remoteName}/remoteEntry.js`;
17742
+ if (!this.environment.production) {
17743
+ remoteEntry = `${this.environment.clientDomain[remoteName]}/remoteEntry.js`;
17744
+ }
17745
+ const options = {
17746
+ remoteName: remoteName,
17747
+ remoteEntry: remoteEntry,
17748
+ exposedModule: componentName,
17749
+ };
17750
+ const component = yield loadRemoteModule(options);
17751
+ const componentFactory = this.resolver.resolveComponentFactory(component[componentName]);
17752
+ viewContainerRef.clear();
17753
+ const compRef = viewContainerRef.createComponent(componentFactory);
17754
+ return compRef;
17755
+ });
17925
17756
  }
17926
17757
  }
17927
- StateMachinesService.ɵprov = i0.ɵɵdefineInjectable({ factory: function StateMachinesService_Factory() { return new StateMachinesService(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(ModuleConfigService)); }, token: StateMachinesService, providedIn: "root" });
17928
- StateMachinesService.decorators = [
17758
+ FederationService.ɵprov = i0.ɵɵdefineInjectable({ factory: function FederationService_Factory() { return new FederationService(i0.ɵɵinject(i0.ComponentFactoryResolver), i0.ɵɵinject(ModuleConfigService)); }, token: FederationService, providedIn: "root" });
17759
+ FederationService.decorators = [
17929
17760
  { type: Injectable, args: [{
17930
17761
  providedIn: 'root'
17931
17762
  },] }
17932
17763
  ];
17933
- StateMachinesService.ctorParameters = () => [
17934
- { type: HttpClient },
17935
- { type: Injector },
17764
+ FederationService.ctorParameters = () => [
17765
+ { type: ComponentFactoryResolver },
17936
17766
  { type: ModuleConfigService }
17937
17767
  ];
17938
17768
 
17939
- class CauHinhWorkflowService extends BaseService {
17940
- constructor(http, injector, _moduleConfigService) {
17941
- super(http, injector, `${_moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint}/${_moduleConfigService.getConfig().environment.apiVersion}/CauHinhWorkflow`);
17942
- this._moduleConfigService = _moduleConfigService;
17943
- this.serviceCode = 'congviec';
17944
- this.entityName = 'CauHinhWorkflow';
17945
- this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint;
17769
+ class PhanQuyenModel {
17770
+ constructor(init) {
17771
+ this.addRoleIds = [];
17772
+ this.removeRoleIds = [];
17773
+ this.addPermissionIds = [];
17774
+ this.removePermissionIds = [];
17775
+ for (const key in init) {
17776
+ this[key] = init[key];
17777
+ }
17946
17778
  }
17947
17779
  }
17948
- CauHinhWorkflowService.ɵprov = i0.ɵɵdefineInjectable({ factory: function CauHinhWorkflowService_Factory() { return new CauHinhWorkflowService(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(ModuleConfigService)); }, token: CauHinhWorkflowService, providedIn: "root" });
17949
- CauHinhWorkflowService.decorators = [
17950
- { type: Injectable, args: [{
17951
- providedIn: 'root'
17952
- },] }
17953
- ];
17954
- CauHinhWorkflowService.ctorParameters = () => [
17955
- { type: HttpClient },
17956
- { type: Injector },
17957
- { type: ModuleConfigService }
17958
- ];
17959
-
17960
- class DmLoaiCongViecService extends BaseService {
17961
- constructor(http, injector, _moduleConfigService) {
17962
- super(http, injector, `${_moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint}/${_moduleConfigService.getConfig().environment.apiVersion}/DM_LoaiCongViec`);
17780
+ class PermissionService extends BaseService {
17781
+ constructor(http, injector, _moduleConfigService, _userService, _oauthService, _appContext) {
17782
+ super(http, injector, `${_moduleConfigService.getConfig().environment.apiDomain.authorizationEndpoint}/${_moduleConfigService.getConfig().environment.apiVersion}/permission`);
17963
17783
  this._moduleConfigService = _moduleConfigService;
17964
- this.serviceCode = 'congviec';
17965
- this.entityName = 'DM_LoaiCongViec';
17966
- this.dicLoaiCongViec = {};
17967
- this.keyIdLoaiCongViecRoot = 'root';
17968
- this.getWorkflowSettingByIdLoaiCongViec = (idLoaiCongViec) => __awaiter(this, void 0, void 0, function* () {
17969
- if (!this.dicWorkflowByLoaiCongViec) {
17970
- yield this.getDatasourceWorkflowCongViec();
17784
+ this._userService = _userService;
17785
+ this._oauthService = _oauthService;
17786
+ this._appContext = _appContext;
17787
+ this.storage = sessionStorage;
17788
+ this.ignoreAdmin = false;
17789
+ this.delayCheckPermissions = [];
17790
+ this.appCode = null;
17791
+ this._config = this._moduleConfigService.getConfig();
17792
+ this.endPoint = this._config.environment.apiDomain.authorizationEndpoint;
17793
+ this.ignoreAdmin = this._config.environment.isIgnoreAdmin;
17794
+ this.appCode = this._config.appCode;
17795
+ }
17796
+ clearPermissionCacheAll() {
17797
+ var _a, _b, _c;
17798
+ const lstAppCodes = (_c = (_b = (_a = this._config.environment.appMetadata) === null || _a === void 0 ? void 0 : _a.appSwitcher) === null || _b === void 0 ? void 0 : _b.map(app => app.code)) !== null && _c !== void 0 ? _c : [];
17799
+ const lstApiEndpoint = [];
17800
+ const apiDomain = this._config.environment.apiDomain;
17801
+ for (const domainName in apiDomain) {
17802
+ if (domainName.startsWith('-') || domainName.startsWith('1') || domainName == 'gateway')
17803
+ continue;
17804
+ const realDomainName = domainName.split('Endpoint') ? domainName.split('Endpoint')[0] : domainName;
17805
+ lstApiEndpoint.push(realDomainName.toUpperCase());
17806
+ }
17807
+ return this.clearPermissionCache([...lstAppCodes, ...lstApiEndpoint]);
17808
+ }
17809
+ clearPermissionCache(lstModule) {
17810
+ const url = `${this.serviceUri}/ClearPermissionCache`;
17811
+ return this.defaultPost(url, lstModule);
17812
+ }
17813
+ getCurrentUserPermission() {
17814
+ const url = `${this.serviceUri}/GetCurrentUserPermission`;
17815
+ return this.defaultGet(url);
17816
+ }
17817
+ getAllBasePermission(userId) {
17818
+ var _a, _b, _c;
17819
+ return __awaiter(this, void 0, void 0, function* () {
17820
+ const url = `${this.serviceUri}/GetAllBasePermission`;
17821
+ // return sớm vì đây là trường hợp lấy permission theo Id của User
17822
+ // ko set local storage vì sẽ làm hỏng quyền của người dùng hiện tại
17823
+ if (userId && userId != '' && userId != this._commonService.guidEmpty()) {
17824
+ return this.defaultGet(url + `?userId=${userId}`);
17825
+ }
17826
+ if (isDevMode()) {
17827
+ return;
17828
+ }
17829
+ const user = this._userService.getCurrentUser();
17830
+ if (user
17831
+ && (user.issuperuser && user.issuperuser.toLowerCase() == 'true')
17832
+ || (user.isadmin && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin)) {
17833
+ return;
17834
+ }
17835
+ const res = yield this.defaultGet(url);
17836
+ const lstAppCodes = (_c = (_b = (_a = this._config.environment.appMetadata) === null || _a === void 0 ? void 0 : _a.appSwitcher) === null || _b === void 0 ? void 0 : _b.map(app => app.code)) !== null && _c !== void 0 ? _c : [];
17837
+ // Nếu Có error lấy dữ liệu quyền tổng hợp thì quay về lấy dữ liệu quyền dựa vào từng module
17838
+ if (!res || !res.success || res.data == null) {
17839
+ const promiseArr = [];
17840
+ for (const code of lstAppCodes) {
17841
+ promiseArr.push(this.getServicePermission(code, true));
17842
+ }
17843
+ yield Promise.all(promiseArr);
17844
+ return;
17845
+ }
17846
+ // Set local storage cho permission của người dùng
17847
+ for (const service of lstAppCodes) {
17848
+ let permissions = [];
17849
+ const serviceCode = service.toUpperCase();
17850
+ for (const key in res.data) {
17851
+ if (key.toUpperCase() != serviceCode) {
17852
+ continue;
17853
+ }
17854
+ permissions = res.data[key];
17855
+ break;
17856
+ }
17857
+ const key = `AUTHORIZATION.${serviceCode}`;
17858
+ const storageItem = this.storage.getItem(key);
17859
+ if (storageItem != null) {
17860
+ this.storage.removeItem(key);
17861
+ }
17862
+ this.storage.setItem(key, JSON.stringify(permissions));
17863
+ }
17864
+ });
17865
+ }
17866
+ /**
17867
+ * Truyền vào danh sách permision cần check
17868
+ * @param lstPermissionCode những perrmision code cần check => nên dùng trong trường hợp check các button trong code
17869
+ * @returns trả ra các perrmisionCode có quyền
17870
+ */
17871
+ getPermissionAuthorized(lstPermissionCode) {
17872
+ return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
17873
+ const user = (yield this._userService.getCurrentUser());
17874
+ if (user && user.issuperuser.toLowerCase() == 'true') {
17875
+ resolve(lstPermissionCode);
17876
+ return;
17877
+ }
17878
+ if (user && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin) {
17879
+ resolve(lstPermissionCode);
17880
+ return;
17881
+ }
17882
+ const result = [];
17883
+ for (const item of lstPermissionCode) {
17884
+ if (yield this.isAuthorizedPermission(item)) {
17885
+ result.push(item);
17886
+ }
17887
+ }
17888
+ resolve(result);
17889
+ }));
17890
+ }
17891
+ isAuthorizedPermission(permission) {
17892
+ return __awaiter(this, void 0, void 0, function* () {
17893
+ let retryCount = 0;
17894
+ while (!this._oauthService.hasValidAccessToken()) {
17895
+ yield this._commonService.delay(100);
17896
+ retryCount++;
17897
+ if (retryCount > 50) {
17898
+ break;
17899
+ }
17900
+ }
17901
+ return yield this.checkPermission(this.appCode, permission);
17902
+ });
17903
+ }
17904
+ isAuthorized(service, permission, checForMenu = false) {
17905
+ return __awaiter(this, void 0, void 0, function* () {
17906
+ this.root = this._appContext.getRootContext();
17907
+ let retryCount = 0;
17908
+ while (!this._oauthService.hasValidAccessToken()) {
17909
+ yield this._commonService.delay(100);
17910
+ retryCount++;
17911
+ if (retryCount > 50) {
17912
+ break;
17913
+ }
17914
+ }
17915
+ return yield this.checkPermission(service, permission, checForMenu);
17916
+ });
17917
+ }
17918
+ checkPermission(service, permissionToCheck, checkForMenu = false) {
17919
+ return __awaiter(this, void 0, void 0, function* () {
17920
+ try {
17921
+ const user = this._userService.getCurrentUser();
17922
+ const valueIsDevMode = true;
17923
+ if (isDevMode() && valueIsDevMode) {
17924
+ return true;
17925
+ }
17926
+ if (user && user.issuperuser && user.issuperuser.toLowerCase() == 'true' && valueIsDevMode) {
17927
+ return true;
17928
+ }
17929
+ if (user && user.isadmin && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin && valueIsDevMode) {
17930
+ return true;
17931
+ }
17932
+ const userPermissions = yield this.getServicePermission(service);
17933
+ if (userPermissions && userPermissions.length > 0) {
17934
+ return checkForMenu
17935
+ ? userPermissions.includes(permissionToCheck)
17936
+ : this._checkPermission(userPermissions, permissionToCheck);
17937
+ }
17938
+ else {
17939
+ // console.log(`Không có quyền với phân hệ [${service}]`);
17940
+ return false;
17941
+ }
17942
+ }
17943
+ catch (_a) {
17944
+ return false;
17945
+ }
17946
+ });
17947
+ }
17948
+ _checkPermission(userPermissions, permissionToCheck) {
17949
+ let isAuthorized = false;
17950
+ // check permission của người dùng
17951
+ // duyệt qua từng permission của người dùng
17952
+ for (const userPermission of userPermissions) {
17953
+ // biến để break khỏi vòng khi người dùng được authorized
17954
+ let breakOuterLoop = false;
17955
+ // pointer permission của người dùng
17956
+ let userPermissionPointer = 0;
17957
+ // pointer permission đang check
17958
+ let permissionToCheckPointer = 0;
17959
+ // mark co the check query param
17960
+ let aboutToCheckQueryParam = false;
17961
+ // check từng char của 2 mảng
17962
+ for (; permissionToCheckPointer < permissionToCheck.length;) {
17963
+ // nếu char là ký tự bắt đầu template => tịnh tiến pointer của 2 mảng
17964
+ let needRecheck = false;
17965
+ if (userPermission[userPermissionPointer] == '{') {
17966
+ // cho đến khi tìm được ký tự '/' tiếp theo thì dừng lại
17967
+ for (; userPermissionPointer < userPermission.length; userPermissionPointer++) {
17968
+ if (userPermissionPointer == userPermission.length - 1) {
17969
+ break;
17970
+ }
17971
+ if (userPermission[userPermissionPointer] != '}') {
17972
+ continue;
17973
+ }
17974
+ if (userPermission[userPermissionPointer] === '?') {
17975
+ aboutToCheckQueryParam = true;
17976
+ }
17977
+ ++userPermissionPointer; // tiến tiến đến ký tự sau kết thúc template
17978
+ // check trường hợp trường hợp chuỗi template có dạng "{template}acsekjf"
17979
+ // => cần check các ký tự sau template và trước ký tự '/'
17980
+ if (userPermission[userPermissionPointer] != '/' && (aboutToCheckQueryParam && userPermission[userPermissionPointer] != '&')) {
17981
+ needRecheck = true;
17982
+ for (; userPermissionPointer < userPermission.length; userPermissionPointer++) {
17983
+ if (userPermissionPointer == userPermission.length - 1) {
17984
+ break;
17985
+ }
17986
+ if (userPermission[userPermissionPointer] != '/') {
17987
+ continue;
17988
+ }
17989
+ break;
17990
+ }
17991
+ }
17992
+ break;
17993
+ }
17994
+ for (; permissionToCheckPointer < permissionToCheck.length; permissionToCheckPointer++) {
17995
+ if (permissionToCheckPointer == permissionToCheck.length - 1) {
17996
+ break;
17997
+ }
17998
+ if (permissionToCheck[permissionToCheckPointer] == '/' || (aboutToCheckQueryParam && permissionToCheck[permissionToCheckPointer] == '&')) {
17999
+ break;
18000
+ }
18001
+ }
18002
+ }
18003
+ let breakInnerLoop = false;
18004
+ if (needRecheck) {
18005
+ // check lại cho trường hợp chuỗi template có dạng "{template}acslekfj"
18006
+ // duyệt ngược lại cho đến khi gặp ký tự kết thúc template
18007
+ let tempUserPointer = userPermissionPointer;
18008
+ let tempToCheckPointer = permissionToCheckPointer;
18009
+ while (userPermission[tempUserPointer] != '}') {
18010
+ // ký tự khác nhau => break khỏi vòng kiểm tra trong
18011
+ if (userPermission[tempUserPointer].toLowerCase() != permissionToCheck[tempToCheckPointer].toLowerCase()) {
18012
+ breakInnerLoop = true;
18013
+ break;
18014
+ }
18015
+ tempUserPointer--;
18016
+ tempToCheckPointer--;
18017
+ }
18018
+ }
18019
+ if (breakInnerLoop) {
18020
+ break;
18021
+ }
18022
+ const userChar = userPermission[userPermissionPointer].toLowerCase();
18023
+ const toCheckChar = permissionToCheck[permissionToCheckPointer].toLowerCase();
18024
+ // nếu userPermission đang ở index cuối
18025
+ if (userPermissionPointer == userPermission.length - 1) {
18026
+ // check char cuối của 2 mảng (trừ khi là ký tự kết thúc template)
18027
+ // và cũng phải là char cuối của mảng permission cần check
18028
+ // => người dùng authorized và break khỏi vòng lặp ngoài cùng
18029
+ if ((userChar == '}' || userChar == toCheckChar)
18030
+ && permissionToCheckPointer == permissionToCheck.length - 1) {
18031
+ breakOuterLoop = true;
18032
+ isAuthorized = true;
18033
+ }
18034
+ break;
18035
+ }
18036
+ // check char có giống nhau không, không giống thì break khỏi vòng check
18037
+ if (userChar != toCheckChar) {
18038
+ break;
18039
+ }
18040
+ // nếu char giống nhau thì tiếp tục vòng lăp
18041
+ permissionToCheckPointer++;
18042
+ userPermissionPointer++;
17971
18043
  }
17972
- if (!idLoaiCongViec) {
17973
- return this.dicWorkflowByLoaiCongViec[this.keyIdLoaiCongViecRoot];
18044
+ if (breakOuterLoop) {
18045
+ break;
17974
18046
  }
17975
- let result = this.dicWorkflowByLoaiCongViec[idLoaiCongViec];
17976
- if (result)
17977
- return result;
17978
- const idLoaiCongViecs = yield this.getIdLoaiCongViecs(idLoaiCongViec);
17979
- if (!Array.isArray(idLoaiCongViecs))
17980
- return null;
17981
- if (idLoaiCongViecs.length > 1) {
17982
- for (let i = idLoaiCongViecs.length - 2; i >= 0; i--) {
17983
- result = this.dicWorkflowByLoaiCongViec[idLoaiCongViecs[i]];
17984
- if (result)
17985
- return result;
18047
+ }
18048
+ return isAuthorized;
18049
+ }
18050
+ _checkPermissionOld(userPermissions, permissionToCheck) {
18051
+ let isAuthorized = false;
18052
+ // check quyền theo cách cũ nếu trường họp là phân quyền module
18053
+ if (permissionToCheck.includes('MODULE')) {
18054
+ return userPermissions.includes(permissionToCheck);
18055
+ }
18056
+ for (const userPermission of userPermissions) {
18057
+ // Cắt chuỗi permission thành mảng để xem mỗi fragement có khớp nhau không
18058
+ const userPermissionFragments = userPermission.split('/');
18059
+ const permissionFragments = permissionToCheck.split('/');
18060
+ // Mảng khác độ dài thì thoát sớm
18061
+ if (userPermissionFragments.length != permissionFragments.length) {
18062
+ continue;
18063
+ }
18064
+ // biến flag ra hiệu người dùng authorized và out vòng
18065
+ let breakLoop = false;
18066
+ // nếu tất cả phần tử khớp nhau => permission này trùng và người dùng được authorized
18067
+ for (let index = 0; index < permissionFragments.length; index++) {
18068
+ const userFragement = userPermissionFragments[index];
18069
+ const permissionFragment = permissionFragments[index];
18070
+ // skip qua các phần tử có ký tự bắt đầu là '{'
18071
+ if (userFragement[0] == '{') {
18072
+ if (index == permissionFragments.length - 1) {
18073
+ isAuthorized = true;
18074
+ breakLoop = true;
18075
+ }
18076
+ continue;
18077
+ }
18078
+ if (userFragement.toLowerCase() != permissionFragment.toLowerCase()) {
18079
+ break;
18080
+ }
18081
+ if (index == permissionFragments.length - 1) {
18082
+ isAuthorized = true;
18083
+ breakLoop = true;
17986
18084
  }
17987
18085
  }
17988
- if (!result) {
17989
- result = this.dicWorkflowByLoaiCongViec[this.keyIdLoaiCongViecRoot];
18086
+ if (breakLoop) {
18087
+ break;
17990
18088
  }
17991
- return result;
17992
- });
17993
- this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint;
18089
+ }
18090
+ return isAuthorized;
17994
18091
  }
17995
- getDatasourceWorkflowCongViec() {
17996
- return __awaiter(this, void 0, void 0, function* () {
17997
- if (!this.dicWorkflowByLoaiCongViec) {
17998
- this.dicWorkflowByLoaiCongViec = {};
18092
+ isAuthorizedByPermissions(permissions, operator = 'OR', ignoreAdmin = false) {
18093
+ return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
18094
+ const user = (yield this._userService.getCurrentUser());
18095
+ if (user && user.issuperuser.toLowerCase() == 'true') {
18096
+ resolve(true);
18097
+ return;
17999
18098
  }
18000
- const cauHinhWorkflowService = this._injector.get(CauHinhWorkflowService);
18001
- const cauHinhWorkflows = (yield cauHinhWorkflowService.getAll([], 'idLoaiCongViec,workflowCodes,workflowCode')).data;
18002
- const notifierService = this._injector.get(NotifierService);
18003
- if (cauHinhWorkflows == null) {
18004
- notifierService.showWarning('Dịch vụ workflow không phản hồi');
18005
- return [];
18099
+ if (user && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin) {
18100
+ resolve(true);
18101
+ return;
18006
18102
  }
18007
- const workflowCodes = [];
18008
- cauHinhWorkflows.forEach(itemWorkflowSetting => {
18009
- if (itemWorkflowSetting.workflowCodes && !Array.isArray(itemWorkflowSetting.workflowCodes)) {
18010
- itemWorkflowSetting.workflowCodes = itemWorkflowSetting.workflowCodes.split(',');
18011
- }
18012
- else {
18013
- itemWorkflowSetting.workflowCodes = [];
18014
- }
18015
- itemWorkflowSetting.workflowCodes.forEach(workflowCode => {
18016
- if (workflowCodes.indexOf(workflowCode) == -1) {
18017
- workflowCodes.push(workflowCode);
18103
+ let isAuthorized = true;
18104
+ if (operator.toUpperCase() == 'OR') {
18105
+ isAuthorized = false;
18106
+ }
18107
+ permissions.forEach(item => {
18108
+ this.getServicePermission(item.service).then(permissionResult => {
18109
+ if (operator.toUpperCase() == 'OR') {
18110
+ if (permissionResult.includes(item.permission)) {
18111
+ isAuthorized = true;
18112
+ return;
18113
+ }
18018
18114
  }
18019
- });
18020
- });
18021
- const stateMachinesService = this._injector.get(StateMachinesService);
18022
- const workflows = (yield stateMachinesService.getDataDropdownByFilter([
18023
- this.newFilter('code', Operator.in, workflowCodes)
18024
- ], new DropdownOptions({
18025
- valueField: 'code',
18026
- displayField: 'title',
18027
- fieldPlus: 'data'
18028
- })));
18029
- workflows.forEach(item => {
18030
- item.data = JSON.parse(item.data);
18031
- const stateMachineData = item.data;
18032
- stateMachineData.actions = {};
18033
- stateMachineData.machines.forEach(machine => {
18034
- stateMachineData.actions[machine.code] = [];
18035
- stateMachineData.connections.forEach(conn => {
18036
- if (conn.source == machine.id) {
18037
- stateMachineData.actions[machine.code].push(conn);
18115
+ else {
18116
+ if (!permissionResult.includes(item.permission)) {
18117
+ isAuthorized = false;
18118
+ return;
18038
18119
  }
18039
- });
18120
+ }
18121
+ }, error => {
18122
+ reject(false);
18040
18123
  });
18041
18124
  });
18042
- cauHinhWorkflows.forEach(itemWorkflowSetting => {
18043
- itemWorkflowSetting.workflows = workflows.filter(q => itemWorkflowSetting.workflowCodes.indexOf(q.code) > -1);
18044
- if (!itemWorkflowSetting.idLoaiCongViec) {
18045
- this.dicWorkflowByLoaiCongViec[this.keyIdLoaiCongViecRoot] = itemWorkflowSetting;
18046
- }
18047
- else {
18048
- this.dicWorkflowByLoaiCongViec[itemWorkflowSetting.idLoaiCongViec] = itemWorkflowSetting;
18049
- }
18050
- });
18051
- return workflows;
18052
- });
18053
- }
18054
- getIdLoaiCongViecs(idLoaiCongViec) {
18055
- return __awaiter(this, void 0, void 0, function* () {
18056
- const notifierService = this._injector.get(NotifierService);
18057
- const itemLoaiCongViec = yield this.getItemLoaiCongViec(idLoaiCongViec);
18058
- if (itemLoaiCongViec == null) {
18059
- notifierService.showWarning('Loại công việc không tồn tại');
18060
- return null;
18061
- }
18062
- const idLoaiCongViecs = itemLoaiCongViec.idDuongDan.split(';').filter(q => !!q);
18063
- return idLoaiCongViecs;
18064
- });
18065
- }
18066
- getItemLoaiCongViec(idLoaiCongViec) {
18067
- return __awaiter(this, void 0, void 0, function* () {
18068
- if (!this.dicLoaiCongViec[idLoaiCongViec]) {
18069
- this.dicLoaiCongViec[idLoaiCongViec] = (yield this.getDetail(idLoaiCongViec)).data;
18070
- }
18071
- return this.dicLoaiCongViec[idLoaiCongViec];
18072
- });
18073
- }
18074
- }
18075
- DmLoaiCongViecService.ɵprov = i0.ɵɵdefineInjectable({ factory: function DmLoaiCongViecService_Factory() { return new DmLoaiCongViecService(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(ModuleConfigService)); }, token: DmLoaiCongViecService, providedIn: "root" });
18076
- DmLoaiCongViecService.decorators = [
18077
- { type: Injectable, args: [{
18078
- providedIn: 'root'
18079
- },] }
18080
- ];
18081
- DmLoaiCongViecService.ctorParameters = () => [
18082
- { type: HttpClient },
18083
- { type: Injector },
18084
- { type: ModuleConfigService }
18085
- ];
18086
-
18087
- class CongViecService extends BaseService {
18088
- constructor(http, injector, _moduleConfigService, _dmLoaiCongViecService) {
18089
- super(http, injector, `${_moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint}/${_moduleConfigService.getConfig().environment.apiVersion}/CongViec_Chinh`);
18090
- this._dmLoaiCongViecService = _dmLoaiCongViecService;
18091
- this.serviceCode = 'congviec';
18092
- this.entityName = 'CongViec_Chinh';
18093
- this.objectName = 'công việc';
18094
- this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint;
18095
- this._moduleConfig = _moduleConfigService.getConfig();
18096
- }
18097
- adjustSettingWorkflowForCrudList(setting) {
18098
- this.useWorkflow = true;
18099
- setting.isWorkflowTree = true;
18100
- setting.baseService = this;
18101
- setting.displayField = (item) => item.ten;
18102
- setting.baseService.useWorkflow = true;
18103
- setting.workflowConfigAdvance = {
18104
- getWorkflowSetting: this.getWorkflowConfig.bind(this)
18105
- };
18125
+ resolve(isAuthorized);
18126
+ }));
18106
18127
  }
18107
- getWorkflowConfig(rowData) {
18128
+ getServicePermission(service, overrideLocalStorage = false) {
18108
18129
  return __awaiter(this, void 0, void 0, function* () {
18109
- return yield this._dmLoaiCongViecService.getWorkflowSettingByIdLoaiCongViec(rowData.idLoaiCongViec);
18130
+ const key = `AUTHORIZATION.${service.toUpperCase()}`;
18131
+ if (!overrideLocalStorage) {
18132
+ const storageItem = this.storage.getItem(key);
18133
+ if (storageItem && storageItem !== 'null') {
18134
+ const result = JSON.parse(storageItem);
18135
+ return result;
18136
+ }
18137
+ }
18138
+ const url = `${this.serviceUri}/GetPermissionsByService?service=${service}`;
18139
+ const response = yield this.defaultGet(url);
18140
+ if (!response || !response.success) {
18141
+ return [];
18142
+ }
18143
+ if (overrideLocalStorage) {
18144
+ this.storage.removeItem(key);
18145
+ }
18146
+ this.storage.setItem(key, JSON.stringify(response.data));
18147
+ return response.data;
18110
18148
  });
18111
18149
  }
18112
- countByMenuState(data) {
18113
- return this.defaultPost(`${this.serviceUri}/CountByMenuState`, data);
18114
- }
18115
- getDicIdByMenuState(data, tuNgay, denNgay) {
18116
- return this.defaultPost(`${this.serviceUri}/GetDicIdByMenuState`, {
18117
- lstTrangThai: data,
18118
- tuNgay,
18119
- denNgay
18120
- });
18150
+ getPermissionIdsByModule(moduleCode, userId) {
18151
+ const url = `${this.serviceUri}/GetPermissionIdsByModule/${moduleCode}/${userId}`;
18152
+ return this.defaultGet(url);
18121
18153
  }
18122
- updateBulkIdCha(model) {
18123
- const url = `${this.serviceUri}/UpdateBulkIdCha`;
18154
+ phanQuyenNguoiDung(model) {
18155
+ const url = `${this.serviceUri}/PhanQuyenNguoiDung`;
18124
18156
  return this.defaultPost(url, model);
18125
18157
  }
18126
- deleteBulkCongViecCon(ids) {
18127
- const url = `${this.serviceUri}/DeleteBulkCongViecCon`;
18128
- return this.defaultPost(url, ids);
18129
- }
18130
- getDataDashboardCaNhan(inputData) {
18131
- const url = `${this.serviceUri}/GetDataDashboardCaNhan`;
18132
- return this.defaultPost(url, inputData);
18133
- }
18134
- getDataDashboardByDonVi(inputData) {
18135
- const url = `${this.serviceUri}/GetDataDashboardByDonVi`;
18136
- return this.defaultPost(url, inputData);
18137
- }
18138
- getListTasksDashboard(dataFilter) {
18139
- const url = `${this.serviceUri}/getListTasksDashboard`;
18140
- return this.defaultPost(url, dataFilter);
18141
- }
18142
18158
  }
18143
- CongViecService.ɵprov = i0.ɵɵdefineInjectable({ factory: function CongViecService_Factory() { return new CongViecService(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(ModuleConfigService), i0.ɵɵinject(DmLoaiCongViecService)); }, token: CongViecService, providedIn: "root" });
18144
- CongViecService.decorators = [
18159
+ PermissionService.ɵprov = i0.ɵɵdefineInjectable({ factory: function PermissionService_Factory() { return new PermissionService(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(ModuleConfigService), i0.ɵɵinject(UserService), i0.ɵɵinject(i4.OAuthService), i0.ɵɵinject(ApplicationContextService)); }, token: PermissionService, providedIn: "root" });
18160
+ PermissionService.decorators = [
18145
18161
  { type: Injectable, args: [{
18146
18162
  providedIn: 'root'
18147
18163
  },] }
18148
18164
  ];
18149
- CongViecService.ctorParameters = () => [
18165
+ PermissionService.ctorParameters = () => [
18150
18166
  { type: HttpClient },
18151
18167
  { type: Injector },
18152
18168
  { type: ModuleConfigService },
18153
- { type: DmLoaiCongViecService }
18169
+ { type: UserService },
18170
+ { type: OAuthService },
18171
+ { type: ApplicationContextService }
18154
18172
  ];
18155
18173
 
18156
- class EntityWorkflowHistoryService extends BaseService {
18174
+ class WorkflowHistoryService extends BaseService {
18157
18175
  constructor(http, injector, _moduleConfigService) {
18158
- super(http, injector, `${_moduleConfigService.getConfig().environment.apiDomain.userOrgEndpoint}/${_moduleConfigService.getConfig().environment.apiVersion}/EntityWorkflowHistory`);
18159
- this.entityName = 'EntityWorkflowHistory';
18176
+ super(http, injector, `${_moduleConfigService.getConfig().environment.apiDomain.workflowEndpoint}/${_moduleConfigService.getConfig().environment.apiVersion}/WorkflowHistory`);
18160
18177
  this.serviceManagers = {};
18161
- this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.userOrgEndpoint;
18178
+ this.entityName = 'WorkflowHistory';
18179
+ this.serviceCode = 'workflow';
18180
+ this.apiDomain = _moduleConfigService.getConfig().environment.apiDomain;
18181
+ this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.workflowEndpoint;
18162
18182
  this._moduleConfig = _moduleConfigService.getConfig();
18183
+ this.apiVersion = _moduleConfigService.getConfig().environment.apiVersion;
18163
18184
  }
18164
- registerService(entityName, service) {
18165
- this.serviceManagers[entityName] = service;
18185
+ registerService(settingKey, service) {
18186
+ this.serviceManagers[settingKey] = service;
18166
18187
  }
18167
18188
  getEndpointByService(service) {
18168
18189
  return `${service.endPoint}/${this._moduleConfig.environment.apiVersion}`;
18169
18190
  }
18170
- setCurrentServiceUri(tableName) {
18171
- const service = this.serviceManagers[tableName];
18172
- if (service == undefined) {
18173
- (this._injector.get(NotifierService)).showWarning('Bạn chưa đăng ký base service cho entity workflow history');
18174
- }
18175
- this.serviceUri = `${this.getEndpointByService(service)}/EntityWorkflowHistory`;
18191
+ changeEndpoint(baseService) {
18192
+ this.serviceUri = `${this.getEndpointByService(baseService)}/WorkflowHistory`;
18193
+ return this;
18176
18194
  }
18177
- getLastHistory(tableName, filters = []) {
18178
- const service = this.serviceManagers[tableName];
18179
- if (service == undefined) {
18180
- (this._injector.get(NotifierService)).showWarning('Bạn chưa đăng ký base service cho entity workflow history');
18195
+ getLastByItemId(itemId) {
18196
+ // return this.getDetailByFilter(
18197
+ // [
18198
+ // this.newFilter('itemId', Operator.equal, itemId)
18199
+ // ],
18200
+ // [{ field: 'time', dir: -1 }]
18201
+ // );
18202
+ return this.defaultPost(`${this.serviceUri}/GetLastByItemIdInMainThread/${itemId}`, {});
18203
+ }
18204
+ choYKien(model) {
18205
+ return this.defaultPost(`${this.serviceUri}/ChoYKien`, model);
18206
+ }
18207
+ getAllObjectRelated(serviceCode, entity, entityKey, fullApiUrl = null) {
18208
+ let apiUrl = fullApiUrl || this.apiDomain[`${serviceCode}Endpoint`];
18209
+ if (!apiUrl) {
18210
+ throw new Error(`Không tìm thấy api endpoint ứng với service ${serviceCode}`);
18181
18211
  }
18182
- const url = `${this.getEndpointByService(service)}/EntityWorkflowHistory/GetLastByFilter`;
18183
- const gridInfo = {
18184
- pageInfo: {
18185
- page: 1,
18186
- pageSize: 1
18187
- },
18188
- filters,
18189
- sorts: [
18190
- new Sort({ field: 'created', dir: 1 })
18191
- ]
18192
- };
18193
- return this.defaultPost(url, gridInfo);
18212
+ apiUrl = `${apiUrl}/${this.apiVersion}/WorkflowHistory/GetAllObjectRelated/${entity}/${entityKey}`;
18213
+ return this.defaultGet(apiUrl);
18194
18214
  }
18195
18215
  }
18196
- EntityWorkflowHistoryService.ɵprov = i0.ɵɵdefineInjectable({ factory: function EntityWorkflowHistoryService_Factory() { return new EntityWorkflowHistoryService(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(ModuleConfigService)); }, token: EntityWorkflowHistoryService, providedIn: "root" });
18197
- EntityWorkflowHistoryService.decorators = [
18216
+ WorkflowHistoryService.ɵprov = i0.ɵɵdefineInjectable({ factory: function WorkflowHistoryService_Factory() { return new WorkflowHistoryService(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(ModuleConfigService)); }, token: WorkflowHistoryService, providedIn: "root" });
18217
+ WorkflowHistoryService.decorators = [
18198
18218
  { type: Injectable, args: [{
18199
18219
  providedIn: 'root'
18200
18220
  },] }
18201
18221
  ];
18202
- EntityWorkflowHistoryService.ctorParameters = () => [
18222
+ WorkflowHistoryService.ctorParameters = () => [
18203
18223
  { type: HttpClient },
18204
18224
  { type: Injector },
18205
18225
  { type: ModuleConfigService }
@@ -18346,83 +18366,66 @@ WorkflowPermissionDetailService.ctorParameters = () => [
18346
18366
  { type: ModuleConfigService }
18347
18367
  ];
18348
18368
 
18349
- class WorkflowHistoryService extends BaseService {
18350
- constructor(http, injector, _moduleConfigService) {
18351
- super(http, injector, `${_moduleConfigService.getConfig().environment.apiDomain.workflowEndpoint}/${_moduleConfigService.getConfig().environment.apiVersion}/WorkflowHistory`);
18352
- this.serviceManagers = {};
18353
- this.entityName = 'WorkflowHistory';
18354
- this.serviceCode = 'workflow';
18355
- this.apiDomain = _moduleConfigService.getConfig().environment.apiDomain;
18356
- this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.workflowEndpoint;
18357
- this._moduleConfig = _moduleConfigService.getConfig();
18358
- this.apiVersion = _moduleConfigService.getConfig().environment.apiVersion;
18359
- }
18360
- registerService(settingKey, service) {
18361
- this.serviceManagers[settingKey] = service;
18362
- }
18363
- getEndpointByService(service) {
18364
- return `${service.endPoint}/${this._moduleConfig.environment.apiVersion}`;
18365
- }
18366
- changeEndpoint(baseService) {
18367
- this.serviceUri = `${this.getEndpointByService(baseService)}/WorkflowHistory`;
18368
- return this;
18369
- }
18370
- getLastByItemId(itemId) {
18371
- // return this.getDetailByFilter(
18372
- // [
18373
- // this.newFilter('itemId', Operator.equal, itemId)
18374
- // ],
18375
- // [{ field: 'time', dir: -1 }]
18376
- // );
18377
- return this.defaultPost(`${this.serviceUri}/GetLastByItemIdInMainThread/${itemId}`, {});
18378
- }
18379
- choYKien(model) {
18380
- return this.defaultPost(`${this.serviceUri}/ChoYKien`, model);
18381
- }
18382
- getAllObjectRelated(serviceCode, entity, entityKey, fullApiUrl = null) {
18383
- let apiUrl = fullApiUrl || this.apiDomain[`${serviceCode}Endpoint`];
18384
- if (!apiUrl) {
18385
- throw new Error(`Không tìm thấy api endpoint ứng với service ${serviceCode}`);
18369
+ var sort_by;
18370
+ (function () {
18371
+ const defaultCompareFunc = function (a, b) {
18372
+ if (a == b)
18373
+ return 0;
18374
+ return a < b ? -1 : 1;
18375
+ };
18376
+ const getCompareFunc = function (primer, reverse) {
18377
+ const defaultCompare = defaultCompareFunc;
18378
+ let compare = defaultCompareFunc;
18379
+ if (primer) {
18380
+ compare = function (a, b) {
18381
+ return defaultCompare(primer(a), primer(b));
18382
+ };
18386
18383
  }
18387
- apiUrl = `${apiUrl}/${this.apiVersion}/WorkflowHistory/GetAllObjectRelated/${entity}/${entityKey}`;
18388
- return this.defaultGet(apiUrl);
18389
- }
18390
- }
18391
- WorkflowHistoryService.ɵprov = i0.ɵɵdefineInjectable({ factory: function WorkflowHistoryService_Factory() { return new WorkflowHistoryService(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(ModuleConfigService)); }, token: WorkflowHistoryService, providedIn: "root" });
18392
- WorkflowHistoryService.decorators = [
18393
- { type: Injectable, args: [{
18394
- providedIn: 'root'
18395
- },] }
18396
- ];
18397
- WorkflowHistoryService.ctorParameters = () => [
18398
- { type: HttpClient },
18399
- { type: Injector },
18400
- { type: ModuleConfigService }
18401
- ];
18402
-
18403
- class BasePermissionService extends BaseService {
18404
- constructor(http, injector, _moduleConfigService) {
18405
- super(http, injector, `${_moduleConfigService.getConfig().environment.apiDomain.authorizationEndpoint}/${_moduleConfigService.getConfig().environment.apiVersion}/BasePermission`);
18406
- this._moduleConfigService = _moduleConfigService;
18407
- this.entityName = 'BasePermission';
18408
- this.serviceCode = 'Authorization';
18409
- this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.authorizationEndpoint;
18410
- }
18411
- getPermissionByCode(code) {
18412
- return this.defaultGet(`${this.serviceUri}/GetPermissionByCode?code=${code}`);
18413
- }
18414
- }
18415
- BasePermissionService.ɵprov = i0.ɵɵdefineInjectable({ factory: function BasePermissionService_Factory() { return new BasePermissionService(i0.ɵɵinject(i1$1.HttpClient), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(ModuleConfigService)); }, token: BasePermissionService, providedIn: "root" });
18416
- BasePermissionService.decorators = [
18417
- { type: Injectable, args: [{
18418
- providedIn: 'root'
18419
- },] }
18420
- ];
18421
- BasePermissionService.ctorParameters = () => [
18422
- { type: HttpClient },
18423
- { type: Injector },
18424
- { type: ModuleConfigService }
18425
- ];
18384
+ if (reverse) {
18385
+ return function (a, b) {
18386
+ return -1 * compare(a, b);
18387
+ };
18388
+ }
18389
+ return compare;
18390
+ };
18391
+ sort_by = function (...args) {
18392
+ const fields = [], n_fields = args.length;
18393
+ let field, name, cmp;
18394
+ // preprocess sorting options
18395
+ for (let i = 0; i < n_fields; i++) {
18396
+ field = args[i];
18397
+ if (typeof field === 'string') {
18398
+ name = field;
18399
+ cmp = defaultCompareFunc;
18400
+ }
18401
+ else {
18402
+ name = field.name;
18403
+ cmp = getCompareFunc(field.primer, field.reverse);
18404
+ }
18405
+ fields.push({
18406
+ name: name,
18407
+ cmp: cmp
18408
+ });
18409
+ }
18410
+ // final comparison function
18411
+ return function (A, B) {
18412
+ let name, result;
18413
+ for (let i = 0; i < n_fields; i++) {
18414
+ result = 0;
18415
+ field = fields[i];
18416
+ name = field.name;
18417
+ result = field.cmp(A[name], B[name]);
18418
+ if (result !== 0)
18419
+ break;
18420
+ }
18421
+ return result;
18422
+ };
18423
+ };
18424
+ }());
18425
+ // multipleSort('idTinhThanh', 'idQuanHuyen')
18426
+ // multipleSort({name: 'idTinhThanh', reverse: true}, 'idQuanHuyen')
18427
+ // multipleSort({name: 'soThuTu', primer: parseInt}, 'idQuanHuyen') // parseInt là function
18428
+ const multipleSort = sort_by;
18426
18429
 
18427
18430
  class ListComponentBase extends ComponentBase {
18428
18431
  constructor(_injector, _isTreeTable) {
@@ -19675,15 +19678,15 @@ class ListComponentBase extends ComponentBase {
19675
19678
  const result = newArr.reduce((x, y) => y.colSpan + x, 0);
19676
19679
  return result > a ? result : a;
19677
19680
  }, 0);
19678
- const startIndex = this.setting.hiddenCheckbox ? 0 : 1;
19679
19681
  const endIndex = maxColSize - (this.setting.hiddenFunctionColumn ? 1 : 2);
19680
19682
  for (let ind = 0; ind < lstRow.length; ind++) {
19681
19683
  const arrTh = [...allTh[ind]];
19684
+ const startIndex = arrTh[0].className.includes('chkbox') ? 1 : 0;
19682
19685
  if (startIndex > endIndex) {
19683
19686
  return null;
19684
19687
  }
19685
19688
  result[ind] = (_a = result[ind]) !== null && _a !== void 0 ? _a : [];
19686
- let colIndex = 0;
19689
+ let colIndex = result[ind].length;
19687
19690
  const numOfColSpan = arrTh.reduce((x, y) => x + y.colSpan - 1, 0);
19688
19691
  for (let i = startIndex; i <= endIndex - numOfColSpan; i++) {
19689
19692
  if (arrTh[i]) {
@@ -19845,6 +19848,7 @@ class ListComponentBase extends ComponentBase {
19845
19848
  }
19846
19849
  getValueCheckboxFormat(data) {
19847
19850
  const checkBox = data.querySelector('p-checkbox');
19851
+ const input = data.querySelector('input');
19848
19852
  if (checkBox) {
19849
19853
  const value = data.querySelector('span.pi-check');
19850
19854
  if (value) {
@@ -19854,6 +19858,9 @@ class ListComponentBase extends ComponentBase {
19854
19858
  return 'Không';
19855
19859
  }
19856
19860
  }
19861
+ if (input) {
19862
+ return input.value;
19863
+ }
19857
19864
  return '';
19858
19865
  }
19859
19866
  view(rowData) {