Commit d921dd6b authored by JinWei's avatar JinWei

feat: 允许上传多个封面

parent 8dc46f24
......@@ -33,11 +33,24 @@
</button>
</div>
<div style="margin: 20px; display: flex; align-items: center;">
<h3 style="min-width: 150px; text-align:left">封面图片:</h3>
<app-upload-image-with-preview style="width: 80%; max-width: 640px;" [picUrl]="item.cover"
(imageUploaded)="onImageUploadSuccess($event)">
</app-upload-image-with-preview>
<div style="margin: 20px; display: flex; align-items: flex-start;">
<h3 style="min-width: 150px; text-align:left; line-height: 32px;">封面图片:</h3>
<div style="display: flex; flex-wrap: wrap; gap: 15px; flex: 1; max-width: 640px;">
<div *ngFor="let url of item.covers; let imgIndex = index" style="width: 200px; position: relative;">
<app-upload-image-with-preview [picUrl]="url" [disableUpload]="true">
</app-upload-image-with-preview>
<button nz-button nzType="danger" nzShape="circle" nzSize="small"
style="position: absolute; top: -10px; right: -10px; z-index: 10;"
(click)="onDeleteCoverMultiImg(item, imgIndex)">
<i nz-icon nzType="close"></i>
</button>
</div>
<div style="width: 200px;">
<app-upload-image-with-preview [picUrl]="null" [TIP]="'点击上传封面'"
(imageUploaded)="onCoverMultiImgUploadSuccess($event, item)">
</app-upload-image-with-preview>
</div>
</div>
</div>
</div>
</div>
......@@ -88,7 +101,7 @@
</span>
</div>
<nz-radio-group [ngModel]="question.correctIndex" (ngModelChange)="onCorrectAnswerChange(question, $event)">
<nz-radio-group [ngModel]="question.correctIndex" (ngModelChange)="onCorrectAnswerChange(question, $event)" style="width: 85%;">
<div *ngFor="let option of question.optionArr; let j = index"
style="border: 1px solid; border-radius: 10px; padding: 12px 15px; margin-bottom: 10px; display: flex; align-items: center; gap: 12px;"
[style.border-color]="question.correctIndex === j ? '#52c41a' : '#ddd'"
......
......@@ -131,6 +131,21 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
this.save();
}
onCoverMultiImgUploadSuccess(e, item, key = 'covers') {
if (!item[key]) {
item[key] = [];
}
item[key].push(e.url);
this.save();
}
onDeleteCoverMultiImg(item, index, key = 'covers') {
if (item[key] && item[key][index]) {
item[key].splice(index, 1);
this.save();
}
}
save() {
(<any>window).courseware.setData(this.item, null, this.saveKey);
this.refresh();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment