Commit 86fff574 authored by JinWei's avatar JinWei

feat: 添加正确选项的key

parent ff02c222
10.24.1
\ No newline at end of file
...@@ -5,8 +5,10 @@ ...@@ -5,8 +5,10 @@
# You can see what browsers were selected by your queries by running: # You can see what browsers were selected by your queries by running:
# npx browserslist # npx browserslist
> 0.5% # Targeting modern browsers only — disables ES5 differential loading bundle, speeds up build significantly.
last 2 versions last 2 Chrome versions
Firefox ESR last 2 Firefox versions
not dead last 2 Edge versions
not IE 9-11 # For IE 9-11 support, remove 'not'. last 2 Safari versions
\ No newline at end of file last 2 iOS versions
not IE 9-11
\ No newline at end of file
...@@ -48,6 +48,17 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O ...@@ -48,6 +48,17 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
if (!this.item.questionArr) { if (!this.item.questionArr) {
this.item.questionArr = []; this.item.questionArr = [];
} }
this.item.questionArr.forEach(q => {
if (q.optionArr) {
this.syncOptionKeys(q.optionArr);
}
});
}
syncOptionKeys(optionArr: any[]) {
optionArr.forEach((option, index) => {
option.key = this.getOptionLabel(index);
});
} }
addQuestion() { addQuestion() {
...@@ -73,7 +84,7 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O ...@@ -73,7 +84,7 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
} }
getOptionLabel(index: number): string { getOptionLabel(index: number): string {
const labels = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']; const labels = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N'];
return labels[index] !== undefined ? labels[index] : String(index + 1); return labels[index] !== undefined ? labels[index] : String(index + 1);
} }
...@@ -82,11 +93,13 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O ...@@ -82,11 +93,13 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
ques.optionArr = []; ques.optionArr = [];
} }
ques.optionArr.push({}); ques.optionArr.push({});
this.syncOptionKeys(ques.optionArr);
this.save(); this.save();
} }
deleteOptionBtnClick(arr, i) { deleteOptionBtnClick(arr, i) {
arr.splice(i, 1); arr.splice(i, 1);
this.syncOptionKeys(arr);
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