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.
@@ -18442,6 +18442,7 @@
18442
18442
  _this.setValidateForm = true;
18443
18443
  _this.haveEntityMetadataAPI = true;
18444
18444
  _this.isBaseModel = true;
18445
+ _this.autoGenerateId = true;
18445
18446
  _this.__isFormView = false;
18446
18447
  var moduleConfigService = _injector.get(ModuleConfigService);
18447
18448
  _this.environment = moduleConfigService.getConfig().environment;
@@ -19064,8 +19065,10 @@
19064
19065
  DataFormBase.prototype.onAfterSave = function (response) {
19065
19066
  };
19066
19067
  DataFormBase.prototype._onAfterSave = function () {
19067
- if (!this.isCloseForm) {
19068
- this.model.data.id = this._commonService.guid();
19068
+ var _a;
19069
+ var _b;
19070
+ if (!this.isCloseForm && this.autoGenerateId) {
19071
+ (_a = (_b = this.model.data).id) !== null && _a !== void 0 ? _a : (_b.id = this._commonService.guid());
19069
19072
  }
19070
19073
  };
19071
19074
  DataFormBase.prototype.onAfterGetDetail = function (data) {
@@ -19336,827 +19339,346 @@
19336
19339
  onDataBinded: [{ type: i0.Output }]
19337
19340
  };
19338
19341
 
19339
- var SearchInfo = /** @class */ (function () {
19340
- function SearchInfo(init) {
19341
- this.fieldSearchText = [];
19342
- this.tooltipSearchText = '';
19343
- this.fieldDropdown = {};
19344
- for (var key in init) {
19345
- this[key] = init[key];
19346
- }
19347
- }
19348
- return SearchInfo;
19349
- }());
19350
-
19351
- var EXCEL_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8';
19352
- var EXCEL_EXTENSION = '.xlsx';
19353
- var ExportService = /** @class */ (function () {
19354
- function ExportService(_http, _injector, _commonService, _moduleConfigService) {
19355
- this._http = _http;
19356
- this._injector = _injector;
19357
- this._commonService = _commonService;
19358
- this._moduleConfig = _moduleConfigService.getConfig();
19359
- this.environment = this._moduleConfig.environment;
19360
- this.serviceUri = this._moduleConfig.environment.apiDomain.templateEndpoint + "/Export";
19342
+ var CauHinhWorkflowService = /** @class */ (function (_super) {
19343
+ __extends(CauHinhWorkflowService, _super);
19344
+ function CauHinhWorkflowService(http, injector, _moduleConfigService) {
19345
+ var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/CauHinhWorkflow") || this;
19346
+ _this._moduleConfigService = _moduleConfigService;
19347
+ _this.serviceCode = 'congviec';
19348
+ _this.entityName = 'CauHinhWorkflow';
19349
+ _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint;
19350
+ return _this;
19361
19351
  }
19362
- ExportService.prototype.objectToExcel = function (data, fileName, numOfHeaderRow) {
19363
- var _this = this;
19364
- return this._http
19365
- .post(this.serviceUri + "/ObjectToExcel?numOfHeaderRow=" + numOfHeaderRow, data, { responseType: 'blob' })
19366
- .pipe(operators.catchError(function (err) { return _this._commonService.handleError(err, _this._injector); }))
19367
- .subscribe(function (res) {
19368
- _this.saveAsExcelFile(res, fileName);
19369
- });
19370
- };
19371
- ExportService.prototype.saveAsExcelFile = function (buffer, fileName) {
19372
- var data = new Blob([buffer], {
19373
- type: EXCEL_TYPE
19374
- });
19375
- FileSaver__default["default"].saveAs(data, fileName + '_' + new Date().getTime() + EXCEL_EXTENSION);
19376
- };
19377
- ExportService.prototype.saveSpreadSheet = function (buffer, fileName) {
19378
- var data = new Blob([buffer], {
19379
- type: EXCEL_TYPE
19380
- });
19381
- FileSaver__default["default"].saveAs(data, new Date().getTime() + '_' + fileName);
19382
- };
19383
- return ExportService;
19384
- }());
19385
- ExportService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ExportService_Factory() { return new ExportService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(CommonService), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: ExportService, providedIn: "root" });
19386
- ExportService.decorators = [
19352
+ return CauHinhWorkflowService;
19353
+ }(BaseService));
19354
+ CauHinhWorkflowService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function CauHinhWorkflowService_Factory() { return new CauHinhWorkflowService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: CauHinhWorkflowService, providedIn: "root" });
19355
+ CauHinhWorkflowService.decorators = [
19387
19356
  { type: i0.Injectable, args: [{
19388
19357
  providedIn: 'root'
19389
19358
  },] }
19390
19359
  ];
19391
- ExportService.ctorParameters = function () { return [
19360
+ CauHinhWorkflowService.ctorParameters = function () { return [
19392
19361
  { type: i1$1.HttpClient },
19393
19362
  { type: i0.Injector },
19394
- { type: CommonService },
19395
19363
  { type: ModuleConfigService }
19396
19364
  ]; };
19397
19365
 
19398
- var PhanQuyenModel = /** @class */ (function () {
19399
- function PhanQuyenModel(init) {
19400
- this.addRoleIds = [];
19401
- this.removeRoleIds = [];
19402
- this.addPermissionIds = [];
19403
- this.removePermissionIds = [];
19404
- for (var key in init) {
19405
- this[key] = init[key];
19406
- }
19407
- }
19408
- return PhanQuyenModel;
19409
- }());
19410
- var PermissionService = /** @class */ (function (_super) {
19411
- __extends(PermissionService, _super);
19412
- function PermissionService(http, injector, _moduleConfigService, _userService, _oauthService, _appContext) {
19413
- var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.authorizationEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/permission") || this;
19366
+ var StateMachinesService = /** @class */ (function (_super) {
19367
+ __extends(StateMachinesService, _super);
19368
+ function StateMachinesService(http, injector, _moduleConfigService) {
19369
+ var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.workflowEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/StateMachines") || this;
19414
19370
  _this._moduleConfigService = _moduleConfigService;
19415
- _this._userService = _userService;
19416
- _this._oauthService = _oauthService;
19417
- _this._appContext = _appContext;
19418
- _this.storage = sessionStorage;
19419
- _this.ignoreAdmin = false;
19420
- _this.delayCheckPermissions = [];
19421
- _this.appCode = null;
19422
- _this._config = _this._moduleConfigService.getConfig();
19423
- _this.endPoint = _this._config.environment.apiDomain.authorizationEndpoint;
19424
- _this.ignoreAdmin = _this._config.environment.isIgnoreAdmin;
19425
- _this.appCode = _this._config.appCode;
19371
+ _this.entityName = 'StateMachines';
19372
+ _this.serviceCode = 'workflow';
19373
+ _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.workflowEndpoint;
19426
19374
  return _this;
19427
19375
  }
19428
- PermissionService.prototype.clearPermissionCacheAll = function () {
19429
- var _a, _b, _c;
19430
- var lstAppCodes = (_c = (_b = (_a = this._config.environment.appMetadata) === null || _a === void 0 ? void 0 : _a.appSwitcher) === null || _b === void 0 ? void 0 : _b.map(function (app) { return app.code; })) !== null && _c !== void 0 ? _c : [];
19431
- var lstApiEndpoint = [];
19432
- var apiDomain = this._config.environment.apiDomain;
19433
- for (var domainName in apiDomain) {
19434
- if (domainName.startsWith('-') || domainName.startsWith('1') || domainName == 'gateway')
19435
- continue;
19436
- var realDomainName = domainName.split('Endpoint') ? domainName.split('Endpoint')[0] : domainName;
19437
- lstApiEndpoint.push(realDomainName.toUpperCase());
19438
- }
19439
- return this.clearPermissionCache(__spreadArray(__spreadArray([], __read(lstAppCodes)), __read(lstApiEndpoint)));
19376
+ StateMachinesService.prototype.changeState = function (itemWorkflowHistory) {
19377
+ return this.defaultPost(this.serviceUri + "/ChangeState", itemWorkflowHistory);
19440
19378
  };
19441
- PermissionService.prototype.clearPermissionCache = function (lstModule) {
19442
- var url = this.serviceUri + "/ClearPermissionCache";
19443
- return this.defaultPost(url, lstModule);
19379
+ StateMachinesService.prototype.rollback = function (rowData) {
19380
+ return this.defaultPost(this.serviceUri + "/Rollback/" + rowData.__workflowCode + "/" + rowData.id, {});
19444
19381
  };
19445
- PermissionService.prototype.getCurrentUserPermission = function () {
19446
- var url = this.serviceUri + "/GetCurrentUserPermission";
19447
- return this.defaultGet(url);
19382
+ StateMachinesService.prototype.getUserInProcessForm = function (workflowCode, stateCode, actionCode, itemId) {
19383
+ return this.defaultPost(this.serviceUri + "/GetUserInProcessForm/" + workflowCode + "/" + stateCode + "/" + actionCode + "/" + itemId, {});
19448
19384
  };
19449
- PermissionService.prototype.getAllBasePermission = function (userId) {
19450
- var _a, _b, _c;
19451
- return __awaiter(this, void 0, void 0, function () {
19452
- var url, user, res, lstAppCodes, promiseArr, lstAppCodes_1, lstAppCodes_1_1, code, lstAppCodes_2, lstAppCodes_2_1, service, permissions, serviceCode, key_1, key, storageItem;
19453
- var e_1, _d, e_2, _e;
19454
- return __generator(this, function (_f) {
19455
- switch (_f.label) {
19385
+ return StateMachinesService;
19386
+ }(BaseService));
19387
+ StateMachinesService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function StateMachinesService_Factory() { return new StateMachinesService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: StateMachinesService, providedIn: "root" });
19388
+ StateMachinesService.decorators = [
19389
+ { type: i0.Injectable, args: [{
19390
+ providedIn: 'root'
19391
+ },] }
19392
+ ];
19393
+ StateMachinesService.ctorParameters = function () { return [
19394
+ { type: i1$1.HttpClient },
19395
+ { type: i0.Injector },
19396
+ { type: ModuleConfigService }
19397
+ ]; };
19398
+
19399
+ var DmLoaiCongViecService = /** @class */ (function (_super) {
19400
+ __extends(DmLoaiCongViecService, _super);
19401
+ function DmLoaiCongViecService(http, injector, _moduleConfigService) {
19402
+ var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/DM_LoaiCongViec") || this;
19403
+ _this._moduleConfigService = _moduleConfigService;
19404
+ _this.serviceCode = 'congviec';
19405
+ _this.entityName = 'DM_LoaiCongViec';
19406
+ _this.dicLoaiCongViec = {};
19407
+ _this.keyIdLoaiCongViecRoot = 'root';
19408
+ _this.getWorkflowSettingByIdLoaiCongViec = function (idLoaiCongViec) { return __awaiter(_this, void 0, void 0, function () {
19409
+ var result, idLoaiCongViecs, i;
19410
+ return __generator(this, function (_a) {
19411
+ switch (_a.label) {
19456
19412
  case 0:
19457
- url = this.serviceUri + "/GetAllBasePermission";
19458
- // return sớm đây là trường hợp lấy permission theo Id của User
19459
- // ko set local storage vì sẽ làm hỏng quyền của người dùng hiện tại
19460
- if (userId && userId != '' && userId != this._commonService.guidEmpty()) {
19461
- return [2 /*return*/, this.defaultGet(url + ("?userId=" + userId))];
19462
- }
19463
- if (i0.isDevMode()) {
19464
- return [2 /*return*/];
19465
- }
19466
- user = this._userService.getCurrentUser();
19467
- if (user
19468
- && (user.issuperuser && user.issuperuser.toLowerCase() == 'true')
19469
- || (user.isadmin && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin)) {
19470
- return [2 /*return*/];
19471
- }
19472
- return [4 /*yield*/, this.defaultGet(url)];
19413
+ if (!!this.dicWorkflowByLoaiCongViec) return [3 /*break*/, 2];
19414
+ return [4 /*yield*/, this.getDatasourceWorkflowCongViec()];
19473
19415
  case 1:
19474
- res = _f.sent();
19475
- lstAppCodes = (_c = (_b = (_a = this._config.environment.appMetadata) === null || _a === void 0 ? void 0 : _a.appSwitcher) === null || _b === void 0 ? void 0 : _b.map(function (app) { return app.code; })) !== null && _c !== void 0 ? _c : [];
19476
- if (!(!res || !res.success || res.data == null)) return [3 /*break*/, 3];
19477
- promiseArr = [];
19478
- try {
19479
- for (lstAppCodes_1 = __values(lstAppCodes), lstAppCodes_1_1 = lstAppCodes_1.next(); !lstAppCodes_1_1.done; lstAppCodes_1_1 = lstAppCodes_1.next()) {
19480
- code = lstAppCodes_1_1.value;
19481
- promiseArr.push(this.getServicePermission(code, true));
19482
- }
19483
- }
19484
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
19485
- finally {
19486
- try {
19487
- if (lstAppCodes_1_1 && !lstAppCodes_1_1.done && (_d = lstAppCodes_1.return)) _d.call(lstAppCodes_1);
19488
- }
19489
- finally { if (e_1) throw e_1.error; }
19490
- }
19491
- return [4 /*yield*/, Promise.all(promiseArr)];
19416
+ _a.sent();
19417
+ _a.label = 2;
19492
19418
  case 2:
19493
- _f.sent();
19494
- return [2 /*return*/];
19419
+ if (!idLoaiCongViec) {
19420
+ return [2 /*return*/, this.dicWorkflowByLoaiCongViec[this.keyIdLoaiCongViecRoot]];
19421
+ }
19422
+ result = this.dicWorkflowByLoaiCongViec[idLoaiCongViec];
19423
+ if (result)
19424
+ return [2 /*return*/, result];
19425
+ return [4 /*yield*/, this.getIdLoaiCongViecs(idLoaiCongViec)];
19495
19426
  case 3:
19496
- try {
19497
- // Set local storage cho permission của người dùng
19498
- for (lstAppCodes_2 = __values(lstAppCodes), lstAppCodes_2_1 = lstAppCodes_2.next(); !lstAppCodes_2_1.done; lstAppCodes_2_1 = lstAppCodes_2.next()) {
19499
- service = lstAppCodes_2_1.value;
19500
- permissions = [];
19501
- serviceCode = service.toUpperCase();
19502
- for (key_1 in res.data) {
19503
- if (key_1.toUpperCase() != serviceCode) {
19504
- continue;
19505
- }
19506
- permissions = res.data[key_1];
19507
- break;
19508
- }
19509
- key = "AUTHORIZATION." + serviceCode;
19510
- storageItem = this.storage.getItem(key);
19511
- if (storageItem != null) {
19512
- this.storage.removeItem(key);
19513
- }
19514
- this.storage.setItem(key, JSON.stringify(permissions));
19427
+ idLoaiCongViecs = _a.sent();
19428
+ if (!Array.isArray(idLoaiCongViecs))
19429
+ return [2 /*return*/, null];
19430
+ if (idLoaiCongViecs.length > 1) {
19431
+ for (i = idLoaiCongViecs.length - 2; i >= 0; i--) {
19432
+ result = this.dicWorkflowByLoaiCongViec[idLoaiCongViecs[i]];
19433
+ if (result)
19434
+ return [2 /*return*/, result];
19515
19435
  }
19516
19436
  }
19517
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
19518
- finally {
19519
- try {
19520
- if (lstAppCodes_2_1 && !lstAppCodes_2_1.done && (_e = lstAppCodes_2.return)) _e.call(lstAppCodes_2);
19521
- }
19522
- finally { if (e_2) throw e_2.error; }
19437
+ if (!result) {
19438
+ result = this.dicWorkflowByLoaiCongViec[this.keyIdLoaiCongViecRoot];
19523
19439
  }
19524
- return [2 /*return*/];
19440
+ return [2 /*return*/, result];
19525
19441
  }
19526
19442
  });
19527
- });
19528
- };
19529
- /**
19530
- * Truyền vào danh sách permision cần check
19531
- * @param lstPermissionCode những perrmision code cần check => nên dùng trong trường hợp check các button trong code
19532
- * @returns trả ra các perrmisionCode quyền
19533
- */
19534
- PermissionService.prototype.getPermissionAuthorized = function (lstPermissionCode) {
19535
- var _this = this;
19536
- return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
19537
- var user, result, lstPermissionCode_1, lstPermissionCode_1_1, item, e_3_1;
19538
- var e_3, _d;
19539
- return __generator(this, function (_e) {
19540
- switch (_e.label) {
19541
- case 0: return [4 /*yield*/, this._userService.getCurrentUser()];
19542
- case 1:
19543
- user = (_e.sent());
19544
- if (user && user.issuperuser.toLowerCase() == 'true') {
19545
- resolve(lstPermissionCode);
19546
- return [2 /*return*/];
19443
+ }); };
19444
+ _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint;
19445
+ return _this;
19446
+ }
19447
+ DmLoaiCongViecService.prototype.getDatasourceWorkflowCongViec = function () {
19448
+ return __awaiter(this, void 0, void 0, function () {
19449
+ var cauHinhWorkflowService, cauHinhWorkflows, notifierService, workflowCodes, stateMachinesService, workflows;
19450
+ var _this = this;
19451
+ return __generator(this, function (_a) {
19452
+ switch (_a.label) {
19453
+ case 0:
19454
+ if (!this.dicWorkflowByLoaiCongViec) {
19455
+ this.dicWorkflowByLoaiCongViec = {};
19547
19456
  }
19548
- if (user && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin) {
19549
- resolve(lstPermissionCode);
19550
- return [2 /*return*/];
19457
+ cauHinhWorkflowService = this._injector.get(CauHinhWorkflowService);
19458
+ return [4 /*yield*/, cauHinhWorkflowService.getAll([], 'idLoaiCongViec,workflowCodes,workflowCode')];
19459
+ case 1:
19460
+ cauHinhWorkflows = (_a.sent()).data;
19461
+ notifierService = this._injector.get(NotifierService);
19462
+ if (cauHinhWorkflows == null) {
19463
+ notifierService.showWarning('Dịch vụ workflow không phản hồi');
19464
+ return [2 /*return*/, []];
19551
19465
  }
19552
- result = [];
19553
- _e.label = 2;
19466
+ workflowCodes = [];
19467
+ cauHinhWorkflows.forEach(function (itemWorkflowSetting) {
19468
+ if (itemWorkflowSetting.workflowCodes && !Array.isArray(itemWorkflowSetting.workflowCodes)) {
19469
+ itemWorkflowSetting.workflowCodes = itemWorkflowSetting.workflowCodes.split(',');
19470
+ }
19471
+ else {
19472
+ itemWorkflowSetting.workflowCodes = [];
19473
+ }
19474
+ itemWorkflowSetting.workflowCodes.forEach(function (workflowCode) {
19475
+ if (workflowCodes.indexOf(workflowCode) == -1) {
19476
+ workflowCodes.push(workflowCode);
19477
+ }
19478
+ });
19479
+ });
19480
+ stateMachinesService = this._injector.get(StateMachinesService);
19481
+ return [4 /*yield*/, stateMachinesService.getDataDropdownByFilter([
19482
+ this.newFilter('code', exports.Operator.in, workflowCodes)
19483
+ ], new DropdownOptions({
19484
+ valueField: 'code',
19485
+ displayField: 'title',
19486
+ fieldPlus: 'data'
19487
+ }))];
19554
19488
  case 2:
19555
- _e.trys.push([2, 7, 8, 9]);
19556
- lstPermissionCode_1 = __values(lstPermissionCode), lstPermissionCode_1_1 = lstPermissionCode_1.next();
19557
- _e.label = 3;
19558
- case 3:
19559
- if (!!lstPermissionCode_1_1.done) return [3 /*break*/, 6];
19560
- item = lstPermissionCode_1_1.value;
19561
- return [4 /*yield*/, this.isAuthorizedPermission(item)];
19562
- case 4:
19563
- if (_e.sent()) {
19564
- result.push(item);
19565
- }
19566
- _e.label = 5;
19567
- case 5:
19568
- lstPermissionCode_1_1 = lstPermissionCode_1.next();
19569
- return [3 /*break*/, 3];
19570
- case 6: return [3 /*break*/, 9];
19571
- case 7:
19572
- e_3_1 = _e.sent();
19573
- e_3 = { error: e_3_1 };
19574
- return [3 /*break*/, 9];
19575
- case 8:
19576
- try {
19577
- if (lstPermissionCode_1_1 && !lstPermissionCode_1_1.done && (_d = lstPermissionCode_1.return)) _d.call(lstPermissionCode_1);
19578
- }
19579
- finally { if (e_3) throw e_3.error; }
19580
- return [7 /*endfinally*/];
19581
- case 9:
19582
- resolve(result);
19583
- return [2 /*return*/];
19489
+ workflows = (_a.sent());
19490
+ workflows.forEach(function (item) {
19491
+ item.data = JSON.parse(item.data);
19492
+ var stateMachineData = item.data;
19493
+ stateMachineData.actions = {};
19494
+ stateMachineData.machines.forEach(function (machine) {
19495
+ stateMachineData.actions[machine.code] = [];
19496
+ stateMachineData.connections.forEach(function (conn) {
19497
+ if (conn.source == machine.id) {
19498
+ stateMachineData.actions[machine.code].push(conn);
19499
+ }
19500
+ });
19501
+ });
19502
+ });
19503
+ cauHinhWorkflows.forEach(function (itemWorkflowSetting) {
19504
+ itemWorkflowSetting.workflows = workflows.filter(function (q) { return itemWorkflowSetting.workflowCodes.indexOf(q.code) > -1; });
19505
+ if (!itemWorkflowSetting.idLoaiCongViec) {
19506
+ _this.dicWorkflowByLoaiCongViec[_this.keyIdLoaiCongViecRoot] = itemWorkflowSetting;
19507
+ }
19508
+ else {
19509
+ _this.dicWorkflowByLoaiCongViec[itemWorkflowSetting.idLoaiCongViec] = itemWorkflowSetting;
19510
+ }
19511
+ });
19512
+ return [2 /*return*/, workflows];
19584
19513
  }
19585
19514
  });
19586
- }); });
19515
+ });
19587
19516
  };
19588
- PermissionService.prototype.isAuthorizedPermission = function (permission) {
19517
+ DmLoaiCongViecService.prototype.getIdLoaiCongViecs = function (idLoaiCongViec) {
19589
19518
  return __awaiter(this, void 0, void 0, function () {
19590
- var retryCount;
19591
- return __generator(this, function (_d) {
19592
- switch (_d.label) {
19519
+ var notifierService, itemLoaiCongViec, idLoaiCongViecs;
19520
+ return __generator(this, function (_a) {
19521
+ switch (_a.label) {
19593
19522
  case 0:
19594
- retryCount = 0;
19595
- _d.label = 1;
19523
+ notifierService = this._injector.get(NotifierService);
19524
+ return [4 /*yield*/, this.getItemLoaiCongViec(idLoaiCongViec)];
19596
19525
  case 1:
19597
- if (!!this._oauthService.hasValidAccessToken()) return [3 /*break*/, 3];
19598
- return [4 /*yield*/, this._commonService.delay(100)];
19599
- case 2:
19600
- _d.sent();
19601
- retryCount++;
19602
- if (retryCount > 50) {
19603
- return [3 /*break*/, 3];
19526
+ itemLoaiCongViec = _a.sent();
19527
+ if (itemLoaiCongViec == null) {
19528
+ notifierService.showWarning('Loại công việc không tồn tại');
19529
+ return [2 /*return*/, null];
19604
19530
  }
19605
- return [3 /*break*/, 1];
19606
- case 3: return [4 /*yield*/, this.checkPermission(this.appCode, permission)];
19607
- case 4: return [2 /*return*/, _d.sent()];
19531
+ idLoaiCongViecs = itemLoaiCongViec.idDuongDan.split(';').filter(function (q) { return !!q; });
19532
+ return [2 /*return*/, idLoaiCongViecs];
19608
19533
  }
19609
19534
  });
19610
19535
  });
19611
19536
  };
19612
- PermissionService.prototype.isAuthorized = function (service, permission, checForMenu) {
19613
- if (checForMenu === void 0) { checForMenu = false; }
19537
+ DmLoaiCongViecService.prototype.getItemLoaiCongViec = function (idLoaiCongViec) {
19614
19538
  return __awaiter(this, void 0, void 0, function () {
19615
- var retryCount;
19616
- return __generator(this, function (_d) {
19617
- switch (_d.label) {
19539
+ var _a, _b;
19540
+ return __generator(this, function (_c) {
19541
+ switch (_c.label) {
19618
19542
  case 0:
19619
- this.root = this._appContext.getRootContext();
19620
- retryCount = 0;
19621
- _d.label = 1;
19543
+ if (!!this.dicLoaiCongViec[idLoaiCongViec]) return [3 /*break*/, 2];
19544
+ _a = this.dicLoaiCongViec;
19545
+ _b = idLoaiCongViec;
19546
+ return [4 /*yield*/, this.getDetail(idLoaiCongViec)];
19622
19547
  case 1:
19623
- if (!!this._oauthService.hasValidAccessToken()) return [3 /*break*/, 3];
19624
- return [4 /*yield*/, this._commonService.delay(100)];
19625
- case 2:
19626
- _d.sent();
19627
- retryCount++;
19628
- if (retryCount > 50) {
19629
- return [3 /*break*/, 3];
19630
- }
19631
- return [3 /*break*/, 1];
19632
- case 3: return [4 /*yield*/, this.checkPermission(service, permission, checForMenu)];
19633
- case 4: return [2 /*return*/, _d.sent()];
19548
+ _a[_b] = (_c.sent()).data;
19549
+ _c.label = 2;
19550
+ case 2: return [2 /*return*/, this.dicLoaiCongViec[idLoaiCongViec]];
19634
19551
  }
19635
19552
  });
19636
19553
  });
19637
19554
  };
19638
- PermissionService.prototype.checkPermission = function (service, permissionToCheck, checkForMenu) {
19639
- if (checkForMenu === void 0) { checkForMenu = false; }
19555
+ return DmLoaiCongViecService;
19556
+ }(BaseService));
19557
+ DmLoaiCongViecService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function DmLoaiCongViecService_Factory() { return new DmLoaiCongViecService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: DmLoaiCongViecService, providedIn: "root" });
19558
+ DmLoaiCongViecService.decorators = [
19559
+ { type: i0.Injectable, args: [{
19560
+ providedIn: 'root'
19561
+ },] }
19562
+ ];
19563
+ DmLoaiCongViecService.ctorParameters = function () { return [
19564
+ { type: i1$1.HttpClient },
19565
+ { type: i0.Injector },
19566
+ { type: ModuleConfigService }
19567
+ ]; };
19568
+
19569
+ var CongViecService = /** @class */ (function (_super) {
19570
+ __extends(CongViecService, _super);
19571
+ function CongViecService(http, injector, _moduleConfigService, _dmLoaiCongViecService) {
19572
+ var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/CongViec_Chinh") || this;
19573
+ _this._dmLoaiCongViecService = _dmLoaiCongViecService;
19574
+ _this.serviceCode = 'congviec';
19575
+ _this.entityName = 'CongViec_Chinh';
19576
+ _this.objectName = 'công việc';
19577
+ _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint;
19578
+ _this._moduleConfig = _moduleConfigService.getConfig();
19579
+ return _this;
19580
+ }
19581
+ CongViecService.prototype.adjustSettingWorkflowForCrudList = function (setting) {
19582
+ this.useWorkflow = true;
19583
+ setting.isWorkflowTree = true;
19584
+ setting.baseService = this;
19585
+ setting.displayField = function (item) { return item.ten; };
19586
+ setting.baseService.useWorkflow = true;
19587
+ setting.workflowConfigAdvance = {
19588
+ getWorkflowSetting: this.getWorkflowConfig.bind(this)
19589
+ };
19590
+ };
19591
+ CongViecService.prototype.getWorkflowConfig = function (rowData) {
19640
19592
  return __awaiter(this, void 0, void 0, function () {
19641
- var user, valueIsDevMode, userPermissions, _a_1;
19642
- return __generator(this, function (_d) {
19643
- switch (_d.label) {
19644
- case 0:
19645
- _d.trys.push([0, 2, , 3]);
19646
- user = this._userService.getCurrentUser();
19647
- valueIsDevMode = true;
19648
- if (i0.isDevMode() && valueIsDevMode) {
19649
- return [2 /*return*/, true];
19650
- }
19651
- if (user && user.issuperuser && user.issuperuser.toLowerCase() == 'true' && valueIsDevMode) {
19652
- return [2 /*return*/, true];
19653
- }
19654
- if (user && user.isadmin && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin && valueIsDevMode) {
19655
- return [2 /*return*/, true];
19656
- }
19657
- return [4 /*yield*/, this.getServicePermission(service)];
19658
- case 1:
19659
- userPermissions = _d.sent();
19660
- if (userPermissions && userPermissions.length > 0) {
19661
- return [2 /*return*/, checkForMenu
19662
- ? userPermissions.includes(permissionToCheck)
19663
- : this._checkPermission(userPermissions, permissionToCheck)];
19664
- }
19665
- else {
19666
- // console.log(`Không có quyền với phân hệ [${service}]`);
19667
- return [2 /*return*/, false];
19668
- }
19669
- return [3 /*break*/, 3];
19670
- case 2:
19671
- _a_1 = _d.sent();
19672
- return [2 /*return*/, false];
19673
- case 3: return [2 /*return*/];
19593
+ return __generator(this, function (_a) {
19594
+ switch (_a.label) {
19595
+ case 0: return [4 /*yield*/, this._dmLoaiCongViecService.getWorkflowSettingByIdLoaiCongViec(rowData.idLoaiCongViec)];
19596
+ case 1: return [2 /*return*/, _a.sent()];
19674
19597
  }
19675
19598
  });
19676
19599
  });
19677
19600
  };
19678
- PermissionService.prototype._checkPermission = function (userPermissions, permissionToCheck) {
19679
- var e_4, _d;
19680
- var isAuthorized = false;
19681
- try {
19682
- // check permission của người dùng
19683
- // duyệt qua từng permission của người dùng
19684
- for (var userPermissions_1 = __values(userPermissions), userPermissions_1_1 = userPermissions_1.next(); !userPermissions_1_1.done; userPermissions_1_1 = userPermissions_1.next()) {
19685
- var userPermission = userPermissions_1_1.value;
19686
- // biến để break khỏi vòng khi người dùng được authorized
19687
- var breakOuterLoop = false;
19688
- // pointer permission của người dùng
19689
- var userPermissionPointer = 0;
19690
- // pointer permission đang check
19691
- var permissionToCheckPointer = 0;
19692
- // mark co the check query param
19693
- var aboutToCheckQueryParam = false;
19694
- // check từng char của 2 mảng
19695
- for (; permissionToCheckPointer < permissionToCheck.length;) {
19696
- // nếu char là ký tự bắt đầu template => tịnh tiến pointer của 2 mảng
19697
- var needRecheck = false;
19698
- if (userPermission[userPermissionPointer] == '{') {
19699
- // cho đến khi tìm được ký tự '/' tiếp theo thì dừng lại
19700
- for (; userPermissionPointer < userPermission.length; userPermissionPointer++) {
19701
- if (userPermissionPointer == userPermission.length - 1) {
19702
- break;
19703
- }
19704
- if (userPermission[userPermissionPointer] != '}') {
19705
- continue;
19706
- }
19707
- if (userPermission[userPermissionPointer] === '?') {
19708
- aboutToCheckQueryParam = true;
19709
- }
19710
- ++userPermissionPointer; // tiến tiến đến ký tự sau kết thúc template
19711
- // check trường hợp trường hợp chuỗi template có dạng "{template}acsekjf"
19712
- // => cần check các ký tự sau template và trước ký tự '/'
19713
- if (userPermission[userPermissionPointer] != '/' && (aboutToCheckQueryParam && userPermission[userPermissionPointer] != '&')) {
19714
- needRecheck = true;
19715
- for (; userPermissionPointer < userPermission.length; userPermissionPointer++) {
19716
- if (userPermissionPointer == userPermission.length - 1) {
19717
- break;
19718
- }
19719
- if (userPermission[userPermissionPointer] != '/') {
19720
- continue;
19721
- }
19722
- break;
19723
- }
19724
- }
19725
- break;
19726
- }
19727
- for (; permissionToCheckPointer < permissionToCheck.length; permissionToCheckPointer++) {
19728
- if (permissionToCheckPointer == permissionToCheck.length - 1) {
19729
- break;
19730
- }
19731
- if (permissionToCheck[permissionToCheckPointer] == '/' || (aboutToCheckQueryParam && permissionToCheck[permissionToCheckPointer] == '&')) {
19732
- break;
19733
- }
19734
- }
19735
- }
19736
- var breakInnerLoop = false;
19737
- if (needRecheck) {
19738
- // check lại cho trường hợp chuỗi template có dạng "{template}acslekfj"
19739
- // duyệt ngược lại cho đến khi gặp ký tự kết thúc template
19740
- var tempUserPointer = userPermissionPointer;
19741
- var tempToCheckPointer = permissionToCheckPointer;
19742
- while (userPermission[tempUserPointer] != '}') {
19743
- // ký tự khác nhau => break khỏi vòng kiểm tra trong
19744
- if (userPermission[tempUserPointer].toLowerCase() != permissionToCheck[tempToCheckPointer].toLowerCase()) {
19745
- breakInnerLoop = true;
19746
- break;
19747
- }
19748
- tempUserPointer--;
19749
- tempToCheckPointer--;
19750
- }
19751
- }
19752
- if (breakInnerLoop) {
19753
- break;
19754
- }
19755
- var userChar = userPermission[userPermissionPointer].toLowerCase();
19756
- var toCheckChar = permissionToCheck[permissionToCheckPointer].toLowerCase();
19757
- // nếu userPermission đang ở index cuối
19758
- if (userPermissionPointer == userPermission.length - 1) {
19759
- // check char cuối của 2 mảng (trừ khi là ký tự kết thúc template)
19760
- // và cũng phải là char cuối của mảng permission cần check
19761
- // => người dùng authorized và break khỏi vòng lặp ngoài cùng
19762
- if ((userChar == '}' || userChar == toCheckChar)
19763
- && permissionToCheckPointer == permissionToCheck.length - 1) {
19764
- breakOuterLoop = true;
19765
- isAuthorized = true;
19766
- }
19767
- break;
19768
- }
19769
- // check char có giống nhau không, không giống thì break khỏi vòng check
19770
- if (userChar != toCheckChar) {
19771
- break;
19772
- }
19773
- // nếu char giống nhau thì tiếp tục vòng lăp
19774
- permissionToCheckPointer++;
19775
- userPermissionPointer++;
19776
- }
19777
- if (breakOuterLoop) {
19778
- break;
19779
- }
19780
- }
19781
- }
19782
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
19783
- finally {
19784
- try {
19785
- if (userPermissions_1_1 && !userPermissions_1_1.done && (_d = userPermissions_1.return)) _d.call(userPermissions_1);
19786
- }
19787
- finally { if (e_4) throw e_4.error; }
19788
- }
19789
- return isAuthorized;
19601
+ CongViecService.prototype.countByMenuState = function (data) {
19602
+ return this.defaultPost(this.serviceUri + "/CountByMenuState", data);
19790
19603
  };
19791
- PermissionService.prototype._checkPermissionOld = function (userPermissions, permissionToCheck) {
19792
- var e_5, _d;
19793
- var isAuthorized = false;
19794
- // check quyền theo cách cũ nếu trường họp là phân quyền module
19795
- if (permissionToCheck.includes('MODULE')) {
19796
- return userPermissions.includes(permissionToCheck);
19797
- }
19798
- try {
19799
- for (var userPermissions_2 = __values(userPermissions), userPermissions_2_1 = userPermissions_2.next(); !userPermissions_2_1.done; userPermissions_2_1 = userPermissions_2.next()) {
19800
- var userPermission = userPermissions_2_1.value;
19801
- // Cắt chuỗi permission thành mảng để xem mỗi fragement có khớp nhau không
19802
- var userPermissionFragments = userPermission.split('/');
19803
- var permissionFragments = permissionToCheck.split('/');
19804
- // Mảng khác độ dài thì thoát sớm
19805
- if (userPermissionFragments.length != permissionFragments.length) {
19806
- continue;
19807
- }
19808
- // biến flag ra hiệu người dùng authorized và out vòng
19809
- var breakLoop = false;
19810
- // nếu tất cả phần tử khớp nhau => permission này trùng và người dùng được authorized
19811
- for (var index = 0; index < permissionFragments.length; index++) {
19812
- var userFragement = userPermissionFragments[index];
19813
- var permissionFragment = permissionFragments[index];
19814
- // skip qua các phần tử có ký tự bắt đầu là '{'
19815
- if (userFragement[0] == '{') {
19816
- if (index == permissionFragments.length - 1) {
19817
- isAuthorized = true;
19818
- breakLoop = true;
19819
- }
19820
- continue;
19821
- }
19822
- if (userFragement.toLowerCase() != permissionFragment.toLowerCase()) {
19823
- break;
19824
- }
19825
- if (index == permissionFragments.length - 1) {
19826
- isAuthorized = true;
19827
- breakLoop = true;
19828
- }
19829
- }
19830
- if (breakLoop) {
19831
- break;
19832
- }
19833
- }
19834
- }
19835
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
19836
- finally {
19837
- try {
19838
- if (userPermissions_2_1 && !userPermissions_2_1.done && (_d = userPermissions_2.return)) _d.call(userPermissions_2);
19839
- }
19840
- finally { if (e_5) throw e_5.error; }
19841
- }
19842
- return isAuthorized;
19604
+ CongViecService.prototype.getDicIdByMenuState = function (data, tuNgay, denNgay) {
19605
+ return this.defaultPost(this.serviceUri + "/GetDicIdByMenuState", {
19606
+ lstTrangThai: data,
19607
+ tuNgay: tuNgay,
19608
+ denNgay: denNgay
19609
+ });
19843
19610
  };
19844
- PermissionService.prototype.isAuthorizedByPermissions = function (permissions, operator, ignoreAdmin) {
19845
- var _this = this;
19846
- if (operator === void 0) { operator = 'OR'; }
19847
- if (ignoreAdmin === void 0) { ignoreAdmin = false; }
19848
- return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
19849
- var user, isAuthorized;
19850
- var _this = this;
19851
- return __generator(this, function (_d) {
19852
- switch (_d.label) {
19853
- case 0: return [4 /*yield*/, this._userService.getCurrentUser()];
19854
- case 1:
19855
- user = (_d.sent());
19856
- if (user && user.issuperuser.toLowerCase() == 'true') {
19857
- resolve(true);
19858
- return [2 /*return*/];
19859
- }
19860
- if (user && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin) {
19861
- resolve(true);
19862
- return [2 /*return*/];
19863
- }
19864
- isAuthorized = true;
19865
- if (operator.toUpperCase() == 'OR') {
19866
- isAuthorized = false;
19867
- }
19868
- permissions.forEach(function (item) {
19869
- _this.getServicePermission(item.service).then(function (permissionResult) {
19870
- if (operator.toUpperCase() == 'OR') {
19871
- if (permissionResult.includes(item.permission)) {
19872
- isAuthorized = true;
19873
- return;
19874
- }
19875
- }
19876
- else {
19877
- if (!permissionResult.includes(item.permission)) {
19878
- isAuthorized = false;
19879
- return;
19880
- }
19881
- }
19882
- }, function (error) {
19883
- reject(false);
19884
- });
19885
- });
19886
- resolve(isAuthorized);
19887
- return [2 /*return*/];
19888
- }
19889
- });
19890
- }); });
19611
+ CongViecService.prototype.updateBulkIdCha = function (model) {
19612
+ var url = this.serviceUri + "/UpdateBulkIdCha";
19613
+ return this.defaultPost(url, model);
19891
19614
  };
19892
- PermissionService.prototype.getServicePermission = function (service, overrideLocalStorage) {
19893
- if (overrideLocalStorage === void 0) { overrideLocalStorage = false; }
19894
- return __awaiter(this, void 0, void 0, function () {
19895
- var key, storageItem, result, url, response;
19896
- return __generator(this, function (_d) {
19897
- switch (_d.label) {
19898
- case 0:
19899
- key = "AUTHORIZATION." + service.toUpperCase();
19900
- if (!overrideLocalStorage) {
19901
- storageItem = this.storage.getItem(key);
19902
- if (storageItem && storageItem !== 'null') {
19903
- result = JSON.parse(storageItem);
19904
- return [2 /*return*/, result];
19905
- }
19906
- }
19907
- url = this.serviceUri + "/GetPermissionsByService?service=" + service;
19908
- return [4 /*yield*/, this.defaultGet(url)];
19909
- case 1:
19910
- response = _d.sent();
19911
- if (!response || !response.success) {
19912
- return [2 /*return*/, []];
19913
- }
19914
- if (overrideLocalStorage) {
19915
- this.storage.removeItem(key);
19916
- }
19917
- this.storage.setItem(key, JSON.stringify(response.data));
19918
- return [2 /*return*/, response.data];
19919
- }
19920
- });
19921
- });
19615
+ CongViecService.prototype.deleteBulkCongViecCon = function (ids) {
19616
+ var url = this.serviceUri + "/DeleteBulkCongViecCon";
19617
+ return this.defaultPost(url, ids);
19922
19618
  };
19923
- PermissionService.prototype.getPermissionIdsByModule = function (moduleCode, userId) {
19924
- var url = this.serviceUri + "/GetPermissionIdsByModule/" + moduleCode + "/" + userId;
19925
- return this.defaultGet(url);
19619
+ CongViecService.prototype.getDataDashboardCaNhan = function (inputData) {
19620
+ var url = this.serviceUri + "/GetDataDashboardCaNhan";
19621
+ return this.defaultPost(url, inputData);
19926
19622
  };
19927
- PermissionService.prototype.phanQuyenNguoiDung = function (model) {
19928
- var url = this.serviceUri + "/PhanQuyenNguoiDung";
19929
- return this.defaultPost(url, model);
19623
+ CongViecService.prototype.getDataDashboardByDonVi = function (inputData) {
19624
+ var url = this.serviceUri + "/GetDataDashboardByDonVi";
19625
+ return this.defaultPost(url, inputData);
19930
19626
  };
19931
- return PermissionService;
19627
+ CongViecService.prototype.getListTasksDashboard = function (dataFilter) {
19628
+ var url = this.serviceUri + "/getListTasksDashboard";
19629
+ return this.defaultPost(url, dataFilter);
19630
+ };
19631
+ return CongViecService;
19932
19632
  }(BaseService));
19933
- PermissionService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function PermissionService_Factory() { return new PermissionService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService), i0__namespace.ɵɵinject(UserService), i0__namespace.ɵɵinject(i4__namespace.OAuthService), i0__namespace.ɵɵinject(ApplicationContextService)); }, token: PermissionService, providedIn: "root" });
19934
- PermissionService.decorators = [
19633
+ CongViecService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function CongViecService_Factory() { return new CongViecService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService), i0__namespace.ɵɵinject(DmLoaiCongViecService)); }, token: CongViecService, providedIn: "root" });
19634
+ CongViecService.decorators = [
19935
19635
  { type: i0.Injectable, args: [{
19936
19636
  providedIn: 'root'
19937
19637
  },] }
19938
19638
  ];
19939
- PermissionService.ctorParameters = function () { return [
19639
+ CongViecService.ctorParameters = function () { return [
19940
19640
  { type: i1$1.HttpClient },
19941
19641
  { type: i0.Injector },
19942
19642
  { type: ModuleConfigService },
19943
- { type: UserService },
19944
- { type: i4.OAuthService },
19945
- { type: ApplicationContextService }
19643
+ { type: DmLoaiCongViecService }
19946
19644
  ]; };
19947
19645
 
19948
- var sort_by;
19949
- (function () {
19950
- var defaultCompareFunc = function (a, b) {
19951
- if (a == b)
19952
- return 0;
19953
- return a < b ? -1 : 1;
19954
- };
19955
- var getCompareFunc = function (primer, reverse) {
19956
- var defaultCompare = defaultCompareFunc;
19957
- var compare = defaultCompareFunc;
19958
- if (primer) {
19959
- compare = function (a, b) {
19960
- return defaultCompare(primer(a), primer(b));
19961
- };
19962
- }
19963
- if (reverse) {
19964
- return function (a, b) {
19965
- return -1 * compare(a, b);
19966
- };
19967
- }
19968
- return compare;
19969
- };
19970
- sort_by = function () {
19971
- var args = [];
19972
- for (var _i = 0; _i < arguments.length; _i++) {
19973
- args[_i] = arguments[_i];
19974
- }
19975
- var fields = [], n_fields = args.length;
19976
- var field, name, cmp;
19977
- // preprocess sorting options
19978
- for (var i = 0; i < n_fields; i++) {
19979
- field = args[i];
19980
- if (typeof field === 'string') {
19981
- name = field;
19982
- cmp = defaultCompareFunc;
19983
- }
19984
- else {
19985
- name = field.name;
19986
- cmp = getCompareFunc(field.primer, field.reverse);
19987
- }
19988
- fields.push({
19989
- name: name,
19990
- cmp: cmp
19991
- });
19646
+ var SearchInfo = /** @class */ (function () {
19647
+ function SearchInfo(init) {
19648
+ this.fieldSearchText = [];
19649
+ this.tooltipSearchText = '';
19650
+ this.fieldDropdown = {};
19651
+ for (var key in init) {
19652
+ this[key] = init[key];
19992
19653
  }
19993
- // final comparison function
19994
- return function (A, B) {
19995
- var name, result;
19996
- for (var i = 0; i < n_fields; i++) {
19997
- result = 0;
19998
- field = fields[i];
19999
- name = field.name;
20000
- result = field.cmp(A[name], B[name]);
20001
- if (result !== 0)
20002
- break;
20003
- }
20004
- return result;
20005
- };
20006
- };
19654
+ }
19655
+ return SearchInfo;
20007
19656
  }());
20008
- // multipleSort('idTinhThanh', 'idQuanHuyen')
20009
- // multipleSort({name: 'idTinhThanh', reverse: true}, 'idQuanHuyen')
20010
- // multipleSort({name: 'soThuTu', primer: parseInt}, 'idQuanHuyen') // parseInt là function
20011
- var multipleSort = sort_by;
20012
19657
 
20013
- var moduleMap = {};
20014
- function loadRemoteEntry(remoteEntry) {
20015
- return new Promise(function (resolve, reject) {
20016
- if (moduleMap[remoteEntry]) {
20017
- resolve();
20018
- return;
20019
- }
20020
- var script = document.createElement('script');
20021
- script.src = remoteEntry;
20022
- script.onerror = reject;
20023
- script.onload = function () {
20024
- moduleMap[remoteEntry] = true;
20025
- resolve(); // window is the global namespace
20026
- };
20027
- document.body.append(script);
20028
- });
20029
- }
20030
- function lookupExposedModule(remoteName, exposedModule) {
20031
- return __awaiter(this, void 0, void 0, function () {
20032
- var container, factory, Module;
20033
- return __generator(this, function (_a) {
20034
- switch (_a.label) {
20035
- case 0:
20036
- // Initializes the share scope. This fills it with known provided modules from this build and all remotes
20037
- return [4 /*yield*/, __webpack_init_sharing__('default')];
20038
- case 1:
20039
- // Initializes the share scope. This fills it with known provided modules from this build and all remotes
20040
- _a.sent();
20041
- container = window[remoteName];
20042
- // Initialize the container, it may provide shared modules
20043
- return [4 /*yield*/, container.init(__webpack_share_scopes__.default)];
20044
- case 2:
20045
- // Initialize the container, it may provide shared modules
20046
- _a.sent();
20047
- return [4 /*yield*/, container.get(exposedModule)];
20048
- case 3:
20049
- factory = _a.sent();
20050
- Module = factory();
20051
- return [2 /*return*/, Module];
20052
- }
20053
- });
20054
- });
20055
- }
20056
- function loadRemoteModule(options) {
20057
- return __awaiter(this, void 0, void 0, function () {
20058
- return __generator(this, function (_a) {
20059
- switch (_a.label) {
20060
- case 0: return [4 /*yield*/, loadRemoteEntry(options.remoteEntry)];
20061
- case 1:
20062
- _a.sent();
20063
- return [4 /*yield*/, lookupExposedModule(options.remoteName, options.exposedModule)];
20064
- case 2: return [2 /*return*/, _a.sent()];
20065
- }
20066
- });
20067
- });
20068
- }
20069
- function loadRemotePageModule(remoteName, module, environment) {
20070
- return __awaiter(this, void 0, void 0, function () {
20071
- var remoteEntry, options;
20072
- return __generator(this, function (_a) {
20073
- switch (_a.label) {
20074
- case 0:
20075
- remoteEntry = environment.clientDomain.appDomain + "/" + remoteName + "/remoteEntry.js";
20076
- if (!environment.production) {
20077
- remoteEntry = environment.clientDomain[remoteName] + "/remoteEntry.js";
20078
- }
20079
- options = {
20080
- remoteName: remoteName,
20081
- remoteEntry: remoteEntry,
20082
- exposedModule: module,
20083
- };
20084
- return [4 /*yield*/, loadRemoteModule(options)];
20085
- case 1: return [2 /*return*/, _a.sent()];
20086
- }
20087
- });
20088
- });
20089
- }
20090
-
20091
- var FederationService = /** @class */ (function () {
20092
- function FederationService(resolver, _moduleConfigService) {
20093
- this.resolver = resolver;
20094
- this._moduleConfigService = _moduleConfigService;
20095
- this.environment = _moduleConfigService.getConfig().environment;
19658
+ var BasePermissionService = /** @class */ (function (_super) {
19659
+ __extends(BasePermissionService, _super);
19660
+ function BasePermissionService(http, injector, _moduleConfigService) {
19661
+ var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.authorizationEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/BasePermission") || this;
19662
+ _this._moduleConfigService = _moduleConfigService;
19663
+ _this.entityName = 'BasePermission';
19664
+ _this.serviceCode = 'Authorization';
19665
+ _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.authorizationEndpoint;
19666
+ return _this;
20096
19667
  }
20097
- FederationService.prototype.loadRemoteComponent = function (remoteName, componentName, viewContainerRef) {
20098
- return __awaiter(this, void 0, void 0, function () {
20099
- var remoteEntry, options, component, componentFactory, viewContainer, compRef;
20100
- return __generator(this, function (_a) {
20101
- switch (_a.label) {
20102
- case 0:
20103
- remoteEntry = this.environment.clientDomain.appDomain + "/" + remoteName + "/remoteEntry.js";
20104
- if (!this.environment.production) {
20105
- remoteEntry = this.environment.clientDomain[remoteName] + "/remoteEntry.js";
20106
- }
20107
- options = {
20108
- remoteName: remoteName,
20109
- remoteEntry: remoteEntry,
20110
- exposedModule: componentName,
20111
- };
20112
- return [4 /*yield*/, loadRemoteModule(options)];
20113
- case 1:
20114
- component = _a.sent();
20115
- componentFactory = this.resolver.resolveComponentFactory(component[componentName]);
20116
- viewContainer = viewContainerRef.viewContainerRef;
20117
- viewContainer.clear();
20118
- compRef = viewContainer.createComponent(componentFactory);
20119
- return [2 /*return*/, compRef];
20120
- }
20121
- });
20122
- });
20123
- };
20124
- FederationService.prototype.loadRemoteNewComponent = function (remoteName, componentName, viewContainerRef) {
20125
- return __awaiter(this, void 0, void 0, function () {
20126
- var remoteEntry, options, component, componentFactory, compRef;
20127
- return __generator(this, function (_a) {
20128
- switch (_a.label) {
20129
- case 0:
20130
- remoteEntry = this.environment.clientDomain.appDomain + "/" + remoteName + "/remoteEntry.js";
20131
- if (!this.environment.production) {
20132
- remoteEntry = this.environment.clientDomain[remoteName] + "/remoteEntry.js";
20133
- }
20134
- options = {
20135
- remoteName: remoteName,
20136
- remoteEntry: remoteEntry,
20137
- exposedModule: componentName,
20138
- };
20139
- return [4 /*yield*/, loadRemoteModule(options)];
20140
- case 1:
20141
- component = _a.sent();
20142
- componentFactory = this.resolver.resolveComponentFactory(component[componentName]);
20143
- viewContainerRef.clear();
20144
- compRef = viewContainerRef.createComponent(componentFactory);
20145
- return [2 /*return*/, compRef];
20146
- }
20147
- });
20148
- });
19668
+ BasePermissionService.prototype.getPermissionByCode = function (code) {
19669
+ return this.defaultGet(this.serviceUri + "/GetPermissionByCode?code=" + code);
20149
19670
  };
20150
- return FederationService;
20151
- }());
20152
- FederationService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function FederationService_Factory() { return new FederationService(i0__namespace.ɵɵinject(i0__namespace.ComponentFactoryResolver), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: FederationService, providedIn: "root" });
20153
- FederationService.decorators = [
19671
+ return BasePermissionService;
19672
+ }(BaseService));
19673
+ BasePermissionService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function BasePermissionService_Factory() { return new BasePermissionService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: BasePermissionService, providedIn: "root" });
19674
+ BasePermissionService.decorators = [
20154
19675
  { type: i0.Injectable, args: [{
20155
19676
  providedIn: 'root'
20156
19677
  },] }
20157
19678
  ];
20158
- FederationService.ctorParameters = function () { return [
20159
- { type: i0.ComponentFactoryResolver },
19679
+ BasePermissionService.ctorParameters = function () { return [
19680
+ { type: i1$1.HttpClient },
19681
+ { type: i0.Injector },
20160
19682
  { type: ModuleConfigService }
20161
19683
  ]; };
20162
19684
 
@@ -21138,380 +20660,881 @@
21138
20660
  var url = this.serviceUri + "/GetDanhSachUserCapTren";
21139
20661
  return this.defaultPost(url, idsDonVi);
21140
20662
  };
21141
- return CanBoHoSoService;
21142
- }(BaseService));
21143
- CanBoHoSoService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function CanBoHoSoService_Factory() { return new CanBoHoSoService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService), i0__namespace.ɵɵinject(UserService), i0__namespace.ɵɵinject(CanBo_HoSo_CoCauToChucService), i0__namespace.ɵɵinject(CoCauToChucService), i0__namespace.ɵɵinject(HoSoDoiTacService), i0__namespace.ɵɵinject(CrudService)); }, token: CanBoHoSoService, providedIn: "root" });
21144
- CanBoHoSoService.decorators = [
20663
+ return CanBoHoSoService;
20664
+ }(BaseService));
20665
+ CanBoHoSoService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function CanBoHoSoService_Factory() { return new CanBoHoSoService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService), i0__namespace.ɵɵinject(UserService), i0__namespace.ɵɵinject(CanBo_HoSo_CoCauToChucService), i0__namespace.ɵɵinject(CoCauToChucService), i0__namespace.ɵɵinject(HoSoDoiTacService), i0__namespace.ɵɵinject(CrudService)); }, token: CanBoHoSoService, providedIn: "root" });
20666
+ CanBoHoSoService.decorators = [
20667
+ { type: i0.Injectable, args: [{
20668
+ providedIn: 'root'
20669
+ },] }
20670
+ ];
20671
+ CanBoHoSoService.ctorParameters = function () { return [
20672
+ { type: i1$1.HttpClient },
20673
+ { type: i0.Injector },
20674
+ { type: ModuleConfigService },
20675
+ { type: UserService },
20676
+ { type: CanBo_HoSo_CoCauToChucService },
20677
+ { type: CoCauToChucService },
20678
+ { type: HoSoDoiTacService },
20679
+ { type: CrudService }
20680
+ ]; };
20681
+
20682
+ var EntityWorkflowHistoryService = /** @class */ (function (_super) {
20683
+ __extends(EntityWorkflowHistoryService, _super);
20684
+ function EntityWorkflowHistoryService(http, injector, _moduleConfigService) {
20685
+ var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.userOrgEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/EntityWorkflowHistory") || this;
20686
+ _this.entityName = 'EntityWorkflowHistory';
20687
+ _this.serviceManagers = {};
20688
+ _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.userOrgEndpoint;
20689
+ _this._moduleConfig = _moduleConfigService.getConfig();
20690
+ return _this;
20691
+ }
20692
+ EntityWorkflowHistoryService.prototype.registerService = function (entityName, service) {
20693
+ this.serviceManagers[entityName] = service;
20694
+ };
20695
+ EntityWorkflowHistoryService.prototype.getEndpointByService = function (service) {
20696
+ return service.endPoint + "/" + this._moduleConfig.environment.apiVersion;
20697
+ };
20698
+ EntityWorkflowHistoryService.prototype.setCurrentServiceUri = function (tableName) {
20699
+ var service = this.serviceManagers[tableName];
20700
+ if (service == undefined) {
20701
+ (this._injector.get(NotifierService)).showWarning('Bạn chưa đăng ký base service cho entity workflow history');
20702
+ }
20703
+ this.serviceUri = this.getEndpointByService(service) + "/EntityWorkflowHistory";
20704
+ };
20705
+ EntityWorkflowHistoryService.prototype.getLastHistory = function (tableName, filters) {
20706
+ if (filters === void 0) { filters = []; }
20707
+ var service = this.serviceManagers[tableName];
20708
+ if (service == undefined) {
20709
+ (this._injector.get(NotifierService)).showWarning('Bạn chưa đăng ký base service cho entity workflow history');
20710
+ }
20711
+ var url = this.getEndpointByService(service) + "/EntityWorkflowHistory/GetLastByFilter";
20712
+ var gridInfo = {
20713
+ pageInfo: {
20714
+ page: 1,
20715
+ pageSize: 1
20716
+ },
20717
+ filters: filters,
20718
+ sorts: [
20719
+ new Sort({ field: 'created', dir: 1 })
20720
+ ]
20721
+ };
20722
+ return this.defaultPost(url, gridInfo);
20723
+ };
20724
+ return EntityWorkflowHistoryService;
20725
+ }(BaseService));
20726
+ EntityWorkflowHistoryService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function EntityWorkflowHistoryService_Factory() { return new EntityWorkflowHistoryService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: EntityWorkflowHistoryService, providedIn: "root" });
20727
+ EntityWorkflowHistoryService.decorators = [
20728
+ { type: i0.Injectable, args: [{
20729
+ providedIn: 'root'
20730
+ },] }
20731
+ ];
20732
+ EntityWorkflowHistoryService.ctorParameters = function () { return [
20733
+ { type: i1$1.HttpClient },
20734
+ { type: i0.Injector },
20735
+ { type: ModuleConfigService }
20736
+ ]; };
20737
+
20738
+ var EXCEL_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8';
20739
+ var EXCEL_EXTENSION = '.xlsx';
20740
+ var ExportService = /** @class */ (function () {
20741
+ function ExportService(_http, _injector, _commonService, _moduleConfigService) {
20742
+ this._http = _http;
20743
+ this._injector = _injector;
20744
+ this._commonService = _commonService;
20745
+ this._moduleConfig = _moduleConfigService.getConfig();
20746
+ this.environment = this._moduleConfig.environment;
20747
+ this.serviceUri = this._moduleConfig.environment.apiDomain.templateEndpoint + "/Export";
20748
+ }
20749
+ ExportService.prototype.objectToExcel = function (data, fileName, numOfHeaderRow) {
20750
+ var _this = this;
20751
+ return this._http
20752
+ .post(this.serviceUri + "/ObjectToExcel?numOfHeaderRow=" + numOfHeaderRow, data, { responseType: 'blob' })
20753
+ .pipe(operators.catchError(function (err) { return _this._commonService.handleError(err, _this._injector); }))
20754
+ .subscribe(function (res) {
20755
+ _this.saveAsExcelFile(res, fileName);
20756
+ });
20757
+ };
20758
+ ExportService.prototype.saveAsExcelFile = function (buffer, fileName) {
20759
+ var data = new Blob([buffer], {
20760
+ type: EXCEL_TYPE
20761
+ });
20762
+ FileSaver__default["default"].saveAs(data, fileName + '_' + new Date().getTime() + EXCEL_EXTENSION);
20763
+ };
20764
+ ExportService.prototype.saveSpreadSheet = function (buffer, fileName) {
20765
+ var data = new Blob([buffer], {
20766
+ type: EXCEL_TYPE
20767
+ });
20768
+ FileSaver__default["default"].saveAs(data, new Date().getTime() + '_' + fileName);
20769
+ };
20770
+ return ExportService;
20771
+ }());
20772
+ ExportService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ExportService_Factory() { return new ExportService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(CommonService), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: ExportService, providedIn: "root" });
20773
+ ExportService.decorators = [
20774
+ { type: i0.Injectable, args: [{
20775
+ providedIn: 'root'
20776
+ },] }
20777
+ ];
20778
+ ExportService.ctorParameters = function () { return [
20779
+ { type: i1$1.HttpClient },
20780
+ { type: i0.Injector },
20781
+ { type: CommonService },
20782
+ { type: ModuleConfigService }
20783
+ ]; };
20784
+
20785
+ var moduleMap = {};
20786
+ function loadRemoteEntry(remoteEntry) {
20787
+ return new Promise(function (resolve, reject) {
20788
+ if (moduleMap[remoteEntry]) {
20789
+ resolve();
20790
+ return;
20791
+ }
20792
+ var script = document.createElement('script');
20793
+ script.src = remoteEntry;
20794
+ script.onerror = reject;
20795
+ script.onload = function () {
20796
+ moduleMap[remoteEntry] = true;
20797
+ resolve(); // window is the global namespace
20798
+ };
20799
+ document.body.append(script);
20800
+ });
20801
+ }
20802
+ function lookupExposedModule(remoteName, exposedModule) {
20803
+ return __awaiter(this, void 0, void 0, function () {
20804
+ var container, factory, Module;
20805
+ return __generator(this, function (_a) {
20806
+ switch (_a.label) {
20807
+ case 0:
20808
+ // Initializes the share scope. This fills it with known provided modules from this build and all remotes
20809
+ return [4 /*yield*/, __webpack_init_sharing__('default')];
20810
+ case 1:
20811
+ // Initializes the share scope. This fills it with known provided modules from this build and all remotes
20812
+ _a.sent();
20813
+ container = window[remoteName];
20814
+ // Initialize the container, it may provide shared modules
20815
+ return [4 /*yield*/, container.init(__webpack_share_scopes__.default)];
20816
+ case 2:
20817
+ // Initialize the container, it may provide shared modules
20818
+ _a.sent();
20819
+ return [4 /*yield*/, container.get(exposedModule)];
20820
+ case 3:
20821
+ factory = _a.sent();
20822
+ Module = factory();
20823
+ return [2 /*return*/, Module];
20824
+ }
20825
+ });
20826
+ });
20827
+ }
20828
+ function loadRemoteModule(options) {
20829
+ return __awaiter(this, void 0, void 0, function () {
20830
+ return __generator(this, function (_a) {
20831
+ switch (_a.label) {
20832
+ case 0: return [4 /*yield*/, loadRemoteEntry(options.remoteEntry)];
20833
+ case 1:
20834
+ _a.sent();
20835
+ return [4 /*yield*/, lookupExposedModule(options.remoteName, options.exposedModule)];
20836
+ case 2: return [2 /*return*/, _a.sent()];
20837
+ }
20838
+ });
20839
+ });
20840
+ }
20841
+ function loadRemotePageModule(remoteName, module, environment) {
20842
+ return __awaiter(this, void 0, void 0, function () {
20843
+ var remoteEntry, options;
20844
+ return __generator(this, function (_a) {
20845
+ switch (_a.label) {
20846
+ case 0:
20847
+ remoteEntry = environment.clientDomain.appDomain + "/" + remoteName + "/remoteEntry.js";
20848
+ if (!environment.production) {
20849
+ remoteEntry = environment.clientDomain[remoteName] + "/remoteEntry.js";
20850
+ }
20851
+ options = {
20852
+ remoteName: remoteName,
20853
+ remoteEntry: remoteEntry,
20854
+ exposedModule: module,
20855
+ };
20856
+ return [4 /*yield*/, loadRemoteModule(options)];
20857
+ case 1: return [2 /*return*/, _a.sent()];
20858
+ }
20859
+ });
20860
+ });
20861
+ }
20862
+
20863
+ var FederationService = /** @class */ (function () {
20864
+ function FederationService(resolver, _moduleConfigService) {
20865
+ this.resolver = resolver;
20866
+ this._moduleConfigService = _moduleConfigService;
20867
+ this.environment = _moduleConfigService.getConfig().environment;
20868
+ }
20869
+ FederationService.prototype.loadRemoteComponent = function (remoteName, componentName, viewContainerRef) {
20870
+ return __awaiter(this, void 0, void 0, function () {
20871
+ var remoteEntry, options, component, componentFactory, viewContainer, compRef;
20872
+ return __generator(this, function (_a) {
20873
+ switch (_a.label) {
20874
+ case 0:
20875
+ remoteEntry = this.environment.clientDomain.appDomain + "/" + remoteName + "/remoteEntry.js";
20876
+ if (!this.environment.production) {
20877
+ remoteEntry = this.environment.clientDomain[remoteName] + "/remoteEntry.js";
20878
+ }
20879
+ options = {
20880
+ remoteName: remoteName,
20881
+ remoteEntry: remoteEntry,
20882
+ exposedModule: componentName,
20883
+ };
20884
+ return [4 /*yield*/, loadRemoteModule(options)];
20885
+ case 1:
20886
+ component = _a.sent();
20887
+ componentFactory = this.resolver.resolveComponentFactory(component[componentName]);
20888
+ viewContainer = viewContainerRef.viewContainerRef;
20889
+ viewContainer.clear();
20890
+ compRef = viewContainer.createComponent(componentFactory);
20891
+ return [2 /*return*/, compRef];
20892
+ }
20893
+ });
20894
+ });
20895
+ };
20896
+ FederationService.prototype.loadRemoteNewComponent = function (remoteName, componentName, viewContainerRef) {
20897
+ return __awaiter(this, void 0, void 0, function () {
20898
+ var remoteEntry, options, component, componentFactory, compRef;
20899
+ return __generator(this, function (_a) {
20900
+ switch (_a.label) {
20901
+ case 0:
20902
+ remoteEntry = this.environment.clientDomain.appDomain + "/" + remoteName + "/remoteEntry.js";
20903
+ if (!this.environment.production) {
20904
+ remoteEntry = this.environment.clientDomain[remoteName] + "/remoteEntry.js";
20905
+ }
20906
+ options = {
20907
+ remoteName: remoteName,
20908
+ remoteEntry: remoteEntry,
20909
+ exposedModule: componentName,
20910
+ };
20911
+ return [4 /*yield*/, loadRemoteModule(options)];
20912
+ case 1:
20913
+ component = _a.sent();
20914
+ componentFactory = this.resolver.resolveComponentFactory(component[componentName]);
20915
+ viewContainerRef.clear();
20916
+ compRef = viewContainerRef.createComponent(componentFactory);
20917
+ return [2 /*return*/, compRef];
20918
+ }
20919
+ });
20920
+ });
20921
+ };
20922
+ return FederationService;
20923
+ }());
20924
+ FederationService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function FederationService_Factory() { return new FederationService(i0__namespace.ɵɵinject(i0__namespace.ComponentFactoryResolver), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: FederationService, providedIn: "root" });
20925
+ FederationService.decorators = [
21145
20926
  { type: i0.Injectable, args: [{
21146
20927
  providedIn: 'root'
21147
20928
  },] }
21148
20929
  ];
21149
- CanBoHoSoService.ctorParameters = function () { return [
21150
- { type: i1$1.HttpClient },
21151
- { type: i0.Injector },
21152
- { type: ModuleConfigService },
21153
- { type: UserService },
21154
- { type: CanBo_HoSo_CoCauToChucService },
21155
- { type: CoCauToChucService },
21156
- { type: HoSoDoiTacService },
21157
- { type: CrudService }
20930
+ FederationService.ctorParameters = function () { return [
20931
+ { type: i0.ComponentFactoryResolver },
20932
+ { type: ModuleConfigService }
21158
20933
  ]; };
21159
20934
 
21160
- var StateMachinesService = /** @class */ (function (_super) {
21161
- __extends(StateMachinesService, _super);
21162
- function StateMachinesService(http, injector, _moduleConfigService) {
21163
- var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.workflowEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/StateMachines") || this;
20935
+ var PhanQuyenModel = /** @class */ (function () {
20936
+ function PhanQuyenModel(init) {
20937
+ this.addRoleIds = [];
20938
+ this.removeRoleIds = [];
20939
+ this.addPermissionIds = [];
20940
+ this.removePermissionIds = [];
20941
+ for (var key in init) {
20942
+ this[key] = init[key];
20943
+ }
20944
+ }
20945
+ return PhanQuyenModel;
20946
+ }());
20947
+ var PermissionService = /** @class */ (function (_super) {
20948
+ __extends(PermissionService, _super);
20949
+ function PermissionService(http, injector, _moduleConfigService, _userService, _oauthService, _appContext) {
20950
+ var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.authorizationEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/permission") || this;
21164
20951
  _this._moduleConfigService = _moduleConfigService;
21165
- _this.entityName = 'StateMachines';
21166
- _this.serviceCode = 'workflow';
21167
- _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.workflowEndpoint;
20952
+ _this._userService = _userService;
20953
+ _this._oauthService = _oauthService;
20954
+ _this._appContext = _appContext;
20955
+ _this.storage = sessionStorage;
20956
+ _this.ignoreAdmin = false;
20957
+ _this.delayCheckPermissions = [];
20958
+ _this.appCode = null;
20959
+ _this._config = _this._moduleConfigService.getConfig();
20960
+ _this.endPoint = _this._config.environment.apiDomain.authorizationEndpoint;
20961
+ _this.ignoreAdmin = _this._config.environment.isIgnoreAdmin;
20962
+ _this.appCode = _this._config.appCode;
21168
20963
  return _this;
21169
20964
  }
21170
- StateMachinesService.prototype.changeState = function (itemWorkflowHistory) {
21171
- return this.defaultPost(this.serviceUri + "/ChangeState", itemWorkflowHistory);
20965
+ PermissionService.prototype.clearPermissionCacheAll = function () {
20966
+ var _a, _b, _c;
20967
+ var lstAppCodes = (_c = (_b = (_a = this._config.environment.appMetadata) === null || _a === void 0 ? void 0 : _a.appSwitcher) === null || _b === void 0 ? void 0 : _b.map(function (app) { return app.code; })) !== null && _c !== void 0 ? _c : [];
20968
+ var lstApiEndpoint = [];
20969
+ var apiDomain = this._config.environment.apiDomain;
20970
+ for (var domainName in apiDomain) {
20971
+ if (domainName.startsWith('-') || domainName.startsWith('1') || domainName == 'gateway')
20972
+ continue;
20973
+ var realDomainName = domainName.split('Endpoint') ? domainName.split('Endpoint')[0] : domainName;
20974
+ lstApiEndpoint.push(realDomainName.toUpperCase());
20975
+ }
20976
+ return this.clearPermissionCache(__spreadArray(__spreadArray([], __read(lstAppCodes)), __read(lstApiEndpoint)));
21172
20977
  };
21173
- StateMachinesService.prototype.rollback = function (rowData) {
21174
- return this.defaultPost(this.serviceUri + "/Rollback/" + rowData.__workflowCode + "/" + rowData.id, {});
20978
+ PermissionService.prototype.clearPermissionCache = function (lstModule) {
20979
+ var url = this.serviceUri + "/ClearPermissionCache";
20980
+ return this.defaultPost(url, lstModule);
20981
+ };
20982
+ PermissionService.prototype.getCurrentUserPermission = function () {
20983
+ var url = this.serviceUri + "/GetCurrentUserPermission";
20984
+ return this.defaultGet(url);
20985
+ };
20986
+ PermissionService.prototype.getAllBasePermission = function (userId) {
20987
+ var _a, _b, _c;
20988
+ return __awaiter(this, void 0, void 0, function () {
20989
+ var url, user, res, lstAppCodes, promiseArr, lstAppCodes_1, lstAppCodes_1_1, code, lstAppCodes_2, lstAppCodes_2_1, service, permissions, serviceCode, key_1, key, storageItem;
20990
+ var e_1, _d, e_2, _e;
20991
+ return __generator(this, function (_f) {
20992
+ switch (_f.label) {
20993
+ case 0:
20994
+ url = this.serviceUri + "/GetAllBasePermission";
20995
+ // return sớm vì đây là trường hợp lấy permission theo Id của User
20996
+ // ko set local storage vì sẽ làm hỏng quyền của người dùng hiện tại
20997
+ if (userId && userId != '' && userId != this._commonService.guidEmpty()) {
20998
+ return [2 /*return*/, this.defaultGet(url + ("?userId=" + userId))];
20999
+ }
21000
+ if (i0.isDevMode()) {
21001
+ return [2 /*return*/];
21002
+ }
21003
+ user = this._userService.getCurrentUser();
21004
+ if (user
21005
+ && (user.issuperuser && user.issuperuser.toLowerCase() == 'true')
21006
+ || (user.isadmin && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin)) {
21007
+ return [2 /*return*/];
21008
+ }
21009
+ return [4 /*yield*/, this.defaultGet(url)];
21010
+ case 1:
21011
+ res = _f.sent();
21012
+ lstAppCodes = (_c = (_b = (_a = this._config.environment.appMetadata) === null || _a === void 0 ? void 0 : _a.appSwitcher) === null || _b === void 0 ? void 0 : _b.map(function (app) { return app.code; })) !== null && _c !== void 0 ? _c : [];
21013
+ if (!(!res || !res.success || res.data == null)) return [3 /*break*/, 3];
21014
+ promiseArr = [];
21015
+ try {
21016
+ for (lstAppCodes_1 = __values(lstAppCodes), lstAppCodes_1_1 = lstAppCodes_1.next(); !lstAppCodes_1_1.done; lstAppCodes_1_1 = lstAppCodes_1.next()) {
21017
+ code = lstAppCodes_1_1.value;
21018
+ promiseArr.push(this.getServicePermission(code, true));
21019
+ }
21020
+ }
21021
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
21022
+ finally {
21023
+ try {
21024
+ if (lstAppCodes_1_1 && !lstAppCodes_1_1.done && (_d = lstAppCodes_1.return)) _d.call(lstAppCodes_1);
21025
+ }
21026
+ finally { if (e_1) throw e_1.error; }
21027
+ }
21028
+ return [4 /*yield*/, Promise.all(promiseArr)];
21029
+ case 2:
21030
+ _f.sent();
21031
+ return [2 /*return*/];
21032
+ case 3:
21033
+ try {
21034
+ // Set local storage cho permission của người dùng
21035
+ for (lstAppCodes_2 = __values(lstAppCodes), lstAppCodes_2_1 = lstAppCodes_2.next(); !lstAppCodes_2_1.done; lstAppCodes_2_1 = lstAppCodes_2.next()) {
21036
+ service = lstAppCodes_2_1.value;
21037
+ permissions = [];
21038
+ serviceCode = service.toUpperCase();
21039
+ for (key_1 in res.data) {
21040
+ if (key_1.toUpperCase() != serviceCode) {
21041
+ continue;
21042
+ }
21043
+ permissions = res.data[key_1];
21044
+ break;
21045
+ }
21046
+ key = "AUTHORIZATION." + serviceCode;
21047
+ storageItem = this.storage.getItem(key);
21048
+ if (storageItem != null) {
21049
+ this.storage.removeItem(key);
21050
+ }
21051
+ this.storage.setItem(key, JSON.stringify(permissions));
21052
+ }
21053
+ }
21054
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
21055
+ finally {
21056
+ try {
21057
+ if (lstAppCodes_2_1 && !lstAppCodes_2_1.done && (_e = lstAppCodes_2.return)) _e.call(lstAppCodes_2);
21058
+ }
21059
+ finally { if (e_2) throw e_2.error; }
21060
+ }
21061
+ return [2 /*return*/];
21062
+ }
21063
+ });
21064
+ });
21065
+ };
21066
+ /**
21067
+ * Truyền vào danh sách permision cần check
21068
+ * @param lstPermissionCode những perrmision code cần check => nên dùng trong trường hợp check các button trong code
21069
+ * @returns trả ra các perrmisionCode có quyền
21070
+ */
21071
+ PermissionService.prototype.getPermissionAuthorized = function (lstPermissionCode) {
21072
+ var _this = this;
21073
+ return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
21074
+ var user, result, lstPermissionCode_1, lstPermissionCode_1_1, item, e_3_1;
21075
+ var e_3, _d;
21076
+ return __generator(this, function (_e) {
21077
+ switch (_e.label) {
21078
+ case 0: return [4 /*yield*/, this._userService.getCurrentUser()];
21079
+ case 1:
21080
+ user = (_e.sent());
21081
+ if (user && user.issuperuser.toLowerCase() == 'true') {
21082
+ resolve(lstPermissionCode);
21083
+ return [2 /*return*/];
21084
+ }
21085
+ if (user && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin) {
21086
+ resolve(lstPermissionCode);
21087
+ return [2 /*return*/];
21088
+ }
21089
+ result = [];
21090
+ _e.label = 2;
21091
+ case 2:
21092
+ _e.trys.push([2, 7, 8, 9]);
21093
+ lstPermissionCode_1 = __values(lstPermissionCode), lstPermissionCode_1_1 = lstPermissionCode_1.next();
21094
+ _e.label = 3;
21095
+ case 3:
21096
+ if (!!lstPermissionCode_1_1.done) return [3 /*break*/, 6];
21097
+ item = lstPermissionCode_1_1.value;
21098
+ return [4 /*yield*/, this.isAuthorizedPermission(item)];
21099
+ case 4:
21100
+ if (_e.sent()) {
21101
+ result.push(item);
21102
+ }
21103
+ _e.label = 5;
21104
+ case 5:
21105
+ lstPermissionCode_1_1 = lstPermissionCode_1.next();
21106
+ return [3 /*break*/, 3];
21107
+ case 6: return [3 /*break*/, 9];
21108
+ case 7:
21109
+ e_3_1 = _e.sent();
21110
+ e_3 = { error: e_3_1 };
21111
+ return [3 /*break*/, 9];
21112
+ case 8:
21113
+ try {
21114
+ if (lstPermissionCode_1_1 && !lstPermissionCode_1_1.done && (_d = lstPermissionCode_1.return)) _d.call(lstPermissionCode_1);
21115
+ }
21116
+ finally { if (e_3) throw e_3.error; }
21117
+ return [7 /*endfinally*/];
21118
+ case 9:
21119
+ resolve(result);
21120
+ return [2 /*return*/];
21121
+ }
21122
+ });
21123
+ }); });
21124
+ };
21125
+ PermissionService.prototype.isAuthorizedPermission = function (permission) {
21126
+ return __awaiter(this, void 0, void 0, function () {
21127
+ var retryCount;
21128
+ return __generator(this, function (_d) {
21129
+ switch (_d.label) {
21130
+ case 0:
21131
+ retryCount = 0;
21132
+ _d.label = 1;
21133
+ case 1:
21134
+ if (!!this._oauthService.hasValidAccessToken()) return [3 /*break*/, 3];
21135
+ return [4 /*yield*/, this._commonService.delay(100)];
21136
+ case 2:
21137
+ _d.sent();
21138
+ retryCount++;
21139
+ if (retryCount > 50) {
21140
+ return [3 /*break*/, 3];
21141
+ }
21142
+ return [3 /*break*/, 1];
21143
+ case 3: return [4 /*yield*/, this.checkPermission(this.appCode, permission)];
21144
+ case 4: return [2 /*return*/, _d.sent()];
21145
+ }
21146
+ });
21147
+ });
21175
21148
  };
21176
- StateMachinesService.prototype.getUserInProcessForm = function (workflowCode, stateCode, actionCode, itemId) {
21177
- return this.defaultPost(this.serviceUri + "/GetUserInProcessForm/" + workflowCode + "/" + stateCode + "/" + actionCode + "/" + itemId, {});
21149
+ PermissionService.prototype.isAuthorized = function (service, permission, checForMenu) {
21150
+ if (checForMenu === void 0) { checForMenu = false; }
21151
+ return __awaiter(this, void 0, void 0, function () {
21152
+ var retryCount;
21153
+ return __generator(this, function (_d) {
21154
+ switch (_d.label) {
21155
+ case 0:
21156
+ this.root = this._appContext.getRootContext();
21157
+ retryCount = 0;
21158
+ _d.label = 1;
21159
+ case 1:
21160
+ if (!!this._oauthService.hasValidAccessToken()) return [3 /*break*/, 3];
21161
+ return [4 /*yield*/, this._commonService.delay(100)];
21162
+ case 2:
21163
+ _d.sent();
21164
+ retryCount++;
21165
+ if (retryCount > 50) {
21166
+ return [3 /*break*/, 3];
21167
+ }
21168
+ return [3 /*break*/, 1];
21169
+ case 3: return [4 /*yield*/, this.checkPermission(service, permission, checForMenu)];
21170
+ case 4: return [2 /*return*/, _d.sent()];
21171
+ }
21172
+ });
21173
+ });
21178
21174
  };
21179
- return StateMachinesService;
21180
- }(BaseService));
21181
- StateMachinesService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function StateMachinesService_Factory() { return new StateMachinesService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: StateMachinesService, providedIn: "root" });
21182
- StateMachinesService.decorators = [
21183
- { type: i0.Injectable, args: [{
21184
- providedIn: 'root'
21185
- },] }
21186
- ];
21187
- StateMachinesService.ctorParameters = function () { return [
21188
- { type: i1$1.HttpClient },
21189
- { type: i0.Injector },
21190
- { type: ModuleConfigService }
21191
- ]; };
21192
-
21193
- var CauHinhWorkflowService = /** @class */ (function (_super) {
21194
- __extends(CauHinhWorkflowService, _super);
21195
- function CauHinhWorkflowService(http, injector, _moduleConfigService) {
21196
- var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/CauHinhWorkflow") || this;
21197
- _this._moduleConfigService = _moduleConfigService;
21198
- _this.serviceCode = 'congviec';
21199
- _this.entityName = 'CauHinhWorkflow';
21200
- _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint;
21201
- return _this;
21202
- }
21203
- return CauHinhWorkflowService;
21204
- }(BaseService));
21205
- CauHinhWorkflowService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function CauHinhWorkflowService_Factory() { return new CauHinhWorkflowService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: CauHinhWorkflowService, providedIn: "root" });
21206
- CauHinhWorkflowService.decorators = [
21207
- { type: i0.Injectable, args: [{
21208
- providedIn: 'root'
21209
- },] }
21210
- ];
21211
- CauHinhWorkflowService.ctorParameters = function () { return [
21212
- { type: i1$1.HttpClient },
21213
- { type: i0.Injector },
21214
- { type: ModuleConfigService }
21215
- ]; };
21216
-
21217
- var DmLoaiCongViecService = /** @class */ (function (_super) {
21218
- __extends(DmLoaiCongViecService, _super);
21219
- function DmLoaiCongViecService(http, injector, _moduleConfigService) {
21220
- var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/DM_LoaiCongViec") || this;
21221
- _this._moduleConfigService = _moduleConfigService;
21222
- _this.serviceCode = 'congviec';
21223
- _this.entityName = 'DM_LoaiCongViec';
21224
- _this.dicLoaiCongViec = {};
21225
- _this.keyIdLoaiCongViecRoot = 'root';
21226
- _this.getWorkflowSettingByIdLoaiCongViec = function (idLoaiCongViec) { return __awaiter(_this, void 0, void 0, function () {
21227
- var result, idLoaiCongViecs, i;
21228
- return __generator(this, function (_a) {
21229
- switch (_a.label) {
21175
+ PermissionService.prototype.checkPermission = function (service, permissionToCheck, checkForMenu) {
21176
+ if (checkForMenu === void 0) { checkForMenu = false; }
21177
+ return __awaiter(this, void 0, void 0, function () {
21178
+ var user, valueIsDevMode, userPermissions, _a_1;
21179
+ return __generator(this, function (_d) {
21180
+ switch (_d.label) {
21230
21181
  case 0:
21231
- if (!!this.dicWorkflowByLoaiCongViec) return [3 /*break*/, 2];
21232
- return [4 /*yield*/, this.getDatasourceWorkflowCongViec()];
21182
+ _d.trys.push([0, 2, , 3]);
21183
+ user = this._userService.getCurrentUser();
21184
+ valueIsDevMode = true;
21185
+ if (i0.isDevMode() && valueIsDevMode) {
21186
+ return [2 /*return*/, true];
21187
+ }
21188
+ if (user && user.issuperuser && user.issuperuser.toLowerCase() == 'true' && valueIsDevMode) {
21189
+ return [2 /*return*/, true];
21190
+ }
21191
+ if (user && user.isadmin && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin && valueIsDevMode) {
21192
+ return [2 /*return*/, true];
21193
+ }
21194
+ return [4 /*yield*/, this.getServicePermission(service)];
21233
21195
  case 1:
21234
- _a.sent();
21235
- _a.label = 2;
21196
+ userPermissions = _d.sent();
21197
+ if (userPermissions && userPermissions.length > 0) {
21198
+ return [2 /*return*/, checkForMenu
21199
+ ? userPermissions.includes(permissionToCheck)
21200
+ : this._checkPermission(userPermissions, permissionToCheck)];
21201
+ }
21202
+ else {
21203
+ // console.log(`Không có quyền với phân hệ [${service}]`);
21204
+ return [2 /*return*/, false];
21205
+ }
21206
+ return [3 /*break*/, 3];
21236
21207
  case 2:
21237
- if (!idLoaiCongViec) {
21238
- return [2 /*return*/, this.dicWorkflowByLoaiCongViec[this.keyIdLoaiCongViecRoot]];
21208
+ _a_1 = _d.sent();
21209
+ return [2 /*return*/, false];
21210
+ case 3: return [2 /*return*/];
21211
+ }
21212
+ });
21213
+ });
21214
+ };
21215
+ PermissionService.prototype._checkPermission = function (userPermissions, permissionToCheck) {
21216
+ var e_4, _d;
21217
+ var isAuthorized = false;
21218
+ try {
21219
+ // check permission của người dùng
21220
+ // duyệt qua từng permission của người dùng
21221
+ for (var userPermissions_1 = __values(userPermissions), userPermissions_1_1 = userPermissions_1.next(); !userPermissions_1_1.done; userPermissions_1_1 = userPermissions_1.next()) {
21222
+ var userPermission = userPermissions_1_1.value;
21223
+ // biến để break khỏi vòng khi người dùng được authorized
21224
+ var breakOuterLoop = false;
21225
+ // pointer permission của người dùng
21226
+ var userPermissionPointer = 0;
21227
+ // pointer permission đang check
21228
+ var permissionToCheckPointer = 0;
21229
+ // mark co the check query param
21230
+ var aboutToCheckQueryParam = false;
21231
+ // check từng char của 2 mảng
21232
+ for (; permissionToCheckPointer < permissionToCheck.length;) {
21233
+ // nếu char là ký tự bắt đầu template => tịnh tiến pointer của 2 mảng
21234
+ var needRecheck = false;
21235
+ if (userPermission[userPermissionPointer] == '{') {
21236
+ // cho đến khi tìm được ký tự '/' tiếp theo thì dừng lại
21237
+ for (; userPermissionPointer < userPermission.length; userPermissionPointer++) {
21238
+ if (userPermissionPointer == userPermission.length - 1) {
21239
+ break;
21240
+ }
21241
+ if (userPermission[userPermissionPointer] != '}') {
21242
+ continue;
21243
+ }
21244
+ if (userPermission[userPermissionPointer] === '?') {
21245
+ aboutToCheckQueryParam = true;
21246
+ }
21247
+ ++userPermissionPointer; // tiến tiến đến ký tự sau kết thúc template
21248
+ // check trường hợp trường hợp chuỗi template có dạng "{template}acsekjf"
21249
+ // => cần check các ký tự sau template và trước ký tự '/'
21250
+ if (userPermission[userPermissionPointer] != '/' && (aboutToCheckQueryParam && userPermission[userPermissionPointer] != '&')) {
21251
+ needRecheck = true;
21252
+ for (; userPermissionPointer < userPermission.length; userPermissionPointer++) {
21253
+ if (userPermissionPointer == userPermission.length - 1) {
21254
+ break;
21255
+ }
21256
+ if (userPermission[userPermissionPointer] != '/') {
21257
+ continue;
21258
+ }
21259
+ break;
21260
+ }
21261
+ }
21262
+ break;
21239
21263
  }
21240
- result = this.dicWorkflowByLoaiCongViec[idLoaiCongViec];
21241
- if (result)
21242
- return [2 /*return*/, result];
21243
- return [4 /*yield*/, this.getIdLoaiCongViecs(idLoaiCongViec)];
21244
- case 3:
21245
- idLoaiCongViecs = _a.sent();
21246
- if (!Array.isArray(idLoaiCongViecs))
21247
- return [2 /*return*/, null];
21248
- if (idLoaiCongViecs.length > 1) {
21249
- for (i = idLoaiCongViecs.length - 2; i >= 0; i--) {
21250
- result = this.dicWorkflowByLoaiCongViec[idLoaiCongViecs[i]];
21251
- if (result)
21252
- return [2 /*return*/, result];
21264
+ for (; permissionToCheckPointer < permissionToCheck.length; permissionToCheckPointer++) {
21265
+ if (permissionToCheckPointer == permissionToCheck.length - 1) {
21266
+ break;
21267
+ }
21268
+ if (permissionToCheck[permissionToCheckPointer] == '/' || (aboutToCheckQueryParam && permissionToCheck[permissionToCheckPointer] == '&')) {
21269
+ break;
21253
21270
  }
21254
21271
  }
21255
- if (!result) {
21256
- result = this.dicWorkflowByLoaiCongViec[this.keyIdLoaiCongViecRoot];
21272
+ }
21273
+ var breakInnerLoop = false;
21274
+ if (needRecheck) {
21275
+ // check lại cho trường hợp chuỗi template có dạng "{template}acslekfj"
21276
+ // duyệt ngược lại cho đến khi gặp ký tự kết thúc template
21277
+ var tempUserPointer = userPermissionPointer;
21278
+ var tempToCheckPointer = permissionToCheckPointer;
21279
+ while (userPermission[tempUserPointer] != '}') {
21280
+ // ký tự khác nhau => break khỏi vòng kiểm tra trong
21281
+ if (userPermission[tempUserPointer].toLowerCase() != permissionToCheck[tempToCheckPointer].toLowerCase()) {
21282
+ breakInnerLoop = true;
21283
+ break;
21284
+ }
21285
+ tempUserPointer--;
21286
+ tempToCheckPointer--;
21287
+ }
21288
+ }
21289
+ if (breakInnerLoop) {
21290
+ break;
21291
+ }
21292
+ var userChar = userPermission[userPermissionPointer].toLowerCase();
21293
+ var toCheckChar = permissionToCheck[permissionToCheckPointer].toLowerCase();
21294
+ // nếu userPermission đang ở index cuối
21295
+ if (userPermissionPointer == userPermission.length - 1) {
21296
+ // check char cuối của 2 mảng (trừ khi là ký tự kết thúc template)
21297
+ // và cũng phải là char cuối của mảng permission cần check
21298
+ // => người dùng authorized và break khỏi vòng lặp ngoài cùng
21299
+ if ((userChar == '}' || userChar == toCheckChar)
21300
+ && permissionToCheckPointer == permissionToCheck.length - 1) {
21301
+ breakOuterLoop = true;
21302
+ isAuthorized = true;
21303
+ }
21304
+ break;
21305
+ }
21306
+ // check char có giống nhau không, không giống thì break khỏi vòng check
21307
+ if (userChar != toCheckChar) {
21308
+ break;
21309
+ }
21310
+ // nếu char giống nhau thì tiếp tục vòng lăp
21311
+ permissionToCheckPointer++;
21312
+ userPermissionPointer++;
21313
+ }
21314
+ if (breakOuterLoop) {
21315
+ break;
21316
+ }
21317
+ }
21318
+ }
21319
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
21320
+ finally {
21321
+ try {
21322
+ if (userPermissions_1_1 && !userPermissions_1_1.done && (_d = userPermissions_1.return)) _d.call(userPermissions_1);
21323
+ }
21324
+ finally { if (e_4) throw e_4.error; }
21325
+ }
21326
+ return isAuthorized;
21327
+ };
21328
+ PermissionService.prototype._checkPermissionOld = function (userPermissions, permissionToCheck) {
21329
+ var e_5, _d;
21330
+ var isAuthorized = false;
21331
+ // check quyền theo cách cũ nếu trường họp là phân quyền module
21332
+ if (permissionToCheck.includes('MODULE')) {
21333
+ return userPermissions.includes(permissionToCheck);
21334
+ }
21335
+ try {
21336
+ for (var userPermissions_2 = __values(userPermissions), userPermissions_2_1 = userPermissions_2.next(); !userPermissions_2_1.done; userPermissions_2_1 = userPermissions_2.next()) {
21337
+ var userPermission = userPermissions_2_1.value;
21338
+ // Cắt chuỗi permission thành mảng để xem mỗi fragement có khớp nhau không
21339
+ var userPermissionFragments = userPermission.split('/');
21340
+ var permissionFragments = permissionToCheck.split('/');
21341
+ // Mảng khác độ dài thì thoát sớm
21342
+ if (userPermissionFragments.length != permissionFragments.length) {
21343
+ continue;
21344
+ }
21345
+ // biến flag ra hiệu người dùng authorized và out vòng
21346
+ var breakLoop = false;
21347
+ // nếu tất cả phần tử khớp nhau => permission này trùng và người dùng được authorized
21348
+ for (var index = 0; index < permissionFragments.length; index++) {
21349
+ var userFragement = userPermissionFragments[index];
21350
+ var permissionFragment = permissionFragments[index];
21351
+ // skip qua các phần tử có ký tự bắt đầu là '{'
21352
+ if (userFragement[0] == '{') {
21353
+ if (index == permissionFragments.length - 1) {
21354
+ isAuthorized = true;
21355
+ breakLoop = true;
21257
21356
  }
21258
- return [2 /*return*/, result];
21357
+ continue;
21358
+ }
21359
+ if (userFragement.toLowerCase() != permissionFragment.toLowerCase()) {
21360
+ break;
21361
+ }
21362
+ if (index == permissionFragments.length - 1) {
21363
+ isAuthorized = true;
21364
+ breakLoop = true;
21365
+ }
21259
21366
  }
21260
- });
21261
- }); };
21262
- _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint;
21263
- return _this;
21264
- }
21265
- DmLoaiCongViecService.prototype.getDatasourceWorkflowCongViec = function () {
21266
- return __awaiter(this, void 0, void 0, function () {
21267
- var cauHinhWorkflowService, cauHinhWorkflows, notifierService, workflowCodes, stateMachinesService, workflows;
21367
+ if (breakLoop) {
21368
+ break;
21369
+ }
21370
+ }
21371
+ }
21372
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
21373
+ finally {
21374
+ try {
21375
+ if (userPermissions_2_1 && !userPermissions_2_1.done && (_d = userPermissions_2.return)) _d.call(userPermissions_2);
21376
+ }
21377
+ finally { if (e_5) throw e_5.error; }
21378
+ }
21379
+ return isAuthorized;
21380
+ };
21381
+ PermissionService.prototype.isAuthorizedByPermissions = function (permissions, operator, ignoreAdmin) {
21382
+ var _this = this;
21383
+ if (operator === void 0) { operator = 'OR'; }
21384
+ if (ignoreAdmin === void 0) { ignoreAdmin = false; }
21385
+ return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
21386
+ var user, isAuthorized;
21268
21387
  var _this = this;
21269
- return __generator(this, function (_a) {
21270
- switch (_a.label) {
21271
- case 0:
21272
- if (!this.dicWorkflowByLoaiCongViec) {
21273
- this.dicWorkflowByLoaiCongViec = {};
21274
- }
21275
- cauHinhWorkflowService = this._injector.get(CauHinhWorkflowService);
21276
- return [4 /*yield*/, cauHinhWorkflowService.getAll([], 'idLoaiCongViec,workflowCodes,workflowCode')];
21388
+ return __generator(this, function (_d) {
21389
+ switch (_d.label) {
21390
+ case 0: return [4 /*yield*/, this._userService.getCurrentUser()];
21277
21391
  case 1:
21278
- cauHinhWorkflows = (_a.sent()).data;
21279
- notifierService = this._injector.get(NotifierService);
21280
- if (cauHinhWorkflows == null) {
21281
- notifierService.showWarning('Dịch vụ workflow không phản hồi');
21282
- return [2 /*return*/, []];
21392
+ user = (_d.sent());
21393
+ if (user && user.issuperuser.toLowerCase() == 'true') {
21394
+ resolve(true);
21395
+ return [2 /*return*/];
21283
21396
  }
21284
- workflowCodes = [];
21285
- cauHinhWorkflows.forEach(function (itemWorkflowSetting) {
21286
- if (itemWorkflowSetting.workflowCodes && !Array.isArray(itemWorkflowSetting.workflowCodes)) {
21287
- itemWorkflowSetting.workflowCodes = itemWorkflowSetting.workflowCodes.split(',');
21288
- }
21289
- else {
21290
- itemWorkflowSetting.workflowCodes = [];
21291
- }
21292
- itemWorkflowSetting.workflowCodes.forEach(function (workflowCode) {
21293
- if (workflowCodes.indexOf(workflowCode) == -1) {
21294
- workflowCodes.push(workflowCode);
21397
+ if (user && user.isadmin.toLowerCase() == 'true' && !this.ignoreAdmin) {
21398
+ resolve(true);
21399
+ return [2 /*return*/];
21400
+ }
21401
+ isAuthorized = true;
21402
+ if (operator.toUpperCase() == 'OR') {
21403
+ isAuthorized = false;
21404
+ }
21405
+ permissions.forEach(function (item) {
21406
+ _this.getServicePermission(item.service).then(function (permissionResult) {
21407
+ if (operator.toUpperCase() == 'OR') {
21408
+ if (permissionResult.includes(item.permission)) {
21409
+ isAuthorized = true;
21410
+ return;
21411
+ }
21295
21412
  }
21296
- });
21297
- });
21298
- stateMachinesService = this._injector.get(StateMachinesService);
21299
- return [4 /*yield*/, stateMachinesService.getDataDropdownByFilter([
21300
- this.newFilter('code', exports.Operator.in, workflowCodes)
21301
- ], new DropdownOptions({
21302
- valueField: 'code',
21303
- displayField: 'title',
21304
- fieldPlus: 'data'
21305
- }))];
21306
- case 2:
21307
- workflows = (_a.sent());
21308
- workflows.forEach(function (item) {
21309
- item.data = JSON.parse(item.data);
21310
- var stateMachineData = item.data;
21311
- stateMachineData.actions = {};
21312
- stateMachineData.machines.forEach(function (machine) {
21313
- stateMachineData.actions[machine.code] = [];
21314
- stateMachineData.connections.forEach(function (conn) {
21315
- if (conn.source == machine.id) {
21316
- stateMachineData.actions[machine.code].push(conn);
21413
+ else {
21414
+ if (!permissionResult.includes(item.permission)) {
21415
+ isAuthorized = false;
21416
+ return;
21317
21417
  }
21318
- });
21418
+ }
21419
+ }, function (error) {
21420
+ reject(false);
21319
21421
  });
21320
21422
  });
21321
- cauHinhWorkflows.forEach(function (itemWorkflowSetting) {
21322
- itemWorkflowSetting.workflows = workflows.filter(function (q) { return itemWorkflowSetting.workflowCodes.indexOf(q.code) > -1; });
21323
- if (!itemWorkflowSetting.idLoaiCongViec) {
21324
- _this.dicWorkflowByLoaiCongViec[_this.keyIdLoaiCongViecRoot] = itemWorkflowSetting;
21325
- }
21326
- else {
21327
- _this.dicWorkflowByLoaiCongViec[itemWorkflowSetting.idLoaiCongViec] = itemWorkflowSetting;
21328
- }
21329
- });
21330
- return [2 /*return*/, workflows];
21423
+ resolve(isAuthorized);
21424
+ return [2 /*return*/];
21331
21425
  }
21332
21426
  });
21333
- });
21427
+ }); });
21334
21428
  };
21335
- DmLoaiCongViecService.prototype.getIdLoaiCongViecs = function (idLoaiCongViec) {
21429
+ PermissionService.prototype.getServicePermission = function (service, overrideLocalStorage) {
21430
+ if (overrideLocalStorage === void 0) { overrideLocalStorage = false; }
21336
21431
  return __awaiter(this, void 0, void 0, function () {
21337
- var notifierService, itemLoaiCongViec, idLoaiCongViecs;
21338
- return __generator(this, function (_a) {
21339
- switch (_a.label) {
21432
+ var key, storageItem, result, url, response;
21433
+ return __generator(this, function (_d) {
21434
+ switch (_d.label) {
21340
21435
  case 0:
21341
- notifierService = this._injector.get(NotifierService);
21342
- return [4 /*yield*/, this.getItemLoaiCongViec(idLoaiCongViec)];
21343
- case 1:
21344
- itemLoaiCongViec = _a.sent();
21345
- if (itemLoaiCongViec == null) {
21346
- notifierService.showWarning('Loại công việc không tồn tại');
21347
- return [2 /*return*/, null];
21436
+ key = "AUTHORIZATION." + service.toUpperCase();
21437
+ if (!overrideLocalStorage) {
21438
+ storageItem = this.storage.getItem(key);
21439
+ if (storageItem && storageItem !== 'null') {
21440
+ result = JSON.parse(storageItem);
21441
+ return [2 /*return*/, result];
21442
+ }
21348
21443
  }
21349
- idLoaiCongViecs = itemLoaiCongViec.idDuongDan.split(';').filter(function (q) { return !!q; });
21350
- return [2 /*return*/, idLoaiCongViecs];
21351
- }
21352
- });
21353
- });
21354
- };
21355
- DmLoaiCongViecService.prototype.getItemLoaiCongViec = function (idLoaiCongViec) {
21356
- return __awaiter(this, void 0, void 0, function () {
21357
- var _a, _b;
21358
- return __generator(this, function (_c) {
21359
- switch (_c.label) {
21360
- case 0:
21361
- if (!!this.dicLoaiCongViec[idLoaiCongViec]) return [3 /*break*/, 2];
21362
- _a = this.dicLoaiCongViec;
21363
- _b = idLoaiCongViec;
21364
- return [4 /*yield*/, this.getDetail(idLoaiCongViec)];
21444
+ url = this.serviceUri + "/GetPermissionsByService?service=" + service;
21445
+ return [4 /*yield*/, this.defaultGet(url)];
21365
21446
  case 1:
21366
- _a[_b] = (_c.sent()).data;
21367
- _c.label = 2;
21368
- case 2: return [2 /*return*/, this.dicLoaiCongViec[idLoaiCongViec]];
21369
- }
21370
- });
21371
- });
21372
- };
21373
- return DmLoaiCongViecService;
21374
- }(BaseService));
21375
- DmLoaiCongViecService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function DmLoaiCongViecService_Factory() { return new DmLoaiCongViecService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: DmLoaiCongViecService, providedIn: "root" });
21376
- DmLoaiCongViecService.decorators = [
21377
- { type: i0.Injectable, args: [{
21378
- providedIn: 'root'
21379
- },] }
21380
- ];
21381
- DmLoaiCongViecService.ctorParameters = function () { return [
21382
- { type: i1$1.HttpClient },
21383
- { type: i0.Injector },
21384
- { type: ModuleConfigService }
21385
- ]; };
21386
-
21387
- var CongViecService = /** @class */ (function (_super) {
21388
- __extends(CongViecService, _super);
21389
- function CongViecService(http, injector, _moduleConfigService, _dmLoaiCongViecService) {
21390
- var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/CongViec_Chinh") || this;
21391
- _this._dmLoaiCongViecService = _dmLoaiCongViecService;
21392
- _this.serviceCode = 'congviec';
21393
- _this.entityName = 'CongViec_Chinh';
21394
- _this.objectName = 'công việc';
21395
- _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.congviecEndpoint;
21396
- _this._moduleConfig = _moduleConfigService.getConfig();
21397
- return _this;
21398
- }
21399
- CongViecService.prototype.adjustSettingWorkflowForCrudList = function (setting) {
21400
- this.useWorkflow = true;
21401
- setting.isWorkflowTree = true;
21402
- setting.baseService = this;
21403
- setting.displayField = function (item) { return item.ten; };
21404
- setting.baseService.useWorkflow = true;
21405
- setting.workflowConfigAdvance = {
21406
- getWorkflowSetting: this.getWorkflowConfig.bind(this)
21407
- };
21408
- };
21409
- CongViecService.prototype.getWorkflowConfig = function (rowData) {
21410
- return __awaiter(this, void 0, void 0, function () {
21411
- return __generator(this, function (_a) {
21412
- switch (_a.label) {
21413
- case 0: return [4 /*yield*/, this._dmLoaiCongViecService.getWorkflowSettingByIdLoaiCongViec(rowData.idLoaiCongViec)];
21414
- case 1: return [2 /*return*/, _a.sent()];
21415
- }
21416
- });
21417
- });
21418
- };
21419
- CongViecService.prototype.countByMenuState = function (data) {
21420
- return this.defaultPost(this.serviceUri + "/CountByMenuState", data);
21421
- };
21422
- CongViecService.prototype.getDicIdByMenuState = function (data, tuNgay, denNgay) {
21423
- return this.defaultPost(this.serviceUri + "/GetDicIdByMenuState", {
21424
- lstTrangThai: data,
21425
- tuNgay: tuNgay,
21426
- denNgay: denNgay
21447
+ response = _d.sent();
21448
+ if (!response || !response.success) {
21449
+ return [2 /*return*/, []];
21450
+ }
21451
+ if (overrideLocalStorage) {
21452
+ this.storage.removeItem(key);
21453
+ }
21454
+ this.storage.setItem(key, JSON.stringify(response.data));
21455
+ return [2 /*return*/, response.data];
21456
+ }
21457
+ });
21427
21458
  });
21428
21459
  };
21429
- CongViecService.prototype.updateBulkIdCha = function (model) {
21430
- var url = this.serviceUri + "/UpdateBulkIdCha";
21431
- return this.defaultPost(url, model);
21432
- };
21433
- CongViecService.prototype.deleteBulkCongViecCon = function (ids) {
21434
- var url = this.serviceUri + "/DeleteBulkCongViecCon";
21435
- return this.defaultPost(url, ids);
21436
- };
21437
- CongViecService.prototype.getDataDashboardCaNhan = function (inputData) {
21438
- var url = this.serviceUri + "/GetDataDashboardCaNhan";
21439
- return this.defaultPost(url, inputData);
21440
- };
21441
- CongViecService.prototype.getDataDashboardByDonVi = function (inputData) {
21442
- var url = this.serviceUri + "/GetDataDashboardByDonVi";
21443
- return this.defaultPost(url, inputData);
21460
+ PermissionService.prototype.getPermissionIdsByModule = function (moduleCode, userId) {
21461
+ var url = this.serviceUri + "/GetPermissionIdsByModule/" + moduleCode + "/" + userId;
21462
+ return this.defaultGet(url);
21444
21463
  };
21445
- CongViecService.prototype.getListTasksDashboard = function (dataFilter) {
21446
- var url = this.serviceUri + "/getListTasksDashboard";
21447
- return this.defaultPost(url, dataFilter);
21464
+ PermissionService.prototype.phanQuyenNguoiDung = function (model) {
21465
+ var url = this.serviceUri + "/PhanQuyenNguoiDung";
21466
+ return this.defaultPost(url, model);
21448
21467
  };
21449
- return CongViecService;
21468
+ return PermissionService;
21450
21469
  }(BaseService));
21451
- CongViecService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function CongViecService_Factory() { return new CongViecService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService), i0__namespace.ɵɵinject(DmLoaiCongViecService)); }, token: CongViecService, providedIn: "root" });
21452
- CongViecService.decorators = [
21470
+ PermissionService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function PermissionService_Factory() { return new PermissionService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService), i0__namespace.ɵɵinject(UserService), i0__namespace.ɵɵinject(i4__namespace.OAuthService), i0__namespace.ɵɵinject(ApplicationContextService)); }, token: PermissionService, providedIn: "root" });
21471
+ PermissionService.decorators = [
21453
21472
  { type: i0.Injectable, args: [{
21454
21473
  providedIn: 'root'
21455
21474
  },] }
21456
21475
  ];
21457
- CongViecService.ctorParameters = function () { return [
21476
+ PermissionService.ctorParameters = function () { return [
21458
21477
  { type: i1$1.HttpClient },
21459
21478
  { type: i0.Injector },
21460
21479
  { type: ModuleConfigService },
21461
- { type: DmLoaiCongViecService }
21480
+ { type: UserService },
21481
+ { type: i4.OAuthService },
21482
+ { type: ApplicationContextService }
21462
21483
  ]; };
21463
21484
 
21464
- var EntityWorkflowHistoryService = /** @class */ (function (_super) {
21465
- __extends(EntityWorkflowHistoryService, _super);
21466
- function EntityWorkflowHistoryService(http, injector, _moduleConfigService) {
21467
- var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.userOrgEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/EntityWorkflowHistory") || this;
21468
- _this.entityName = 'EntityWorkflowHistory';
21485
+ var WorkflowHistoryService = /** @class */ (function (_super) {
21486
+ __extends(WorkflowHistoryService, _super);
21487
+ function WorkflowHistoryService(http, injector, _moduleConfigService) {
21488
+ var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.workflowEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/WorkflowHistory") || this;
21469
21489
  _this.serviceManagers = {};
21470
- _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.userOrgEndpoint;
21490
+ _this.entityName = 'WorkflowHistory';
21491
+ _this.serviceCode = 'workflow';
21492
+ _this.apiDomain = _moduleConfigService.getConfig().environment.apiDomain;
21493
+ _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.workflowEndpoint;
21471
21494
  _this._moduleConfig = _moduleConfigService.getConfig();
21495
+ _this.apiVersion = _moduleConfigService.getConfig().environment.apiVersion;
21472
21496
  return _this;
21473
21497
  }
21474
- EntityWorkflowHistoryService.prototype.registerService = function (entityName, service) {
21475
- this.serviceManagers[entityName] = service;
21498
+ WorkflowHistoryService.prototype.registerService = function (settingKey, service) {
21499
+ this.serviceManagers[settingKey] = service;
21476
21500
  };
21477
- EntityWorkflowHistoryService.prototype.getEndpointByService = function (service) {
21501
+ WorkflowHistoryService.prototype.getEndpointByService = function (service) {
21478
21502
  return service.endPoint + "/" + this._moduleConfig.environment.apiVersion;
21479
21503
  };
21480
- EntityWorkflowHistoryService.prototype.setCurrentServiceUri = function (tableName) {
21481
- var service = this.serviceManagers[tableName];
21482
- if (service == undefined) {
21483
- (this._injector.get(NotifierService)).showWarning('Bạn chưa đăng ký base service cho entity workflow history');
21484
- }
21485
- this.serviceUri = this.getEndpointByService(service) + "/EntityWorkflowHistory";
21504
+ WorkflowHistoryService.prototype.changeEndpoint = function (baseService) {
21505
+ this.serviceUri = this.getEndpointByService(baseService) + "/WorkflowHistory";
21506
+ return this;
21486
21507
  };
21487
- EntityWorkflowHistoryService.prototype.getLastHistory = function (tableName, filters) {
21488
- if (filters === void 0) { filters = []; }
21489
- var service = this.serviceManagers[tableName];
21490
- if (service == undefined) {
21491
- (this._injector.get(NotifierService)).showWarning('Bạn chưa đăng ký base service cho entity workflow history');
21508
+ WorkflowHistoryService.prototype.getLastByItemId = function (itemId) {
21509
+ // return this.getDetailByFilter(
21510
+ // [
21511
+ // this.newFilter('itemId', Operator.equal, itemId)
21512
+ // ],
21513
+ // [{ field: 'time', dir: -1 }]
21514
+ // );
21515
+ return this.defaultPost(this.serviceUri + "/GetLastByItemIdInMainThread/" + itemId, {});
21516
+ };
21517
+ WorkflowHistoryService.prototype.choYKien = function (model) {
21518
+ return this.defaultPost(this.serviceUri + "/ChoYKien", model);
21519
+ };
21520
+ WorkflowHistoryService.prototype.getAllObjectRelated = function (serviceCode, entity, entityKey, fullApiUrl) {
21521
+ if (fullApiUrl === void 0) { fullApiUrl = null; }
21522
+ var apiUrl = fullApiUrl || this.apiDomain[serviceCode + "Endpoint"];
21523
+ if (!apiUrl) {
21524
+ throw new Error("Kh\u00F4ng t\u00ECm th\u1EA5y api endpoint \u1EE9ng v\u1EDBi service " + serviceCode);
21492
21525
  }
21493
- var url = this.getEndpointByService(service) + "/EntityWorkflowHistory/GetLastByFilter";
21494
- var gridInfo = {
21495
- pageInfo: {
21496
- page: 1,
21497
- pageSize: 1
21498
- },
21499
- filters: filters,
21500
- sorts: [
21501
- new Sort({ field: 'created', dir: 1 })
21502
- ]
21503
- };
21504
- return this.defaultPost(url, gridInfo);
21526
+ apiUrl = apiUrl + "/" + this.apiVersion + "/WorkflowHistory/GetAllObjectRelated/" + entity + "/" + entityKey;
21527
+ return this.defaultGet(apiUrl);
21505
21528
  };
21506
- return EntityWorkflowHistoryService;
21529
+ return WorkflowHistoryService;
21507
21530
  }(BaseService));
21508
- EntityWorkflowHistoryService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function EntityWorkflowHistoryService_Factory() { return new EntityWorkflowHistoryService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: EntityWorkflowHistoryService, providedIn: "root" });
21509
- EntityWorkflowHistoryService.decorators = [
21531
+ WorkflowHistoryService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function WorkflowHistoryService_Factory() { return new WorkflowHistoryService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: WorkflowHistoryService, providedIn: "root" });
21532
+ WorkflowHistoryService.decorators = [
21510
21533
  { type: i0.Injectable, args: [{
21511
21534
  providedIn: 'root'
21512
21535
  },] }
21513
21536
  ];
21514
- EntityWorkflowHistoryService.ctorParameters = function () { return [
21537
+ WorkflowHistoryService.ctorParameters = function () { return [
21515
21538
  { type: i1$1.HttpClient },
21516
21539
  { type: i0.Injector },
21517
21540
  { type: ModuleConfigService }
@@ -21685,90 +21708,70 @@
21685
21708
  { type: ModuleConfigService }
21686
21709
  ]; };
21687
21710
 
21688
- var WorkflowHistoryService = /** @class */ (function (_super) {
21689
- __extends(WorkflowHistoryService, _super);
21690
- function WorkflowHistoryService(http, injector, _moduleConfigService) {
21691
- var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.workflowEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/WorkflowHistory") || this;
21692
- _this.serviceManagers = {};
21693
- _this.entityName = 'WorkflowHistory';
21694
- _this.serviceCode = 'workflow';
21695
- _this.apiDomain = _moduleConfigService.getConfig().environment.apiDomain;
21696
- _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.workflowEndpoint;
21697
- _this._moduleConfig = _moduleConfigService.getConfig();
21698
- _this.apiVersion = _moduleConfigService.getConfig().environment.apiVersion;
21699
- return _this;
21700
- }
21701
- WorkflowHistoryService.prototype.registerService = function (settingKey, service) {
21702
- this.serviceManagers[settingKey] = service;
21703
- };
21704
- WorkflowHistoryService.prototype.getEndpointByService = function (service) {
21705
- return service.endPoint + "/" + this._moduleConfig.environment.apiVersion;
21706
- };
21707
- WorkflowHistoryService.prototype.changeEndpoint = function (baseService) {
21708
- this.serviceUri = this.getEndpointByService(baseService) + "/WorkflowHistory";
21709
- return this;
21710
- };
21711
- WorkflowHistoryService.prototype.getLastByItemId = function (itemId) {
21712
- // return this.getDetailByFilter(
21713
- // [
21714
- // this.newFilter('itemId', Operator.equal, itemId)
21715
- // ],
21716
- // [{ field: 'time', dir: -1 }]
21717
- // );
21718
- return this.defaultPost(this.serviceUri + "/GetLastByItemIdInMainThread/" + itemId, {});
21719
- };
21720
- WorkflowHistoryService.prototype.choYKien = function (model) {
21721
- return this.defaultPost(this.serviceUri + "/ChoYKien", model);
21711
+ var sort_by;
21712
+ (function () {
21713
+ var defaultCompareFunc = function (a, b) {
21714
+ if (a == b)
21715
+ return 0;
21716
+ return a < b ? -1 : 1;
21722
21717
  };
21723
- WorkflowHistoryService.prototype.getAllObjectRelated = function (serviceCode, entity, entityKey, fullApiUrl) {
21724
- if (fullApiUrl === void 0) { fullApiUrl = null; }
21725
- var apiUrl = fullApiUrl || this.apiDomain[serviceCode + "Endpoint"];
21726
- if (!apiUrl) {
21727
- throw new Error("Kh\u00F4ng t\u00ECm th\u1EA5y api endpoint \u1EE9ng v\u1EDBi service " + serviceCode);
21718
+ var getCompareFunc = function (primer, reverse) {
21719
+ var defaultCompare = defaultCompareFunc;
21720
+ var compare = defaultCompareFunc;
21721
+ if (primer) {
21722
+ compare = function (a, b) {
21723
+ return defaultCompare(primer(a), primer(b));
21724
+ };
21728
21725
  }
21729
- apiUrl = apiUrl + "/" + this.apiVersion + "/WorkflowHistory/GetAllObjectRelated/" + entity + "/" + entityKey;
21730
- return this.defaultGet(apiUrl);
21726
+ if (reverse) {
21727
+ return function (a, b) {
21728
+ return -1 * compare(a, b);
21729
+ };
21730
+ }
21731
+ return compare;
21731
21732
  };
21732
- return WorkflowHistoryService;
21733
- }(BaseService));
21734
- WorkflowHistoryService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function WorkflowHistoryService_Factory() { return new WorkflowHistoryService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: WorkflowHistoryService, providedIn: "root" });
21735
- WorkflowHistoryService.decorators = [
21736
- { type: i0.Injectable, args: [{
21737
- providedIn: 'root'
21738
- },] }
21739
- ];
21740
- WorkflowHistoryService.ctorParameters = function () { return [
21741
- { type: i1$1.HttpClient },
21742
- { type: i0.Injector },
21743
- { type: ModuleConfigService }
21744
- ]; };
21745
-
21746
- var BasePermissionService = /** @class */ (function (_super) {
21747
- __extends(BasePermissionService, _super);
21748
- function BasePermissionService(http, injector, _moduleConfigService) {
21749
- var _this = _super.call(this, http, injector, _moduleConfigService.getConfig().environment.apiDomain.authorizationEndpoint + "/" + _moduleConfigService.getConfig().environment.apiVersion + "/BasePermission") || this;
21750
- _this._moduleConfigService = _moduleConfigService;
21751
- _this.entityName = 'BasePermission';
21752
- _this.serviceCode = 'Authorization';
21753
- _this.endPoint = _moduleConfigService.getConfig().environment.apiDomain.authorizationEndpoint;
21754
- return _this;
21755
- }
21756
- BasePermissionService.prototype.getPermissionByCode = function (code) {
21757
- return this.defaultGet(this.serviceUri + "/GetPermissionByCode?code=" + code);
21733
+ sort_by = function () {
21734
+ var args = [];
21735
+ for (var _i = 0; _i < arguments.length; _i++) {
21736
+ args[_i] = arguments[_i];
21737
+ }
21738
+ var fields = [], n_fields = args.length;
21739
+ var field, name, cmp;
21740
+ // preprocess sorting options
21741
+ for (var i = 0; i < n_fields; i++) {
21742
+ field = args[i];
21743
+ if (typeof field === 'string') {
21744
+ name = field;
21745
+ cmp = defaultCompareFunc;
21746
+ }
21747
+ else {
21748
+ name = field.name;
21749
+ cmp = getCompareFunc(field.primer, field.reverse);
21750
+ }
21751
+ fields.push({
21752
+ name: name,
21753
+ cmp: cmp
21754
+ });
21755
+ }
21756
+ // final comparison function
21757
+ return function (A, B) {
21758
+ var name, result;
21759
+ for (var i = 0; i < n_fields; i++) {
21760
+ result = 0;
21761
+ field = fields[i];
21762
+ name = field.name;
21763
+ result = field.cmp(A[name], B[name]);
21764
+ if (result !== 0)
21765
+ break;
21766
+ }
21767
+ return result;
21768
+ };
21758
21769
  };
21759
- return BasePermissionService;
21760
- }(BaseService));
21761
- BasePermissionService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function BasePermissionService_Factory() { return new BasePermissionService(i0__namespace.ɵɵinject(i1__namespace$1.HttpClient), i0__namespace.ɵɵinject(i0__namespace.INJECTOR), i0__namespace.ɵɵinject(ModuleConfigService)); }, token: BasePermissionService, providedIn: "root" });
21762
- BasePermissionService.decorators = [
21763
- { type: i0.Injectable, args: [{
21764
- providedIn: 'root'
21765
- },] }
21766
- ];
21767
- BasePermissionService.ctorParameters = function () { return [
21768
- { type: i1$1.HttpClient },
21769
- { type: i0.Injector },
21770
- { type: ModuleConfigService }
21771
- ]; };
21770
+ }());
21771
+ // multipleSort('idTinhThanh', 'idQuanHuyen')
21772
+ // multipleSort({name: 'idTinhThanh', reverse: true}, 'idQuanHuyen')
21773
+ // multipleSort({name: 'soThuTu', primer: parseInt}, 'idQuanHuyen') // parseInt là function
21774
+ var multipleSort = sort_by;
21772
21775
 
21773
21776
  var ListComponentBase = /** @class */ (function (_super) {
21774
21777
  __extends(ListComponentBase, _super);
@@ -23182,15 +23185,15 @@
23182
23185
  var result = newArr.reduce(function (x, y) { return y.colSpan + x; }, 0);
23183
23186
  return result > a ? result : a;
23184
23187
  }, 0);
23185
- var startIndex = this.setting.hiddenCheckbox ? 0 : 1;
23186
23188
  var endIndex = maxColSize - (this.setting.hiddenFunctionColumn ? 1 : 2);
23187
23189
  for (var ind = 0; ind < lstRow.length; ind++) {
23188
23190
  var arrTh = __spreadArray([], __read(allTh[ind]));
23191
+ var startIndex = arrTh[0].className.includes('chkbox') ? 1 : 0;
23189
23192
  if (startIndex > endIndex) {
23190
23193
  return null;
23191
23194
  }
23192
23195
  result[ind] = (_a = result[ind]) !== null && _a !== void 0 ? _a : [];
23193
- var colIndex = 0;
23196
+ var colIndex = result[ind].length;
23194
23197
  var numOfColSpan = arrTh.reduce(function (x, y) { return x + y.colSpan - 1; }, 0);
23195
23198
  for (var i = startIndex; i <= endIndex - numOfColSpan; i++) {
23196
23199
  if (arrTh[i]) {
@@ -23355,6 +23358,7 @@
23355
23358
  };
23356
23359
  ListComponentBase.prototype.getValueCheckboxFormat = function (data) {
23357
23360
  var checkBox = data.querySelector('p-checkbox');
23361
+ var input = data.querySelector('input');
23358
23362
  if (checkBox) {
23359
23363
  var value = data.querySelector('span.pi-check');
23360
23364
  if (value) {
@@ -23364,6 +23368,9 @@
23364
23368
  return 'Không';
23365
23369
  }
23366
23370
  }
23371
+ if (input) {
23372
+ return input.value;
23373
+ }
23367
23374
  return '';
23368
23375
  };
23369
23376
  ListComponentBase.prototype.view = function (rowData) {