Commit d921dd6b authored by JinWei's avatar JinWei

feat: 允许上传多个封面

parent 8dc46f24
...@@ -33,11 +33,24 @@ ...@@ -33,11 +33,24 @@
</button> </button>
</div> </div>
<div style="margin: 20px; display: flex; align-items: center;"> <div style="margin: 20px; display: flex; align-items: flex-start;">
<h3 style="min-width: 150px; text-align:left">封面图片:</h3> <h3 style="min-width: 150px; text-align:left; line-height: 32px;">封面图片:</h3>
<app-upload-image-with-preview style="width: 80%; max-width: 640px;" [picUrl]="item.cover" <div style="display: flex; flex-wrap: wrap; gap: 15px; flex: 1; max-width: 640px;">
(imageUploaded)="onImageUploadSuccess($event)"> <div *ngFor="let url of item.covers; let imgIndex = index" style="width: 200px; position: relative;">
</app-upload-image-with-preview> <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> </div>
</div> </div>
...@@ -88,7 +101,7 @@ ...@@ -88,7 +101,7 @@
</span> </span>
</div> </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" <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: 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'" [style.border-color]="question.correctIndex === j ? '#52c41a' : '#ddd'"
......
...@@ -131,6 +131,21 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O ...@@ -131,6 +131,21 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
this.save(); 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() { save() {
(<any>window).courseware.setData(this.item, null, this.saveKey); (<any>window).courseware.setData(this.item, null, this.saveKey);
this.refresh(); 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