tnx-shared 5.3.310 → 5.3.311

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.
@@ -2552,6 +2552,28 @@
2552
2552
  }
2553
2553
  return FieldRowSpan;
2554
2554
  }());
2555
+ var LogSetting = /** @class */ (function () {
2556
+ function LogSetting(init) {
2557
+ this.isEnableLog = false;
2558
+ this.isCustomAll = false;
2559
+ this.emptyValue = 'Không có giá trị';
2560
+ this.arrValueAfterUpdate = [];
2561
+ for (var key in init) {
2562
+ this[key] = init[key];
2563
+ }
2564
+ }
2565
+ return LogSetting;
2566
+ }());
2567
+ var LogColumn = /** @class */ (function () {
2568
+ function LogColumn(init) {
2569
+ this.visible = true;
2570
+ this.isHtml = false;
2571
+ for (var key in init) {
2572
+ this[key] = init[key];
2573
+ }
2574
+ }
2575
+ return LogColumn;
2576
+ }());
2555
2577
  exports.DataType = void 0;
2556
2578
  (function (DataType) {
2557
2579
  DataType["date"] = "date";
@@ -11452,6 +11474,10 @@
11452
11474
  { id: ɵ3, ten: 'Nam' },
11453
11475
  { id: ɵ4, ten: 'Nữ' }
11454
11476
  ];
11477
+ var DataSourceBoolean = [
11478
+ { id: false, ten: 'Không' },
11479
+ { id: true, ten: 'Có' }
11480
+ ];
11455
11481
 
11456
11482
  var ExceptionHandlerService = /** @class */ (function () {
11457
11483
  function ExceptionHandlerService() {
@@ -18652,6 +18678,7 @@
18652
18678
  _this.messageInsertSuccess = '';
18653
18679
  _this.messageUpdateSuccess = '';
18654
18680
  _this.setting = new CrudFormSetting();
18681
+ _this.logSetting = new LogSetting();
18655
18682
  _this.vi = CONFIG_CALENDAR_VIETNAMESE;
18656
18683
  _this.formControlsList = {};
18657
18684
  _this.environment = {};
@@ -18671,6 +18698,7 @@
18671
18698
  var moduleConfigService = _injector.get(ModuleConfigService);
18672
18699
  _this.environment = moduleConfigService.getConfig().environment;
18673
18700
  _this._notifierService = _this._injector.get(NotifierService);
18701
+ _this._numberPipe = _this._injector.get(i3.DecimalPipe);
18674
18702
  _this._masterDataService = _this._injector.get(MasterDataService);
18675
18703
  _this._router = _this._injector.get(i3$1.Router);
18676
18704
  _this._activatedRoute = _this._injector.get(i3$1.ActivatedRoute);
@@ -18910,6 +18938,9 @@
18910
18938
  return [4 /*yield*/, this.onAfterGetDetail(response.data)];
18911
18939
  case 7:
18912
18940
  _e.sent();
18941
+ if (this.logSetting.isEnableLog) {
18942
+ this.logSetting.valueBeforeUpdate = this._commonService.cloneObject(response.data);
18943
+ }
18913
18944
  return [3 /*break*/, 10];
18914
18945
  case 8:
18915
18946
  if (!this.crudForm) return [3 /*break*/, 10];
@@ -19034,13 +19065,45 @@
19034
19065
  _e.label = 2;
19035
19066
  case 2:
19036
19067
  this.disableBuildInField();
19068
+ if (this.logSetting.isEnableLog) {
19069
+ this.getLogValueAfterLoadDetail();
19070
+ }
19037
19071
  return [2 /*return*/];
19038
19072
  }
19039
19073
  });
19040
19074
  });
19041
19075
  };
19076
+ DataFormBase.prototype.getLogValueAfterLoadDetail = function () {
19077
+ var _this = this;
19078
+ setTimeout(function () {
19079
+ var e_1, _e;
19080
+ var _a;
19081
+ try {
19082
+ for (var _f = __values(Object.keys(_this.formControls)), _g = _f.next(); !_g.done; _g = _f.next()) {
19083
+ var controlName = _g.value;
19084
+ var control = _this.crudForm.formControls[controlName];
19085
+ if (controlName.includes('.') || ((_a = _this.crudForm.formControls[controlName]) === null || _a === void 0 ? void 0 : _a.hidden) === true
19086
+ || !(control instanceof AutoCompletePickerControlSchema))
19087
+ continue;
19088
+ _this.logSetting.arrValueAfterUpdate.push(new LogColumn({
19089
+ column: control.label,
19090
+ valueBefore: control._component.dataSource.map(function (p) { return p.label; }).join(', '),
19091
+ visible: false,
19092
+ valueAfter: ''
19093
+ }));
19094
+ }
19095
+ }
19096
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
19097
+ finally {
19098
+ try {
19099
+ if (_g && !_g.done && (_e = _f.return)) _e.call(_f);
19100
+ }
19101
+ finally { if (e_1) throw e_1.error; }
19102
+ }
19103
+ }, 2000);
19104
+ };
19042
19105
  DataFormBase.prototype.fixDateValue = function (control, parentModel, parentPath) {
19043
- var e_1, _e, e_2, _f, e_3, _g;
19106
+ var e_2, _e, e_3, _f, e_4, _g;
19044
19107
  var _parentPath = control.field;
19045
19108
  if (parentPath != null)
19046
19109
  _parentPath = parentPath + '.' + _parentPath;
@@ -19053,27 +19116,27 @@
19053
19116
  for (var _h = __values(parentModel[control.field]), _j = _h.next(); !_j.done; _j = _h.next()) {
19054
19117
  var item = _j.value;
19055
19118
  try {
19056
- for (var _k = (e_2 = void 0, __values(control.rowTemplate)), _l = _k.next(); !_l.done; _l = _k.next()) {
19119
+ for (var _k = (e_3 = void 0, __values(control.rowTemplate)), _l = _k.next(); !_l.done; _l = _k.next()) {
19057
19120
  var subControl = _l.value;
19058
19121
  this.fixDateValue(subControl, item, _parentPath + '[' + i + ']');
19059
19122
  }
19060
19123
  }
19061
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
19124
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
19062
19125
  finally {
19063
19126
  try {
19064
19127
  if (_l && !_l.done && (_f = _k.return)) _f.call(_k);
19065
19128
  }
19066
- finally { if (e_2) throw e_2.error; }
19129
+ finally { if (e_3) throw e_3.error; }
19067
19130
  }
19068
19131
  i++;
19069
19132
  }
19070
19133
  }
19071
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
19134
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
19072
19135
  finally {
19073
19136
  try {
19074
19137
  if (_j && !_j.done && (_e = _h.return)) _e.call(_h);
19075
19138
  }
19076
- finally { if (e_1) throw e_1.error; }
19139
+ finally { if (e_2) throw e_2.error; }
19077
19140
  }
19078
19141
  }
19079
19142
  else if (control instanceof ContainerSchema) {
@@ -19086,12 +19149,12 @@
19086
19149
  this.fixDateValue(subControl, parentModel[control.field], _parentPath);
19087
19150
  }
19088
19151
  }
19089
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
19152
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
19090
19153
  finally {
19091
19154
  try {
19092
19155
  if (_o && !_o.done && (_g = _m.return)) _g.call(_m);
19093
19156
  }
19094
- finally { if (e_3) throw e_3.error; }
19157
+ finally { if (e_4) throw e_4.error; }
19095
19158
  }
19096
19159
  }
19097
19160
  else {
@@ -19123,7 +19186,7 @@
19123
19186
  }
19124
19187
  };
19125
19188
  DataFormBase.prototype._addRequiredValidator = function (schema) {
19126
- var e_4, _e;
19189
+ var e_5, _e;
19127
19190
  var exist = false;
19128
19191
  try {
19129
19192
  for (var _f = __values(schema.validators), _g = _f.next(); !_g.done; _g = _f.next()) {
@@ -19134,12 +19197,12 @@
19134
19197
  }
19135
19198
  }
19136
19199
  }
19137
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
19200
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
19138
19201
  finally {
19139
19202
  try {
19140
19203
  if (_g && !_g.done && (_e = _f.return)) _e.call(_f);
19141
19204
  }
19142
- finally { if (e_4) throw e_4.error; }
19205
+ finally { if (e_5) throw e_5.error; }
19143
19206
  }
19144
19207
  if (!exist) {
19145
19208
  schema.validators.push(new RequiredValidator());
@@ -19147,7 +19210,7 @@
19147
19210
  schema.required = true;
19148
19211
  };
19149
19212
  DataFormBase.prototype._removeRequiredValidator = function (schema) {
19150
- var e_5, _e;
19213
+ var e_6, _e;
19151
19214
  var validators = [];
19152
19215
  try {
19153
19216
  for (var _f = __values(schema.validators), _g = _f.next(); !_g.done; _g = _f.next()) {
@@ -19159,12 +19222,12 @@
19159
19222
  }
19160
19223
  }
19161
19224
  }
19162
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
19225
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
19163
19226
  finally {
19164
19227
  try {
19165
19228
  if (_g && !_g.done && (_e = _f.return)) _e.call(_f);
19166
19229
  }
19167
- finally { if (e_5) throw e_5.error; }
19230
+ finally { if (e_6) throw e_6.error; }
19168
19231
  }
19169
19232
  schema.validators = validators;
19170
19233
  schema.required = false;
@@ -19187,6 +19250,154 @@
19187
19250
  DataFormBase.prototype._triggerSave = function () {
19188
19251
  this.save();
19189
19252
  };
19253
+ DataFormBase.prototype.onAfterGetLogValue = function () {
19254
+ return __awaiter(this, void 0, void 0, function () {
19255
+ return __generator(this, function (_e) {
19256
+ return [2 /*return*/];
19257
+ });
19258
+ });
19259
+ };
19260
+ DataFormBase.prototype.getSingleLabel = function (control, dataSource, valueParam) {
19261
+ var result = dataSource.find(function (p) { return p.value[control.valueField] == valueParam; });
19262
+ if (!!result) {
19263
+ var funcGetLabel = control.funcGetLabel;
19264
+ if (funcGetLabel) {
19265
+ result = funcGetLabel(result.value);
19266
+ }
19267
+ }
19268
+ else {
19269
+ result = this.logSetting.emptyValue;
19270
+ }
19271
+ return result;
19272
+ };
19273
+ DataFormBase.prototype.getMultipleLabel = function (control, dataSource, valueParam) {
19274
+ try {
19275
+ if (valueParam.some(function (p) { return p == Number(p); })) {
19276
+ valueParam = valueParam.map(function (p) { return Number(p); });
19277
+ }
19278
+ }
19279
+ catch (_a) { }
19280
+ var result = dataSource
19281
+ .filter(function (p) { return valueParam.includes(p.value[control.valueField]); })
19282
+ .map(function (p) { return control.funcGetLabel(p.value); })
19283
+ .join(', ');
19284
+ if (!result) {
19285
+ result = this.logSetting.emptyValue;
19286
+ }
19287
+ return result;
19288
+ };
19289
+ DataFormBase.prototype.addSinglePropertyLog = function (control, oldValue, newValue) {
19290
+ if (control instanceof AutoCompletePickerControlSchema) {
19291
+ var logColumn = this.logSetting.arrValueAfterUpdate.find(function (p) { return p.column == control.label; });
19292
+ var dataSource = control._component.selectedValueObject;
19293
+ if (!Array.isArray(dataSource))
19294
+ dataSource = [dataSource];
19295
+ logColumn.visible = true;
19296
+ logColumn.valueAfter = this.getSingleLabel(control, dataSource, newValue);
19297
+ }
19298
+ else {
19299
+ var dataSource = control._component.dataSourceInternal;
19300
+ this.logSetting.arrValueAfterUpdate.push(new LogColumn({
19301
+ column: control.label,
19302
+ valueBefore: this.getSingleLabel(control, dataSource, oldValue),
19303
+ valueAfter: this.getSingleLabel(control, dataSource, newValue)
19304
+ }));
19305
+ }
19306
+ };
19307
+ DataFormBase.prototype.addMultiplePropertyLog = function (control, oldValue, newValue) {
19308
+ if (control instanceof AutoCompletePickerControlSchema) {
19309
+ var logColumn = this.logSetting.arrValueAfterUpdate.find(function (p) { return p.column == control.label; });
19310
+ logColumn.visible = true;
19311
+ logColumn.valueAfter = this.getMultipleLabel(control, control._component.selectedValueObject, newValue);
19312
+ }
19313
+ else {
19314
+ var dataSource = control._component.dataSourceInternal;
19315
+ this.logSetting.arrValueAfterUpdate.push(new LogColumn({
19316
+ column: control.label,
19317
+ valueBefore: this.getMultipleLabel(control, dataSource, oldValue),
19318
+ valueAfter: this.getMultipleLabel(control, dataSource, newValue)
19319
+ }));
19320
+ }
19321
+ };
19322
+ DataFormBase.prototype.getLogValueDefault = function (control, oldValue, newValue) {
19323
+ var _a, _b;
19324
+ var isNullOldValue = this.isNullOrEmpty(oldValue);
19325
+ var isNullNewValue = this.isNullOrEmpty(newValue);
19326
+ if (control instanceof DateTimeControlSchema) {
19327
+ var format = control.showTime ? 'HH:mm dd/MM/yyyy' : 'dd/MM/yyyy';
19328
+ oldValue = isNullOldValue ? this.logSetting.emptyValue : this._datePipe.transform(oldValue, format);
19329
+ newValue = isNullNewValue ? this.logSetting.emptyValue : this._datePipe.transform(newValue, format);
19330
+ }
19331
+ else if (control instanceof MaskControlSchema) {
19332
+ oldValue = isNullOldValue ? this.logSetting.emptyValue : this._numberPipe.transform(oldValue, '', 'vi-VN');
19333
+ newValue = isNullNewValue ? this.logSetting.emptyValue : this._numberPipe.transform(newValue, '', 'vi-VN');
19334
+ }
19335
+ else if (control instanceof CheckboxControlSchema || control instanceof SwitchControlSchema) {
19336
+ oldValue = isNullOldValue ? this.logSetting.emptyValue : (_a = DataSourceBoolean.find(function (p) { return p.id == oldValue; })) === null || _a === void 0 ? void 0 : _a.ten;
19337
+ newValue = isNullNewValue ? this.logSetting.emptyValue : (_b = DataSourceBoolean.find(function (p) { return p.id == newValue; })) === null || _b === void 0 ? void 0 : _b.ten;
19338
+ }
19339
+ return [oldValue, newValue];
19340
+ };
19341
+ DataFormBase.prototype.getLogValue = function () {
19342
+ var e_7, _e;
19343
+ var _a;
19344
+ try {
19345
+ var cloneModel = this._commonService.cloneObject(this.model.data);
19346
+ try {
19347
+ for (var _f = __values(Object.keys(this.formControls)), _g = _f.next(); !_g.done; _g = _f.next()) {
19348
+ var controlName = _g.value;
19349
+ if (controlName.includes('.') || ((_a = this.crudForm.formControls[controlName]) === null || _a === void 0 ? void 0 : _a.hidden) === true)
19350
+ continue;
19351
+ var control = this.formControls[controlName];
19352
+ var oldValue = this.logSetting.valueBeforeUpdate[control.field];
19353
+ var newValue = cloneModel[control.field];
19354
+ var isMultiple = Array.isArray(oldValue);
19355
+ if (!this.isNullOrEmpty(oldValue) || !this.isNullOrEmpty(newValue)) {
19356
+ if (control instanceof DropdownControlSchema || control instanceof AutoCompletePickerControlSchema) {
19357
+ if (!isMultiple && oldValue != newValue) {
19358
+ this.addSinglePropertyLog(control, oldValue, newValue);
19359
+ }
19360
+ else if (isMultiple && !this._commonService.isSameArray(oldValue, newValue)) {
19361
+ this.addMultiplePropertyLog(control, oldValue, newValue);
19362
+ }
19363
+ }
19364
+ else {
19365
+ if (oldValue != newValue) {
19366
+ var _h = __read(this.getLogValueDefault(control, oldValue, newValue), 2), valueBefore = _h[0], valueAfter = _h[1];
19367
+ this.logSetting.arrValueAfterUpdate.push(new LogColumn({
19368
+ column: control.label,
19369
+ valueBefore: valueBefore,
19370
+ valueAfter: valueAfter,
19371
+ isHtml: (control instanceof EditorControlSchema || control instanceof TextAreaControlSchema)
19372
+ }));
19373
+ }
19374
+ }
19375
+ }
19376
+ }
19377
+ }
19378
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
19379
+ finally {
19380
+ try {
19381
+ if (_g && !_g.done && (_e = _f.return)) _e.call(_f);
19382
+ }
19383
+ finally { if (e_7) throw e_7.error; }
19384
+ }
19385
+ }
19386
+ catch (_b) {
19387
+ console.error('----log data fail----');
19388
+ }
19389
+ };
19390
+ DataFormBase.prototype.isNullOrEmpty = function (input) {
19391
+ if (input !== undefined && input !== null) {
19392
+ if (Array.isArray(input)) {
19393
+ return input.length ? false : true;
19394
+ }
19395
+ if (input.toString().trim() !== '') {
19396
+ return false;
19397
+ }
19398
+ }
19399
+ return true;
19400
+ };
19190
19401
  DataFormBase.prototype.save = function () {
19191
19402
  return __awaiter(this, void 0, void 0, function () {
19192
19403
  var validated;
@@ -19195,32 +19406,46 @@
19195
19406
  case 0: return [4 /*yield*/, this.validateFormBase()];
19196
19407
  case 1:
19197
19408
  validated = _e.sent();
19198
- if (!validated) return [3 /*break*/, 9];
19199
- return [4 /*yield*/, this.onBeforeSave()];
19409
+ if (!validated) return [3 /*break*/, 13];
19410
+ if (!this.logSetting.isEnableLog) return [3 /*break*/, 5];
19411
+ if (!!this.logSetting.isCustomAll) return [3 /*break*/, 3];
19412
+ return [4 /*yield*/, this.getLogValue()];
19200
19413
  case 2:
19414
+ _e.sent();
19415
+ _e.label = 3;
19416
+ case 3:
19417
+ // cấu hình thêm
19418
+ return [4 /*yield*/, this.onAfterGetLogValue()];
19419
+ case 4:
19420
+ // cấu hình thêm
19421
+ _e.sent();
19422
+ this.model.data.logMetaData = JSON.stringify(this.logSetting.arrValueAfterUpdate.filter(function (p) { return p.visible; }));
19423
+ _e.label = 5;
19424
+ case 5: return [4 /*yield*/, this.onBeforeSave()];
19425
+ case 6:
19201
19426
  _e.sent();
19202
19427
  this.triggerSaveFileUpload();
19203
- if (!this.autoSave) return [3 /*break*/, 7];
19204
- if (!(this._isFormEdit() || this._isFormView())) return [3 /*break*/, 4];
19428
+ if (!this.autoSave) return [3 /*break*/, 11];
19429
+ if (!(this._isFormEdit() || this._isFormView())) return [3 /*break*/, 8];
19205
19430
  return [4 /*yield*/, this.onUpdate()];
19206
- case 3:
19431
+ case 7:
19207
19432
  _e.sent();
19208
- return [3 /*break*/, 6];
19209
- case 4:
19210
- if (!this._isFormAddNew()) return [3 /*break*/, 6];
19433
+ return [3 /*break*/, 10];
19434
+ case 8:
19435
+ if (!this._isFormAddNew()) return [3 /*break*/, 10];
19211
19436
  return [4 /*yield*/, this.onInsert()];
19212
- case 5:
19437
+ case 9:
19213
19438
  _e.sent();
19214
- return [3 /*break*/, 6];
19215
- case 6: return [3 /*break*/, 8];
19216
- case 7:
19439
+ return [3 /*break*/, 10];
19440
+ case 10: return [3 /*break*/, 12];
19441
+ case 11:
19217
19442
  this.handleManualSave();
19218
- _e.label = 8;
19219
- case 8: return [3 /*break*/, 10];
19220
- case 9:
19443
+ _e.label = 12;
19444
+ case 12: return [3 /*break*/, 14];
19445
+ case 13:
19221
19446
  this.model.submitting = false;
19222
- _e.label = 10;
19223
- case 10: return [2 /*return*/];
19447
+ _e.label = 14;
19448
+ case 14: return [2 /*return*/];
19224
19449
  }
19225
19450
  });
19226
19451
  });
@@ -19429,6 +19654,9 @@
19429
19654
  _this.model.submitting = false;
19430
19655
  _this.showMessageAfterUpdate(false, error);
19431
19656
  });
19657
+ if (this.logSetting.isEnableLog) {
19658
+ this.logSetting.arrValueAfterUpdate = [];
19659
+ }
19432
19660
  return [2 /*return*/];
19433
19661
  });
19434
19662
  });
@@ -27957,7 +28185,7 @@
27957
28185
  lstHeader = ['TT'];
27958
28186
  fieldSchemaMap = new Map(this.setting.modelSchemas.map(function (schema) { return [schema.field, schema.name]; }));
27959
28187
  lstVisibleField.forEach(function (field) {
27960
- var schemaName = fieldSchemaMap.get(field) || fieldSchemaMap.get(field.slice(3)) || "";
28188
+ var schemaName = fieldSchemaMap.get(field) || fieldSchemaMap.get(field.slice(3)) || '';
27961
28189
  lstHeader.push(schemaName);
27962
28190
  });
27963
28191
  printData = __spreadArray([
@@ -56346,6 +56574,7 @@
56346
56574
  exports.DataExcel = DataExcel;
56347
56575
  exports.DataFormBase = DataFormBase;
56348
56576
  exports.DataListBase = DataListBase;
56577
+ exports.DataSourceBoolean = DataSourceBoolean;
56349
56578
  exports.DataSourceControlSchema = DataSourceControlSchema;
56350
56579
  exports.DataSourceGioiTinh = DataSourceGioiTinh;
56351
56580
  exports.DataSourcePermissionBase = DataSourcePermissionBase;
@@ -56450,6 +56679,8 @@
56450
56679
  exports.LengthValidator = LengthValidator;
56451
56680
  exports.ListHelperService = ListHelperService;
56452
56681
  exports.LocalCacheService = LocalCacheService;
56682
+ exports.LogColumn = LogColumn;
56683
+ exports.LogSetting = LogSetting;
56453
56684
  exports.LowerCorrector = LowerCorrector;
56454
56685
  exports.LstEmailValidator = LstEmailValidator;
56455
56686
  exports.MA_THONG_BAO_PHAN_HE = MA_THONG_BAO_PHAN_HE;