hl-core 0.0.7-beta.13 → 0.0.7-beta.15

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.
@@ -2,7 +2,7 @@ import { defineStore } from 'pinia';
2
2
  import { t } from './messages';
3
3
  import { rules } from './rules';
4
4
  import { Toast, Types, Positions, ToastOptions } from './toast';
5
- import { isValidGUID, yearEnding, jwtDecode } from '../composables';
5
+ import { isValidGUID, yearEnding, jwtDecode, ErrorHandler, getKeyWithPattern } from '../composables';
6
6
  import { DataStoreClass, Contragent } from '../composables/classes';
7
7
  import { ApiClass } from '@/api';
8
8
  import { useFormStore } from './form.store';
@@ -16,6 +16,7 @@ export const useDataStore = defineStore('data', {
16
16
  toastTypes: Types,
17
17
  toastPositions: Positions,
18
18
  isValidGUID: isValidGUID,
19
+ route: useRoute(),
19
20
  router: useRouter(),
20
21
  formStore: useFormStore(),
21
22
  contragent: useContragentStore(),
@@ -82,7 +83,6 @@ export const useDataStore = defineStore('data', {
82
83
  async loginUser(login, password, numAttempt) {
83
84
  try {
84
85
  const token = localStorage.getItem('accessToken') || null;
85
-
86
86
  if (token && isValidToken(token)) {
87
87
  this.accessToken = token;
88
88
  this.getUserRoles();
@@ -97,28 +97,34 @@ export const useDataStore = defineStore('data', {
97
97
  this.refreshToken = response.refreshToken;
98
98
  this.getUserRoles();
99
99
  }
100
- if (
101
- this.isManager() ||
102
- this.isUnderwriter() ||
103
- this.isAdmin() ||
104
- this.isAgent() ||
105
- this.isCompliance() ||
106
- this.isAgentMycar() ||
107
- this.isAnalyst() ||
108
- this.isUpk() ||
109
- this.isFinanceCenter() ||
110
- this.isSupervisor()
111
- ) {
100
+ if (this.controls.onAuth) {
101
+ const hasPermission =
102
+ this.isManager() ||
103
+ this.isUnderwriter() ||
104
+ this.isAdmin() ||
105
+ this.isAgent() ||
106
+ this.isCompliance() ||
107
+ this.isAgentMycar() ||
108
+ this.isAnalyst() ||
109
+ this.isUpk() ||
110
+ this.isFinanceCenter() ||
111
+ this.isSupervisor() ||
112
+ this.isSupport() ||
113
+ this.isManagerHalykBank();
114
+ if (hasPermission) {
115
+ localStorage.setItem('accessToken', this.accessToken);
116
+ localStorage.setItem('refreshToken', this.refreshToken);
117
+ } else {
118
+ this.showToaster('error', this.t('toaster.noProductPermission'), 5000);
119
+ this.accessToken = null;
120
+ this.refreshToken = null;
121
+ }
122
+ } else {
112
123
  localStorage.setItem('accessToken', this.accessToken);
113
124
  localStorage.setItem('refreshToken', this.refreshToken);
114
- } else {
115
- this.showToaster('error', this.t('toaster.noProductPermission'), 5000);
116
125
  }
117
126
  } catch (err) {
118
- console.log(err);
119
- if ('response' in err) {
120
- this.showToaster('error', err.response.data, 3000);
121
- }
127
+ ErrorHandler(err);
122
128
  }
123
129
  },
124
130
  getUserRoles() {
@@ -145,7 +151,7 @@ export const useDataStore = defineStore('data', {
145
151
  return !!isRole;
146
152
  },
147
153
  isInitiator() {
148
- return this.isRole(constants.roles.manager) || this.isRole(constants.roles.agent) || this.isRole(constants.roles.agentMycar);
154
+ return this.isManager() || this.isAgent() || this.isAgentMycar();
149
155
  },
150
156
  isManager() {
151
157
  return this.isRole(constants.roles.manager);
@@ -159,6 +165,9 @@ export const useDataStore = defineStore('data', {
159
165
  isAgent() {
160
166
  return this.isRole(constants.roles.agent);
161
167
  },
168
+ isManagerHalykBank() {
169
+ return this.isRole(constants.roles.managerHalykBank);
170
+ },
162
171
  isUnderwriter() {
163
172
  return this.isRole(constants.roles.underwriter);
164
173
  },
@@ -171,19 +180,26 @@ export const useDataStore = defineStore('data', {
171
180
  isUpk() {
172
181
  return this.isRole(constants.roles.upk);
173
182
  },
183
+ isSupport() {
184
+ return this.isRole(constants.roles.support);
185
+ },
174
186
  isFinanceCenter() {
175
187
  return this.isRole(constants.roles.financeCenter);
176
188
  },
177
189
  isSupervisor() {
178
190
  return this.isRole(constants.roles.supervisor);
179
191
  },
180
-
181
192
  isProcessEditable(statusCode) {
182
193
  return !!constants.editableStatuses.find(status => status === statusCode);
183
194
  },
184
195
  isTask() {
185
196
  return this.formStore.applicationData.processInstanceId != 0 && this.formStore.applicationData.isTask;
186
197
  },
198
+ resetSelected() {
199
+ this.settings.open = false;
200
+ this.menu.selectedItem = new MenuItem();
201
+ this.router.replace({ name: this.route.name });
202
+ },
187
203
  async logoutUser() {
188
204
  this.isLoading = true;
189
205
  try {
@@ -1002,7 +1018,7 @@ export const useDataStore = defineStore('data', {
1002
1018
  };
1003
1019
 
1004
1020
  if (getDataCondition()) {
1005
- this.whichField = [];
1021
+ this[whichField] = [];
1006
1022
  try {
1007
1023
  const response = await this.api[whichRequest](parameter);
1008
1024
  if (response) {
@@ -1015,9 +1031,6 @@ export const useDataStore = defineStore('data', {
1015
1031
  }),
1016
1032
  );
1017
1033
  this[whichField] = response;
1018
- if (this[whichField].length && this[whichField][this[whichField].length - 1].nameRu == 'невключено') {
1019
- this[whichField].unshift(this[whichField].pop());
1020
- }
1021
1034
  }
1022
1035
  } catch (err) {
1023
1036
  console.log(err);
@@ -12,13 +12,32 @@ export const useMemberStore = defineStore('members', {
12
12
  }),
13
13
  getters: {},
14
14
  actions: {
15
+ isStatementEditible(whichForm: string, showToaster: boolean = false) {
16
+ if (this.formStore.isDisabled[whichForm as keyof typeof this.formStore.isDisabled] === true) {
17
+ if (showToaster) this.dataStore.showToaster('error', this.dataStore.t('toaster.viewErrorText'), 2000);
18
+ return false;
19
+ }
20
+ return true;
21
+ },
22
+ validateInitiator(showToaster: boolean = true) {
23
+ if (!this.dataStore.isInitiator()) {
24
+ if (showToaster) this.dataStore.showToaster('error', this.dataStore.t('toaster.viewErrorText'));
25
+ return false;
26
+ }
27
+ return true;
28
+ },
15
29
  hasMemberData(whichForm: keyof typeof this.formStore, whichIndex?: number, key: string = 'id', emptyValue: any = 0) {
16
30
  if (!this.validateInitiator(false)) return false;
31
+ if (!this.isStatementEditible(whichForm)) return false;
17
32
  return typeof whichIndex === 'number' ? this.formStore[whichForm][whichIndex][key] != emptyValue : this.formStore[whichForm][key] != emptyValue;
18
33
  },
19
34
  canMemberDeleted(whichForm: keyof typeof this.formStore, whichIndex?: number) {
20
35
  if (!whichForm) return false;
36
+ if (!this.isStatementEditible(whichForm)) return false;
21
37
  if (!this.validateInitiator(false)) return false;
38
+ if (typeof whichIndex === 'number' && whichIndex > 0) {
39
+ return true;
40
+ }
22
41
  if (this.dataStore.isTask() && this.dataStore.isProcessEditable(this.formStore.applicationData.statusCode)) {
23
42
  if (whichForm !== this.formStore.policyholderFormKey) {
24
43
  return this.hasMemberData(whichForm, whichIndex);
@@ -27,7 +46,6 @@ export const useMemberStore = defineStore('members', {
27
46
  return false;
28
47
  },
29
48
  getMemberFromStore(whichForm: keyof typeof this.formStore, whichIndex?: number) {
30
- if (!whichForm) return false;
31
49
  switch (whichForm) {
32
50
  case this.formStore.policyholderFormKey:
33
51
  return this.formStore.policyholderForm;
@@ -39,6 +57,8 @@ export const useMemberStore = defineStore('members', {
39
57
  return this.formStore.beneficiaryForm[whichIndex!];
40
58
  case this.formStore.beneficialOwnerFormKey:
41
59
  return this.formStore.beneficialOwnerForm[whichIndex!];
60
+ default:
61
+ return this.formStore.policyholderForm;
42
62
  }
43
63
  },
44
64
  getMemberFromApplication(whichForm: keyof typeof this.formStore, whichIndex?: number) {
@@ -91,15 +111,9 @@ export const useMemberStore = defineStore('members', {
91
111
  return 'Spokesman';
92
112
  }
93
113
  },
94
- validateInitiator(showToaster: boolean = true) {
95
- if (!this.dataStore.isInitiator()) {
96
- if (showToaster) this.dataStore.showToaster('error', this.dataStore.t('toaster.viewErrorText'));
97
- return false;
98
- }
99
- return true;
100
- },
101
114
  clearMember(whichForm: keyof typeof this.formStore, whichIndex?: number) {
102
115
  if (!whichForm) return false;
116
+ if (!this.isStatementEditible(whichForm)) return false;
103
117
  if (!this.validateInitiator()) return false;
104
118
  const memberClass = this.getMemberClass(whichForm);
105
119
  if (!memberClass) return false;
@@ -120,24 +134,31 @@ export const useMemberStore = defineStore('members', {
120
134
  },
121
135
  async deleteMember(whichForm: keyof typeof this.formStore, whichIndex?: number) {
122
136
  if (!whichForm) return false;
137
+ if (!this.isStatementEditible(whichForm)) return false;
123
138
  if (!this.validateInitiator()) return false;
124
139
  try {
125
140
  const memberCode = this.getMemberCode(whichForm);
141
+ const memberData = this.getMemberFromApplication(whichForm, whichIndex);
126
142
  if (!memberCode) return false;
127
143
  if (typeof whichIndex !== 'number') {
128
144
  if (whichForm === this.formStore.policyholdersRepresentativeFormKey) {
129
145
  await this.dataStore.api.deleteMember(memberCode, this.formStore.applicationData.processInstanceId);
130
146
  }
131
147
  } else {
132
- const memberData = this.getMemberFromApplication(whichForm, whichIndex);
133
- if (!memberData) return false;
134
- await this.dataStore.api.deleteMember(memberCode, memberData.id as number);
148
+ if (memberData) await this.dataStore.api.deleteMember(memberCode, memberData.id as number);
135
149
  }
136
- await this.dataStore.getApplicationData(this.route.params.taskId, true, true, true, false);
150
+ if (memberData) await this.dataStore.getApplicationData(this.route.params.taskId, true, true, true, false);
137
151
  return this.clearMember(whichForm, whichIndex);
138
152
  } catch (err) {
153
+ console.log(err);
139
154
  return ErrorHandler(err);
140
155
  }
141
156
  },
157
+ addMember(whichForm: keyof typeof this.formStore) {
158
+ if (!whichForm) return false;
159
+ if (!this.isStatementEditible(whichForm)) return false;
160
+ if (!this.validateInitiator()) return false;
161
+ this.formStore[whichForm].push(this.getMemberClass(whichForm));
162
+ },
142
163
  },
143
164
  });
package/store/messages.ts CHANGED
@@ -92,6 +92,7 @@ export const messages = {
92
92
  tokenExpire: 'Истекло время ожидания',
93
93
  },
94
94
  buttons: {
95
+ add: 'Добавить',
95
96
  userLogin: 'Логин',
96
97
  password: 'Пароль',
97
98
  login: 'Вход в систему',
@@ -182,6 +183,8 @@ export const messages = {
182
183
  chooseAll: 'Выбрать все',
183
184
  statement: 'Заявление',
184
185
  policyholderForm: 'Страхователь',
186
+ policyholderAndInsured: 'Застрахованный / Страхователь',
187
+ policyholderAndInsuredSame: 'Застрахованный / Страхователь является одним лицом',
185
188
  insuredForm: 'Застрахованный',
186
189
  beneficiaryForm: 'Выгодоприобретатель',
187
190
  beneficialOwnerForm: 'Бенефициарный собственник',
@@ -191,6 +194,7 @@ export const messages = {
191
194
  recalculationInfo: 'Данные для перерасчета',
192
195
  generalConditions: 'Основные условия страхования',
193
196
  isPolicyholderInsured: 'Является ли страхователь застрахованным?',
197
+ isPolicyholderIPDL: 'Принадлежит ли и/или причастен ли Застрахованный / Страхователь или его члены семьи и близкие родственники к иностранному публичному должностному лицу?',
194
198
  isPolicyholderBeneficiary: 'Является ли страхователь выгодоприобретателем?',
195
199
  hasRepresentative: 'Подписантом договора выступает представитель? ',
196
200
  isActOwnBehalf: ' Клиент действует от своего имени и в своих интересах?',
@@ -228,6 +232,9 @@ export const messages = {
228
232
  conditions: 'Условия оплаты страховой премии',
229
233
  processTariff: 'Тариф',
230
234
  riskGroup: 'Группа риска',
235
+ requestedProductConditions: 'Запрашиваемые условия страхования',
236
+ coverPeriodFrom3to20: 'Срок страхования (от 3-х до 20 лет)',
237
+ insurancePremiumAmount: 'Размер Страховой премии (страховой взнос)',
231
238
  },
232
239
  history: {
233
240
  addRegNumber: 'Номер',