@shisyamo4131/air-guard-v2-schemas 2.3.7-dev.15 → 2.3.7-dev.17
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 +96 -48
- package/src/parts/accessorDefinitions.js +11 -27
- package/src/parts/fieldDefinitions.js +37 -1
package/package.json
CHANGED
package/src/Employee.js
CHANGED
|
@@ -15,9 +15,8 @@ const classProps = {
|
|
|
15
15
|
lastNameKana: defField("lastNameKana", { required: true }),
|
|
16
16
|
firstNameKana: defField("firstNameKana", { required: true }),
|
|
17
17
|
displayName: defField("displayName", { required: true }),
|
|
18
|
-
title: defField("oneLine", { label: "肩書", required: true }),
|
|
19
18
|
gender: defField("gender", { required: true }),
|
|
20
|
-
dateOfBirth: defField("
|
|
19
|
+
dateOfBirth: defField("dateOfBirth", { required: true }),
|
|
21
20
|
zipcode: defField("zipcode", { required: true }),
|
|
22
21
|
prefCode: defField("prefCode", { required: true }),
|
|
23
22
|
city: defField("city", { required: true }),
|
|
@@ -26,10 +25,10 @@ const classProps = {
|
|
|
26
25
|
location: defField("location", { hidden: true }), // 非表示でOK
|
|
27
26
|
mobile: defField("mobile", { required: true }),
|
|
28
27
|
email: defField("email", { required: false }),
|
|
29
|
-
dateOfHire: defField("
|
|
28
|
+
dateOfHire: defField("dateOfHire", { required: true }),
|
|
30
29
|
employmentStatus: defField("employmentStatus", { required: true }),
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
title: defField("title"),
|
|
31
|
+
dateOfTermination: defField("dateOfTermination", {
|
|
33
32
|
default: null,
|
|
34
33
|
component: {
|
|
35
34
|
attrs: {
|
|
@@ -52,60 +51,61 @@ const classProps = {
|
|
|
52
51
|
},
|
|
53
52
|
},
|
|
54
53
|
}),
|
|
55
|
-
residenceStatus: {
|
|
56
|
-
type: String,
|
|
57
|
-
default: null,
|
|
58
|
-
label: "在留資格",
|
|
59
|
-
required: undefined,
|
|
54
|
+
residenceStatus: defField("residenceStatus", {
|
|
60
55
|
component: {
|
|
61
|
-
name: "air-text-field",
|
|
62
56
|
attrs: {
|
|
63
57
|
required: (item) => item.isForeigner,
|
|
64
58
|
},
|
|
65
59
|
},
|
|
66
|
-
},
|
|
67
|
-
periodOfStay: defField("
|
|
68
|
-
label: "在留期間満了日",
|
|
60
|
+
}),
|
|
61
|
+
periodOfStay: defField("periodOfStay", {
|
|
69
62
|
component: {
|
|
70
63
|
attrs: {
|
|
71
64
|
required: (item) => item.isForeigner,
|
|
72
65
|
},
|
|
73
66
|
},
|
|
74
67
|
}),
|
|
75
|
-
remarks: defField("
|
|
68
|
+
remarks: defField("remarks"),
|
|
76
69
|
};
|
|
77
70
|
|
|
78
71
|
/*****************************************************************************
|
|
79
|
-
* Employee
|
|
80
|
-
* @
|
|
81
|
-
* @
|
|
82
|
-
* @
|
|
83
|
-
* @
|
|
84
|
-
* @
|
|
85
|
-
* @
|
|
86
|
-
* @
|
|
87
|
-
* @
|
|
88
|
-
* @
|
|
89
|
-
* @
|
|
90
|
-
* @
|
|
91
|
-
* @
|
|
92
|
-
* @
|
|
93
|
-
* @
|
|
94
|
-
* @
|
|
95
|
-
* @
|
|
96
|
-
* @
|
|
97
|
-
* @
|
|
98
|
-
* @
|
|
99
|
-
* @
|
|
100
|
-
* @
|
|
101
|
-
* @
|
|
102
|
-
* @
|
|
103
|
-
* @
|
|
104
|
-
* @
|
|
105
|
-
*
|
|
106
|
-
* @
|
|
107
|
-
* @
|
|
108
|
-
* @
|
|
72
|
+
* @prop {string} code - Employee code.
|
|
73
|
+
* @prop {string} lastName - Last name.
|
|
74
|
+
* @prop {string} firstName - First name.
|
|
75
|
+
* @prop {string} lastNameKana - Last name in Kana.
|
|
76
|
+
* @prop {string} firstNameKana - First name in Kana.
|
|
77
|
+
* @prop {string} displayName - Display name.
|
|
78
|
+
* @prop {string} gender - Gender.
|
|
79
|
+
* @prop {Date} dateOfBirth - Date of birth.
|
|
80
|
+
* @prop {string} zipcode - Postal code.
|
|
81
|
+
* @prop {string} prefCode - Prefecture code.
|
|
82
|
+
* @prop {string} city - City name.
|
|
83
|
+
* @prop {string} address - Address details.
|
|
84
|
+
* @prop {string} building - Building name.
|
|
85
|
+
* @prop {object} location - Geographical location.
|
|
86
|
+
* @prop {string} mobile - Mobile phone number.
|
|
87
|
+
* @prop {string} email - Email address.
|
|
88
|
+
* @prop {Date} dateOfHire - Date of hire.
|
|
89
|
+
* @prop {string} employmentStatus - Employment status.
|
|
90
|
+
* @prop {string} title - Job title.
|
|
91
|
+
* @prop {Date} dateOfTermination - Date of termination.
|
|
92
|
+
* @prop {boolean} isForeigner - Is the employee a foreigner.
|
|
93
|
+
* @prop {string} foreignName - Foreign name.
|
|
94
|
+
* @prop {string} nationality - Nationality.
|
|
95
|
+
* @prop {string} residenceStatus - Residence status.
|
|
96
|
+
* @prop {Date} periodOfStay - Period of stay expiration date.
|
|
97
|
+
* @prop {string} remarks - Additional remarks.
|
|
98
|
+
*
|
|
99
|
+
* @prop {string} fullName - Full name combining last and first names (read-only)
|
|
100
|
+
* @prop {string} fullNameKana - Full name in Kana combining last and first names (read-only)
|
|
101
|
+
* @prop {string} fullAddress - Full address combining prefecture, city, and address (read-only)
|
|
102
|
+
* @prop {string} prefecture - Prefecture name derived from `prefCode` (read-only)
|
|
103
|
+
* @prop {number} age - Age calculated from `dateOfBirth` (read-only)
|
|
104
|
+
* @prop {number} yearsOfService - Years of service calculated from `dateOfHire` (read-only)
|
|
105
|
+
*
|
|
106
|
+
* @static
|
|
107
|
+
* @prop {string} STATUS_ACTIVE - constant for active employment status
|
|
108
|
+
* @prop {string} STATUS_TERMINATED - constant for terminated employment status
|
|
109
109
|
*****************************************************************************/
|
|
110
110
|
export default class Employee extends FireModel {
|
|
111
111
|
static className = "従業員";
|
|
@@ -114,6 +114,7 @@ export default class Employee extends FireModel {
|
|
|
114
114
|
static logicalDelete = true;
|
|
115
115
|
static classProps = classProps;
|
|
116
116
|
static tokenFields = [
|
|
117
|
+
"code",
|
|
117
118
|
"lastName",
|
|
118
119
|
"firstName",
|
|
119
120
|
"lastNameKana",
|
|
@@ -134,14 +135,50 @@ export default class Employee extends FireModel {
|
|
|
134
135
|
super.afterInitialize(item);
|
|
135
136
|
Object.defineProperties(this, {
|
|
136
137
|
fullName: defAccessor("fullName"),
|
|
138
|
+
fullNameKana: defAccessor("fullNameKana"),
|
|
137
139
|
fullAddress: defAccessor("fullAddress"),
|
|
138
140
|
prefecture: defAccessor("prefecture"),
|
|
141
|
+
age: {
|
|
142
|
+
enumerable: true,
|
|
143
|
+
configurable: true,
|
|
144
|
+
get() {
|
|
145
|
+
if (!this.dateOfBirth) return null;
|
|
146
|
+
const today = new Date();
|
|
147
|
+
let age = today.getUTCFullYear() - this.dateOfBirth.getUTCFullYear();
|
|
148
|
+
const m = today.getUTCMonth() - this.dateOfBirth.getUTCMonth();
|
|
149
|
+
const d = today.getUTCDate() - this.dateOfBirth.getUTCDate();
|
|
150
|
+
if (m < 0 || (m === 0 && d < 0)) age--;
|
|
151
|
+
return age;
|
|
152
|
+
},
|
|
153
|
+
set() {},
|
|
154
|
+
},
|
|
155
|
+
yearsOfService: {
|
|
156
|
+
enumerable: true,
|
|
157
|
+
configurable: true,
|
|
158
|
+
get() {
|
|
159
|
+
if (!this.dateOfHire) return null;
|
|
160
|
+
const today = new Date();
|
|
161
|
+
let years = today.getUTCFullYear() - this.dateOfHire.getUTCFullYear();
|
|
162
|
+
const m = today.getUTCMonth() - this.dateOfHire.getUTCMonth();
|
|
163
|
+
const d = today.getUTCDate() - this.dateOfHire.getUTCDate();
|
|
164
|
+
if (m < 0 || (m === 0 && d < 0)) years--;
|
|
165
|
+
return years;
|
|
166
|
+
},
|
|
167
|
+
set() {},
|
|
168
|
+
},
|
|
139
169
|
});
|
|
140
170
|
}
|
|
141
171
|
|
|
142
172
|
/**
|
|
143
173
|
* 外国籍の場合の必須フィールドを検証します。
|
|
144
|
-
* エラーがある場合は例外をスローします。
|
|
174
|
+
* - エラーがある場合は例外をスローします。
|
|
175
|
+
* - `isForeigner` が false の場合、以下のプロパティを初期化します。
|
|
176
|
+
* - `foreignName`
|
|
177
|
+
* - `nationality`
|
|
178
|
+
* - `residenceStatus`
|
|
179
|
+
* - `periodOfStay`
|
|
180
|
+
* @returns {void}
|
|
181
|
+
* @throws {Error} 外国籍の場合に必須フィールドが未入力の場合。
|
|
145
182
|
*/
|
|
146
183
|
_validateForeignerRequiredFields() {
|
|
147
184
|
if (this.isForeigner) {
|
|
@@ -165,20 +202,31 @@ export default class Employee extends FireModel {
|
|
|
165
202
|
"[Employee.js] periodOfStay is required when isForeigner is true."
|
|
166
203
|
);
|
|
167
204
|
}
|
|
205
|
+
} else {
|
|
206
|
+
// 外国籍でない場合、関連フィールドを初期化
|
|
207
|
+
this.foreignName = null;
|
|
208
|
+
this.nationality = null;
|
|
209
|
+
this.residenceStatus = null;
|
|
210
|
+
this.periodOfStay = null;
|
|
168
211
|
}
|
|
169
212
|
}
|
|
170
213
|
|
|
171
214
|
/**
|
|
172
215
|
* 退職済である場合の必須フィールドを検証します。
|
|
173
|
-
* エラーがある場合は例外をスローします。
|
|
216
|
+
* - エラーがある場合は例外をスローします。
|
|
217
|
+
* - `employmentStatus` が `active` の場合、`dateOfTermination` を初期化します。
|
|
218
|
+
* @returns {void}
|
|
219
|
+
* @throws {Error} 退職済の場合に必須フィールドが未入力の場合。
|
|
174
220
|
*/
|
|
175
221
|
_validateTerminatedRequiredFields() {
|
|
176
|
-
if (this.employmentStatus ===
|
|
222
|
+
if (this.employmentStatus === VALUES.TERMINATED.value) {
|
|
177
223
|
if (!this.dateOfTermination) {
|
|
178
224
|
throw new Error(
|
|
179
225
|
"[Employee.js] dateOfTermination is required when employmentStatus is 'terminated'."
|
|
180
226
|
);
|
|
181
227
|
}
|
|
228
|
+
} else {
|
|
229
|
+
this.dateOfTermination = null;
|
|
182
230
|
}
|
|
183
231
|
}
|
|
184
232
|
|
|
@@ -11,16 +11,12 @@ import { OPTIONS } from "../constants/prefectures.js";
|
|
|
11
11
|
*/
|
|
12
12
|
const accessorImplementations = {
|
|
13
13
|
customerId: {
|
|
14
|
-
enumerable: true,
|
|
15
14
|
get() {
|
|
16
15
|
return this?.customer?.docId;
|
|
17
16
|
},
|
|
18
|
-
set(
|
|
19
|
-
// No-op setter for read-only access
|
|
20
|
-
},
|
|
17
|
+
set() {},
|
|
21
18
|
},
|
|
22
19
|
fullAddress: {
|
|
23
|
-
enumerable: true,
|
|
24
20
|
get() {
|
|
25
21
|
// 同じオブジェクトに 'prefecture' アクセサが定義されていることを前提とします
|
|
26
22
|
const prefecture = this.prefecture || "";
|
|
@@ -28,53 +24,41 @@ const accessorImplementations = {
|
|
|
28
24
|
const address = this.address || "";
|
|
29
25
|
return `${prefecture}${city}${address}`;
|
|
30
26
|
},
|
|
31
|
-
set(
|
|
32
|
-
// No-op setter for read-only access
|
|
33
|
-
},
|
|
27
|
+
set() {},
|
|
34
28
|
},
|
|
35
29
|
fullName: {
|
|
36
|
-
enumerable: true,
|
|
37
30
|
get() {
|
|
38
31
|
if (!this.lastName || !this.firstName) return "";
|
|
39
32
|
return `${this.lastName} ${this.firstName}`;
|
|
40
33
|
},
|
|
41
|
-
set(
|
|
42
|
-
|
|
34
|
+
set() {},
|
|
35
|
+
},
|
|
36
|
+
fullNameKana: {
|
|
37
|
+
get() {
|
|
38
|
+
if (!this.lastNameKana || !this.firstNameKana) return "";
|
|
39
|
+
return `${this.lastNameKana} ${this.firstNameKana}`;
|
|
43
40
|
},
|
|
41
|
+
set() {},
|
|
44
42
|
},
|
|
45
43
|
prefecture: {
|
|
46
|
-
enumerable: true,
|
|
47
44
|
get() {
|
|
48
|
-
// if (!this.hasOwnProperty("prefCode")) {
|
|
49
|
-
// console.warn(
|
|
50
|
-
// "[アクセサ: prefecture] このオブジェクトに prefCode が定義されていません。"
|
|
51
|
-
// );
|
|
52
|
-
// return "";
|
|
53
|
-
// }
|
|
54
|
-
|
|
55
45
|
if (!this.prefCode) return ""; // No warning if prefCode is falsy but present
|
|
56
|
-
|
|
57
46
|
const result = OPTIONS.find(({ value }) => value === this.prefCode);
|
|
58
|
-
|
|
59
47
|
if (!result) {
|
|
60
48
|
console.warn(
|
|
61
49
|
`[アクセサ: prefecture] prefCode '${this.prefCode}' は OPTIONS に見つかりません。`
|
|
62
50
|
);
|
|
63
51
|
return "";
|
|
64
52
|
}
|
|
65
|
-
|
|
66
53
|
if (!result.hasOwnProperty("title")) {
|
|
67
54
|
console.warn(
|
|
68
55
|
`[アクセサ: prefecture] OPTIONS の prefCode '${this.prefCode}' に title が定義されていません。`
|
|
69
56
|
);
|
|
70
57
|
return "";
|
|
71
58
|
}
|
|
72
|
-
|
|
73
59
|
return result.title;
|
|
74
60
|
},
|
|
75
|
-
set(
|
|
76
|
-
// No-op setter for read-only access
|
|
77
|
-
},
|
|
61
|
+
set() {},
|
|
78
62
|
},
|
|
79
63
|
};
|
|
80
64
|
|
|
@@ -90,7 +74,7 @@ const accessorImplementations = {
|
|
|
90
74
|
*/
|
|
91
75
|
export const defAccessor = (
|
|
92
76
|
key,
|
|
93
|
-
{ configurable =
|
|
77
|
+
{ configurable = true, enumerable = true } = {}
|
|
94
78
|
) => {
|
|
95
79
|
const implementation = accessorImplementations[key];
|
|
96
80
|
if (!implementation) {
|
|
@@ -147,11 +147,30 @@ export const fieldDefinitions = {
|
|
|
147
147
|
code: generalDefinitions.code,
|
|
148
148
|
/** dateAt */
|
|
149
149
|
dateAt: generalDefinitions.dateAt,
|
|
150
|
+
dateOfBirth: {
|
|
151
|
+
...generalDefinitions.dateAt,
|
|
152
|
+
label: "生年月日",
|
|
153
|
+
},
|
|
154
|
+
dateOfHire: {
|
|
155
|
+
...generalDefinitions.dateAt,
|
|
156
|
+
label: "入社日",
|
|
157
|
+
},
|
|
158
|
+
dateOfTermination: {
|
|
159
|
+
...generalDefinitions.dateAt,
|
|
160
|
+
label: "退職日",
|
|
161
|
+
},
|
|
162
|
+
periodOfStay: {
|
|
163
|
+
...generalDefinitions.dateAt,
|
|
164
|
+
label: "在留期間満了日",
|
|
165
|
+
},
|
|
150
166
|
/** dateTimeAt */
|
|
151
167
|
dateTimeAt: generalDefinitions.dateTimeAt,
|
|
152
168
|
/** multiple-line */
|
|
153
169
|
multipleLine: generalDefinitions.multipleLine,
|
|
154
|
-
|
|
170
|
+
remarks: {
|
|
171
|
+
...generalDefinitions.multipleLine,
|
|
172
|
+
label: "備考",
|
|
173
|
+
},
|
|
155
174
|
/** number */
|
|
156
175
|
number: generalDefinitions.number,
|
|
157
176
|
breakMinutes: {
|
|
@@ -276,6 +295,13 @@ export const fieldDefinitions = {
|
|
|
276
295
|
...generalDefinitions.oneLine,
|
|
277
296
|
label: "本名",
|
|
278
297
|
length: 50,
|
|
298
|
+
component: {
|
|
299
|
+
name: generalDefinitions.oneLine.component.name,
|
|
300
|
+
attrs: {
|
|
301
|
+
hint: "パスポート等の表記をご入力ください。",
|
|
302
|
+
persistentHint: true,
|
|
303
|
+
},
|
|
304
|
+
},
|
|
279
305
|
},
|
|
280
306
|
lastName: {
|
|
281
307
|
...generalDefinitions.oneLine,
|
|
@@ -326,6 +352,11 @@ export const fieldDefinitions = {
|
|
|
326
352
|
label: "国籍",
|
|
327
353
|
length: 50,
|
|
328
354
|
},
|
|
355
|
+
residenceStatus: {
|
|
356
|
+
...generalDefinitions.oneLine,
|
|
357
|
+
label: "在留資格",
|
|
358
|
+
length: 10,
|
|
359
|
+
},
|
|
329
360
|
siteId: {
|
|
330
361
|
...generalDefinitions.oneLine,
|
|
331
362
|
label: "現場",
|
|
@@ -350,6 +381,11 @@ export const fieldDefinitions = {
|
|
|
350
381
|
},
|
|
351
382
|
},
|
|
352
383
|
},
|
|
384
|
+
title: {
|
|
385
|
+
...generalDefinitions.oneLine,
|
|
386
|
+
label: "肩書",
|
|
387
|
+
length: 20,
|
|
388
|
+
},
|
|
353
389
|
workDescription: {
|
|
354
390
|
...generalDefinitions.oneLine,
|
|
355
391
|
label: "作業内容",
|