feat[survey]: NPS 内容调整
- NPS value使用 hooks 方式. - 解决 preview 的 NPS 组件无法调整的问题 - PreviewNPS 组件实现方式调整 - 增加 nps组件相应的类型文件
This commit is contained in:
@@ -30,7 +30,6 @@
|
||||
<p>{{ element.config.prompt_right }}</p>
|
||||
</div>
|
||||
<RateCharacter
|
||||
v-model="answerValue"
|
||||
:config="element.config"
|
||||
:index="optionIndex"
|
||||
@change="handleRateChange"
|
||||
@@ -47,7 +46,7 @@ import { ref } from 'vue';
|
||||
import RateCharacter from './RateCharacter.vue';
|
||||
|
||||
const isPreview = defineModel('isPreview', { default: false, type: Boolean });
|
||||
const props = defineProps({
|
||||
/*const props = */ defineProps({
|
||||
index: {
|
||||
type: Number,
|
||||
default: 0
|
||||
@@ -60,11 +59,10 @@ const props = defineProps({
|
||||
questionType: { type: [String, Number], default: 4 }
|
||||
});
|
||||
|
||||
// answer 的答案以 矩阵形式存储, 例如 [4,7],上层更新答案的时候也容易
|
||||
const rates = defineModel('rates', { default: [], type: Array });
|
||||
const rate = ref(0);
|
||||
const answerValue = ref();
|
||||
|
||||
/**
|
||||
* element === question
|
||||
* @type {ModelRef<Object, string, Object, Object>}
|
||||
*/
|
||||
const element = defineModel('element', {
|
||||
type: Object,
|
||||
default: () => {
|
||||
@@ -72,29 +70,13 @@ const element = defineModel('element', {
|
||||
}
|
||||
});
|
||||
|
||||
// 不知道的 BUG ,开始的时候不能重置颜色。 故如此
|
||||
setTimeout(() => {
|
||||
rate.value = localStorage.getItem(props.sn);
|
||||
// console.log(`rate value:`, rate.value);
|
||||
// if (rates.value[0] !== undefined) {
|
||||
// console.log(`rates value:`, rates.value);
|
||||
// rate.value = rates.value[0]
|
||||
// }
|
||||
// else return
|
||||
}, 1000);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param index {number} 索引
|
||||
* @param rate {number} 具体数值
|
||||
*/
|
||||
function handleRateChange(index, rate) {
|
||||
// 如果没有查询到对应索引的数值, 那么就直接push一个,直到有数值为止
|
||||
while (rates.value.length < index) {
|
||||
rates.value.push(NaN);
|
||||
}
|
||||
rates.value[index] = rate;
|
||||
localStorage.setItem(props.sn, rate.value);
|
||||
function handleRateChange(/* index, rate */) {
|
||||
// 占位
|
||||
}
|
||||
|
||||
const chooseId = ref('');
|
||||
|
||||
Reference in New Issue
Block a user