Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
op_09
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
op_09
Commits
00d881c6
Commit
00d881c6
authored
Sep 17, 2021
by
limingzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 表单提交
parent
d1db06fd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
21 deletions
+93
-21
form.component.html
form/src/app/form/form.component.html
+54
-2
form.component.ts
form/src/app/form/form.component.ts
+39
-19
No files found.
form/src/app/form/form.component.html
View file @
00d881c6
<div
class=
"model-content"
>
<div
style=
"padding: 10px;"
>
<div
*
ngFor=
"let q of questionArr; let i = index;"
style=
"width: 500px; margin-top: 20px; border: 1px solid #ccc; border-radius: 5px; padding: 15px;"
>
<div
style=
" display: flex; align-items: center;"
>
<h3
style=
"margin-top: 5px"
>
question-{{i+1}}:
</h3>
<app-audio-recorder
style=
"margin-left: 10px; "
[
audioUrl
]="
q
.
audio_url
"
(
audioUploaded
)="
onAudioUploadSuccess
($
event
,
'
audio_url
',
q
)"
></app-audio-recorder>
<button
*
ngIf=
"q.option_arr.length < 5"
nz-button
nzType=
"primary"
(
click
)="
addOptionBtnClick
(
q
)"
style=
"margin-left: 15px;"
>
+
</button>
<button
nz-button
nzType=
"danger"
(
click
)="
deleteQuestionBtnClick
(
i
)"
style=
"margin-left: 5px;"
>
x
</button>
</div>
<div
*
ngFor=
"let o of q.option_arr; let oi = index"
style=
"margin-top: 5px; display: flex;"
>
<div
style=
"width: 200px;"
>
<app-upload-image-with-preview
[
picUrl
]="
o
.
pic_url
"
(
imageUploaded
)="
onImageUploadSuccess
($
event
,
'
pic_url
',
o
)"
>
</app-upload-image-with-preview>
</div>
<div
style=
"margin-left: 10px"
>
<h4>
option-{{oi+1}} :
</h4>
<app-audio-recorder
[
audioUrl
]="
o
.
audio_url
"
(
audioUploaded
)="
onAudioUploadSuccess
($
event
,
'
audio_url
',
o
)"
></app-audio-recorder>
<div
style=
"display: flex; align-items: center; margin-top: 10px;"
>
<nz-switch
[(
ngModel
)]="
o
.
is_right
"
(
ngModelChange
)="
save
()"
></nz-switch>
<button
nz-button
nzType=
"danger"
(
click
)="
deleteOptionBtnClick
(
q
.
option_arr
,
oi
)"
style=
"margin-left: 5px;"
>
delete
</button>
</div>
</div>
</div>
</div>
<button
nz-button
nzType=
"dashed"
(
click
)="
addQuestionBtnClick
()"
style=
"height: 70px; margin-top: 20px;"
>
<i
nz-icon
nzType=
"plus-circle"
nzTheme=
"outline"
></i>
Add Question
</button>
<div
style=
"width: 300px;"
align=
'center'
>
<
!-- <
div style="width: 300px;" align='center'>
<span>图1: </span>
<app-upload-image-with-preview
[picUrl]="item.pic_url"
...
...
@@ -29,7 +81,7 @@
[audioUrl]="item.audio_url"
(audioUploaded)="onAudioUploadSuccess($event, 'audio_url')"
></app-audio-recorder>
</div>
</div>
-->
</div>
...
...
form/src/app/form/form.component.ts
View file @
00d881c6
...
...
@@ -14,23 +14,10 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 储存对象
item
;
constructor
(
private
appRef
:
ApplicationRef
,
private
changeDetectorRef
:
ChangeDetectorRef
)
{
}
questionArr
=
[];
createShell
()
{
this
.
item
.
wordList
.
push
({
word
:
''
,
audio
:
''
,
backWord
:
''
,
backWordAudio
:
''
,
});
this
.
save
();
}
constructor
(
private
appRef
:
ApplicationRef
,
private
changeDetectorRef
:
ChangeDetectorRef
)
{
removeShell
(
idx
)
{
this
.
item
.
wordList
.
splice
(
idx
,
1
);
this
.
save
();
}
ngOnInit
()
{
...
...
@@ -44,6 +31,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this
.
item
=
data
;
}
console
.
log
(
'
data:
'
,
data
);
this
.
init
();
this
.
changeDetectorRef
.
markForCheck
();
this
.
changeDetectorRef
.
detectChanges
();
...
...
@@ -59,17 +48,48 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}
init
()
{
if
(
!
this
.
item
.
question_arr
)
{
this
.
item
.
question_arr
=
[];
}
this
.
questionArr
=
this
.
item
.
question_arr
;
}
addQuestionBtnClick
()
{
this
.
questionArr
.
push
({
question_audio_url
:
''
,
option_arr
:
[
//选项 (多选)
]
})
this
.
save
();
}
addOptionBtnClick
(
question
)
{
question
.
option_arr
.
push
({
pic_url
:
''
,
// 图片路径
audio_url
:
''
,
//音频路径
is_right
:
false
,
//是否正确
})
this
.
save
();
}
deleteQuestionBtnClick
(
index
)
{
this
.
questionArr
.
splice
(
index
,
1
);
this
.
save
();
}
deleteOptionBtnClick
(
option
,
index
)
{
option
.
splice
(
index
,
1
)
this
.
save
();
}
/**
* 储存图片数据
* @param e
*/
onImageUploadSuccess
(
e
,
key
)
{
onImageUploadSuccess
(
e
,
key
,
item
)
{
this
.
item
[
key
]
=
e
.
url
;
item
[
key
]
=
e
.
url
;
this
.
save
();
}
...
...
@@ -77,8 +97,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
* 储存音频数据
* @param e
*/
onAudioUploadSuccess
(
e
,
key
)
{
this
.
item
[
key
]
=
e
.
url
;
onAudioUploadSuccess
(
e
,
key
,
item
)
{
item
[
key
]
=
e
.
url
;
this
.
save
();
}
...
...
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