@shisyamo4131/air-guard-v2-schemas 2.3.7-dev.25 → 2.3.7-dev.27
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.
- package/package.json +1 -1
- package/src/Employee.js +75 -4
- package/src/parts/fieldDefinitions.js +5 -0
package/package.json
CHANGED
package/src/Employee.js
CHANGED
|
@@ -84,27 +84,42 @@ const classProps = {
|
|
|
84
84
|
// Security guard related fields
|
|
85
85
|
hasSecurityGuardRegistration: defField("check", { label: "警備員登録" }),
|
|
86
86
|
priorSecurityExperienceYears: defField("number", {
|
|
87
|
-
label: "年",
|
|
87
|
+
label: "入社前経験(年)",
|
|
88
88
|
default: 0,
|
|
89
|
+
required: true,
|
|
89
90
|
component: {
|
|
90
91
|
attrs: {
|
|
91
92
|
required: (item) => item.hasSecurityGuardRegistration,
|
|
92
93
|
disabled: (item) => !item.hasSecurityGuardRegistration,
|
|
94
|
+
suffix: "年",
|
|
93
95
|
},
|
|
94
96
|
},
|
|
95
97
|
}),
|
|
96
98
|
priorSecurityExperienceMonths: defField("number", {
|
|
97
|
-
label: "月",
|
|
99
|
+
label: "入社前経験(月)",
|
|
98
100
|
default: 0,
|
|
101
|
+
required: true,
|
|
99
102
|
component: {
|
|
100
103
|
attrs: {
|
|
101
104
|
required: (item) => item.hasSecurityGuardRegistration,
|
|
102
105
|
disabled: (item) => !item.hasSecurityGuardRegistration,
|
|
106
|
+
suffix: "ヶ月",
|
|
107
|
+
min: 0,
|
|
108
|
+
max: 11,
|
|
103
109
|
},
|
|
104
110
|
},
|
|
105
111
|
}),
|
|
106
112
|
dateOfSecurityGuardRegistration: defField("dateAt", {
|
|
107
113
|
label: "警備員登録日",
|
|
114
|
+
default: null,
|
|
115
|
+
component: {
|
|
116
|
+
attrs: {
|
|
117
|
+
required: (item) => item.hasSecurityGuardRegistration,
|
|
118
|
+
disabled: (item) => !item.hasSecurityGuardRegistration,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
}),
|
|
122
|
+
bloodType: defField("bloodType", {
|
|
108
123
|
component: {
|
|
109
124
|
attrs: {
|
|
110
125
|
required: (item) => item.hasSecurityGuardRegistration,
|
|
@@ -112,7 +127,6 @@ const classProps = {
|
|
|
112
127
|
},
|
|
113
128
|
},
|
|
114
129
|
}),
|
|
115
|
-
bloodType: defField("bloodType"),
|
|
116
130
|
emergencyContactName: defField("emergencyContactName", {
|
|
117
131
|
component: {
|
|
118
132
|
attrs: {
|
|
@@ -153,6 +167,14 @@ const classProps = {
|
|
|
153
167
|
},
|
|
154
168
|
},
|
|
155
169
|
}),
|
|
170
|
+
domicile: defField("domicile", {
|
|
171
|
+
component: {
|
|
172
|
+
attrs: {
|
|
173
|
+
required: (item) => item.hasSecurityGuardRegistration,
|
|
174
|
+
disabled: (item) => !item.hasSecurityGuardRegistration,
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
}),
|
|
156
178
|
|
|
157
179
|
remarks: defField("remarks"),
|
|
158
180
|
};
|
|
@@ -263,11 +285,12 @@ export default class Employee extends FireModel {
|
|
|
263
285
|
|
|
264
286
|
/**
|
|
265
287
|
* 入社日からの勤続年数を計算します。
|
|
288
|
+
* - 退職日が設定されている場合は、退職日までの勤続年数を計算します。
|
|
266
289
|
* @returns {{years: number, months: number}|null} 勤続年数(年数と月数)。dateOfHireが設定されていない場合はnull。
|
|
267
290
|
*/
|
|
268
291
|
get yearsOfService() {
|
|
269
292
|
if (!this.dateOfHire) return null;
|
|
270
|
-
const today = new Date();
|
|
293
|
+
const today = this.dateOfTermination || new Date();
|
|
271
294
|
|
|
272
295
|
let years = today.getUTCFullYear() - this.dateOfHire.getUTCFullYear();
|
|
273
296
|
let months = today.getUTCMonth() - this.dateOfHire.getUTCMonth();
|
|
@@ -355,6 +378,52 @@ export default class Employee extends FireModel {
|
|
|
355
378
|
}
|
|
356
379
|
}
|
|
357
380
|
|
|
381
|
+
_validateSecurityGuardFields() {
|
|
382
|
+
if (this.hasSecurityGuardRegistration) {
|
|
383
|
+
if (!this.dateOfSecurityGuardRegistration) {
|
|
384
|
+
throw new Error(
|
|
385
|
+
"[Employee.js] dateOfSecurityGuardRegistration is required when hasSecurityGuardRegistration is true."
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
if (!this.emergencyContactName) {
|
|
389
|
+
throw new Error(
|
|
390
|
+
"[Employee.js] emergencyContactName is required when hasSecurityGuardRegistration is true."
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
if (!this.emergencyContactRelationDetail) {
|
|
394
|
+
throw new Error(
|
|
395
|
+
"[Employee.js] emergencyContactRelationDetail is required when hasSecurityGuardRegistration is true."
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
if (!this.emergencyContactAddress) {
|
|
399
|
+
throw new Error(
|
|
400
|
+
"[Employee.js] emergencyContactAddress is required when hasSecurityGuardRegistration is true."
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
if (!this.emergencyContactPhone) {
|
|
404
|
+
throw new Error(
|
|
405
|
+
"[Employee.js] emergencyContactPhone is required when hasSecurityGuardRegistration is true."
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
if (!this.domicile) {
|
|
409
|
+
throw new Error(
|
|
410
|
+
"[Employee.js] domicile is required when hasSecurityGuardRegistration is true."
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
} else {
|
|
414
|
+
this.priorSecurityExperienceYears = 0;
|
|
415
|
+
this.priorSecurityExperienceMonths = 0;
|
|
416
|
+
this.dateOfSecurityGuardRegistration = null;
|
|
417
|
+
this.bloodType = BLOOD_TYPE_VALUES.A.value;
|
|
418
|
+
this.emergencyContactName = null;
|
|
419
|
+
this.emergencyContactRelation = null;
|
|
420
|
+
this.emergencyContactRelationDetail = null;
|
|
421
|
+
this.emergencyContactAddress = null;
|
|
422
|
+
this.emergencyContactPhone = null;
|
|
423
|
+
this.domicile = null;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
358
427
|
/**
|
|
359
428
|
* 新しい従業員ドキュメントが作成される前に実行されるフック。
|
|
360
429
|
* - 親クラスの `beforeCreate` を呼び出します。
|
|
@@ -364,6 +433,7 @@ export default class Employee extends FireModel {
|
|
|
364
433
|
await super.beforeCreate();
|
|
365
434
|
this._validateForeignerRequiredFields();
|
|
366
435
|
this._validateTerminatedRequiredFields();
|
|
436
|
+
this._validateSecurityGuardFields();
|
|
367
437
|
}
|
|
368
438
|
|
|
369
439
|
/**
|
|
@@ -390,6 +460,7 @@ export default class Employee extends FireModel {
|
|
|
390
460
|
|
|
391
461
|
this._validateForeignerRequiredFields();
|
|
392
462
|
this._validateTerminatedRequiredFields();
|
|
463
|
+
this._validateSecurityGuardFields();
|
|
393
464
|
}
|
|
394
465
|
|
|
395
466
|
/**
|