@shisyamo4131/air-guard-v2-schemas 2.4.2-dev.91 → 2.4.2-dev.93
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
CHANGED
package/src/Site.js
CHANGED
|
@@ -15,9 +15,11 @@ import { default as FireModel } from "@shisyamo4131/air-firebase-v2";
|
|
|
15
15
|
import { defField } from "./parts/fieldDefinitions.js";
|
|
16
16
|
import { defAccessor } from "./parts/accessorDefinitions.js";
|
|
17
17
|
import Customer from "./Customer.js";
|
|
18
|
+
import SiteOperationSchedule from "./SiteOperationSchedule.js";
|
|
18
19
|
import AgreementV2 from "./AgreementV2.js";
|
|
19
20
|
import { VALUES } from "./constants/site-status.js";
|
|
20
21
|
import { GeocodableMixin } from "./mixins/GeocodableMixin.js";
|
|
22
|
+
import { formatJstDate } from "./utils/index.js";
|
|
21
23
|
|
|
22
24
|
const classProps = {
|
|
23
25
|
customerId: defField("customerId", {
|
|
@@ -54,6 +56,12 @@ const classProps = {
|
|
|
54
56
|
address: defField("address", { required: true }),
|
|
55
57
|
building: defField("building"),
|
|
56
58
|
securityType: defField("securityType", { required: true }),
|
|
59
|
+
constructionPeriodStartAt: defField("constructionPeriodStartAt", {
|
|
60
|
+
required: true,
|
|
61
|
+
}),
|
|
62
|
+
constructionPeriodEndAt: defField("constructionPeriodEndAt", {
|
|
63
|
+
required: true,
|
|
64
|
+
}),
|
|
57
65
|
location: defField("location"),
|
|
58
66
|
remarks: defField("remarks"),
|
|
59
67
|
agreementsV2: defField("array", {
|
|
@@ -74,18 +82,22 @@ const classProps = {
|
|
|
74
82
|
* @property {string} code - 現場コード
|
|
75
83
|
* @property {string} name - 現場名
|
|
76
84
|
* @property {string} nameKana - 現場名カナ
|
|
77
|
-
* @property {string} zipcode -
|
|
78
|
-
* @property {string} prefCode -
|
|
79
|
-
* @property {string} prefecture -
|
|
80
|
-
* @property {string} city -
|
|
81
|
-
* @property {string} address -
|
|
82
|
-
* @property {string} building -
|
|
83
|
-
* @property {string} fullAddress -
|
|
85
|
+
* @property {string} zipcode - 郵便番号
|
|
86
|
+
* @property {string} prefCode - 都道府県コード
|
|
87
|
+
* @property {string} prefecture - 都道府県名(`prefCode` から派生)(読み取り専用)
|
|
88
|
+
* @property {string} city - 市区町村名
|
|
89
|
+
* @property {string} address - 町域名・番地
|
|
90
|
+
* @property {string} building - 建物名
|
|
91
|
+
* @property {string} fullAddress - 住所(郵便番号、都道府県、市区町村、番地、建物名を結合したもの)(読み取り専用)
|
|
84
92
|
* @property {object} location - Geographical location.
|
|
85
|
-
* @property {string}
|
|
93
|
+
* @property {string} securityType - 警備種別
|
|
94
|
+
* @property {string} constructionPeriodStartAt - 工期開始日
|
|
95
|
+
* @property {string} constructionPeriodEndAt - 工期終了日
|
|
96
|
+
* @property {boolean} hasConstructionPeriod - 工期が設定されているかどうかを表すフラグ(読み取り専用)
|
|
97
|
+
* @property {string} remarks - 備考
|
|
86
98
|
* @property {array} agreementsV2 - 取極めの配列(バージョン2)。`AgreementV2` クラスのインスタンスを要素とする。
|
|
87
99
|
*
|
|
88
|
-
* @property {string} status -
|
|
100
|
+
* @property {string} status - 現場のステータス(例: "ACTIVE", "TERMINATED")
|
|
89
101
|
* @property {boolean} isTemporary - 仮登録状態かどうかを表すフラグ
|
|
90
102
|
*
|
|
91
103
|
* @function getAgreement
|
|
@@ -226,6 +238,19 @@ export default class Site extends GeocodableMixin(FireModel) {
|
|
|
226
238
|
},
|
|
227
239
|
set() {},
|
|
228
240
|
},
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* 工期が設定されているかどうかを表すアクセサー
|
|
244
|
+
* - `constructionPeriodStartAt` または `constructionPeriodEndAt` のいずれかが設定されている場合に `true` を返します。
|
|
245
|
+
*/
|
|
246
|
+
hasConstructionPeriod: {
|
|
247
|
+
configurable: true,
|
|
248
|
+
enumerable: true,
|
|
249
|
+
get() {
|
|
250
|
+
return this.constructionPeriodStartAt || this.constructionPeriodEndAt;
|
|
251
|
+
},
|
|
252
|
+
set() {},
|
|
253
|
+
},
|
|
229
254
|
});
|
|
230
255
|
|
|
231
256
|
/** 2026-03-31 Deprecated */
|
|
@@ -345,4 +370,47 @@ export default class Site extends GeocodableMixin(FireModel) {
|
|
|
345
370
|
);
|
|
346
371
|
return null;
|
|
347
372
|
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* 現場を稼働終了状態に更新します。
|
|
376
|
+
* @returns {Promise<DocumentReference>} 更新されたドキュメントリファレンス
|
|
377
|
+
* @throws {Error} ドキュメントが読み込まれていない場合、既に稼働終了している場合、または稼働予定が存在する場合にスローされます。
|
|
378
|
+
*/
|
|
379
|
+
async terminate() {
|
|
380
|
+
// 自身が `docId` を持っていない場合はエラーをスロー(インスタンスにドキュメントが読み込まれていない)
|
|
381
|
+
if (!this.docId) {
|
|
382
|
+
throw new Error(
|
|
383
|
+
"ドキュメントが読み込まれていないため、現場を稼働終了できません。",
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// 既に稼働終了している場合はエラーをスロー
|
|
388
|
+
if (this.status === Site.STATUS_TERMINATED) {
|
|
389
|
+
throw new Error("既に稼働終了している現場です。");
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// 現在日時の JST 日付文字列を取得
|
|
393
|
+
const nowJst = formatJstDate(new Date(), "YYYY-MM-DD");
|
|
394
|
+
|
|
395
|
+
// 現在日付以降の SiteOperationSchedule ドキュメントを取得
|
|
396
|
+
const scheduleInstance = new SiteOperationSchedule();
|
|
397
|
+
const futureScheduleDocs = await scheduleInstance.fetchDocs({
|
|
398
|
+
constraints: [
|
|
399
|
+
["where", "siteId", "==", this.docId],
|
|
400
|
+
["where", "date", ">=", nowJst],
|
|
401
|
+
["limit", 1],
|
|
402
|
+
],
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
// SiteOperationSchedule ドキュメントが存在する場合はエラーをスロー
|
|
406
|
+
if (futureScheduleDocs.length > 0) {
|
|
407
|
+
throw new Error(
|
|
408
|
+
"稼働予定が存在するため、現場を終了させることはできません。先に稼働予定を削除する必要があります。",
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// 状態を稼働終了に更新して保存
|
|
413
|
+
this.status = Site.STATUS_TERMINATED;
|
|
414
|
+
return await this.update();
|
|
415
|
+
}
|
|
348
416
|
}
|
|
@@ -5,6 +5,14 @@ import { generalDefinitions } from "./defaultDefinition.js";
|
|
|
5
5
|
*/
|
|
6
6
|
export const dateAtFields = {
|
|
7
7
|
dateAt: generalDefinitions.dateAt,
|
|
8
|
+
constructionPeriodEndAt: {
|
|
9
|
+
...generalDefinitions.dateAt,
|
|
10
|
+
label: "工期(終了日)",
|
|
11
|
+
},
|
|
12
|
+
constructionPeriodStartAt: {
|
|
13
|
+
...generalDefinitions.dateAt,
|
|
14
|
+
label: "工期(開始日)",
|
|
15
|
+
},
|
|
8
16
|
dateOfBirth: {
|
|
9
17
|
...generalDefinitions.dateAt,
|
|
10
18
|
label: "生年月日",
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getDateAt } from "../../utils/index.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* フィールド定義のデフォルト値
|
|
3
5
|
* - `air-firebase` が提供する `FireModel (BaseClass)` において、クラスが保有するフィールドの定義および値の検証に使用されます。
|
|
@@ -55,11 +57,7 @@ export const generalDefinitions = {
|
|
|
55
57
|
...defaultDefinition,
|
|
56
58
|
type: Object,
|
|
57
59
|
label: "日付",
|
|
58
|
-
default: () =>
|
|
59
|
-
const date = new Date();
|
|
60
|
-
date.setHours(0, 0, 0, 0);
|
|
61
|
-
return date;
|
|
62
|
-
},
|
|
60
|
+
default: () => getDateAt(new Date(), "00:00"),
|
|
63
61
|
component: {
|
|
64
62
|
name: "air-date-input",
|
|
65
63
|
},
|
package/src/utils/index.js
CHANGED
|
@@ -66,7 +66,7 @@ export function getDateAt(date, time, dateOffset = 0) {
|
|
|
66
66
|
* @example
|
|
67
67
|
* // YYYY-MM-DD形式
|
|
68
68
|
* formatJstDate(new Date('2024-03-04T15:00:00Z')) // '2024-03-05'
|
|
69
|
-
*
|
|
69
|
+
*
|
|
70
70
|
* // YYYY-MM形式
|
|
71
71
|
* formatJstDate(new Date('2024-03-04T15:00:00Z'), 'YYYY-MM') // '2024-03'
|
|
72
72
|
*/
|