Update style of scale rating
This commit is contained in:
parent
c70a304ae5
commit
e30ef0c495
36
src/App.vue
36
src/App.vue
@ -49,6 +49,7 @@ export default {
|
|||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
allowBack: true,
|
allowBack: true,
|
||||||
|
allowAutoNext: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -103,6 +104,13 @@ export default {
|
|||||||
iterOptions() {
|
iterOptions() {
|
||||||
return this.itemStatus.item.optTexts.map((optText, index) => [index, optText]);
|
return this.itemStatus.item.optTexts.map((optText, index) => [index, optText]);
|
||||||
},
|
},
|
||||||
|
getScaleMarks() {
|
||||||
|
const marks = {};
|
||||||
|
this.itemStatus.item.optTexts.forEach((optText, index) => {
|
||||||
|
marks[index] = (index === 0 || index === this.itemStatus.item.optTexts.length - 1) ? optText : '';
|
||||||
|
});
|
||||||
|
return marks;
|
||||||
|
},
|
||||||
clickNext() {
|
clickNext() {
|
||||||
const item = this.items[this.currentIdx];
|
const item = this.items[this.currentIdx];
|
||||||
if (item.type !== 'display' && item.type !== 'checkbox' && item.required && this.itemStatus.answer === undefined) {
|
if (item.type !== 'display' && item.type !== 'checkbox' && item.required && this.itemStatus.answer === undefined) {
|
||||||
@ -123,8 +131,8 @@ export default {
|
|||||||
item.answerText = item.answer.map(idx => item.optTexts[idx]).join(', ');
|
item.answerText = item.answer.map(idx => item.optTexts[idx]).join(', ');
|
||||||
item.answerValue = item.answer.map(idx => item.optValues[idx]).join(', ');
|
item.answerValue = item.answer.map(idx => item.optValues[idx]).join(', ');
|
||||||
} if (item.type === 'scale' && item.answer !== undefined) {
|
} if (item.type === 'scale' && item.answer !== undefined) {
|
||||||
item.answerText = item.optTexts[item.answer - 1];
|
item.answerText = item.optTexts[item.answer];
|
||||||
item.answerValue = item.optValues[item.answer - 1];
|
item.answerValue = item.optValues[item.answer];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.currentIdx === this.items.length - 1) {
|
if (this.currentIdx === this.items.length - 1) {
|
||||||
@ -135,7 +143,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
autoNext() {
|
autoNext() {
|
||||||
if (this.currentIdx < this.items.length - 1 && !this.itemStatus.refilled) {
|
if (this.settings.allowAutoNext && this.currentIdx < this.items.length - 1 && !this.itemStatus.refilled) {
|
||||||
this.clickNext();
|
this.clickNext();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -193,10 +201,19 @@ export default {
|
|||||||
</el-checkbox-group>
|
</el-checkbox-group>
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="itemStatus.item.type === 'scale'">
|
<template v-else-if="itemStatus.item.type === 'scale'">
|
||||||
<el-rate v-model="itemStatus.answer" :texts="itemStatus.item.optTexts"
|
<el-row id="scale-row">
|
||||||
show-text size="large" void-icon="ArrowRightBold"
|
<el-col :span="4">
|
||||||
:icons="['ArrowRightBold', 'ArrowRightBold', 'ArrowRightBold']"
|
<el-text size="large" tag="b">{{ itemStatus.item.optTexts[0] }}</el-text>
|
||||||
@change="autoNext" />
|
</el-col>
|
||||||
|
<el-col :span="16">
|
||||||
|
<el-slider v-model="itemStatus.answer" size="small"
|
||||||
|
show-stops :min="0" :max="itemStatus.item.optTexts.length - 1"
|
||||||
|
:format-tooltip="val => itemStatus.item.optTexts[val]" @change="autoNext" />
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="4">
|
||||||
|
<el-text size="large" tag="b">{{ itemStatus.item.optTexts[itemStatus.item.optTexts.length - 1] }}</el-text>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
</template>
|
</template>
|
||||||
</el-main>
|
</el-main>
|
||||||
|
|
||||||
@ -269,7 +286,8 @@ export default {
|
|||||||
font-size: 16pt;
|
font-size: 16pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
#display-content el-rate {
|
#display-content #scale-row {
|
||||||
font-size: 24pt;
|
text-align: center;
|
||||||
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
Loading…
Reference in New Issue
Block a user