Commit 5e998af5 authored by JinWei's avatar JinWei

feat: 新增复制按钮

parent ce5d5dad
...@@ -47,7 +47,10 @@ ...@@ -47,7 +47,10 @@
<!-- 题目头部 --> <!-- 题目头部 -->
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; padding-bottom: 15px; border-bottom: 1px solid #eee;"> <div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; padding-bottom: 15px; border-bottom: 1px solid #eee;">
<h3 style="margin: 0; color: #333;">第 {{i+1}} 题</h3> <h3 style="margin: 0; color: #333;">第 {{i+1}} 题</h3>
<button nz-button nzType="danger" (click)="deleteQuestion(i)">删除题目</button> <div style="display: flex; gap: 8px;">
<button nz-button (click)="copyQuestion(i)">复制题目</button>
<button nz-button nzType="danger" (click)="deleteQuestion(i)">删除题目</button>
</div>
</div> </div>
<!-- 题目图片 --> <!-- 题目图片 -->
......
...@@ -65,10 +65,12 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O ...@@ -65,10 +65,12 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
if (!this.item.questionArr) { if (!this.item.questionArr) {
this.item.questionArr = []; this.item.questionArr = [];
} }
const defaultOptions = [{}, {}];
this.syncOptionKeys(defaultOptions);
this.item.questionArr.push({ this.item.questionArr.push({
text: "", text: "",
correctIndex: null, correctIndex: 0,
optionArr: [] optionArr: defaultOptions
}); });
this.save(); this.save();
} }
...@@ -78,6 +80,12 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O ...@@ -78,6 +80,12 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
this.save(); this.save();
} }
copyQuestion(i: number) {
const copy = JSON.parse(JSON.stringify(this.item.questionArr[i]));
this.item.questionArr.push(copy);
this.save();
}
onCorrectAnswerChange(question: any, index: number) { onCorrectAnswerChange(question: any, index: number) {
question.correctIndex = index; question.correctIndex = index;
this.save(); 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