tnx-shared 5.3.260 → 5.3.262

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.
@@ -6186,12 +6186,14 @@
6186
6186
  var MasterDataService = /** @class */ (function () {
6187
6187
  function MasterDataService(_httpClient, _commonService, _injector, _storageUpdatedService, _moduleConfigService) {
6188
6188
  var _this = this;
6189
+ var _a, _b;
6189
6190
  this._httpClient = _httpClient;
6190
6191
  this._commonService = _commonService;
6191
6192
  this._injector = _injector;
6192
6193
  this._storageUpdatedService = _storageUpdatedService;
6193
6194
  this._moduleConfigService = _moduleConfigService;
6194
6195
  this.setupSignalr = false;
6196
+ this.isDisabledGetCache = false;
6195
6197
  this.storage = localStorage;
6196
6198
  this.categoryPrefix = 'cat_';
6197
6199
  this.categoryGroupPrefix = 'cat_group_';
@@ -6200,13 +6202,14 @@
6200
6202
  this.env = this._moduleConfigService.getConfig().environment;
6201
6203
  this.apiEndpoint = this.env.apiDomain.commonMasterDataEndpoint;
6202
6204
  this.apiVersion = this.env.apiVersion;
6205
+ this.isDisabledGetCache = (_b = (_a = this.env.cauHinhNghiepVu) === null || _a === void 0 ? void 0 : _a.isDisabledGetCacheCommonMasterdata) !== null && _b !== void 0 ? _b : false;
6203
6206
  this.groupCategoryEndpoint = this.apiEndpoint + "/" + this.apiVersion + "/Groupcategory";
6204
6207
  this.singleCategoryEndpoint = this.apiEndpoint + "/" + this.apiVersion + "/SingleCategory";
6205
6208
  if (!this.setupSignalr) {
6206
6209
  this._storageUpdatedService.subscribeChangedLocalStorage('cat_*', function (data) { return __awaiter(_this, void 0, void 0, function () {
6207
6210
  var dataObj, dataSource_1, content, groupCode, result, groupCode, result;
6208
- return __generator(this, function (_a) {
6209
- switch (_a.label) {
6211
+ return __generator(this, function (_c) {
6212
+ switch (_c.label) {
6210
6213
  case 0:
6211
6214
  if (typeof data == 'string') {
6212
6215
  dataObj = JSON.parse(data);
@@ -6221,19 +6224,19 @@
6221
6224
  groupCode = dataObj.message.content.replace(this.categoryGroupPrefix, '');
6222
6225
  return [4 /*yield*/, this.getGroupItemByCode(groupCode)];
6223
6226
  case 1:
6224
- result = _a.sent();
6227
+ result = _c.sent();
6225
6228
  this.storage.setItem("" + this.categoryGroupPrefix + groupCode, JSON.stringify(result.data));
6226
6229
  return [3 /*break*/, 4];
6227
6230
  case 2:
6228
6231
  groupCode = dataObj.message.content.replace(this.categoryPrefix, '');
6229
6232
  return [4 /*yield*/, this.doGetAll(groupCode)];
6230
6233
  case 3:
6231
- result = _a.sent();
6234
+ result = _c.sent();
6232
6235
  result.data.forEach(function (element) {
6233
6236
  dataSource_1.push({ id: element.id, code: element.code, name: element.name });
6234
6237
  });
6235
6238
  this.storage.setItem("" + this.categoryPrefix + groupCode, JSON.stringify(dataSource_1));
6236
- _a.label = 4;
6239
+ _c.label = 4;
6237
6240
  case 4: return [2 /*return*/];
6238
6241
  }
6239
6242
  });
@@ -6241,27 +6244,48 @@
6241
6244
  this.setupSignalr = true;
6242
6245
  }
6243
6246
  }
6244
- MasterDataService.prototype.get = function (groupCode) {
6245
- var _this = this;
6246
- return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
6247
+ MasterDataService.prototype.getAllByGroupCode = function (groupCode) {
6248
+ return __awaiter(this, void 0, void 0, function () {
6247
6249
  var dataSource, result;
6248
- return __generator(this, function (_a) {
6249
- switch (_a.label) {
6250
+ return __generator(this, function (_c) {
6251
+ switch (_c.label) {
6250
6252
  case 0:
6251
6253
  dataSource = [];
6252
- if (!!this.storage.getItem("" + this.categoryPrefix + groupCode)) return [3 /*break*/, 2];
6253
- return [4 /*yield*/, this.doGetAll(groupCode)];
6254
+ return [4 /*yield*/, this.doGetAllCustom(groupCode)];
6254
6255
  case 1:
6255
- result = _a.sent();
6256
+ result = _c.sent();
6256
6257
  result.data.forEach(function (element) {
6257
6258
  dataSource.push({ id: element.id, code: element.code, name: element.name });
6258
6259
  });
6259
- this.storage.setItem("" + this.categoryPrefix + groupCode, JSON.stringify(dataSource));
6260
- return [3 /*break*/, 3];
6260
+ return [2 /*return*/, dataSource];
6261
+ }
6262
+ });
6263
+ });
6264
+ };
6265
+ MasterDataService.prototype.get = function (groupCode) {
6266
+ var _this = this;
6267
+ return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
6268
+ var dataSource;
6269
+ return __generator(this, function (_c) {
6270
+ switch (_c.label) {
6271
+ case 0:
6272
+ dataSource = [];
6273
+ if (!(this.isDisabledGetCache === true)) return [3 /*break*/, 2];
6274
+ return [4 /*yield*/, this.getAllByGroupCode(groupCode)];
6275
+ case 1:
6276
+ dataSource = _c.sent();
6277
+ return [3 /*break*/, 5];
6261
6278
  case 2:
6262
- dataSource = JSON.parse(this.storage.getItem("" + this.categoryPrefix + groupCode));
6263
- _a.label = 3;
6279
+ if (!!this.storage.getItem("" + this.categoryPrefix + groupCode)) return [3 /*break*/, 4];
6280
+ return [4 /*yield*/, this.getAllByGroupCode(groupCode)];
6264
6281
  case 3:
6282
+ dataSource = _c.sent();
6283
+ this.storage.setItem("" + this.categoryPrefix + groupCode, JSON.stringify(dataSource));
6284
+ return [3 /*break*/, 5];
6285
+ case 4:
6286
+ dataSource = JSON.parse(this.storage.getItem("" + this.categoryPrefix + groupCode));
6287
+ _c.label = 5;
6288
+ case 5:
6265
6289
  resolve(dataSource);
6266
6290
  return [2 /*return*/];
6267
6291
  }
@@ -6272,20 +6296,20 @@
6272
6296
  var _this = this;
6273
6297
  return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
6274
6298
  var config, result;
6275
- return __generator(this, function (_a) {
6276
- switch (_a.label) {
6299
+ return __generator(this, function (_c) {
6300
+ switch (_c.label) {
6277
6301
  case 0:
6278
6302
  config = '';
6279
6303
  if (!!this.storage.getItem(code)) return [3 /*break*/, 2];
6280
6304
  return [4 /*yield*/, this.doGetConfigByCode(code)];
6281
6305
  case 1:
6282
- result = _a.sent();
6306
+ result = _c.sent();
6283
6307
  this.storage.setItem(code, JSON.stringify(result.data));
6284
6308
  config = result.data;
6285
6309
  return [3 /*break*/, 3];
6286
6310
  case 2:
6287
6311
  config = JSON.parse(this.storage.getItem(code));
6288
- _a.label = 3;
6312
+ _c.label = 3;
6289
6313
  case 3:
6290
6314
  resolve(config);
6291
6315
  return [2 /*return*/];
@@ -6296,7 +6320,7 @@
6296
6320
  MasterDataService.prototype.getDropdown = function (groupCode) {
6297
6321
  var _this = this;
6298
6322
  return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
6299
- return __generator(this, function (_a) {
6323
+ return __generator(this, function (_c) {
6300
6324
  this.get(groupCode).then(function (source) {
6301
6325
  var op = source.map(function (x) { return ({ title: x.name, label: x.name, value: x.code }); });
6302
6326
  resolve(op);
@@ -6314,7 +6338,7 @@
6314
6338
  MasterDataService.prototype.getItems = function (groupCode) {
6315
6339
  var _this = this;
6316
6340
  return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
6317
- return __generator(this, function (_a) {
6341
+ return __generator(this, function (_c) {
6318
6342
  this.get(groupCode).then(function (source) {
6319
6343
  var op = source.map(function (x) { return ({ label: x.name, value: x.code }); });
6320
6344
  resolve(op);
@@ -6334,7 +6358,7 @@
6334
6358
  var _this = this;
6335
6359
  if (level === void 0) { level = 1; }
6336
6360
  return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
6337
- return __generator(this, function (_a) {
6361
+ return __generator(this, function (_c) {
6338
6362
  this.getAddress(id, level).then(function (source) {
6339
6363
  var op = source.map(function (x) { return ({ title: x.name, label: x.name, value: x.code }); });
6340
6364
  resolve(op);
@@ -6348,20 +6372,20 @@
6348
6372
  if (level === void 0) { level = 1; }
6349
6373
  return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
6350
6374
  var dataSource, result;
6351
- return __generator(this, function (_a) {
6352
- switch (_a.label) {
6375
+ return __generator(this, function (_c) {
6376
+ switch (_c.label) {
6353
6377
  case 0:
6354
6378
  dataSource = [];
6355
6379
  if (!!this.storage.getItem(this.administrativeUnit + ".Level" + level + "." + id)) return [3 /*break*/, 2];
6356
6380
  return [4 /*yield*/, this.dogetAddress(id, level)];
6357
6381
  case 1:
6358
- result = _a.sent();
6382
+ result = _c.sent();
6359
6383
  this.storage.setItem(this.administrativeUnit + ".Level" + level + "." + id, JSON.stringify(result.data));
6360
6384
  dataSource = result.data;
6361
6385
  return [3 /*break*/, 3];
6362
6386
  case 2:
6363
6387
  dataSource = JSON.parse(this.storage.getItem(this.administrativeUnit + ".Level" + level + "." + id));
6364
- _a.label = 3;
6388
+ _c.label = 3;
6365
6389
  case 3:
6366
6390
  resolve(dataSource);
6367
6391
  return [2 /*return*/];
@@ -6373,11 +6397,11 @@
6373
6397
  var _this = this;
6374
6398
  return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
6375
6399
  var streets, parentIds;
6376
- return __generator(this, function (_a) {
6377
- switch (_a.label) {
6400
+ return __generator(this, function (_c) {
6401
+ switch (_c.label) {
6378
6402
  case 0: return [4 /*yield*/, this.getAddress(districtCode, 2)];
6379
6403
  case 1:
6380
- streets = _a.sent();
6404
+ streets = _c.sent();
6381
6405
  parentIds = streets.filter(function (x) { return x.name == streetName; }).map(function (x) { return x.parentId; });
6382
6406
  resolve(parentIds);
6383
6407
  return [2 /*return*/];
@@ -6398,8 +6422,8 @@
6398
6422
  return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
6399
6423
  var itemData, serviceUri, result;
6400
6424
  var _this = this;
6401
- return __generator(this, function (_a) {
6402
- switch (_a.label) {
6425
+ return __generator(this, function (_c) {
6426
+ switch (_c.label) {
6403
6427
  case 0:
6404
6428
  itemData = new MasterDataItem();
6405
6429
  if (!!this.storage.getItem("" + this.administrativeUnitItem + id)) return [3 /*break*/, 2];
@@ -6408,13 +6432,13 @@
6408
6432
  .pipe(operators.catchError(function (err) { return _this._commonService.handleError(err, _this._injector); }))
6409
6433
  .toPromise()];
6410
6434
  case 1:
6411
- result = _a.sent();
6435
+ result = _c.sent();
6412
6436
  this.storage.setItem("" + this.administrativeUnitItem + id, JSON.stringify(result.data));
6413
6437
  itemData = result.data;
6414
6438
  return [3 /*break*/, 3];
6415
6439
  case 2:
6416
6440
  itemData = JSON.parse(this.storage.getItem("" + this.administrativeUnitItem + id));
6417
- _a.label = 3;
6441
+ _c.label = 3;
6418
6442
  case 3:
6419
6443
  resolve(itemData);
6420
6444
  return [2 /*return*/];
@@ -6436,14 +6460,14 @@
6436
6460
  return __awaiter(this, void 0, void 0, function () {
6437
6461
  var group, gridInfo;
6438
6462
  var _this = this;
6439
- return __generator(this, function (_a) {
6440
- switch (_a.label) {
6463
+ return __generator(this, function (_c) {
6464
+ switch (_c.label) {
6441
6465
  case 0: return [4 /*yield*/, this.getGroupByCode(groupCode)];
6442
6466
  case 1:
6443
- group = _a.sent();
6467
+ group = _c.sent();
6444
6468
  if (!group.data) {
6445
6469
  return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
6446
- return __generator(this, function (_a) {
6470
+ return __generator(this, function (_c) {
6447
6471
  resolve({ success: true, data: [] });
6448
6472
  return [2 /*return*/];
6449
6473
  });
@@ -6463,13 +6487,23 @@
6463
6487
  });
6464
6488
  });
6465
6489
  };
6490
+ // thực hiện get list singleCategory theo groupCategoryCode trên redis
6491
+ MasterDataService.prototype.doGetAllCustom = function (groupCode) {
6492
+ return __awaiter(this, void 0, void 0, function () {
6493
+ var uri;
6494
+ return __generator(this, function (_c) {
6495
+ uri = this.singleCategoryEndpoint + "/GetDataByGroupCode/" + groupCode;
6496
+ return [2 /*return*/, this._httpClient.get(uri).toPromise()];
6497
+ });
6498
+ });
6499
+ };
6466
6500
  MasterDataService.prototype.getData = function (uri, gridInfo) {
6467
6501
  return this._httpClient.post(uri, gridInfo).toPromise();
6468
6502
  };
6469
6503
  MasterDataService.prototype.getGroupByCode = function (groupCode) {
6470
6504
  return __awaiter(this, void 0, void 0, function () {
6471
6505
  var uri;
6472
- return __generator(this, function (_a) {
6506
+ return __generator(this, function (_c) {
6473
6507
  uri = this.groupCategoryEndpoint + "/getByCode/" + groupCode;
6474
6508
  return [2 /*return*/, this._httpClient.get(uri).toPromise()];
6475
6509
  });
@@ -6503,20 +6537,20 @@
6503
6537
  var _this = this;
6504
6538
  return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
6505
6539
  var dataSource, result;
6506
- return __generator(this, function (_a) {
6507
- switch (_a.label) {
6540
+ return __generator(this, function (_c) {
6541
+ switch (_c.label) {
6508
6542
  case 0:
6509
6543
  dataSource = [];
6510
6544
  if (!!this.storage.getItem("" + this.categoryPrefix + groupCode)) return [3 /*break*/, 2];
6511
6545
  return [4 /*yield*/, this.doGetAll(groupCode)];
6512
6546
  case 1:
6513
- result = _a.sent();
6547
+ result = _c.sent();
6514
6548
  this.storage.setItem("" + this.categoryPrefix + groupCode, JSON.stringify(result.data));
6515
6549
  dataSource = result.data;
6516
6550
  return [3 /*break*/, 3];
6517
6551
  case 2:
6518
6552
  dataSource = JSON.parse(this.storage.getItem("" + this.categoryPrefix + groupCode));
6519
- _a.label = 3;
6553
+ _c.label = 3;
6520
6554
  case 3:
6521
6555
  resolve(dataSource.find(function (x) { return x.code === code; }));
6522
6556
  return [2 /*return*/];
@@ -6537,8 +6571,8 @@
6537
6571
  var _this = this;
6538
6572
  return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
6539
6573
  var strResult, x, x, x;
6540
- return __generator(this, function (_a) {
6541
- switch (_a.label) {
6574
+ return __generator(this, function (_c) {
6575
+ switch (_c.label) {
6542
6576
  case 0:
6543
6577
  strResult = '';
6544
6578
  if (strText && strText != '') {
@@ -6550,29 +6584,29 @@
6550
6584
  if (!(ward && ward != '')) return [3 /*break*/, 2];
6551
6585
  return [4 /*yield*/, this.getItemDetailUnit(ward)];
6552
6586
  case 1:
6553
- x = _a.sent();
6587
+ x = _c.sent();
6554
6588
  if (x !== null) {
6555
6589
  strResult += x.name + ', ';
6556
6590
  }
6557
- _a.label = 2;
6591
+ _c.label = 2;
6558
6592
  case 2:
6559
6593
  if (!(district && district != '')) return [3 /*break*/, 4];
6560
6594
  return [4 /*yield*/, this.getItemDetailUnit(district)];
6561
6595
  case 3:
6562
- x = _a.sent();
6596
+ x = _c.sent();
6563
6597
  if (x !== null) {
6564
6598
  strResult += x.name + ', ';
6565
6599
  }
6566
- _a.label = 4;
6600
+ _c.label = 4;
6567
6601
  case 4:
6568
6602
  if (!(city && city != '')) return [3 /*break*/, 6];
6569
6603
  return [4 /*yield*/, this.getItemDetailUnit(city)];
6570
6604
  case 5:
6571
- x = _a.sent();
6605
+ x = _c.sent();
6572
6606
  if (x !== null) {
6573
6607
  strResult += x.name;
6574
6608
  }
6575
- _a.label = 6;
6609
+ _c.label = 6;
6576
6610
  case 6:
6577
6611
  resolve(strResult);
6578
6612
  return [2 /*return*/];
@@ -6608,8 +6642,8 @@
6608
6642
  return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
6609
6643
  var data, dataStorage, apiUrl;
6610
6644
  var _this = this;
6611
- return __generator(this, function (_a) {
6612
- switch (_a.label) {
6645
+ return __generator(this, function (_c) {
6646
+ switch (_c.label) {
6613
6647
  case 0:
6614
6648
  dataStorage = this.storage.getItem("" + this.categoryPrefix + groupCode);
6615
6649
  if (!!dataStorage) return [3 /*break*/, 2];
@@ -6620,7 +6654,7 @@
6620
6654
  .post(apiUrl, gridInfo)
6621
6655
  .pipe(operators.catchError(function (err) { return _this.handleError(err, _this._injector); })).toPromise()];
6622
6656
  case 1:
6623
- data = _a.sent();
6657
+ data = _c.sent();
6624
6658
  this.storage.setItem("" + this.categoryPrefix + groupCode, JSON.stringify(data.data));
6625
6659
  return [3 /*break*/, 3];
6626
6660
  case 2:
@@ -6628,7 +6662,7 @@
6628
6662
  success: true,
6629
6663
  data: JSON.parse(dataStorage)
6630
6664
  };
6631
- _a.label = 3;
6665
+ _c.label = 3;
6632
6666
  case 3:
6633
6667
  resolve(data);
6634
6668
  return [2 /*return*/];
@@ -6685,10 +6719,12 @@
6685
6719
  _this.get(groupCode)
6686
6720
  .then(function (res) {
6687
6721
  var result = [];
6688
- if (arrValue == null)
6722
+ if (arrValue == null) {
6689
6723
  result = res;
6690
- else
6724
+ }
6725
+ else {
6691
6726
  result = res.filter(function (x) { return arrValue.some(function (v) { return v == x[options.valueField]; }); });
6727
+ }
6692
6728
  resolve(result);
6693
6729
  }).catch(function (err) { return reject(err); });
6694
6730
  });