Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
DF-L204
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
DF-L204
Commits
ee2bed6e
Commit
ee2bed6e
authored
Mar 24, 2020
by
Chen Jiping
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善
parent
6d421345
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
47 deletions
+82
-47
form.component.css
src/app/form/form.component.css
+5
-0
form.component.html
src/app/form/form.component.html
+60
-47
form.component.ts
src/app/form/form.component.ts
+17
-0
No files found.
src/app/form/form.component.css
View file @
ee2bed6e
...
@@ -6,3 +6,8 @@
...
@@ -6,3 +6,8 @@
height
:
100%
;
height
:
100%
;
}
}
.border
{
border-radius
:
20px
;
border-style
:
dashed
;
}
src/app/form/form.component.html
View file @
ee2bed6e
...
@@ -16,60 +16,73 @@
...
@@ -16,60 +16,73 @@
<nz-form-item>
<nz-form-item>
<nz-form-control
[
nzSpan
]="
15
"
nzOffset=
"3"
>
<nz-form-control
[
nzSpan
]="
15
"
nzOffset=
"3"
>
<div
*
ngFor=
"let it of item.exercises; let i = index"
class=
"card-item"
style=
"padding: 0.5vw;"
>
<div
*
ngFor=
"let it of item.exercises; let i = index"
class=
"card-item"
style=
"padding: 0.5vw;"
>
<div
class=
"border"
>
<nz-form-item>
<nz-form-label
[
nzSpan
]="
6
"
nzFor=
"{{i}}.contents"
>
内容
</nz-form-label>
<nz-form-control
[
nzSpan
]="
6
"
>
<button
nz-button
nzType=
"dashed"
class=
"add-btn"
id=
"add-btn"
(
click
)="
addContentItem
(
it
.
contents
)"
>
<i
nz-icon
nzType=
"plus-circle"
nzTheme=
"outline"
></i>
添加
</button>
</nz-form-control>
</nz-form-item>
<div
>
<!--
<nz-divider nzText="练习-{{i+1}}" nzOrientation="left"></nz-divider>
<nz-divider nzText="练习-{{i+1}}" nzOrientation="left"></nz-divider>
-->
<!--
<!--
<button style="margin: 10px;" nz-button nzType="danger" (click)="delExercisesItem(i)">
<button style="margin: 10px;" nz-button nzType="danger" (click)="delExercisesItem(i)">
<span>删除</span>
<span>删除</span>
</button>
</button>
-->
-->
<div
nz-form
>
<nz-form-item>
<div
*
ngFor=
"let data of it.contents;let j = index"
class=
"card-item"
style=
"padding: 0.5vw;"
>
<nz-form-label
[
nzSpan
]="
6
"
nzFor=
"it.contents"
>
内容
</nz-form-label>
<div
class=
"border"
>
<nz-form-control
[
nzSpan
]="
6
"
>
<nz-divider
nzText=
"内容-{{j+1}}"
nzOrientation=
"left"
></nz-divider>
<button
nz-button
nzType=
"dashed"
class=
"add-btn"
id=
"add-btn"
<nz-form-item>
(
click
)="
addContentItem
(
it
.
contents
)"
>
<nz-form-label
[
nzSpan
]="
6
"
>
内容形式
</nz-form-label>
<i
nz-icon
nzType=
"plus-circle"
nzTheme=
"outline"
></i>
添加
<nz-form-control
[
nzSpan
]="
6
"
>
</button>
<nz-radio-group
[(
ngModel
)]="
data
.
contentType
"
(
ngModelChange
)="
setContentType
($
event
,
data
)"
>
</nz-form-control>
<label
nz-radio
nzValue=
"T"
>
文字
</label>
</nz-form-item>
<label
nz-radio
nzValue=
"P"
>
图片
</label>
<nz-form-item>
</nz-radio-group>
<div
nz-col
[
nzSpan
]="
22
"
nzOffset=
"1"
>
</nz-form-control>
<nz-table
#
answersTable
[
nzHideOnSinglePage
]="
true
"
[
nzBordered
]="
true
"
[
nzNoResult
]=''
>
</nz-form-item>
<thead>
<div
*
ngIf=
"data.contentType == 'T'"
>
<tr>
<nz-form-item>
<th>
序号
</th>
<nz-form-label
[
nzSpan
]="
6
"
nzFor=
"{{j}}.val"
>
文本
</nz-form-label>
<th>
内容(文字)
</th>
<nz-form-control
[
nzSpan
]="
6
"
>
<th>
内容(图片)
</th>
<input
nz-input
type=
"text"
id=
"{{j}}.val"
placeholder=
"请录入内容"
[(
ngModel
)]="
data
.
val
"
(
blur
)="
save
()"
>
<th>
发音
</th>
</nz-form-control>
<th>
操作
</th>
</nz-form-item>
</tr>
</div>
</thead>
<div
*
ngIf=
"data.contentType == 'P'"
>
<tbody>
<nz-form-item>
<tr
*
ngFor=
"let data of it.contents;let j = index"
>
<nz-form-label
[
nzSpan
]="
6
"
nzFor=
"{{j}}.pic_url"
>
图片
</nz-form-label>
<td>
{{j+1}}
</td>
<nz-form-control
[
nzSpan
]="
6
"
>
<td><input
type=
"text"
nz-input
placeholder=
"请录入内容"
[(
ngModel
)]="
data
.
val
"
(
blur
)="
save
()"
></td>
<app-upload-image-with-preview
<td>
style=
"width: 100%"
<app-upload-image-with-preview
[
picUrl
]="
data
.
pic_url
"
style=
"width: 100%"
(
imageUploaded
)="
onImageUploadSuccess
($
event
,
data
,
'
pic_url
')"
[
picUrl
]="
data
.
pic_url
"
></app-upload-image-with-preview>
(
imageUploaded
)="
onImageUploadSuccess
($
event
,
data
,
'
pic_url
')"
</nz-form-control>
></app-upload-image-with-preview>
</nz-form-item>
</td>
<td>
<app-audio-recorder
id=
"data.audio_url"
[
audioUrl
]="
data
.
audio_url
"
(
audioUploaded
)="
onAudioUploadSuccess
($
event
,
data
,
'
audio_url
')"
>
</app-audio-recorder>
</td>
<td>
<a
(
click
)="
delContentItem
(
it
.
contents
,
j
)"
>
delete
</a>
</td>
</tr>
</tbody>
</nz-table>
</div>
</div>
</nz-form-item>
<nz-form-item>
<nz-form-label
[
nzSpan
]="
6
"
nzFor=
"{{j}}.pic_url"
>
音频
</nz-form-label>
<nz-form-control
[
nzSpan
]="
6
"
>
<app-audio-recorder
id=
"{{j}}.audio_url"
[
audioUrl
]="
data
.
audio_url
"
(
audioUploaded
)="
onAudioUploadSuccess
($
event
,
data
,
'
audio_url
')"
>
</app-audio-recorder>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<button
style=
"margin: 10px;"
nz-button
nzType=
"danger"
(
click
)="
delContentItem
(
it
.
contents
,
j
)"
>
<span>
删除
</span>
</button>
</nz-form-item>
</div>
</div>
</div>
</div>
</div>
...
...
src/app/form/form.component.ts
View file @
ee2bed6e
...
@@ -37,6 +37,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -37,6 +37,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this
.
addExercisesItem
();
this
.
addExercisesItem
();
}
}
console
.
log
(
'
data
'
,
this
.
item
);
this
.
init
();
this
.
init
();
this
.
refresh
();
this
.
refresh
();
...
@@ -156,6 +158,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -156,6 +158,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
*/
*/
getDefaultContentItem
(){
getDefaultContentItem
(){
let
content
=
{
let
content
=
{
contentType
:
"
T
"
,
val
:
""
,
val
:
""
,
pic_url
:
""
,
pic_url
:
""
,
audio_url
:
""
audio_url
:
""
...
@@ -163,5 +166,19 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -163,5 +166,19 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
return
content
;
return
content
;
}
}
setContentType
(
e
,
item
){
item
[
'
contentType
'
]
=
e
;
if
(
"
T
"
==
e
){
item
[
'
pic_url
'
]
=
""
;
}
else
if
(
"
P
"
==
e
){
item
[
'
val
'
]
=
""
;
}
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