@wg-npm/survey-response 0.5.1 → 0.5.123
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/survey-response.esm.js +17201 -678
- package/package.json +10 -7
- package/src/components/more-survey-response.vue +232 -0
- package/src/components/question/question-body.vue +6 -0
- package/src/components/question/question-title-dynamic.vue +61 -0
- package/src/components/question/question-title.vue +35 -5
- package/src/components/question/type/fill-blank.vue +12 -14
- package/src/components/question/type/matrix.vue +21 -4
- package/src/components/question/type/multi-selection.vue +116 -104
- package/src/components/question/type/quill-rich-text.vue +293 -0
- package/src/components/question/type/scoring.vue +84 -92
- package/src/components/question/type/short-answer.vue +10 -24
- package/src/components/question/type/single-selection.vue +120 -115
- package/src/components/slider-input-number.vue +142 -0
- package/src/components/survey-response.vue +23 -218
- package/src/constants.ts +1 -0
- package/src/event-bus.js +3 -0
- package/src/index.ts +5 -1
- package/src/locale/lang/en-US.ts +7 -0
- package/src/locale/lang/zh-CN.ts +6 -0
- package/src/mixins/option-layout-mixin.ts +14 -10
- package/src/mixins/question-mixin.ts +23 -0
- package/src/mixins/survey-response-mixin.ts +245 -0
- package/src/styles/components/survey-response.less +2 -0
|
@@ -2,58 +2,43 @@
|
|
|
2
2
|
<div>
|
|
3
3
|
<!-- question slider -->
|
|
4
4
|
<Row v-if="showQuestionScoreSlider">
|
|
5
|
-
<
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
<Col
|
|
6
|
+
:xs="24"
|
|
7
|
+
:sm="$rootComponent.layout === 'vertical' ? 24 : 12"
|
|
8
|
+
:xl="$rootComponent.layout === 'vertical' ? 24 : 12"
|
|
9
|
+
:md="$rootComponent.layout === 'vertical' ? 24 : 12"
|
|
10
|
+
:lg="$rootComponent.layout === 'vertical' ? 24 : 12"
|
|
11
|
+
>
|
|
12
|
+
<slider-input-number
|
|
8
13
|
v-model="value.score"
|
|
9
14
|
:min="question.options.minRange"
|
|
10
15
|
:max="question.options.maxRange"
|
|
11
|
-
:step="sliderStep"
|
|
12
|
-
|
|
16
|
+
:slider-step="sliderStep"
|
|
17
|
+
:form-item-prop="answerProp"
|
|
13
18
|
:disabled="question.options.readonly || question.options.disabled"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
:
|
|
18
|
-
:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
:max="question.options.maxRange"
|
|
31
|
-
>
|
|
32
|
-
</InputNumber>
|
|
33
|
-
</FormItem>
|
|
34
|
-
<div v-show="extremeValueLabelSelected">
|
|
35
|
-
<span style="float: left; margin-left: 36px">
|
|
36
|
-
{{
|
|
37
|
-
t(
|
|
38
|
-
`survey_creator.question.scoring.extreme_value_labels.${question.options.extremeValueLabel}.minValue`
|
|
39
|
-
)
|
|
40
|
-
}}
|
|
41
|
-
</span>
|
|
42
|
-
<span style="float: right; align-items: flex-end; margin-right: 88px">
|
|
43
|
-
{{
|
|
44
|
-
t(
|
|
45
|
-
`survey_creator.question.scoring.extreme_value_labels.${question.options.extremeValueLabel}.maxValue`
|
|
46
|
-
)
|
|
47
|
-
}}
|
|
48
|
-
</span>
|
|
49
|
-
</div>
|
|
50
|
-
</div>
|
|
19
|
+
:precision="question.options.decimalPlaces"
|
|
20
|
+
:show-label="extremeValueLabelSelected"
|
|
21
|
+
:required="question.options.required && !question.options.disabled"
|
|
22
|
+
:required-desc="t('survey_response.question.question_required')"
|
|
23
|
+
:min-label="
|
|
24
|
+
t(
|
|
25
|
+
`survey_creator.question.scoring.extreme_value_labels.${question.options.extremeValueLabel}.minValue`
|
|
26
|
+
)
|
|
27
|
+
"
|
|
28
|
+
:max-label="
|
|
29
|
+
t(
|
|
30
|
+
`survey_creator.question.scoring.extreme_value_labels.${question.options.extremeValueLabel}.maxValue`
|
|
31
|
+
)
|
|
32
|
+
"
|
|
33
|
+
/>
|
|
34
|
+
</Col>
|
|
51
35
|
</Row>
|
|
52
36
|
<div
|
|
53
37
|
v-else
|
|
54
38
|
v-for="(subQuestion, subIndex) in question.subQuestions"
|
|
55
39
|
:key="subIndex"
|
|
56
40
|
class="sub-question"
|
|
41
|
+
:class="subIndex > 0 ? 'score-sub-question' : ''"
|
|
57
42
|
>
|
|
58
43
|
<span class="number">
|
|
59
44
|
{{ question.header.number }}-{{ subQuestion.number }}.</span
|
|
@@ -61,57 +46,38 @@
|
|
|
61
46
|
<span class="title"> {{ i18nText(subQuestion.text) }} </span>
|
|
62
47
|
<!-- sub question slider -->
|
|
63
48
|
<Row>
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
|
|
49
|
+
<Col
|
|
50
|
+
:xs="24"
|
|
51
|
+
:sm="$rootComponent.layout === 'vertical' ? 24 : 12"
|
|
52
|
+
:xl="$rootComponent.layout === 'vertical' ? 24 : 12"
|
|
53
|
+
:md="$rootComponent.layout === 'vertical' ? 24 : 12"
|
|
54
|
+
:lg="$rootComponent.layout === 'vertical' ? 24 : 12"
|
|
55
|
+
>
|
|
56
|
+
<slider-input-number
|
|
67
57
|
v-model="value.answer[subIndex].score"
|
|
68
58
|
:min="question.options.minRange"
|
|
69
59
|
:max="question.options.maxRange"
|
|
70
|
-
:step="sliderStep"
|
|
71
|
-
|
|
60
|
+
:slider-step="sliderStep"
|
|
61
|
+
:form-item-prop="subAnswerProp(subIndex)"
|
|
72
62
|
:disabled="
|
|
73
63
|
subQuestion.options.readonly || question.options.disabled
|
|
74
64
|
"
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
:
|
|
79
|
-
:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
:min="question.options.minRange"
|
|
92
|
-
:max="question.options.maxRange"
|
|
93
|
-
>
|
|
94
|
-
</InputNumber>
|
|
95
|
-
</FormItem>
|
|
96
|
-
<div v-show="extremeValueLabelSelected">
|
|
97
|
-
<span style="float: left; margin-left: 36px">
|
|
98
|
-
{{
|
|
99
|
-
t(
|
|
100
|
-
`survey_creator.question.scoring.extreme_value_labels.${question.options.extremeValueLabel}.minValue`
|
|
101
|
-
)
|
|
102
|
-
}}
|
|
103
|
-
</span>
|
|
104
|
-
<span
|
|
105
|
-
style="float: right; align-items: flex-end; margin-right: 88px"
|
|
106
|
-
>
|
|
107
|
-
{{
|
|
108
|
-
t(
|
|
109
|
-
`survey_creator.question.scoring.extreme_value_labels.${question.options.extremeValueLabel}.maxValue`
|
|
110
|
-
)
|
|
111
|
-
}}
|
|
112
|
-
</span>
|
|
113
|
-
</div>
|
|
114
|
-
</div>
|
|
65
|
+
:precision="question.options.decimalPlaces"
|
|
66
|
+
:show-label="extremeValueLabelSelected"
|
|
67
|
+
:required="question.options.required && !question.options.disabled"
|
|
68
|
+
:required-desc="t('survey_response.question.question_required')"
|
|
69
|
+
:min-label="
|
|
70
|
+
t(
|
|
71
|
+
`survey_creator.question.scoring.extreme_value_labels.${question.options.extremeValueLabel}.minValue`
|
|
72
|
+
)
|
|
73
|
+
"
|
|
74
|
+
:max-label="
|
|
75
|
+
t(
|
|
76
|
+
`survey_creator.question.scoring.extreme_value_labels.${question.options.extremeValueLabel}.maxValue`
|
|
77
|
+
)
|
|
78
|
+
"
|
|
79
|
+
/>
|
|
80
|
+
</Col>
|
|
115
81
|
</Row>
|
|
116
82
|
</div>
|
|
117
83
|
</div>
|
|
@@ -120,7 +86,8 @@
|
|
|
120
86
|
<script lang="ts">
|
|
121
87
|
import Vue from "vue";
|
|
122
88
|
import OptionLayoutMixin from "../../../mixins/option-layout-mixin";
|
|
123
|
-
import { Row,
|
|
89
|
+
import { Row, Col } from "view-design";
|
|
90
|
+
import SliderInputNumber from "../../../components/slider-input-number.vue";
|
|
124
91
|
import _ from "lodash";
|
|
125
92
|
|
|
126
93
|
export default Vue.extend({
|
|
@@ -130,9 +97,8 @@ export default Vue.extend({
|
|
|
130
97
|
|
|
131
98
|
components: {
|
|
132
99
|
Row,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
InputNumber,
|
|
100
|
+
Col,
|
|
101
|
+
SliderInputNumber,
|
|
136
102
|
},
|
|
137
103
|
props: {
|
|
138
104
|
question: {
|
|
@@ -140,6 +106,12 @@ export default Vue.extend({
|
|
|
140
106
|
required: true,
|
|
141
107
|
},
|
|
142
108
|
index: Number,
|
|
109
|
+
surveyIndex: Number,
|
|
110
|
+
isMoreSurvey: {
|
|
111
|
+
type: Boolean,
|
|
112
|
+
required: false,
|
|
113
|
+
default: false,
|
|
114
|
+
},
|
|
143
115
|
answer: {
|
|
144
116
|
type: Object,
|
|
145
117
|
required: true,
|
|
@@ -173,8 +145,19 @@ export default Vue.extend({
|
|
|
173
145
|
this.value.answer.push(_answer);
|
|
174
146
|
});
|
|
175
147
|
},
|
|
176
|
-
methods: {
|
|
148
|
+
methods: {
|
|
149
|
+
subAnswerProp(subIndex) {
|
|
150
|
+
return this.isMoreSurvey
|
|
151
|
+
? `moreSurveyAnswers[${this.surveyIndex}].answers[${this.index}].answer[${subIndex}].score`
|
|
152
|
+
: `answers[${this.index}].answer[${subIndex}].score`;
|
|
153
|
+
},
|
|
154
|
+
},
|
|
177
155
|
computed: {
|
|
156
|
+
answerProp() {
|
|
157
|
+
return this.isMoreSurvey
|
|
158
|
+
? `moreSurveyAnswers[${this.surveyIndex}].answers[${this.index}].score`
|
|
159
|
+
: `answers[${this.index}].score`;
|
|
160
|
+
},
|
|
178
161
|
showQuestionScoreSlider() {
|
|
179
162
|
return !(
|
|
180
163
|
this.question.subQuestions && this.question.subQuestions.length > 0
|
|
@@ -194,6 +177,15 @@ export default Vue.extend({
|
|
|
194
177
|
_.forEach(this.value.answer, (a) => (a.score = 0));
|
|
195
178
|
}
|
|
196
179
|
},
|
|
180
|
+
answer(n) {
|
|
181
|
+
this.value = n;
|
|
182
|
+
},
|
|
197
183
|
},
|
|
198
184
|
});
|
|
199
185
|
</script>
|
|
186
|
+
|
|
187
|
+
<style lang="less" scoped>
|
|
188
|
+
.score-sub-question {
|
|
189
|
+
padding-top: 24px;
|
|
190
|
+
}
|
|
191
|
+
</style>
|
|
@@ -1,36 +1,19 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
-
<div
|
|
4
|
-
v-if="readonly || question.options.disabled"
|
|
5
|
-
class="processed-answer"
|
|
6
|
-
v-html="decodeHTML(value)"
|
|
7
|
-
/>
|
|
8
3
|
<FormItem
|
|
9
|
-
|
|
10
|
-
:prop="`answers[${index}].answer`"
|
|
4
|
+
:prop="answerProp"
|
|
11
5
|
:rules="{
|
|
12
6
|
required: question.options.required,
|
|
13
7
|
message: t('survey_response.question.question_required'),
|
|
14
8
|
}"
|
|
15
9
|
>
|
|
16
|
-
<
|
|
17
|
-
v-if="question.options && question.options.wordLimit"
|
|
10
|
+
<quill-rich-text
|
|
18
11
|
v-model.trim="value.answer"
|
|
19
|
-
|
|
20
|
-
:rows="4"
|
|
21
|
-
show-word-limit
|
|
12
|
+
:disabled="readonly || question.options.readonly"
|
|
22
13
|
:placeholder="placeholder"
|
|
23
14
|
:maxlength="question.options.wordLimit"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
<Input
|
|
27
|
-
v-else
|
|
28
|
-
v-model.trim="value.answer"
|
|
29
|
-
type="textarea"
|
|
30
|
-
:rows="4"
|
|
31
|
-
:placeholder="placeholder"
|
|
32
|
-
:disabled="question.options.readonly"
|
|
33
|
-
/>
|
|
15
|
+
></quill-rich-text>
|
|
16
|
+
<div></div>
|
|
34
17
|
</FormItem>
|
|
35
18
|
</div>
|
|
36
19
|
</template>
|
|
@@ -38,19 +21,22 @@
|
|
|
38
21
|
<script lang="ts">
|
|
39
22
|
import Vue from "vue";
|
|
40
23
|
import { FormItem, Input } from "view-design";
|
|
24
|
+
import QuestionMixin from "../../../mixins/question-mixin";
|
|
25
|
+
import QuillRichText from "./quill-rich-text.vue";
|
|
41
26
|
|
|
42
27
|
export default Vue.extend({
|
|
43
28
|
name: "short-answer",
|
|
29
|
+
mixins: [QuestionMixin],
|
|
44
30
|
components: {
|
|
31
|
+
QuillRichText,
|
|
45
32
|
FormItem,
|
|
46
|
-
Input,
|
|
47
33
|
},
|
|
34
|
+
inject: ["$rootComponent"],
|
|
48
35
|
props: {
|
|
49
36
|
question: {
|
|
50
37
|
type: Object,
|
|
51
38
|
required: true,
|
|
52
39
|
},
|
|
53
|
-
index: Number,
|
|
54
40
|
answer: {
|
|
55
41
|
type: Object,
|
|
56
42
|
required: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<FormItem
|
|
3
|
-
:prop="
|
|
3
|
+
:prop="answerProp"
|
|
4
4
|
:rules="{
|
|
5
5
|
required: question.options.required && !question.options.disabled,
|
|
6
6
|
message: t('survey_response.question.question_required'),
|
|
@@ -11,18 +11,18 @@
|
|
|
11
11
|
@on-change="selChange"
|
|
12
12
|
class="question-choice"
|
|
13
13
|
>
|
|
14
|
-
<Row type="
|
|
14
|
+
<Row :type="flexOrBlock" justify="start" :gutter="60" :style="{'display':(isMobile()?'inline-block':'flex')}">
|
|
15
15
|
<Col
|
|
16
16
|
v-for="choice in question.choices"
|
|
17
17
|
:key="choice.id"
|
|
18
18
|
:class="optionLayout"
|
|
19
|
-
style="display:
|
|
19
|
+
:style="{'display':(isMobile()?'inline-block':'flex')}"
|
|
20
20
|
>
|
|
21
|
-
<Radio
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
<Radio :style="{'display':(isMobile()?'inline-block':'flex'),'align-items':(isMobile()?'':'center')}"
|
|
22
|
+
:disabled="question.options.readonly || question.options.disabled"
|
|
23
|
+
:label="choice.id"
|
|
24
|
+
:key="choice.id"
|
|
25
|
+
@click.native="
|
|
26
26
|
toggleAnswer($event, choice.id, question.options.disabled)
|
|
27
27
|
"
|
|
28
28
|
>
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
v-if="
|
|
40
40
|
choice.id === inputAnswer.choiceId && choice.id === value.answer
|
|
41
41
|
"
|
|
42
|
-
:prop="
|
|
42
|
+
:prop="inputAnswerProp(inputIndex)"
|
|
43
43
|
:rules="[
|
|
44
44
|
{
|
|
45
45
|
required: true,
|
|
@@ -56,11 +56,10 @@
|
|
|
56
56
|
},
|
|
57
57
|
]"
|
|
58
58
|
>
|
|
59
|
-
<
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
v-model.trim="inputAnswer.inputText"
|
|
59
|
+
<Span v-if="responseStatus=='ENABLED'">
|
|
60
|
+
{{ inputAnswer.inputText }}</Span>
|
|
61
|
+
<Input v-if="responseStatus=='DRAFT'"
|
|
62
|
+
v-model.trim="inputAnswer.inputText"
|
|
64
63
|
/>
|
|
65
64
|
</FormItem>
|
|
66
65
|
</div>
|
|
@@ -71,120 +70,126 @@
|
|
|
71
70
|
</template>
|
|
72
71
|
|
|
73
72
|
<script lang="ts">
|
|
74
|
-
import Vue from "vue";
|
|
75
|
-
import OptionLayoutMixin from "../../../mixins/option-layout-mixin";
|
|
76
|
-
import {
|
|
77
|
-
|
|
78
|
-
FormItem,
|
|
79
|
-
Icon,
|
|
80
|
-
Radio,
|
|
81
|
-
RadioGroup,
|
|
82
|
-
Row,
|
|
83
|
-
Input,
|
|
84
|
-
} from "view-design";
|
|
85
|
-
import _ from "lodash";
|
|
86
|
-
import { SurveyLayout } from "@wg-npm/survey-core";
|
|
87
|
-
|
|
88
|
-
export default Vue.extend({
|
|
89
|
-
name: "single-selection",
|
|
90
|
-
components: {
|
|
73
|
+
import Vue from "vue";
|
|
74
|
+
import OptionLayoutMixin from "../../../mixins/option-layout-mixin";
|
|
75
|
+
import {
|
|
76
|
+
Col,
|
|
91
77
|
FormItem,
|
|
92
|
-
|
|
78
|
+
Icon,
|
|
93
79
|
Radio,
|
|
80
|
+
RadioGroup,
|
|
94
81
|
Row,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
mixins
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
},
|
|
112
|
-
data() {
|
|
113
|
-
return {
|
|
114
|
-
value: this.answer,
|
|
115
|
-
// @ts-ignore
|
|
116
|
-
choiceClasses: this.buildChoiceClasses(),
|
|
117
|
-
};
|
|
118
|
-
},
|
|
119
|
-
watch: {
|
|
120
|
-
"question.options.layout"() {
|
|
121
|
-
this.choiceClasses = this.buildChoiceClasses();
|
|
122
|
-
},
|
|
123
|
-
answer(n) {
|
|
124
|
-
this.value = n;
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
methods: {
|
|
128
|
-
selChange(id) {
|
|
129
|
-
// @ts-ignore
|
|
130
|
-
_.each(this.question.choices, (choice) => {
|
|
131
|
-
if (choice.id == id) {
|
|
132
|
-
// @ts-ignore
|
|
133
|
-
this.answer.score = parseInt(choice?.options?.score ?? 0);
|
|
134
|
-
this.answer.star = parseInt(choice?.options?.starCount ?? 0);
|
|
135
|
-
}
|
|
136
|
-
});
|
|
82
|
+
Input
|
|
83
|
+
} from "view-design";
|
|
84
|
+
import _ from "lodash";
|
|
85
|
+
import { SurveyLayout } from "@wg-npm/survey-core";
|
|
86
|
+
import QuestionMixin from "../../../mixins/question-mixin";
|
|
87
|
+
|
|
88
|
+
export default Vue.extend({
|
|
89
|
+
name: "single-selection",
|
|
90
|
+
components: {
|
|
91
|
+
FormItem,
|
|
92
|
+
RadioGroup,
|
|
93
|
+
Radio,
|
|
94
|
+
Row,
|
|
95
|
+
Col,
|
|
96
|
+
Icon,
|
|
97
|
+
Input
|
|
137
98
|
},
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
99
|
+
mixins: [OptionLayoutMixin, QuestionMixin],
|
|
100
|
+
inject: ["responseStatus", "$rootComponent"],
|
|
101
|
+
props: {
|
|
102
|
+
question: {
|
|
103
|
+
type: Object,
|
|
104
|
+
required: true
|
|
105
|
+
},
|
|
106
|
+
answer: {
|
|
107
|
+
type: Object,
|
|
108
|
+
required: true
|
|
109
|
+
}
|
|
145
110
|
},
|
|
146
|
-
|
|
147
|
-
return
|
|
111
|
+
data() {
|
|
112
|
+
return {
|
|
113
|
+
value: this.answer,
|
|
114
|
+
// @ts-ignore
|
|
115
|
+
choiceClasses: this.buildChoiceClasses()
|
|
116
|
+
};
|
|
148
117
|
},
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
this.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
return;
|
|
118
|
+
watch: {
|
|
119
|
+
"question.options.layout"() {
|
|
120
|
+
this.choiceClasses = this.buildChoiceClasses();
|
|
121
|
+
},
|
|
122
|
+
answer(n) {
|
|
123
|
+
this.value = n;
|
|
156
124
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
});
|
|
125
|
+
},
|
|
126
|
+
computed: {
|
|
127
|
+
flexOrBlock() {
|
|
128
|
+
if (this.isMobile()) {
|
|
129
|
+
return "inline-block";
|
|
163
130
|
} else {
|
|
164
|
-
|
|
131
|
+
return "flex";
|
|
165
132
|
}
|
|
166
133
|
}
|
|
167
|
-
this.$emit("singleQuestion", {
|
|
168
|
-
questionId: this.question.id,
|
|
169
|
-
choiceId: this.value.answer,
|
|
170
|
-
});
|
|
171
134
|
},
|
|
172
|
-
|
|
173
|
-
|
|
135
|
+
methods: {
|
|
136
|
+
inputAnswerProp(inputIndex) {
|
|
137
|
+
return this.isMoreSurvey
|
|
138
|
+
? `moreSurveyAnswers[${this.surveyIndex}].answers[${this.index}].inputAnswers[${inputIndex}].inputText`
|
|
139
|
+
: `answers[${this.index}].inputAnswers[${inputIndex}].inputText`;
|
|
140
|
+
},
|
|
141
|
+
selChange(id) {
|
|
142
|
+
// @ts-ignore
|
|
143
|
+
_.each(this.question.choices, (choice) => {
|
|
144
|
+
if (choice.id == id) {
|
|
145
|
+
// @ts-ignore
|
|
146
|
+
this.answer.score = parseInt(choice?.options?.score ?? 0);
|
|
147
|
+
this.answer.star = parseInt(choice?.options?.starCount ?? 0);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
},
|
|
151
|
+
buildChoiceClasses() {
|
|
152
|
+
return [
|
|
153
|
+
`question-choice`,
|
|
154
|
+
`question-choice-${_.lowerCase(
|
|
155
|
+
this.question.options.layout || SurveyLayout.HORIZONTAL
|
|
156
|
+
)}`
|
|
157
|
+
];
|
|
158
|
+
},
|
|
159
|
+
haveStar(choice) {
|
|
160
|
+
return choice.options?.star ?? false;
|
|
161
|
+
},
|
|
162
|
+
toggleAnswer(e, value, disabled) {
|
|
163
|
+
if (
|
|
164
|
+
this.question.options.readonly ||
|
|
165
|
+
disabled ||
|
|
166
|
+
e.target.tagName !== "INPUT"
|
|
167
|
+
) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (this.responseStatus == this.$consts.STATUS_DRAFT) {
|
|
171
|
+
if (this.value.answer && this.value.answer === value) {
|
|
172
|
+
this.value.answer = null;
|
|
173
|
+
_.forEach(this.value.inputAnswers, (input) => {
|
|
174
|
+
input.inputText = null;
|
|
175
|
+
});
|
|
176
|
+
} else {
|
|
177
|
+
this.value.answer = value;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
this.$emit("singleQuestion", {
|
|
181
|
+
questionId: this.question.id,
|
|
182
|
+
choiceId: this.value.answer
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
});
|
|
174
187
|
</script>
|
|
175
188
|
|
|
176
189
|
<style lang="less" scoped>
|
|
177
|
-
.
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
display: flex;
|
|
182
|
-
flex-direction: row;
|
|
183
|
-
align-items: center;
|
|
184
|
-
}
|
|
190
|
+
.choice-title {
|
|
191
|
+
margin-left: 8px;
|
|
192
|
+
margin-right: 8px;
|
|
193
|
+
}
|
|
185
194
|
|
|
186
|
-
.choice-title {
|
|
187
|
-
margin-left: 8px;
|
|
188
|
-
margin-right: 8px;
|
|
189
|
-
}
|
|
190
195
|
</style>
|