Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
allCampaign
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
allCampaign
Commits
2605ad48
Commit
2605ad48
authored
Sep 18, 2019
by
Chao Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
孩子名字修改
parent
5c201182
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
58 deletions
+95
-58
consulting1/.idea/workspace.xml
+0
-0
questionnaire/src/app/children-health/children-health.component.ts
+95
-58
No files found.
consulting1/.idea/workspace.xml
View file @
2605ad48
This source diff could not be displayed because it is too large. You can
view the blob
instead.
questionnaire/src/app/children-health/children-health.component.ts
View file @
2605ad48
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
Component
,
OnInit
}
from
"@angular/core"
;
import
{
CommonService
}
from
'../common.service'
;
import
{
CommonService
}
from
"../common.service"
;
import
{
ActivatedRoute
,
Router
}
from
"@angular/router"
;
import
{
ActivatedRoute
,
Router
}
from
"@angular/router"
;
@
Component
({
@
Component
({
selector
:
'app-children-health'
,
selector
:
"app-children-health"
,
templateUrl
:
'./children-health.component.html'
,
templateUrl
:
"./children-health.component.html"
,
styleUrls
:
[
'./children-health.component.css'
]
styleUrls
:
[
"./children-health.component.css"
]
})
})
export
class
ChildrenHealthComponent
implements
OnInit
{
export
class
ChildrenHealthComponent
implements
OnInit
{
// 问题数据
// 问题数据
curPageData
:
any
;
curPageData
:
any
;
// 获取是第几个孩子的健康状况
// 获取是第几个孩子的健康状况
id
:
any
;
id
:
any
;
// 获取家庭结构
// 获取家庭结构
...
@@ -25,9 +25,11 @@ export class ChildrenHealthComponent implements OnInit {
...
@@ -25,9 +25,11 @@ export class ChildrenHealthComponent implements OnInit {
nextBtn
:
boolean
=
false
;
nextBtn
:
boolean
=
false
;
lastQuestions
:
Array
<
any
>
;
lastQuestions
:
Array
<
any
>
;
constructor
(
private
commonService
:
CommonService
,
constructor
(
private
commonService
:
CommonService
,
private
router
:
Router
,
private
router
:
Router
,
private
route
:
ActivatedRoute
)
{
private
route
:
ActivatedRoute
)
{
/**
/**
* 1:单身贵族
* 1:单身贵族
* 2:二人世界
* 2:二人世界
...
@@ -35,15 +37,19 @@ export class ChildrenHealthComponent implements OnInit {
...
@@ -35,15 +37,19 @@ export class ChildrenHealthComponent implements OnInit {
* 4:多口之家
* 4:多口之家
* @type {any}
* @type {any}
*/
*/
this
.
type
=
this
.
route
.
snapshot
.
queryParams
[
'type'
];
this
.
type
=
this
.
route
.
snapshot
.
queryParams
[
"type"
];
this
.
id
=
this
.
route
.
snapshot
.
params
[
'childId'
];
this
.
id
=
this
.
route
.
snapshot
.
params
[
"childId"
];
this
.
pageAnswers
=
{
this
.
pageAnswers
=
{
pageId
:
''
,
pageId
:
""
,
questions
:
[{
questions
:
[
questionId
:
''
,
{
questionName
:
''
,
questionId
:
""
,
options
:
[{
optionId
:
''
,
optionName
:
''
,
optionOrder
:
''
,
selected
:
''
}]
questionName
:
""
,
}],
options
:
[
{
optionId
:
""
,
optionName
:
""
,
optionOrder
:
""
,
selected
:
""
}
]
}
]
};
};
}
}
...
@@ -54,27 +60,30 @@ export class ChildrenHealthComponent implements OnInit {
...
@@ -54,27 +60,30 @@ export class ChildrenHealthComponent implements OnInit {
// 选择健康情况(多选)
// 选择健康情况(多选)
selectedHealth
(
option
,
lastFlag
)
{
selectedHealth
(
option
,
lastFlag
)
{
if
(
lastFlag
===
false
)
{
if
(
lastFlag
===
false
)
{
option
[
'selected'
]
=
!
option
[
'selected'
];
option
[
"selected"
]
=
!
option
[
"selected"
];
}
}
this
.
id
=
this
.
route
.
snapshot
.
params
[
'childId'
];
this
.
id
=
this
.
route
.
snapshot
.
params
[
"childId"
];
this
.
questions
=
[];
this
.
questions
=
[];
this
.
getOptions
(
99
,
option
);
this
.
getOptions
(
99
,
option
);
const
questions
=
{
const
questions
=
{
questionId
:
this
.
curPageData
[
'questions'
][
'0'
][
'questionId'
],
questionId
:
this
.
curPageData
[
"questions"
][
"0"
][
"questionId"
],
questionName
:
'孩子'
+
this
.
id
+
'的健康状态'
,
questionName
:
"孩子"
+
((
this
.
id
-
1
)
===
0
?
""
:
(
this
.
id
-
1
))
+
"的健康状态"
,
childId
:
this
.
id
,
childId
:
this
.
id
,
options
:
this
.
questions
options
:
this
.
questions
};
};
for
(
let
i
=
0
;
i
<
this
.
childTotalQuestions
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
childTotalQuestions
.
length
;
i
++
)
{
if
(
this
.
childTotalQuestions
[
i
].
childId
==
questions
.
childId
)
{
if
(
this
.
childTotalQuestions
[
i
].
childId
==
questions
.
childId
)
{
this
.
childTotalQuestions
.
splice
(
this
.
childTotalQuestions
.
indexOf
(
this
.
childTotalQuestions
[
i
]),
1
);
this
.
childTotalQuestions
.
splice
(
this
.
childTotalQuestions
.
indexOf
(
this
.
childTotalQuestions
[
i
]),
1
);
break
;
break
;
}
}
}
}
this
.
childTotalQuestions
.
push
(
questions
);
this
.
childTotalQuestions
.
push
(
questions
);
this
.
pageAnswers
=
{
this
.
pageAnswers
=
{
pageId
:
this
.
curPageData
[
'pageId'
],
pageId
:
this
.
curPageData
[
"pageId"
],
questions
:
this
.
childTotalQuestions
,
questions
:
this
.
childTotalQuestions
};
};
if
(
this
.
pageAnswers
.
questions
.
every
(
item
=>
item
.
options
.
length
>
0
))
{
if
(
this
.
pageAnswers
.
questions
.
every
(
item
=>
item
.
options
.
length
>
0
))
{
this
.
nextBtn
=
true
;
this
.
nextBtn
=
true
;
...
@@ -86,69 +95,96 @@ export class ChildrenHealthComponent implements OnInit {
...
@@ -86,69 +95,96 @@ export class ChildrenHealthComponent implements OnInit {
// 获取所有用户选择的健康选项
// 获取所有用户选择的健康选项
getOptions
(
nonDiseaseOptionId
,
option
)
{
getOptions
(
nonDiseaseOptionId
,
option
)
{
for
(
let
i
=
0
;
i
<
this
.
curPageData
[
'questions'
][
0
][
'options'
].
length
;
i
++
)
{
for
(
if
(
option
.
optionId
==
nonDiseaseOptionId
&&
option
[
'selected'
])
{
let
i
=
0
;
this
.
curPageData
[
'questions'
][
0
][
'options'
][
i
][
'selected'
]
=
false
;
i
<
this
.
curPageData
[
"questions"
][
0
][
"options"
].
length
;
if
(
this
.
curPageData
[
'questions'
][
0
][
'options'
][
i
][
'optionId'
]
==
nonDiseaseOptionId
)
{
i
++
this
.
curPageData
[
'questions'
][
0
][
'options'
][
i
][
'selected'
]
=
true
;
)
{
if
(
option
.
optionId
==
nonDiseaseOptionId
&&
option
[
"selected"
])
{
this
.
curPageData
[
"questions"
][
0
][
"options"
][
i
][
"selected"
]
=
false
;
if
(
this
.
curPageData
[
"questions"
][
0
][
"options"
][
i
][
"optionId"
]
==
nonDiseaseOptionId
)
{
this
.
curPageData
[
"questions"
][
0
][
"options"
][
i
][
"selected"
]
=
true
;
}
}
}
else
{
}
else
{
if
(
this
.
curPageData
[
'questions'
][
0
][
'options'
][
i
][
'optionId'
]
==
nonDiseaseOptionId
)
{
if
(
this
.
curPageData
[
'questions'
][
0
][
'options'
][
i
][
'selected'
]
=
false
;
this
.
curPageData
[
"questions"
][
0
][
"options"
][
i
][
"optionId"
]
==
nonDiseaseOptionId
)
{
this
.
curPageData
[
"questions"
][
0
][
"options"
][
i
][
"selected"
]
=
false
;
}
}
}
}
// 拿到所有selected为true的选项
// 拿到所有selected为true的选项
if
(
this
.
curPageData
[
'questions'
][
0
][
'options'
][
i
][
'selected'
])
{
if
(
this
.
curPageData
[
"questions"
][
0
][
"options"
][
i
][
"selected"
])
{
this
.
questions
.
push
(
this
.
curPageData
[
'questions'
][
0
][
'options'
][
i
]);
this
.
questions
.
push
(
this
.
curPageData
[
"questions"
][
0
][
"options"
][
i
]);
}
}
}
}
}
}
surveyInfo
()
{
surveyInfo
()
{
this
.
commonService
.
surveyInfo
().
then
(
res
=>
{
this
.
commonService
.
surveyInfo
().
then
(
res
=>
{
if
(
res
[
'success'
])
{
if
(
res
[
"success"
])
{
this
.
curPageData
=
res
[
'data'
][
'survey'
].
pages
[
'12'
];
this
.
curPageData
=
res
[
"data"
][
"survey"
].
pages
[
"12"
];
this
.
lastQuestions
=
this
.
commonService
.
todosCopy
.
filter
(
item
=>
item
.
pageId
==
13
).
pop
();
this
.
lastQuestions
=
this
.
commonService
.
todosCopy
this
.
id
=
this
.
route
.
snapshot
.
params
[
'childId'
];
.
filter
(
item
=>
item
.
pageId
==
13
)
for
(
let
j
=
0
;
j
<
this
.
curPageData
[
'questions'
].
length
;
j
++
)
{
.
pop
();
this
.
curPageData
[
'questions'
][
j
][
'questionName'
]
=
'孩子'
+
this
.
id
+
'的健康状态'
;
this
.
id
=
this
.
route
.
snapshot
.
params
[
"childId"
];
for
(
let
j
=
0
;
j
<
this
.
curPageData
[
"questions"
].
length
;
j
++
)
{
this
.
curPageData
[
"questions"
][
j
][
"questionName"
]
=
"孩子"
+
((
this
.
id
-
1
)
===
0
?
""
:
(
this
.
id
-
1
))
+
"的健康状态"
;
break
;
break
;
}
}
if
(
this
.
lastQuestions
)
{
if
(
this
.
lastQuestions
)
{
this
.
childTotalQuestions
=
this
.
lastQuestions
[
'questions'
];
this
.
childTotalQuestions
=
this
.
lastQuestions
[
"questions"
];
for
(
let
i
=
0
;
i
<
this
.
lastQuestions
[
'questions'
].
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
lastQuestions
[
"questions"
].
length
;
i
++
)
{
for
(
let
j
=
0
;
j
<
this
.
curPageData
[
'questions'
].
length
;
j
++
)
{
for
(
let
j
=
0
;
j
<
this
.
curPageData
[
"questions"
].
length
;
j
++
)
{
if
(
this
.
lastQuestions
[
'questions'
][
i
].
questionId
==
this
.
curPageData
[
'questions'
][
j
].
questionId
)
{
if
(
if
(
this
.
id
==
this
.
lastQuestions
[
'questions'
][
i
][
'childId'
])
{
this
.
lastQuestions
[
"questions"
][
i
].
questionId
==
this
.
lastQuestions
[
'questions'
][
i
][
'options'
].
forEach
(
option
=>
{
this
.
curPageData
[
"questions"
][
j
].
questionId
if
(
Object
.
keys
(
option
).
indexOf
(
'optionId'
)
>
-
1
)
{
)
{
if
(
this
.
id
==
this
.
lastQuestions
[
"questions"
][
i
][
"childId"
])
{
this
.
lastQuestions
[
"questions"
][
i
][
"options"
].
forEach
(
option
=>
{
if
(
Object
.
keys
(
option
).
indexOf
(
"optionId"
)
>
-
1
)
{
const
targetObj
=
option
;
const
targetObj
=
option
;
this
.
curPageData
[
'questions'
][
j
][
'options'
].
forEach
(
option
=>
{
this
.
curPageData
[
"questions"
][
j
][
"options"
].
forEach
(
if
(
targetObj
[
'optionId'
]
==
option
[
'optionId'
])
{
option
=>
{
this
.
curPageData
[
'questions'
][
j
][
'options'
][
this
.
curPageData
[
'questions'
][
j
][
'options'
].
indexOf
(
option
)]
=
targetObj
;
if
(
targetObj
[
"optionId"
]
==
option
[
"optionId"
])
{
this
.
curPageData
[
"questions"
][
j
][
"options"
][
this
.
curPageData
[
"questions"
][
j
][
"options"
].
indexOf
(
option
)
]
=
targetObj
;
}
}
});
}
);
this
.
selectedHealth
(
targetObj
,
true
);
this
.
selectedHealth
(
targetObj
,
true
);
}
}
});
}
}
);
}
}
}
}
}
}
}
}
}
}
})
}
});
}
}
// 下一步
// 下一步
next
()
{
next
()
{
const
age
=
this
.
commonService
.
todosCopy
.
filter
(
item
=>
item
.
pageId
==
3
).
pop
();
const
age
=
this
.
commonService
.
todosCopy
this
.
childTotalCount
=
age
[
'questions'
].
filter
(
item
=>
item
.
questionId
==
4
).
length
;
.
filter
(
item
=>
item
.
pageId
==
3
)
.
pop
();
this
.
childTotalCount
=
age
[
"questions"
].
filter
(
item
=>
item
.
questionId
==
4
).
length
;
if
(
this
.
nextBtn
)
{
if
(
this
.
nextBtn
)
{
this
.
id
=
this
.
route
.
snapshot
.
params
[
'childId'
];
this
.
id
=
this
.
route
.
snapshot
.
params
[
"childId"
];
// 查看有几个孩子,一个直接跳到疾病页,多个跳多个孩子页
// 查看有几个孩子,一个直接跳到疾病页,多个跳多个孩子页
if
(
this
.
id
<
parseInt
(
this
.
childTotalCount
,
0
))
{
if
(
this
.
id
<
parseInt
(
this
.
childTotalCount
,
0
))
{
this
.
router
.
navigate
([
'/children_health'
,
parseInt
(
this
.
id
,
0
)
+
1
],
{
this
.
router
.
navigate
([
"/children_health"
,
parseInt
(
this
.
id
,
0
)
+
1
],
{
queryParams
:
{
queryParams
:
{
type
:
this
.
type
type
:
this
.
type
}
}
...
@@ -156,12 +192,13 @@ export class ChildrenHealthComponent implements OnInit {
...
@@ -156,12 +192,13 @@ export class ChildrenHealthComponent implements OnInit {
this
.
nextBtn
=
false
;
this
.
nextBtn
=
false
;
this
.
surveyInfo
();
this
.
surveyInfo
();
}
else
{
}
else
{
this
.
router
.
navigate
([
'/disease'
],
{
queryParams
:
{
type
:
this
.
type
}});
this
.
router
.
navigate
([
"/disease"
],
{
queryParams
:
{
type
:
this
.
type
}
});
}
}
}
else
{
}
else
{
return
;
return
;
}
}
}
}
// 上一步
// 上一步
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment