tnx-shared 5.3.310 → 5.3.312

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,46 @@
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
+ field: control.field,
19090
+ label: control.label,
19091
+ valueBefore: control._component.dataSource.map(function (p) { return p.label; }).join(', '),
19092
+ visible: false,
19093
+ valueAfter: ''
19094
+ }));
19095
+ }
19096
+ }
19097
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
19098
+ finally {
19099
+ try {
19100
+ if (_g && !_g.done && (_e = _f.return)) _e.call(_f);
19101
+ }
19102
+ finally { if (e_1) throw e_1.error; }
19103
+ }
19104
+ }, 2000);
19105
+ };
19042
19106
  DataFormBase.prototype.fixDateValue = function (control, parentModel, parentPath) {
19043
- var e_1, _e, e_2, _f, e_3, _g;
19107
+ var e_2, _e, e_3, _f, e_4, _g;
19044
19108
  var _parentPath = control.field;
19045
19109
  if (parentPath != null)
19046
19110
  _parentPath = parentPath + '.' + _parentPath;
@@ -19053,27 +19117,27 @@
19053
19117
  for (var _h = __values(parentModel[control.field]), _j = _h.next(); !_j.done; _j = _h.next()) {
19054
19118
  var item = _j.value;
19055
19119
  try {
19056
- for (var _k = (e_2 = void 0, __values(control.rowTemplate)), _l = _k.next(); !_l.done; _l = _k.next()) {
19120
+ for (var _k = (e_3 = void 0, __values(control.rowTemplate)), _l = _k.next(); !_l.done; _l = _k.next()) {
19057
19121
  var subControl = _l.value;
19058
19122
  this.fixDateValue(subControl, item, _parentPath + '[' + i + ']');
19059
19123
  }
19060
19124
  }
19061
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
19125
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
19062
19126
  finally {
19063
19127
  try {
19064
19128
  if (_l && !_l.done && (_f = _k.return)) _f.call(_k);
19065
19129
  }
19066
- finally { if (e_2) throw e_2.error; }
19130
+ finally { if (e_3) throw e_3.error; }
19067
19131
  }
19068
19132
  i++;
19069
19133
  }
19070
19134
  }
19071
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
19135
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
19072
19136
  finally {
19073
19137
  try {
19074
19138
  if (_j && !_j.done && (_e = _h.return)) _e.call(_h);
19075
19139
  }
19076
- finally { if (e_1) throw e_1.error; }
19140
+ finally { if (e_2) throw e_2.error; }
19077
19141
  }
19078
19142
  }
19079
19143
  else if (control instanceof ContainerSchema) {
@@ -19086,12 +19150,12 @@
19086
19150
  this.fixDateValue(subControl, parentModel[control.field], _parentPath);
19087
19151
  }
19088
19152
  }
19089
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
19153
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
19090
19154
  finally {
19091
19155
  try {
19092
19156
  if (_o && !_o.done && (_g = _m.return)) _g.call(_m);
19093
19157
  }
19094
- finally { if (e_3) throw e_3.error; }
19158
+ finally { if (e_4) throw e_4.error; }
19095
19159
  }
19096
19160
  }
19097
19161
  else {
@@ -19123,7 +19187,7 @@
19123
19187
  }
19124
19188
  };
19125
19189
  DataFormBase.prototype._addRequiredValidator = function (schema) {
19126
- var e_4, _e;
19190
+ var e_5, _e;
19127
19191
  var exist = false;
19128
19192
  try {
19129
19193
  for (var _f = __values(schema.validators), _g = _f.next(); !_g.done; _g = _f.next()) {
@@ -19134,12 +19198,12 @@
19134
19198
  }
19135
19199
  }
19136
19200
  }
19137
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
19201
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
19138
19202
  finally {
19139
19203
  try {
19140
19204
  if (_g && !_g.done && (_e = _f.return)) _e.call(_f);
19141
19205
  }
19142
- finally { if (e_4) throw e_4.error; }
19206
+ finally { if (e_5) throw e_5.error; }
19143
19207
  }
19144
19208
  if (!exist) {
19145
19209
  schema.validators.push(new RequiredValidator());
@@ -19147,7 +19211,7 @@
19147
19211
  schema.required = true;
19148
19212
  };
19149
19213
  DataFormBase.prototype._removeRequiredValidator = function (schema) {
19150
- var e_5, _e;
19214
+ var e_6, _e;
19151
19215
  var validators = [];
19152
19216
  try {
19153
19217
  for (var _f = __values(schema.validators), _g = _f.next(); !_g.done; _g = _f.next()) {
@@ -19159,12 +19223,12 @@
19159
19223
  }
19160
19224
  }
19161
19225
  }
19162
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
19226
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
19163
19227
  finally {
19164
19228
  try {
19165
19229
  if (_g && !_g.done && (_e = _f.return)) _e.call(_f);
19166
19230
  }
19167
- finally { if (e_5) throw e_5.error; }
19231
+ finally { if (e_6) throw e_6.error; }
19168
19232
  }
19169
19233
  schema.validators = validators;
19170
19234
  schema.required = false;
@@ -19187,6 +19251,157 @@
19187
19251
  DataFormBase.prototype._triggerSave = function () {
19188
19252
  this.save();
19189
19253
  };
19254
+ DataFormBase.prototype.onAfterGetLogValue = function () {
19255
+ return __awaiter(this, void 0, void 0, function () {
19256
+ return __generator(this, function (_e) {
19257
+ return [2 /*return*/];
19258
+ });
19259
+ });
19260
+ };
19261
+ DataFormBase.prototype.getSingleLabel = function (control, dataSource, valueParam) {
19262
+ var result = dataSource.find(function (p) { return p.value[control.valueField] == valueParam; });
19263
+ if (!!result) {
19264
+ var funcGetLabel = control.funcGetLabel;
19265
+ if (funcGetLabel) {
19266
+ result = funcGetLabel(result.value);
19267
+ }
19268
+ }
19269
+ else {
19270
+ result = this.logSetting.emptyValue;
19271
+ }
19272
+ return result;
19273
+ };
19274
+ DataFormBase.prototype.getMultipleLabel = function (control, dataSource, valueParam) {
19275
+ try {
19276
+ if (valueParam.some(function (p) { return p == Number(p); })) {
19277
+ valueParam = valueParam.map(function (p) { return Number(p); });
19278
+ }
19279
+ }
19280
+ catch (_a) { }
19281
+ var result = dataSource
19282
+ .filter(function (p) { return valueParam.includes(p.value[control.valueField]); })
19283
+ .map(function (p) { return control.funcGetLabel(p.value); })
19284
+ .join(', ');
19285
+ if (!result) {
19286
+ result = this.logSetting.emptyValue;
19287
+ }
19288
+ return result;
19289
+ };
19290
+ DataFormBase.prototype.addSinglePropertyLog = function (control, oldValue, newValue) {
19291
+ if (control instanceof AutoCompletePickerControlSchema) {
19292
+ var logColumn = this.logSetting.arrValueAfterUpdate.find(function (p) { return p.field == control.field; });
19293
+ var dataSource = control._component.selectedValueObject;
19294
+ if (!Array.isArray(dataSource))
19295
+ dataSource = [dataSource];
19296
+ logColumn.visible = true;
19297
+ logColumn.valueAfter = this.getSingleLabel(control, dataSource, newValue);
19298
+ }
19299
+ else {
19300
+ var dataSource = control._component.dataSourceInternal;
19301
+ this.logSetting.arrValueAfterUpdate.push(new LogColumn({
19302
+ field: control.field,
19303
+ label: control.label,
19304
+ valueBefore: this.getSingleLabel(control, dataSource, oldValue),
19305
+ valueAfter: this.getSingleLabel(control, dataSource, newValue)
19306
+ }));
19307
+ }
19308
+ };
19309
+ DataFormBase.prototype.addMultiplePropertyLog = function (control, oldValue, newValue) {
19310
+ if (control instanceof AutoCompletePickerControlSchema) {
19311
+ var logColumn = this.logSetting.arrValueAfterUpdate.find(function (p) { return p.field == control.field; });
19312
+ logColumn.visible = true;
19313
+ logColumn.valueAfter = this.getMultipleLabel(control, control._component.selectedValueObject, newValue);
19314
+ }
19315
+ else {
19316
+ var dataSource = control._component.dataSourceInternal;
19317
+ this.logSetting.arrValueAfterUpdate.push(new LogColumn({
19318
+ field: control.field,
19319
+ label: control.label,
19320
+ valueBefore: this.getMultipleLabel(control, dataSource, oldValue),
19321
+ valueAfter: this.getMultipleLabel(control, dataSource, newValue)
19322
+ }));
19323
+ }
19324
+ };
19325
+ DataFormBase.prototype.getLogValueDefault = function (control, oldValue, newValue) {
19326
+ var _a, _b;
19327
+ var isNullOldValue = this.isNullOrEmpty(oldValue);
19328
+ var isNullNewValue = this.isNullOrEmpty(newValue);
19329
+ if (control instanceof DateTimeControlSchema) {
19330
+ var format = control.showTime ? 'HH:mm dd/MM/yyyy' : 'dd/MM/yyyy';
19331
+ oldValue = isNullOldValue ? this.logSetting.emptyValue : this._datePipe.transform(oldValue, format);
19332
+ newValue = isNullNewValue ? this.logSetting.emptyValue : this._datePipe.transform(newValue, format);
19333
+ }
19334
+ else if (control instanceof MaskControlSchema) {
19335
+ oldValue = isNullOldValue ? this.logSetting.emptyValue : this._numberPipe.transform(oldValue, '', 'vi-VN');
19336
+ newValue = isNullNewValue ? this.logSetting.emptyValue : this._numberPipe.transform(newValue, '', 'vi-VN');
19337
+ }
19338
+ else if (control instanceof CheckboxControlSchema || control instanceof SwitchControlSchema) {
19339
+ oldValue = isNullOldValue ? this.logSetting.emptyValue : (_a = DataSourceBoolean.find(function (p) { return p.id == oldValue; })) === null || _a === void 0 ? void 0 : _a.ten;
19340
+ newValue = isNullNewValue ? this.logSetting.emptyValue : (_b = DataSourceBoolean.find(function (p) { return p.id == newValue; })) === null || _b === void 0 ? void 0 : _b.ten;
19341
+ }
19342
+ return [oldValue, newValue];
19343
+ };
19344
+ DataFormBase.prototype.getLogValue = function () {
19345
+ var e_7, _e;
19346
+ var _a;
19347
+ try {
19348
+ var cloneModel = this._commonService.cloneObject(this.model.data);
19349
+ try {
19350
+ for (var _f = __values(Object.keys(this.formControls)), _g = _f.next(); !_g.done; _g = _f.next()) {
19351
+ var controlName = _g.value;
19352
+ if (controlName.includes('.') || ((_a = this.crudForm.formControls[controlName]) === null || _a === void 0 ? void 0 : _a.hidden) === true)
19353
+ continue;
19354
+ var control = this.formControls[controlName];
19355
+ var oldValue = this.logSetting.valueBeforeUpdate[control.field];
19356
+ var newValue = cloneModel[control.field];
19357
+ var isMultiple = Array.isArray(oldValue);
19358
+ if (!this.isNullOrEmpty(oldValue) || !this.isNullOrEmpty(newValue)) {
19359
+ if (control instanceof DropdownControlSchema || control instanceof AutoCompletePickerControlSchema) {
19360
+ if (!isMultiple && oldValue != newValue) {
19361
+ this.addSinglePropertyLog(control, oldValue, newValue);
19362
+ }
19363
+ else if (isMultiple && !this._commonService.isSameArray(oldValue, newValue)) {
19364
+ this.addMultiplePropertyLog(control, oldValue, newValue);
19365
+ }
19366
+ }
19367
+ else {
19368
+ if (oldValue != newValue) {
19369
+ var _h = __read(this.getLogValueDefault(control, oldValue, newValue), 2), valueBefore = _h[0], valueAfter = _h[1];
19370
+ this.logSetting.arrValueAfterUpdate.push(new LogColumn({
19371
+ field: control.field,
19372
+ label: control.label,
19373
+ valueBefore: valueBefore,
19374
+ valueAfter: valueAfter,
19375
+ isHtml: (control instanceof EditorControlSchema || control instanceof TextAreaControlSchema)
19376
+ }));
19377
+ }
19378
+ }
19379
+ }
19380
+ }
19381
+ }
19382
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
19383
+ finally {
19384
+ try {
19385
+ if (_g && !_g.done && (_e = _f.return)) _e.call(_f);
19386
+ }
19387
+ finally { if (e_7) throw e_7.error; }
19388
+ }
19389
+ }
19390
+ catch (_b) {
19391
+ console.error('----log data fail----');
19392
+ }
19393
+ };
19394
+ DataFormBase.prototype.isNullOrEmpty = function (input) {
19395
+ if (input !== undefined && input !== null) {
19396
+ if (Array.isArray(input)) {
19397
+ return input.length ? false : true;
19398
+ }
19399
+ if (input.toString().trim() !== '') {
19400
+ return false;
19401
+ }
19402
+ }
19403
+ return true;
19404
+ };
19190
19405
  DataFormBase.prototype.save = function () {
19191
19406
  return __awaiter(this, void 0, void 0, function () {
19192
19407
  var validated;
@@ -19195,32 +19410,46 @@
19195
19410
  case 0: return [4 /*yield*/, this.validateFormBase()];
19196
19411
  case 1:
19197
19412
  validated = _e.sent();
19198
- if (!validated) return [3 /*break*/, 9];
19199
- return [4 /*yield*/, this.onBeforeSave()];
19413
+ if (!validated) return [3 /*break*/, 13];
19414
+ if (!this.logSetting.isEnableLog) return [3 /*break*/, 5];
19415
+ if (!!this.logSetting.isCustomAll) return [3 /*break*/, 3];
19416
+ return [4 /*yield*/, this.getLogValue()];
19200
19417
  case 2:
19418
+ _e.sent();
19419
+ _e.label = 3;
19420
+ case 3:
19421
+ // cấu hình thêm
19422
+ return [4 /*yield*/, this.onAfterGetLogValue()];
19423
+ case 4:
19424
+ // cấu hình thêm
19425
+ _e.sent();
19426
+ this.model.data.logMetaData = JSON.stringify(this.logSetting.arrValueAfterUpdate.filter(function (p) { return p.visible; }));
19427
+ _e.label = 5;
19428
+ case 5: return [4 /*yield*/, this.onBeforeSave()];
19429
+ case 6:
19201
19430
  _e.sent();
19202
19431
  this.triggerSaveFileUpload();
19203
- if (!this.autoSave) return [3 /*break*/, 7];
19204
- if (!(this._isFormEdit() || this._isFormView())) return [3 /*break*/, 4];
19432
+ if (!this.autoSave) return [3 /*break*/, 11];
19433
+ if (!(this._isFormEdit() || this._isFormView())) return [3 /*break*/, 8];
19205
19434
  return [4 /*yield*/, this.onUpdate()];
19206
- case 3:
19435
+ case 7:
19207
19436
  _e.sent();
19208
- return [3 /*break*/, 6];
19209
- case 4:
19210
- if (!this._isFormAddNew()) return [3 /*break*/, 6];
19437
+ return [3 /*break*/, 10];
19438
+ case 8:
19439
+ if (!this._isFormAddNew()) return [3 /*break*/, 10];
19211
19440
  return [4 /*yield*/, this.onInsert()];
19212
- case 5:
19441
+ case 9:
19213
19442
  _e.sent();
19214
- return [3 /*break*/, 6];
19215
- case 6: return [3 /*break*/, 8];
19216
- case 7:
19443
+ return [3 /*break*/, 10];
19444
+ case 10: return [3 /*break*/, 12];
19445
+ case 11:
19217
19446
  this.handleManualSave();
19218
- _e.label = 8;
19219
- case 8: return [3 /*break*/, 10];
19220
- case 9:
19447
+ _e.label = 12;
19448
+ case 12: return [3 /*break*/, 14];
19449
+ case 13:
19221
19450
  this.model.submitting = false;
19222
- _e.label = 10;
19223
- case 10: return [2 /*return*/];
19451
+ _e.label = 14;
19452
+ case 14: return [2 /*return*/];
19224
19453
  }
19225
19454
  });
19226
19455
  });
@@ -19429,6 +19658,9 @@
19429
19658
  _this.model.submitting = false;
19430
19659
  _this.showMessageAfterUpdate(false, error);
19431
19660
  });
19661
+ if (this.logSetting.isEnableLog) {
19662
+ this.logSetting.arrValueAfterUpdate = [];
19663
+ }
19432
19664
  return [2 /*return*/];
19433
19665
  });
19434
19666
  });
@@ -27957,7 +28189,7 @@
27957
28189
  lstHeader = ['TT'];
27958
28190
  fieldSchemaMap = new Map(this.setting.modelSchemas.map(function (schema) { return [schema.field, schema.name]; }));
27959
28191
  lstVisibleField.forEach(function (field) {
27960
- var schemaName = fieldSchemaMap.get(field) || fieldSchemaMap.get(field.slice(3)) || "";
28192
+ var schemaName = fieldSchemaMap.get(field) || fieldSchemaMap.get(field.slice(3)) || '';
27961
28193
  lstHeader.push(schemaName);
27962
28194
  });
27963
28195
  printData = __spreadArray([
@@ -56346,6 +56578,7 @@
56346
56578
  exports.DataExcel = DataExcel;
56347
56579
  exports.DataFormBase = DataFormBase;
56348
56580
  exports.DataListBase = DataListBase;
56581
+ exports.DataSourceBoolean = DataSourceBoolean;
56349
56582
  exports.DataSourceControlSchema = DataSourceControlSchema;
56350
56583
  exports.DataSourceGioiTinh = DataSourceGioiTinh;
56351
56584
  exports.DataSourcePermissionBase = DataSourcePermissionBase;
@@ -56450,6 +56683,8 @@
56450
56683
  exports.LengthValidator = LengthValidator;
56451
56684
  exports.ListHelperService = ListHelperService;
56452
56685
  exports.LocalCacheService = LocalCacheService;
56686
+ exports.LogColumn = LogColumn;
56687
+ exports.LogSetting = LogSetting;
56453
56688
  exports.LowerCorrector = LowerCorrector;
56454
56689
  exports.LstEmailValidator = LstEmailValidator;
56455
56690
  exports.MA_THONG_BAO_PHAN_HE = MA_THONG_BAO_PHAN_HE;