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
adc478ef
Commit
adc478ef
authored
May 16, 2019
by
Sweet Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试
parent
fb98e718
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
104 additions
and
21 deletions
+104
-21
questionnair/src/app/ask/ask.component.ts
+0
-4
questionnair/src/app/page3/page3.component.html
+1
-1
questionnair/src/app/page3/page3.component.ts
+103
-16
No files found.
questionnair/src/app/ask/ask.component.ts
View file @
adc478ef
...
...
@@ -46,10 +46,6 @@ export class AskComponent implements OnInit {
})
}
reducePage
()
{
if
(
this
.
questionInfo
){
this
.
allAnswers
[
this
.
curPage
]
=
this
.
questionInfo
;
this
.
questionInfo
=
null
}
if
(
this
.
curPage
>
0
)
{
const
page2Answer
=
this
.
allAnswers
[
1
]
if
(
page2Answer
){
...
...
questionnair/src/app/page3/page3.component.html
View file @
adc478ef
...
...
@@ -27,7 +27,7 @@
*
ngFor=
"let options of curQues.options"
(
click
)="
closeToast
();
getAnswer
(
options
);
getAnswer
(
curQues
['
questionId
'],
options
);
changeStyle
(
options
,
options
.
optionId
)
"
>
...
...
questionnair/src/app/page3/page3.component.ts
View file @
adc478ef
import
{
Component
,
OnInit
,
Input
,
Output
,
EventEmitter
}
from
'@angular/core'
import
{
Component
,
OnInit
,
Input
,
Output
,
EventEmitter
}
from
'@angular/core'
@
Component
({
selector
:
'app-page3'
,
...
...
@@ -20,16 +20,23 @@ export class Page3Component implements OnInit {
curQuesLen
:
number
//增加孩子点击次数
addChildCount
:
number
curQuestionSelecte
:
string
;
constructor
()
{}
curQuestionSelecte
:
string
;
questions
:
Array
<
any
>
;
constructor
()
{
this
.
questions
=
[];
}
ngOnInit
()
{
this
.
curQues
=
{}
this
.
curAllQues
=
{}
this
.
curQuesLen
=
this
.
curPageData
[
'questions'
].
length
//初始化增加孩子按钮可以点2次
this
.
addChildCount
=
2
this
.
addChildCount
=
2
;
// console.log(this.curPageData)
this
.
selectedOptions
();
}
showToast
(
question
,
idx
)
{
this
.
isShow
=
true
this
.
curQues
=
question
...
...
@@ -37,27 +44,107 @@ export class Page3Component implements OnInit {
// console.log(question)
this
.
curQuestionSelecte
=
question
.
name
}
closeToast
()
{
this
.
isShow
=
false
}
getAnswer
(
option
)
{
const
questionId
=
this
.
curQues
[
'questionId'
]
this
.
curAllQues
[
questionId
]
=
option
const
questions
=
Object
.
keys
(
this
.
curAllQues
).
map
(
questionId
=>
{
return
{
questionId
,
options
:
[
this
.
curAllQues
[
questionId
]]
}
})
const
ret
=
{
pageId
:
3
,
questions
}
this
.
getAllAnswer
.
emit
(
ret
)
}
// getAnswer(option) {
// const questionId = this.curQues['questionId']
// this.curAllQues[questionId] = option
// const questions = Object.keys(this.curAllQues).map(questionId => {
// return {questionId, options: [this.curAllQues[questionId]]}
// })
// const ret = {
// pageId: 3,
// questions
// }
// console.log(ret);
// this.getAllAnswer.emit(ret)
// }
changeStyle
(
options
,
optionId
)
{
//当前选中项
this
.
curPageData
[
'questions'
][
this
.
curQuesIndex
][
'name'
]
=
options
.
optionName
this
.
curPageData
[
'questions'
][
this
.
curQuesIndex
][
'optionId'
]
=
options
.
optionId
}
// 保存用户选择的信息
selectedOptions
()
{
if
(
this
.
curPageData
[
'questions'
].
length
>
0
)
{
for
(
let
i
=
0
;
i
<
this
.
curPageData
[
'questions'
].
length
;
i
++
)
{
if
(
!
this
.
curPageData
[
'questions'
][
i
][
'name'
])
{
return
;
}
let
option
=
{};
let
question
=
{
questionId
:
''
,
options
:
[]
};
question
.
questionId
=
this
.
curPageData
[
'questions'
][
i
].
questionId
;
option
=
{
customerInput
:
null
,
optionId
:
this
.
curPageData
[
'questions'
][
i
][
'optionId'
],
optionName
:
this
.
curPageData
[
'questions'
][
i
][
'name'
],
optionOrder
:
2
,
selected
:
true
};
question
.
options
.
push
(
option
);
this
.
questions
.
push
(
question
);
}
}
const
ret
=
{
pageId
:
3
,
questions
:
this
.
questions
}
console
.
log
(
ret
);
this
.
getAllAnswer
.
emit
(
ret
);
}
getAnswer
(
questionId
,
option
)
{
debugger
;
if
(
this
.
curPageData
[
'questions'
].
length
>
0
)
{
for
(
let
i
=
0
;
i
<
this
.
curPageData
[
'questions'
].
length
;
i
++
)
{
let
oldOption
=
{};
let
question
=
{
questionId
:
''
,
options
:
[]
};
question
.
questionId
=
this
.
curPageData
[
'questions'
][
i
].
questionId
;
oldOption
=
{
customerInput
:
null
,
optionId
:
this
.
curPageData
[
'questions'
][
i
][
'optionId'
],
optionName
:
this
.
curPageData
[
'questions'
][
i
][
'name'
],
optionOrder
:
2
,
selected
:
true
};
if
(
this
.
curPageData
[
'questions'
][
i
][
'optionId'
])
{
question
.
options
.
push
(
oldOption
);
this
.
questions
.
push
(
question
);
}
for
(
let
j
=
0
;
j
<
this
.
questions
.
length
;
j
++
)
{
if
(
this
.
questions
[
j
].
questionId
==
questionId
)
{
this
.
questions
[
j
].
options
[
0
]
=
option
;
}
else
{
const
questions
=
{
questionId
:
''
,
options
:
[
option
]
};
this
.
questions
.
push
(
questions
);
}
}
}
}
const
ret
=
{
pageId
:
3
,
questions
:
this
.
questions
}
console
.
log
(
ret
);
this
.
getAllAnswer
.
emit
(
ret
);
}
addChild
()
{
...
...
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