Commit dfa7d78e authored by JinWei's avatar JinWei

Merge branch 'feature/jj_exam' into 'master'

feat:显示之前上传的图片

See merge request !8
parents 42d22a27 62194f52
......@@ -36,6 +36,17 @@
<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;">
<!-- 只有一张图片且在 cover 字段时显示 -->
<div *ngIf="(!item.covers || item.covers.length === 0) && item.cover" style="width: 200px; position: relative;">
<app-upload-image-with-preview [picUrl]="item.cover" [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)="onDeletaImg(item, 'cover')">
<i nz-icon nzType="close"></i>
</button>
</div>
<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>
......
......@@ -52,6 +52,10 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
if (q.optionArr) {
this.syncOptionKeys(q.optionArr);
}
// 兼容旧版本:如果只有 cover 没有 covers,或者 covers 为空但 cover 有值
if (q.cover && (!q.covers || q.covers.length === 0)) {
q.covers = [q.cover];
}
});
}
......@@ -136,12 +140,20 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
item[key] = [];
}
item[key].push(e.url);
if (item[key].length === 1) {
item.cover = item[key][0];
}
this.save();
}
onDeleteCoverMultiImg(item, index, key = 'covers') {
if (item[key] && item[key][index]) {
item[key].splice(index, 1);
if (item[key].length > 0) {
item.cover = item[key][0];
} else {
item.cover = "";
}
this.save();
}
}
......
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