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
daeaf70b
Commit
daeaf70b
authored
May 21, 2019
by
Sweet Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
保存上一页的数据
parent
5a811422
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
4 deletions
+29
-4
questionnaire/src/app/age/age.component.ts
+3
-1
questionnaire/src/app/common.service.ts
+8
-1
questionnaire/src/app/family/family.component.ts
+18
-2
No files found.
questionnaire/src/app/age/age.component.ts
View file @
daeaf70b
...
@@ -14,12 +14,13 @@ export class AgeComponent implements OnInit {
...
@@ -14,12 +14,13 @@ export class AgeComponent implements OnInit {
isShow
:
boolean
;
isShow
:
boolean
;
curQues
:
any
;
curQues
:
any
;
curQuesIndex
:
number
;
curQuesIndex
:
number
;
curQuestionSelecte
:
string
;
pageAnswers
:
any
;
pageAnswers
:
any
;
// 可添加的孩子总个数
// 可添加的孩子总个数
totalChildLimitCount
:
number
;
totalChildLimitCount
:
number
;
questionSubId
:
number
;
questionSubId
:
number
;
question
:
any
;
question
:
any
;
// 上一次的答案
lastQuestions
:
Array
<
any
>
;
constructor
(
private
commonService
:
CommonService
,
private
router
:
Router
,
private
route
:
ActivatedRoute
)
{
constructor
(
private
commonService
:
CommonService
,
private
router
:
Router
,
private
route
:
ActivatedRoute
)
{
/**
/**
...
@@ -39,6 +40,7 @@ export class AgeComponent implements OnInit {
...
@@ -39,6 +40,7 @@ export class AgeComponent implements OnInit {
}
}
ngOnInit
()
{
ngOnInit
()
{
this
.
lastQuestions
=
this
.
commonService
.
todosCopy
.
filter
(
item
=>
item
.
pageId
==
3
).
pop
();
this
.
commonService
.
surveyInfo
().
then
(
res
=>
{
this
.
commonService
.
surveyInfo
().
then
(
res
=>
{
this
.
curPageData
=
res
[
'data'
][
'survey'
][
'pages'
].
filter
(
item
=>
item
.
pageId
===
3
).
pop
();
this
.
curPageData
=
res
[
'data'
][
'survey'
][
'pages'
].
filter
(
item
=>
item
.
pageId
===
3
).
pop
();
this
.
pageAnswers
.
pageId
=
this
.
curPageData
[
'pageId'
];
this
.
pageAnswers
.
pageId
=
this
.
curPageData
[
'pageId'
];
...
...
questionnaire/src/app/common.service.ts
View file @
daeaf70b
...
@@ -22,7 +22,9 @@ export class CommonService {
...
@@ -22,7 +22,9 @@ export class CommonService {
'X-Authorization'
:
''
'X-Authorization'
:
''
})
})
};
};
if
(
sessionStorage
.
getItem
(
'todos'
))
{
this
.
todos
=
JSON
.
parse
(
sessionStorage
.
getItem
(
'todos'
));
}
}
}
/**
/**
...
@@ -125,8 +127,13 @@ export class CommonService {
...
@@ -125,8 +127,13 @@ export class CommonService {
}
}
}
}
this
.
todos
.
push
(
todo
);
this
.
todos
.
push
(
todo
);
sessionStorage
.
setItem
(
'todos'
,
JSON
.
stringify
(
this
.
todos
));
this
.
todosSource
.
next
(
this
.
todos
);
this
.
todosSource
.
next
(
this
.
todos
);
return
this
;
return
this
;
}
}
get
todosCopy
()
{
return
this
.
todos
;
}
}
}
questionnaire/src/app/family/family.component.ts
View file @
daeaf70b
...
@@ -10,6 +10,8 @@ export class FamilyComponent implements OnInit {
...
@@ -10,6 +10,8 @@ export class FamilyComponent implements OnInit {
curPageData
:
Array
<
any
>
;
curPageData
:
Array
<
any
>
;
pageAnswers
:
any
;
pageAnswers
:
any
;
selectedOptionId
:
any
;
selectedOptionId
:
any
;
// 上一次的答案
lastQuestions
:
Array
<
any
>
;
constructor
(
private
commonService
:
CommonService
,
private
router
:
Router
)
{
constructor
(
private
commonService
:
CommonService
,
private
router
:
Router
)
{
this
.
pageAnswers
=
{
this
.
pageAnswers
=
{
...
@@ -23,8 +25,22 @@ export class FamilyComponent implements OnInit {
...
@@ -23,8 +25,22 @@ export class FamilyComponent implements OnInit {
}
}
ngOnInit
()
{
ngOnInit
()
{
this
.
lastQuestions
=
this
.
commonService
.
todosCopy
.
filter
(
item
=>
item
.
pageId
==
2
).
pop
();
this
.
commonService
.
surveyInfo
().
then
(
res
=>
{
this
.
commonService
.
surveyInfo
().
then
(
res
=>
{
this
.
curPageData
=
res
[
'data'
][
'survey'
][
'pages'
].
filter
(
item
=>
item
.
pageId
===
2
).
pop
();
this
.
curPageData
=
res
[
'data'
][
'survey'
][
'pages'
].
filter
(
item
=>
item
.
pageId
===
2
).
pop
();
for
(
let
i
=
0
;
i
<
this
.
lastQuestions
[
'questions'
].
length
;
i
++
)
{
for
(
let
j
=
0
;
j
<
this
.
curPageData
[
'questions'
].
length
;
j
++
)
{
if
(
this
.
lastQuestions
[
'questions'
][
i
].
questionId
==
this
.
curPageData
[
'questions'
][
j
].
questionId
)
{
for
(
let
m
=
0
;
m
<
this
.
lastQuestions
[
'questions'
][
i
].
options
.
length
;
m
++
)
{
for
(
let
n
=
0
;
n
<
this
.
curPageData
[
'questions'
][
i
].
options
.
length
;
n
++
)
{
if
(
this
.
lastQuestions
[
'questions'
][
i
].
options
[
m
].
optionId
==
this
.
curPageData
[
'questions'
][
i
].
options
[
n
].
optionId
)
{
this
.
selectedFamily
(
this
.
curPageData
[
'questions'
][
i
].
options
[
n
]);
}
}
}
}
}
}
// console.log(this.curPageData)
// console.log(this.curPageData)
});
});
}
}
...
@@ -32,7 +48,7 @@ export class FamilyComponent implements OnInit {
...
@@ -32,7 +48,7 @@ export class FamilyComponent implements OnInit {
// 选择家庭结构
// 选择家庭结构
selectedFamily
(
option
)
{
selectedFamily
(
option
)
{
this
.
selectedOptionId
=
option
.
optionId
;
this
.
selectedOptionId
=
option
.
optionId
;
const
options
=
this
.
curPageData
[
'questions'
][
0
][
'options'
]
const
options
=
this
.
curPageData
[
'questions'
][
0
][
'options'
]
;
for
(
let
i
=
0
;
i
<
options
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
options
.
length
;
i
++
)
{
if
(
option
[
'optionId'
]
==
options
[
i
][
'optionId'
])
{
if
(
option
[
'optionId'
]
==
options
[
i
][
'optionId'
])
{
options
[
i
][
'selected'
]
=
true
;
options
[
i
][
'selected'
]
=
true
;
...
@@ -49,7 +65,7 @@ export class FamilyComponent implements OnInit {
...
@@ -49,7 +65,7 @@ export class FamilyComponent implements OnInit {
}],
}],
};
};
this
.
commonService
.
addAnswer
(
this
.
pageAnswers
);
this
.
commonService
.
addAnswer
(
this
.
pageAnswers
);
console
.
log
(
this
.
pageAnswers
)
//
console.log(this.pageAnswers)
}
}
// 下一步
// 下一步
...
...
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