Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
DF-L220
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-L220
Commits
a5d8f3b4
Commit
a5d8f3b4
authored
Mar 26, 2020
by
Chen Jiping
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化代码
parent
5e32c10d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
305 deletions
+39
-305
form.component.html
src/app/form/form.component.html
+15
-301
form.component.ts
src/app/form/form.component.ts
+24
-4
No files found.
src/app/form/form.component.html
View file @
a5d8f3b4
...
...
@@ -31,42 +31,48 @@
<nz-form-label
[
nzSpan
]="
6
"
nzFor=
"it.answers"
>
答案
</nz-form-label>
<nz-form-control
[
nzSpan
]="
6
"
>
<button
nz-button
nzType=
"dashed"
class=
"add-btn"
id=
"add-btn"
(
click
)="
addAnswerItem
(
it
.
answers
)"
>
(
click
)="
addAnswerItem
(
it
.
answers
,
it
)"
>
<i
nz-icon
nzType=
"plus-circle"
nzTheme=
"outline"
></i>
添加
</button>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<div
nz-col
[
nzSpan
]="
22
"
nzOffset=
"1"
>
<nz-table
#
answersTable
[
nzHideOnSinglePage
]="
true
"
[
nzBordered
]="
true
"
[
nzNoResult
]=''
>
<nz-table
#
answersTable
[
nz
Data
]="
it
.
answers
"
[
nz
HideOnSinglePage
]="
true
"
[
nzBordered
]="
true
"
[
nzNoResult
]=''
>
<thead>
<tr>
<th>
序号
</th>
<th>
答案类型
</th>
<th>
备选答案
</th>
<th>
备选答案(图片)
</th>
<th>
是否正确
</th>
<th>
操作
</th>
</tr>
</thead>
<tbody>
<tr
*
ngFor=
"let data of
it.answers
;let j = index"
>
<tr
*
ngFor=
"let data of
answersTable.data
;let j = index"
>
<td>
{{j+1}}
</td>
<td><input
type=
"text"
nz-input
placeholder=
"请录入备选答案"
[(
ngModel
)]="
data
.
val
"
(
blur
)="
save
()"
></td>
<td>
<nz-select
[(
ngModel
)]="
data
.
type
"
nzPlaceHolder=
"请选择"
(
ngModelChange
)="
setAnswerType
($
event
,
data
)"
>
<nz-option
nzValue=
"T"
nzLabel=
"文字"
></nz-option>
<nz-option
nzValue=
"P"
nzLabel=
"图片"
></nz-option>
</nz-select>
</td>
<td
*
ngIf=
"data.type == 'T'"
><input
type=
"text"
nz-input
placeholder=
"请录入备选答案"
[(
ngModel
)]="
data
.
val
"
(
blur
)="
save
()"
></td>
<td
*
ngIf=
"data.type == 'P'"
>
<app-upload-image-with-preview
style=
"width: 100%"
[
picUrl
]="
data
.
pic_url
"
(
imageUploaded
)="
onImageUploadSuccess
($
event
,
data
,
'
pic_url
')"
></app-upload-image-with-preview>
</td>
</td>
<td>
<nz-select
[(
ngModel
)]="
data
.
correct
"
nz
AllowClear
nz
PlaceHolder=
"请选择"
(
ngModelChange
)="
save
()"
>
<nz-select
[(
ngModel
)]="
data
.
correct
"
nzPlaceHolder=
"请选择"
(
ngModelChange
)="
save
()"
>
<nz-option
nzValue=
"0"
nzLabel=
"否"
></nz-option>
<nz-option
nzValue=
"1"
nzLabel=
"是"
></nz-option>
</nz-select>
</td>
<td>
<a
(
click
)="
delAnswerItem
(
it
.
answers
,
j
)"
>
delete
</a>
<a
(
click
)="
delAnswerItem
(
it
.
answers
,
j
,
it
)"
>
delete
</a>
</td>
</tr>
</tbody>
...
...
@@ -82,296 +88,4 @@
</nz-form-control>
</nz-form-item>
</div>
</div>
<!--<app-audio-recorder-->
<!--[audioUrl]="item.audio_url"-->
<!--(audioUploaded)="onAudioUploadSuccess($event)"-->
<!--></app-audio-recorder>-->
<!--<div *ngFor="let it of picArr; let i = index"-->
<!--nz-col nzSpan="8" >-->
<!--<div class="item-box">-->
<!--<app-upload-image-with-preview-->
<!--style="width: 100%"-->
<!--[picUrl]="it.pic_url"-->
<!--(imageUploaded)="onImageUploadSuccessByItem($event, it)"-->
<!--></app-upload-image-with-preview>-->
<!--<div style="display: flex; justify-items: center; padding-top: 10px">-->
<!--<app-audio-recorder-->
<!--[audioUrl]="it.audio_url"-->
<!--(audioUploaded)="onAudioUploadSuccessByItem($event, it)">-->
<!--</app-audio-recorder>-->
<!--<button style="margin-left: 10px;" nz-button nzType="danger" (click)="deleteItem(it)">-->
<!--<i nz-icon type="close"></i>-->
<!--</button>-->
<!--</div>-->
<!--</div>-->
<!--<!–<h5> id-{{i+1}} </h5>–>-->
<!--<!–<div style="display: flex; align-items: center; justify-content: center; padding-bottom: 5px">–>-->
<!--<!–<input type="text" nz-input placeholder="" [(ngModel)]="it.text" (blur)="saveItem()">–>-->
<!--<!–<button style="margin-left: 10px;" nz-button nzType="danger" (click)="deleteItem(it)">–>-->
<!--<!–<i nz-icon type="close"></i>–>-->
<!--<!–</button>–>-->
<!--<!–</div>–>-->
<!--<!–<app-upload-image-with-preview–>-->
<!--<!–style="width: 100%"–>-->
<!--<!–[picUrl]="it.pic_url"–>-->
<!--<!–(imageUploaded)="onImageUploadSuccessByItem($event, it)"–>-->
<!--<!–></app-upload-image-with-preview>–>-->
<!--<!–<div style="display: flex; align-items: center; justify-content: center">–>-->
<!--<!–<span style="width: 80px;">–>-->
<!--<!–question:–>-->
<!--<!–</span>–>-->
<!--<!–<app-audio-recorder–>-->
<!--<!–[audioUrl]="it['q_audio_url']"–>-->
<!--<!–(audioUploaded)="onAudioUploadSuccessByItem($event, it, 'q')">–>-->
<!--<!–</app-audio-recorder>–>-->
<!--<!–</div>–>-->
<!--<!–<div style="display: flex; align-items: center; justify-content: center">–>-->
<!--<!–<span style="width: 80px;">–>-->
<!--<!–answer:–>-->
<!--<!–</span>–>-->
<!--<!–<app-audio-recorder–>-->
<!--<!–[audioUrl]="it['a_audio_url']"–>-->
<!--<!–(audioUploaded)="onAudioUploadSuccessByItem($event, it, 'a')">–>-->
<!--<!–</app-audio-recorder>–>-->
<!--<!–</div>–>-->
<!--<!–<nz-radio-group [(ngModel)]="it.radioValue" >–>-->
<!--<!–<label nz-radio nzValue="A" (click)="radioClick(it, 'A')"> <i nz-icon nzType="check" nzTheme="outline"></i> </label>–>-->
<!--<!–<label nz-radio nzValue="B" (click)="radioClick(it, 'B')"> <i nz-icon nzType="close" nzTheme="outline"></i> </label>–>-->
<!--<!–</nz-radio-group>–>-->
<!--</div>-->
<!--<div nz-col nzSpan="8" class="add-btn-box" >-->
<!--<!–<div style="width: 100%; height: 100%;">–>-->
<!--<button style=" margin: auto; width: 60%; height: 60%;" nz-button nzType="dashed" class="add-btn"-->
<!--(click)="addPic()">-->
<!--<i nz-icon nzType="plus-circle" nzTheme="outline"></i>-->
<!--Add-->
<!--</button>-->
<!--<!–</div>–>-->
<!--</div>-->
<!--<!–<div style="padding-bottom: 30px;">–>-->
<!--<!–<h5> title-sound: </h5>–>-->
<!--<!–<app-audio-recorder–>-->
<!--<!–[audioUrl]="item.contentObj.title_audio_url"–>-->
<!--<!–(audioUploaded)="onAudioUploadSuccessByItem($event, item.contentObj, 'title')">–>-->
<!--<!–</app-audio-recorder>–>-->
<!--<!–</div>–>-->
<!--<!–<div style="padding-bottom: 30px;">–>-->
<!--<!–<h5> bg-sound: </h5>–>-->
<!--<!–<app-audio-recorder–>-->
<!--<!–[audioUrl]="item.contentObj.bg_audio_url"–>-->
<!--<!–(audioUploaded)="onAudioUploadSuccessByItem($event, item.contentObj, 'bg')">–>-->
<!--<!–</app-audio-recorder>–>-->
<!--<!–</div>–>-->
<!--<!–<span style="margin-bottom: 20px"> 10 : 23 </span>–>-->
<!--<!–<div *ngFor="let it of picArr; let i = index">–>-->
<!--<!–<span> pic-{{i + 1}}: </span>–>-->
<!--<!–<div style="display: flex; align-items: center; padding-bottom: 20px">–>-->
<!--<!–<div style="width: 40%; padding-right: 20px">–>-->
<!--<!–<app-upload-image-with-preview–>-->
<!--<!–[picUrl]="it.pic_url"–>-->
<!--<!–(imageUploaded)="onImageUploadSuccessByItem($event, it)"–>-->
<!--<!–></app-upload-image-with-preview>–>-->
<!--<!–</div>–>-->
<!--<!–<div class="pic-sound-box">–>-->
<!--<!–<div nz-row style="width: 50%; padding-bottom: 20px;">–>-->
<!--<!–<div *ngFor="let it2 of it.soundArr; let i2 = index" nz-col nzSpan="8">–>-->
<!--<!–<label nz-checkbox nzValue="{{'answer_' + (i2 + 1)}}" [(ngModel)]="it2.answer" (ngModelChange)="clickCheckBox()" >{{i2 + 1}}</label>–>-->
<!--<!–</div>–>-->
<!--<!–</div>–>-->
<!--<!–<div *ngFor="let it2 of it.soundArr; let i2 = index" style="display: flex; align-items: center; padding-bottom: 5px">–>-->
<!--<!–<span style="padding-right: 10px">sound-{{i2 + 1}}:</span>–>-->
<!--<!–<app-audio-recorder–>-->
<!--<!–[audioUrl]="it2.audio_url"–>-->
<!--<!–(audioUploaded)="onAudioUploadSuccessByItem($event, it2)">–>-->
<!--<!–</app-audio-recorder>–>-->
<!--<!–</div>–>-->
<!--<!–</div>–>-->
<!--<!–</div>–>-->
<!--<!–</div>–>-->
<!--<!–<div style="margin: auto; width: 95%;" nz-row nzType="flex" nzJustify="start" nzAlign="middle">–>-->
<!--<!–<div *ngFor="let it of picArr; let i = index"–>-->
<!--<!–nz-col nzSpan="8" >–>-->
<!--<!–<div class="item-box">–>-->
<!--<!–<h5> id-{{i+1}} </h5>–>-->
<!--<!–<div style="display: flex; align-items: center; justify-content: center; padding-bottom: 5px">–>-->
<!--<!–<input type="text" nz-input placeholder="" [(ngModel)]="it.text" (blur)="saveItem()">–>-->
<!--<!–<button style="margin-left: 10px;" nz-button nzType="danger" (click)="deleteItem(it)">–>-->
<!--<!–<i nz-icon type="close"></i>–>-->
<!--<!–</button>–>-->
<!--<!–</div>–>-->
<!--<!–<app-upload-image-with-preview–>-->
<!--<!–style="width: 100%"–>-->
<!--<!–[picUrl]="it.pic_url"–>-->
<!--<!–(imageUploaded)="onImageUploadSuccessByItem($event, it)"–>-->
<!--<!–></app-upload-image-with-preview>–>-->
<!--<!–<div style="display: flex; align-items: center; justify-content: center">–>-->
<!--<!–<span style="width: 80px;">–>-->
<!--<!–question:–>-->
<!--<!–</span>–>-->
<!--<!–<app-audio-recorder–>-->
<!--<!–[audioUrl]="it['q_audio_url']"–>-->
<!--<!–(audioUploaded)="onAudioUploadSuccessByItem($event, it, 'q')">–>-->
<!--<!–</app-audio-recorder>–>-->
<!--<!–</div>–>-->
<!--<!–<div style="display: flex; align-items: center; justify-content: center">–>-->
<!--<!–<span style="width: 80px;">–>-->
<!--<!–answer:–>-->
<!--<!–</span>–>-->
<!--<!–<app-audio-recorder–>-->
<!--<!–[audioUrl]="it['a_audio_url']"–>-->
<!--<!–(audioUploaded)="onAudioUploadSuccessByItem($event, it, 'a')">–>-->
<!--<!–</app-audio-recorder>–>-->
<!--<!–</div>–>-->
<!--<!–<nz-radio-group [(ngModel)]="it.radioValue" >–>-->
<!--<!–<label nz-radio nzValue="A" (click)="radioClick(it, 'A')"> <i nz-icon nzType="check" nzTheme="outline"></i> </label>–>-->
<!--<!–<label nz-radio nzValue="B" (click)="radioClick(it, 'B')"> <i nz-icon nzType="close" nzTheme="outline"></i> </label>–>-->
<!--<!–</nz-radio-group>–>-->
<!--<!–</div>–>-->
<!--<!–</div>–>-->
<!--</div>-->
</div>
\ No newline at end of file
src/app/form/form.component.ts
View file @
a5d8f3b4
...
...
@@ -134,11 +134,11 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
/**
* 添加答案
*/
addAnswerItem
(
answers
){
addAnswerItem
(
answers
,
practice
){
let
answer
=
this
.
getDefaultAnswerItem
();
answers
.
push
(
answer
)
;
practice
.
answers
=
[...
answers
,
answer
]
;
this
.
save
();
}
...
...
@@ -148,10 +148,14 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
* @param answers
* @param index
*/
delAnswerItem
(
answers
,
index
){
delAnswerItem
(
answers
,
index
,
practice
){
if
(
index
!==
-
1
)
{
answers
.
splice
(
index
,
1
);
practice
.
answers
=
[...
answers
];
this
.
save
();
}
}
...
...
@@ -163,7 +167,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
let
answer
=
{
val
:
""
,
pic_url
:
""
,
correct
:
'
0
'
correct
:
'
0
'
,
type
:
'
T
'
}
return
answer
;
...
...
@@ -174,5 +179,20 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
item
[
key
]
=
e
.
url
;
this
.
save
();
}
setAnswerType
(
e
,
item
){
if
(
e
==
'
P
'
){
item
.
val
=
""
;
}
else
if
(
e
==
'
T
'
){
item
.
pic_url
=
""
;
}
else
{
item
.
val
=
""
;
item
.
pic_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