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
c0cfab8a
Commit
c0cfab8a
authored
May 22, 2019
by
Chao Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
吸烟
parent
f16774c7
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
126 additions
and
74 deletions
+126
-74
questionnaire/src/app/disease/disease.component.html
+1
-1
questionnaire/src/app/disease/disease.component.ts
+63
-36
questionnaire/src/app/family/family.component.ts
+1
-1
questionnaire/src/app/smoking/smoking.component.html
+1
-1
questionnaire/src/app/smoking/smoking.component.ts
+60
-35
No files found.
questionnaire/src/app/disease/disease.component.html
View file @
c0cfab8a
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
<li
<li
*
ngFor=
"let options of this.options"
*
ngFor=
"let options of this.options"
[
ngClass
]="{
selected:
options
['
selected
']
==
true
}"
[
ngClass
]="{
selected:
options
['
selected
']
==
true
}"
(
click
)="
checkFun
(
options
)"
(
click
)="
checkFun
(
options
,
false
)"
>
>
{{ options.optionName }}
{{ options.optionName }}
</li>
</li>
...
...
questionnaire/src/app/disease/disease.component.ts
View file @
c0cfab8a
...
@@ -14,7 +14,7 @@ export class DiseaseComponent implements OnInit {
...
@@ -14,7 +14,7 @@ export class DiseaseComponent implements OnInit {
nextBtn
:
boolean
;
nextBtn
:
boolean
;
options
:
Array
<
any
>
;
options
:
Array
<
any
>
;
questions
:
Array
<
any
>
=
[];
questions
:
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
)
{
...
@@ -31,44 +31,42 @@ export class DiseaseComponent implements OnInit {
...
@@ -31,44 +31,42 @@ export class DiseaseComponent implements OnInit {
ngOnInit
()
{
ngOnInit
()
{
this
.
nextBtn
=
false
;
this
.
nextBtn
=
false
;
this
.
surveyInfo
()
this
.
lastQuestions
=
this
.
commonService
.
todosCopy
.
filter
(
item
=>
item
.
pageId
==
14
).
pop
();
this
.
surveyInfo
();
}
}
surveyInfo
()
{
surveyInfo
()
{
this
.
commonService
.
surveyInfo
().
then
(
res
=>
{
this
.
commonService
.
surveyInfo
().
then
(
res
=>
{
if
(
res
[
'success'
])
{
if
(
res
[
'success'
])
{
this
.
curPageData
=
res
[
'data'
][
'survey'
].
pages
[
'13'
]
this
.
curPageData
=
res
[
'data'
][
'survey'
].
pages
[
'13'
]
/**
//过滤页面数据
* 1:单身贵族
this
.
filterOptions
(
this
.
type
)
* 2:二人世界
if
(
this
.
lastQuestions
){
* 3:独立带娃
for
(
let
i
=
0
;
i
<
this
.
lastQuestions
[
'questions'
].
length
;
i
++
)
{
* 4:多口之家
for
(
let
j
=
0
;
j
<
this
.
curPageData
[
'questions'
].
length
;
j
++
)
{
* @type {any}
if
(
this
.
lastQuestions
[
'questions'
][
i
].
questionId
==
this
.
curPageData
[
'questions'
][
j
].
questionId
)
{
*/
this
.
lastQuestions
[
'questions'
][
i
][
'options'
].
forEach
(
option
=>
{
// 过滤选项
if
(
Object
.
keys
(
option
).
indexOf
(
'optionId'
)
>
-
1
)
{
if
(
this
.
type
==
1
)
{
const
targetObj
=
option
;
this
.
options
=
this
.
curPageData
[
'questions'
][
'0'
][
'options'
]
this
.
curPageData
[
'questions'
][
j
][
'options'
].
forEach
(
option
=>
{
this
.
options
=
this
.
options
.
filter
(
option
=>
{
if
(
targetObj
[
'optionId'
]
==
option
[
'optionId'
])
{
return
option
.
optionId
==
106
||
option
.
optionId
==
107
this
.
curPageData
[
'questions'
][
j
][
'options'
][
this
.
curPageData
[
'questions'
][
j
][
'options'
].
indexOf
(
option
)]
=
targetObj
;
})
// 过滤选项
}
this
.
filterOptions
(
this
.
type
)
if
(
this
.
type
==
2
)
{
// console.log(targetObj)
this
.
options
=
this
.
curPageData
[
'questions'
][
'0'
][
'options'
]
}
this
.
options
=
this
.
options
.
filter
(
option
=>
{
});
return
option
.
optionId
==
108
||
option
.
optionId
==
109
||
option
.
optionId
==
111
if
(
this
.
type
==
1
)
{
})
this
.
getOneAnswer
(
targetObj
)
}
}
else
{
if
(
this
.
type
==
3
)
{
console
.
log
(
targetObj
)
this
.
options
=
this
.
curPageData
[
'questions'
][
'0'
][
'options'
]
this
.
getManyAnswer
(
targetObj
,
true
)
this
.
options
=
this
.
options
.
filter
(
option
=>
{
}
return
option
.
optionId
==
108
||
option
.
optionId
==
110
||
option
.
optionId
==
111
}
})
});
}
}
if
(
this
.
type
==
4
)
{
}
this
.
options
=
this
.
curPageData
[
'questions'
][
'0'
][
'options'
]
}
this
.
options
=
this
.
options
.
filter
(
option
=>
{
return
option
.
optionId
==
108
||
option
.
optionId
==
109
||
option
.
optionId
==
110
||
option
.
optionId
==
111
})
}
}
}
}
})
})
...
@@ -103,8 +101,10 @@ export class DiseaseComponent implements OnInit {
...
@@ -103,8 +101,10 @@ export class DiseaseComponent implements OnInit {
}
}
}
}
getManyAnswer
(
option
)
{
getManyAnswer
(
option
,
lastFlag
)
{
option
[
'selected'
]
=
!
option
[
'selected'
];
if
(
lastFlag
===
false
)
{
option
[
'selected'
]
=
!
option
[
'selected'
];
}
this
.
questions
=
[];
this
.
questions
=
[];
for
(
let
i
=
0
;
i
<
this
.
curPageData
[
'questions'
][
0
][
'options'
].
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
curPageData
[
'questions'
][
0
][
'options'
].
length
;
i
++
)
{
if
(
option
.
optionId
==
111
&&
option
[
'selected'
])
{
if
(
option
.
optionId
==
111
&&
option
[
'selected'
])
{
...
@@ -148,7 +148,7 @@ export class DiseaseComponent implements OnInit {
...
@@ -148,7 +148,7 @@ export class DiseaseComponent implements OnInit {
if
(
this
.
type
==
1
)
{
if
(
this
.
type
==
1
)
{
this
.
getOneAnswer
(
option
)
this
.
getOneAnswer
(
option
)
}
else
{
}
else
{
this
.
getManyAnswer
(
option
)
this
.
getManyAnswer
(
option
,
false
)
}
}
}
}
...
@@ -160,6 +160,33 @@ export class DiseaseComponent implements OnInit {
...
@@ -160,6 +160,33 @@ export class DiseaseComponent implements OnInit {
}
}
}
}
//过滤页面选项
filterOptions
(
type
){
if
(
type
==
1
)
{
this
.
options
=
this
.
curPageData
[
'questions'
][
'0'
][
'options'
]
this
.
options
=
this
.
options
.
filter
(
option
=>
{
return
option
.
optionId
==
106
||
option
.
optionId
==
107
})
}
if
(
type
==
2
)
{
this
.
options
=
this
.
curPageData
[
'questions'
][
'0'
][
'options'
]
this
.
options
=
this
.
options
.
filter
(
option
=>
{
return
option
.
optionId
==
108
||
option
.
optionId
==
109
||
option
.
optionId
==
111
})
}
if
(
type
==
3
)
{
this
.
options
=
this
.
curPageData
[
'questions'
][
'0'
][
'options'
]
this
.
options
=
this
.
options
.
filter
(
option
=>
{
return
option
.
optionId
==
108
||
option
.
optionId
==
110
||
option
.
optionId
==
111
})
}
if
(
type
==
4
)
{
this
.
options
=
this
.
curPageData
[
'questions'
][
'0'
][
'options'
]
this
.
options
=
this
.
options
.
filter
(
option
=>
{
return
option
.
optionId
==
108
||
option
.
optionId
==
109
||
option
.
optionId
==
110
||
option
.
optionId
==
111
})
}
}
// 上一步
// 上一步
before
()
{
before
()
{
this
.
commonService
.
before
();
this
.
commonService
.
before
();
...
...
questionnaire/src/app/family/family.component.ts
View file @
c0cfab8a
...
@@ -34,6 +34,7 @@ export class FamilyComponent implements OnInit {
...
@@ -34,6 +34,7 @@ export class FamilyComponent implements OnInit {
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
();
if
(
this
.
lastQuestions
)
{
if
(
this
.
lastQuestions
)
{
this
.
lastSelectedOptionId
=
this
.
lastQuestions
[
'questions'
][
0
][
'options'
][
0
][
'optionId'
]
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
(
this
.
lastQuestions
[
'questions'
][
i
].
questionId
==
this
.
curPageData
[
'questions'
][
j
].
questionId
)
{
...
@@ -41,7 +42,6 @@ export class FamilyComponent implements OnInit {
...
@@ -41,7 +42,6 @@ export class FamilyComponent implements OnInit {
if
(
Object
.
keys
(
option
).
indexOf
(
'optionId'
)
>
-
1
)
{
if
(
Object
.
keys
(
option
).
indexOf
(
'optionId'
)
>
-
1
)
{
this
.
targetObj
=
option
;
this
.
targetObj
=
option
;
}
}
console
.
log
(
this
.
targetObj
)
this
.
selectedFamily
(
this
.
targetObj
);
this
.
selectedFamily
(
this
.
targetObj
);
});
});
}
}
...
...
questionnaire/src/app/smoking/smoking.component.html
View file @
c0cfab8a
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
<li
<li
*
ngFor=
"let options of this.options"
*
ngFor=
"let options of this.options"
[
ngClass
]="{
selected:
options
['
selected
']
==
true
}"
[
ngClass
]="{
selected:
options
['
selected
']
==
true
}"
(
click
)="
checkFun
(
options
)"
(
click
)="
checkFun
(
options
,
false
)"
>
>
{{ options.optionName }}
{{ options.optionName }}
</li>
</li>
...
...
questionnaire/src/app/smoking/smoking.component.ts
View file @
c0cfab8a
...
@@ -14,6 +14,7 @@ export class SmokingComponent implements OnInit {
...
@@ -14,6 +14,7 @@ export class SmokingComponent implements OnInit {
pageAnswers
:
any
;
pageAnswers
:
any
;
options
:
Array
<
any
>
;
options
:
Array
<
any
>
;
questions
:
Array
<
any
>
=
[];
questions
:
Array
<
any
>
=
[];
lastQuestions
:
Array
<
any
>
;
constructor
(
private
commonService
:
CommonService
,
constructor
(
private
commonService
:
CommonService
,
private
router
:
Router
,
private
router
:
Router
,
...
@@ -31,6 +32,7 @@ export class SmokingComponent implements OnInit {
...
@@ -31,6 +32,7 @@ export class SmokingComponent implements OnInit {
ngOnInit
()
{
ngOnInit
()
{
this
.
nextBtn
=
false
;
this
.
nextBtn
=
false
;
this
.
lastQuestions
=
this
.
commonService
.
todosCopy
.
filter
(
item
=>
item
.
pageId
==
15
).
pop
();
this
.
surveyInfo
();
this
.
surveyInfo
();
}
}
...
@@ -38,37 +40,32 @@ export class SmokingComponent implements OnInit {
...
@@ -38,37 +40,32 @@ export class SmokingComponent implements OnInit {
this
.
commonService
.
surveyInfo
().
then
(
res
=>
{
this
.
commonService
.
surveyInfo
().
then
(
res
=>
{
if
(
res
[
'success'
])
{
if
(
res
[
'success'
])
{
this
.
curPageData
=
res
[
'data'
][
'survey'
].
pages
[
'14'
];
this
.
curPageData
=
res
[
'data'
][
'survey'
].
pages
[
'14'
];
/**
this
.
filterOptions
(
this
.
type
)
* 1:单身贵族
if
(
this
.
lastQuestions
){
* 2:二人世界
for
(
let
i
=
0
;
i
<
this
.
lastQuestions
[
'questions'
].
length
;
i
++
)
{
* 3:独立带娃
for
(
let
j
=
0
;
j
<
this
.
curPageData
[
'questions'
].
length
;
j
++
)
{
* 4:多口之家
if
(
this
.
lastQuestions
[
'questions'
][
i
].
questionId
==
this
.
curPageData
[
'questions'
][
j
].
questionId
)
{
* @type {any}
this
.
lastQuestions
[
'questions'
][
i
][
'options'
].
forEach
(
option
=>
{
*/
if
(
Object
.
keys
(
option
).
indexOf
(
'optionId'
)
>
-
1
)
{
//过滤选项
const
targetObj
=
option
;
if
(
this
.
type
==
1
)
{
this
.
curPageData
[
'questions'
][
j
][
'options'
].
forEach
(
option
=>
{
this
.
options
=
this
.
curPageData
[
'questions'
][
'0'
][
'options'
];
if
(
targetObj
[
'optionId'
]
==
option
[
'optionId'
])
{
this
.
options
=
this
.
options
.
filter
(
option
=>
{
this
.
curPageData
[
'questions'
][
j
][
'options'
][
this
.
curPageData
[
'questions'
][
j
][
'options'
].
indexOf
(
option
)]
=
targetObj
;
return
option
.
optionId
==
112
||
option
.
optionId
==
113
;
// 过滤选项
})
this
.
filterOptions
(
this
.
type
)
}
// console.log(targetObj)
if
(
this
.
type
==
2
)
{
}
this
.
options
=
this
.
curPageData
[
'questions'
][
'0'
][
'options'
];
});
this
.
options
=
this
.
options
.
filter
(
option
=>
{
if
(
this
.
type
==
1
)
{
return
option
.
optionId
==
114
||
option
.
optionId
==
115
||
option
.
optionId
==
117
;
this
.
getOneAnswer
(
targetObj
)
})
}
else
{
}
this
.
getManyAnswer
(
targetObj
,
true
)
if
(
this
.
type
==
3
)
{
}
this
.
options
=
this
.
curPageData
[
'questions'
][
'0'
][
'options'
];
}
this
.
options
=
this
.
options
.
filter
(
option
=>
{
});
return
option
.
optionId
==
114
||
option
.
optionId
==
116
||
option
.
optionId
==
117
;
}
})
}
}
}
if
(
this
.
type
==
4
)
{
this
.
options
=
this
.
curPageData
[
'questions'
][
'0'
][
'options'
];
this
.
options
=
this
.
options
.
filter
(
option
=>
{
return
option
.
optionId
==
114
||
option
.
optionId
==
115
||
option
.
optionId
==
116
||
option
.
optionId
==
117
;
})
}
}
}
}
})
})
...
@@ -103,8 +100,10 @@ export class SmokingComponent implements OnInit {
...
@@ -103,8 +100,10 @@ export class SmokingComponent implements OnInit {
}
}
}
}
getManyAnswer
(
option
)
{
getManyAnswer
(
option
,
lastFlag
)
{
option
[
'selected'
]
=
!
option
[
'selected'
];
if
(
lastFlag
===
false
)
{
option
[
'selected'
]
=
!
option
[
'selected'
];
}
this
.
questions
=
[];
this
.
questions
=
[];
for
(
let
i
=
0
;
i
<
this
.
curPageData
[
'questions'
][
0
][
'options'
].
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
curPageData
[
'questions'
][
0
][
'options'
].
length
;
i
++
)
{
if
(
option
.
optionId
==
117
&&
option
[
'selected'
])
{
if
(
option
.
optionId
==
117
&&
option
[
'selected'
])
{
...
@@ -147,7 +146,7 @@ export class SmokingComponent implements OnInit {
...
@@ -147,7 +146,7 @@ export class SmokingComponent implements OnInit {
if
(
this
.
type
==
1
)
{
if
(
this
.
type
==
1
)
{
this
.
getOneAnswer
(
option
);
this
.
getOneAnswer
(
option
);
}
else
{
}
else
{
this
.
getManyAnswer
(
option
);
this
.
getManyAnswer
(
option
,
false
);
}
}
}
}
...
@@ -158,7 +157,33 @@ export class SmokingComponent implements OnInit {
...
@@ -158,7 +157,33 @@ export class SmokingComponent implements OnInit {
return
;
return
;
}
}
}
}
filterOptions
(
type
){
//过滤选项
if
(
type
==
1
)
{
this
.
options
=
this
.
curPageData
[
'questions'
][
'0'
][
'options'
];
this
.
options
=
this
.
options
.
filter
(
option
=>
{
return
option
.
optionId
==
112
||
option
.
optionId
==
113
;
})
}
if
(
type
==
2
)
{
this
.
options
=
this
.
curPageData
[
'questions'
][
'0'
][
'options'
];
this
.
options
=
this
.
options
.
filter
(
option
=>
{
return
option
.
optionId
==
114
||
option
.
optionId
==
115
||
option
.
optionId
==
117
;
})
}
if
(
type
==
3
)
{
this
.
options
=
this
.
curPageData
[
'questions'
][
'0'
][
'options'
];
this
.
options
=
this
.
options
.
filter
(
option
=>
{
return
option
.
optionId
==
114
||
option
.
optionId
==
116
||
option
.
optionId
==
117
;
})
}
if
(
type
==
4
)
{
this
.
options
=
this
.
curPageData
[
'questions'
][
'0'
][
'options'
];
this
.
options
=
this
.
options
.
filter
(
option
=>
{
return
option
.
optionId
==
114
||
option
.
optionId
==
115
||
option
.
optionId
==
116
||
option
.
optionId
==
117
;
})
}
}
// 上一步
// 上一步
before
()
{
before
()
{
this
.
commonService
.
before
();
this
.
commonService
.
before
();
...
...
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