|
|
@@ -1,4 +1,4 @@
|
|
1
|
|
-import { Component } from '@angular/core';
|
|
|
1
|
+import { Component, OnInit } from '@angular/core';
|
|
2
|
2
|
import { FormBuilder, FormsModule } from '@angular/forms';
|
|
3
|
3
|
import { Router, RouterLink } from '@angular/router';
|
|
4
|
4
|
import { Danka } from '../../models/danka';
|
|
|
@@ -16,7 +16,7 @@ import { AppSideMenu } from '../../share/side-menu/app-side-menu';
|
|
16
|
16
|
templateUrl: './search.html',
|
|
17
|
17
|
styleUrl: './search.scss',
|
|
18
|
18
|
})
|
|
19
|
|
-export class Search {
|
|
|
19
|
+export class Search implements OnInit{
|
|
20
|
20
|
searchKeyword = '';
|
|
21
|
21
|
selectedSearchType = 'all';
|
|
22
|
22
|
searchTypeFilters = [
|
|
|
@@ -34,7 +34,10 @@ export class Search {
|
|
34
|
34
|
private dankaService: DankaService,
|
|
35
|
35
|
private familyService: FamilyService,
|
|
36
|
36
|
private kakochoService: KakochoService,
|
|
37
|
|
- ) {}
|
|
|
37
|
+ ) { }
|
|
|
38
|
+
|
|
|
39
|
+ ngOnInit(): void {
|
|
|
40
|
+ }
|
|
38
|
41
|
|
|
39
|
42
|
// フィルタータブの選択処理
|
|
40
|
43
|
changeSearchType(searchType: string): void {
|
|
|
@@ -43,57 +46,65 @@ export class Search {
|
|
43
|
46
|
}
|
|
44
|
47
|
|
|
45
|
48
|
// 全検索の処理
|
|
46
|
|
- searchAll() {
|
|
|
49
|
+ async searchAll(): Promise<void> {
|
|
47
|
50
|
const keyword = this.searchKeyword.trim();
|
|
|
51
|
+
|
|
48
|
52
|
this.dankaResults = [];
|
|
49
|
53
|
this.familyResults = [];
|
|
50
|
54
|
this.kakochoResults = [];
|
|
51
|
55
|
this.totalResultCount = 0;
|
|
52
|
|
- if (keyword === '') {
|
|
53
|
|
- return;
|
|
54
|
|
- }
|
|
55
|
|
- // 檀家・家族・過去帳の情報を取得
|
|
56
|
|
- const dankaList = this.dankaService.getDankaList();
|
|
57
|
|
- const familyList = this.familyService.getFamilyList();
|
|
58
|
|
- const kakochoList = this.kakochoService.getKakochoList();
|
|
59
|
|
- //檀家のキーワード検索
|
|
|
56
|
+
|
|
|
57
|
+ if (keyword === '') return;
|
|
|
58
|
+
|
|
|
59
|
+ const [dankaList, familyList, kakochoList] = await Promise.all([
|
|
|
60
|
+ this.dankaService.getDankaList(),
|
|
|
61
|
+ this.familyService.getFamilyList(),
|
|
|
62
|
+ this.kakochoService.getKakochoList(),
|
|
|
63
|
+ ]);
|
|
|
64
|
+
|
|
|
65
|
+ // 檀家検索
|
|
60
|
66
|
if (this.selectedSearchType === 'all' || this.selectedSearchType === 'danka') {
|
|
61
|
|
- this.dankaResults = dankaList.filter(
|
|
62
|
|
- (danka) =>
|
|
63
|
|
- danka.householdName.includes(keyword) ||
|
|
64
|
|
- danka.householder.includes(keyword) ||
|
|
65
|
|
- danka.postalCode.includes(keyword) ||
|
|
66
|
|
- danka.address.includes(keyword) ||
|
|
67
|
|
- danka.phones.some((phone) => phone.tel.includes(keyword) || phone.note.includes(keyword)),
|
|
|
67
|
+ this.dankaResults = dankaList.filter((danka) =>
|
|
|
68
|
+ danka.householdName.includes(keyword) ||
|
|
|
69
|
+ danka.householder.includes(keyword) ||
|
|
|
70
|
+ danka.postalCode.includes(keyword) ||
|
|
|
71
|
+ danka.address.includes(keyword) ||
|
|
|
72
|
+ danka.phones.some(
|
|
|
73
|
+ (phone) =>
|
|
|
74
|
+ phone.tel.includes(keyword) ||
|
|
|
75
|
+ phone.note.includes(keyword)
|
|
|
76
|
+ )
|
|
68
|
77
|
);
|
|
69
|
78
|
}
|
|
70
|
|
- //家族のキーワード検索
|
|
|
79
|
+
|
|
|
80
|
+ // 家族検索
|
|
71
|
81
|
if (this.selectedSearchType === 'all' || this.selectedSearchType === 'family') {
|
|
72
|
|
- this.familyResults = familyList.filter(
|
|
73
|
|
- (family) =>
|
|
74
|
|
- family.name.includes(keyword) ||
|
|
75
|
|
- family.furigana.includes(keyword) ||
|
|
76
|
|
- family.relationship.includes(keyword) ||
|
|
77
|
|
- family.birthDate.includes(keyword) ||
|
|
78
|
|
- family.note.includes(keyword),
|
|
|
82
|
+ this.familyResults = familyList.filter((family) =>
|
|
|
83
|
+ family.name.includes(keyword) ||
|
|
|
84
|
+ family.furigana.includes(keyword) ||
|
|
|
85
|
+ family.relationship.includes(keyword) ||
|
|
|
86
|
+ family.birthDate.includes(keyword) ||
|
|
|
87
|
+ family.note.includes(keyword)
|
|
79
|
88
|
);
|
|
80
|
89
|
}
|
|
81
|
|
- //過去帳のキーワード検索
|
|
|
90
|
+
|
|
|
91
|
+ // 過去帳検索
|
|
82
|
92
|
if (this.selectedSearchType === 'all' || this.selectedSearchType === 'kakocho') {
|
|
83
|
|
- this.kakochoResults = kakochoList.filter(
|
|
84
|
|
- (kakocho) =>
|
|
85
|
|
- kakocho.name.includes(keyword) ||
|
|
86
|
|
- kakocho.furigana.includes(keyword) ||
|
|
87
|
|
- kakocho.relationship.includes(keyword) ||
|
|
88
|
|
- kakocho.kaimyo.includes(keyword) ||
|
|
89
|
|
- kakocho.deathDate.includes(keyword) ||
|
|
90
|
|
- kakocho.ageAtDeath.includes(keyword) ||
|
|
91
|
|
- kakocho.note.includes(keyword),
|
|
|
93
|
+ this.kakochoResults = kakochoList.filter((kakocho) =>
|
|
|
94
|
+ kakocho.name.includes(keyword) ||
|
|
|
95
|
+ kakocho.furigana.includes(keyword) ||
|
|
|
96
|
+ kakocho.relationship.includes(keyword) ||
|
|
|
97
|
+ kakocho.kaimyo.includes(keyword) ||
|
|
|
98
|
+ kakocho.deathDate.includes(keyword) ||
|
|
|
99
|
+ kakocho.ageAtDeath.includes(keyword) ||
|
|
|
100
|
+ kakocho.note.includes(keyword)
|
|
92
|
101
|
);
|
|
93
|
102
|
}
|
|
94
|
|
- //検索結果の件数カウント
|
|
|
103
|
+
|
|
95
|
104
|
this.totalResultCount =
|
|
96
|
|
- this.dankaResults.length + this.familyResults.length + this.kakochoResults.length;
|
|
|
105
|
+ this.dankaResults.length +
|
|
|
106
|
+ this.familyResults.length +
|
|
|
107
|
+ this.kakochoResults.length;
|
|
97
|
108
|
}
|
|
98
|
109
|
|
|
99
|
110
|
clearSearch(): void {
|