@wg-npm/survey-response 0.5.157 → 0.5.158
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 +130 -90
- package/package.json +5 -5
- package/src/components/question/question-title.vue +66 -62
- package/src/components/question/type/multi-selection.vue +131 -114
- package/src/components/question/type/single-selection.vue +121 -121
- package/src/mixins/option-layout-mixin.ts +16 -12
|
@@ -179,26 +179,67 @@ var __vue_staticRenderFns__$h = [];
|
|
|
179
179
|
|
|
180
180
|
var EmptyQuestion = __vue_component__$h;
|
|
181
181
|
|
|
182
|
+
var OptionLayoutMixin = Vue.extend({
|
|
183
|
+
props: {
|
|
184
|
+
options: {
|
|
185
|
+
type: Object,
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
methods: {
|
|
189
|
+
isMobile() {
|
|
190
|
+
const val = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
|
|
191
|
+
return !_.isEmpty(val);
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
computed: {
|
|
195
|
+
optionLayout() {
|
|
196
|
+
const globalLayout = _.lowerCase(_.get(this.options, "layout", "horizontal"));
|
|
197
|
+
return `question-choice-${globalLayout}`;
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
var QuestionMixin = Vue.extend({
|
|
203
|
+
props: {
|
|
204
|
+
index: Number,
|
|
205
|
+
surveyIndex: Number,
|
|
206
|
+
isMoreSurvey: {
|
|
207
|
+
type: Boolean,
|
|
208
|
+
required: false,
|
|
209
|
+
default: false,
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
computed: {
|
|
213
|
+
answerProp() {
|
|
214
|
+
return this.isMoreSurvey
|
|
215
|
+
? `moreSurveyAnswers[${this.surveyIndex}].answers[${this.index}].answer`
|
|
216
|
+
: `answers[${this.index}].answer`;
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
methods: {},
|
|
220
|
+
});
|
|
221
|
+
|
|
182
222
|
var script$g = Vue.extend({
|
|
183
223
|
name: "question-title",
|
|
224
|
+
mixins: [OptionLayoutMixin, QuestionMixin],
|
|
184
225
|
components: { Icon },
|
|
185
226
|
inject: ["$rootComponent"],
|
|
186
227
|
props: {
|
|
187
228
|
index: {
|
|
188
229
|
type: Number,
|
|
189
|
-
default: 0
|
|
230
|
+
default: 0
|
|
190
231
|
},
|
|
191
232
|
question: {
|
|
192
233
|
type: Object,
|
|
193
|
-
required: true
|
|
234
|
+
required: true
|
|
194
235
|
},
|
|
195
236
|
language: {
|
|
196
|
-
type: String
|
|
237
|
+
type: String
|
|
197
238
|
},
|
|
198
239
|
customQuestion: {
|
|
199
240
|
type: Object,
|
|
200
|
-
required: false
|
|
201
|
-
}
|
|
241
|
+
required: false
|
|
242
|
+
}
|
|
202
243
|
},
|
|
203
244
|
computed: {
|
|
204
245
|
customFilledTitle() {
|
|
@@ -209,7 +250,7 @@ var script$g = Vue.extend({
|
|
|
209
250
|
},
|
|
210
251
|
isSingleSelection() {
|
|
211
252
|
return this.question.type == "SINGLE_SELECTION";
|
|
212
|
-
}
|
|
253
|
+
}
|
|
213
254
|
},
|
|
214
255
|
methods: {
|
|
215
256
|
getShowInput(index, formatTitle) {
|
|
@@ -217,18 +258,18 @@ var script$g = Vue.extend({
|
|
|
217
258
|
},
|
|
218
259
|
getTitle(question) {
|
|
219
260
|
return formatTitle(question, this.$rootComponent.currentLanguage);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
222
263
|
});
|
|
223
264
|
|
|
224
265
|
/* script */
|
|
225
266
|
const __vue_script__$g = script$g;
|
|
226
267
|
|
|
227
268
|
/* template */
|
|
228
|
-
var __vue_render__$g = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"question-title"},[(_vm.question.type !== 'text_title')?_c('span',{staticClass:"pr-sm"},[(_vm.question.options.required)?_c('label',{staticClass:"require-label"},[_vm._v("*")]):_vm._e(),_vm._v(" "),(_vm.question.header.number)?_c('label',{staticClass:"number"},[_vm._v(_vm._s(_vm.question.header.number)+".")]):_vm._e()]):_vm._e(),_vm._v(" "),_vm._l((_vm.getTitle(_vm.question)),function(title,index){return _c('div',{key:index,staticClass:"flex"},[(title !== '')?_c('span',{staticClass:"content"},[_vm._v(_vm._s(title))]):_vm._e(),_vm._v(" "),_vm._l((_vm.customFilledTitle),function(customTitle){return _c('div',{key:index + customTitle.index},[(title === '' && index === customTitle.index)?_c('span',{staticClass:"content"},[_vm._v(_vm._s(customTitle.title))]):_c('div',[(
|
|
269
|
+
var __vue_render__$g = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"question-title",style:({'display':(_vm.isMobile()?'inline-block':'')})},[(_vm.question.type !== 'text_title')?_c('span',{staticClass:"pr-sm",style:({'display':(_vm.isMobile()?'inline-block':'')})},[(_vm.question.options.required)?_c('label',{staticClass:"require-label"},[_vm._v("*")]):_vm._e(),_vm._v(" "),(_vm.question.header.number)?_c('label',{staticClass:"number"},[_vm._v(_vm._s(_vm.question.header.number)+".")]):_vm._e()]):_vm._e(),_vm._v(" "),_vm._l((_vm.getTitle(_vm.question)),function(title,index){return _c('div',{key:index,staticClass:"flex",style:({'display':(_vm.isMobile()?'inline-block':'')})},[(title !== '')?_c('span',{staticClass:"content"},[_vm._v(_vm._s(title))]):_vm._e(),_vm._v(" "),_vm._l((_vm.customFilledTitle),function(customTitle){return _c('div',{key:index + customTitle.index},[(title === '' && index === customTitle.index)?_c('span',{staticClass:"content"},[_vm._v(_vm._s(customTitle.title))]):_c('div',[(
|
|
229
270
|
_vm.getShowInput(index, _vm.getTitle(_vm.question)) &&
|
|
230
271
|
index === customTitle.index
|
|
231
|
-
)?_c('span',{staticClass:"content"},[_vm._v(_vm._s(customTitle.title))]):_vm._e()])])})],2)}),_vm._v(" "),(_vm.haveStar)?_c('span',{staticClass:"options-explain"},[(_vm.isSingleSelection)?_c('span',[_vm._v("\n ("+_vm._s(_vm.t(
|
|
272
|
+
)?_c('span',{staticClass:"content"},[_vm._v(_vm._s(customTitle.title))]):_vm._e()])])})],2)}),_vm._v(" "),(_vm.haveStar)?_c('span',{staticClass:"options-explain",style:({'display':(_vm.isMobile()?'block':'')})},[(_vm.isSingleSelection)?_c('span',[_vm._v("\n ("+_vm._s(_vm.t(
|
|
232
273
|
"survey_creator.question.star_single",
|
|
233
274
|
_vm.$rootComponent.currentLanguage
|
|
234
275
|
))+"\n "),_c('span',[_c('Icon',{attrs:{"type":"md-star","color":"orange","size":16}})],1),_vm._v(")\n ")]):_c('span',[_vm._v("\n (\n "+_vm._s(_vm.t(
|
|
@@ -246,11 +287,11 @@ var __vue_staticRenderFns__$g = [];
|
|
|
246
287
|
/* style */
|
|
247
288
|
const __vue_inject_styles__$g = function (inject) {
|
|
248
289
|
if (!inject) return
|
|
249
|
-
inject("data-v-
|
|
290
|
+
inject("data-v-67dae2e1_0", { source: ".flex[data-v-67dae2e1]{display:flex;align-items:center;white-space:nowrap}.pr-sm[data-v-67dae2e1]{padding-right:4px}", map: undefined, media: undefined });
|
|
250
291
|
|
|
251
292
|
};
|
|
252
293
|
/* scoped */
|
|
253
|
-
const __vue_scope_id__$g = "data-v-
|
|
294
|
+
const __vue_scope_id__$g = "data-v-67dae2e1";
|
|
254
295
|
/* module identifier */
|
|
255
296
|
const __vue_module_identifier__$g = undefined;
|
|
256
297
|
/* functional template */
|
|
@@ -276,45 +317,6 @@ var __vue_staticRenderFns__$g = [];
|
|
|
276
317
|
|
|
277
318
|
var QuestionTitle = __vue_component__$g;
|
|
278
319
|
|
|
279
|
-
var OptionLayoutMixin = Vue.extend({
|
|
280
|
-
methods: {
|
|
281
|
-
isMobile() {
|
|
282
|
-
const flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
|
|
283
|
-
return flag;
|
|
284
|
-
},
|
|
285
|
-
},
|
|
286
|
-
computed: {
|
|
287
|
-
optionLayout() {
|
|
288
|
-
const globalLayout = _.lowerCase(_.get(this.options, "layout", undefined));
|
|
289
|
-
if (this.isMobile() || "vertical" == globalLayout) {
|
|
290
|
-
return "";
|
|
291
|
-
}
|
|
292
|
-
const questionLayout = _.lowerCase(_.get(this.question.options, "layout", "horizontal"));
|
|
293
|
-
return `question-choice-${questionLayout}`;
|
|
294
|
-
},
|
|
295
|
-
},
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
var QuestionMixin = Vue.extend({
|
|
299
|
-
props: {
|
|
300
|
-
index: Number,
|
|
301
|
-
surveyIndex: Number,
|
|
302
|
-
isMoreSurvey: {
|
|
303
|
-
type: Boolean,
|
|
304
|
-
required: false,
|
|
305
|
-
default: false,
|
|
306
|
-
},
|
|
307
|
-
},
|
|
308
|
-
computed: {
|
|
309
|
-
answerProp() {
|
|
310
|
-
return this.isMoreSurvey
|
|
311
|
-
? `moreSurveyAnswers[${this.surveyIndex}].answers[${this.index}].answer`
|
|
312
|
-
: `answers[${this.index}].answer`;
|
|
313
|
-
},
|
|
314
|
-
},
|
|
315
|
-
methods: {},
|
|
316
|
-
});
|
|
317
|
-
|
|
318
320
|
var script$f = Vue.extend({
|
|
319
321
|
name: "multi-selection",
|
|
320
322
|
inject: ["responseStatus", "$rootComponent"],
|
|
@@ -325,27 +327,55 @@ var script$f = Vue.extend({
|
|
|
325
327
|
Checkbox,
|
|
326
328
|
Row,
|
|
327
329
|
Col,
|
|
328
|
-
Input
|
|
330
|
+
Input
|
|
329
331
|
},
|
|
330
332
|
props: {
|
|
331
333
|
question: {
|
|
332
334
|
type: Object,
|
|
333
|
-
required: true
|
|
335
|
+
required: true
|
|
334
336
|
},
|
|
335
337
|
answer: {
|
|
336
338
|
type: Object,
|
|
337
|
-
required: true
|
|
338
|
-
}
|
|
339
|
+
required: true
|
|
340
|
+
}
|
|
339
341
|
},
|
|
340
342
|
data() {
|
|
341
343
|
return {
|
|
342
|
-
value: this.answer
|
|
344
|
+
value: this.answer
|
|
343
345
|
};
|
|
344
346
|
},
|
|
345
347
|
watch: {
|
|
346
348
|
answer(n) {
|
|
347
349
|
this.value = n;
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
computed: {
|
|
353
|
+
flexOrBlock() {
|
|
354
|
+
if (this.isMobile()) {
|
|
355
|
+
_.each(document.querySelectorAll(".ivu-radio-group-item"), (ele) => {
|
|
356
|
+
ele.style.display = "inline-block";
|
|
357
|
+
});
|
|
358
|
+
return "inline-block";
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
_.each(document.querySelectorAll(".ivu-row-flex-start"), (ele) => {
|
|
362
|
+
ele.style.alignItems = "center";
|
|
363
|
+
});
|
|
364
|
+
_.each(document.querySelectorAll(".ivu-radio-group-item"), (ele) => {
|
|
365
|
+
ele.style.display = "flex";
|
|
366
|
+
ele.style.flexDirection = "row";
|
|
367
|
+
});
|
|
368
|
+
return "flex";
|
|
369
|
+
}
|
|
348
370
|
},
|
|
371
|
+
flexOrBlockStyle() {
|
|
372
|
+
if (this.isMobile()) {
|
|
373
|
+
return "display: inline-block";
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
return "display: flex";
|
|
377
|
+
}
|
|
378
|
+
}
|
|
349
379
|
},
|
|
350
380
|
methods: {
|
|
351
381
|
inputAnswerProp(inputIndex) {
|
|
@@ -397,8 +427,8 @@ var script$f = Vue.extend({
|
|
|
397
427
|
this.answer.star =
|
|
398
428
|
minStarCount >= this.question.options.starMinCount ? 1 : 0;
|
|
399
429
|
}
|
|
400
|
-
}
|
|
401
|
-
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
402
432
|
});
|
|
403
433
|
|
|
404
434
|
/* script */
|
|
@@ -410,7 +440,7 @@ var __vue_render__$f = function () {var _vm=this;var _h=_vm.$createElement;var _
|
|
|
410
440
|
type: 'array',
|
|
411
441
|
min: 1,
|
|
412
442
|
message: _vm.t('survey_response.question.question_required'),
|
|
413
|
-
}}},[_c('CheckboxGroup',{on:{"on-change":_vm.selChange},model:{value:(_vm.value.answer),callback:function ($$v) {_vm.$set(_vm.value, "answer", $$v);},expression:"value.answer"}},[_c('Row',{attrs:{"type":
|
|
443
|
+
}}},[_c('CheckboxGroup',{on:{"on-change":_vm.selChange},model:{value:(_vm.value.answer),callback:function ($$v) {_vm.$set(_vm.value, "answer", $$v);},expression:"value.answer"}},[_c('Row',{attrs:{"type":_vm.flexOrBlock,"justify":"start","gutter":60}},_vm._l((_vm.question.choices),function(choice){return _c('Col',{key:choice.id,class:_vm.optionLayout,style:(_vm.flexOrBlockStyle)},[_c('Checkbox',{key:choice.id,attrs:{"label":choice.id,"disabled":_vm.question.options.readonly ||
|
|
414
444
|
choice.readonly ||
|
|
415
445
|
_vm.question.options.disabled}},[_c('span',[_vm._v(_vm._s(_vm.i18nText(choice.text)))])]),_vm._v(" "),_vm._l((_vm.value.inputAnswers),function(inputAnswer,inputIndex){return _c('div',{key:inputIndex},[(
|
|
416
446
|
choice.id === inputAnswer.choiceId &&
|
|
@@ -433,11 +463,11 @@ var __vue_staticRenderFns__$f = [];
|
|
|
433
463
|
/* style */
|
|
434
464
|
const __vue_inject_styles__$f = function (inject) {
|
|
435
465
|
if (!inject) return
|
|
436
|
-
inject("data-v-
|
|
466
|
+
inject("data-v-778a2db7_0", { source: ".ivu-row[data-v-778a2db7]{display:inline-block}.choice-title[data-v-778a2db7]{margin-left:8px;margin-right:8px}.choice-score[data-v-778a2db7]{margin-right:8px}.ivu-checkbox-wrapper[data-v-778a2db7]{white-space:nowrap}", map: undefined, media: undefined });
|
|
437
467
|
|
|
438
468
|
};
|
|
439
469
|
/* scoped */
|
|
440
|
-
const __vue_scope_id__$f = "data-v-
|
|
470
|
+
const __vue_scope_id__$f = "data-v-778a2db7";
|
|
441
471
|
/* module identifier */
|
|
442
472
|
const __vue_module_identifier__$f = undefined;
|
|
443
473
|
/* functional template */
|
|
@@ -568,24 +598,24 @@ var script$d = Vue.extend({
|
|
|
568
598
|
Row,
|
|
569
599
|
Col,
|
|
570
600
|
Icon,
|
|
571
|
-
Input
|
|
601
|
+
Input
|
|
572
602
|
},
|
|
573
603
|
mixins: [OptionLayoutMixin, QuestionMixin],
|
|
574
604
|
inject: ["responseStatus", "$rootComponent"],
|
|
575
605
|
props: {
|
|
576
606
|
question: {
|
|
577
607
|
type: Object,
|
|
578
|
-
required: true
|
|
608
|
+
required: true
|
|
579
609
|
},
|
|
580
610
|
answer: {
|
|
581
611
|
type: Object,
|
|
582
|
-
required: true
|
|
583
|
-
}
|
|
612
|
+
required: true
|
|
613
|
+
}
|
|
584
614
|
},
|
|
585
615
|
data() {
|
|
586
616
|
return {
|
|
587
617
|
value: this.answer,
|
|
588
|
-
choiceClasses: this.buildChoiceClasses()
|
|
618
|
+
choiceClasses: this.buildChoiceClasses()
|
|
589
619
|
};
|
|
590
620
|
},
|
|
591
621
|
watch: {
|
|
@@ -594,7 +624,17 @@ var script$d = Vue.extend({
|
|
|
594
624
|
},
|
|
595
625
|
answer(n) {
|
|
596
626
|
this.value = n;
|
|
597
|
-
}
|
|
627
|
+
}
|
|
628
|
+
},
|
|
629
|
+
computed: {
|
|
630
|
+
flexOrBlock() {
|
|
631
|
+
if (this.isMobile()) {
|
|
632
|
+
return "inline-block";
|
|
633
|
+
}
|
|
634
|
+
else {
|
|
635
|
+
return "flex";
|
|
636
|
+
}
|
|
637
|
+
}
|
|
598
638
|
},
|
|
599
639
|
methods: {
|
|
600
640
|
inputAnswerProp(inputIndex) {
|
|
@@ -613,7 +653,7 @@ var script$d = Vue.extend({
|
|
|
613
653
|
buildChoiceClasses() {
|
|
614
654
|
return [
|
|
615
655
|
`question-choice`,
|
|
616
|
-
`question-choice-${_.lowerCase(this.question.options.layout || "HORIZONTAL")}
|
|
656
|
+
`question-choice-${_.lowerCase(this.question.options.layout || "HORIZONTAL")}`
|
|
617
657
|
];
|
|
618
658
|
},
|
|
619
659
|
haveStar(choice) {
|
|
@@ -638,10 +678,10 @@ var script$d = Vue.extend({
|
|
|
638
678
|
}
|
|
639
679
|
this.$emit("singleQuestion", {
|
|
640
680
|
questionId: this.question.id,
|
|
641
|
-
choiceId: this.value.answer
|
|
681
|
+
choiceId: this.value.answer
|
|
642
682
|
});
|
|
643
|
-
}
|
|
644
|
-
}
|
|
683
|
+
}
|
|
684
|
+
}
|
|
645
685
|
});
|
|
646
686
|
|
|
647
687
|
/* script */
|
|
@@ -649,33 +689,33 @@ const __vue_script__$d = script$d;
|
|
|
649
689
|
|
|
650
690
|
/* template */
|
|
651
691
|
var __vue_render__$d = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('FormItem',{attrs:{"prop":_vm.answerProp,"rules":{
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
692
|
+
required: _vm.question.options.required && !_vm.question.options.disabled,
|
|
693
|
+
message: _vm.t('survey_response.question.question_required'),
|
|
694
|
+
}}},[_c('RadioGroup',{staticClass:"question-choice",on:{"on-change":_vm.selChange},model:{value:(_vm.value.answer),callback:function ($$v) {_vm.$set(_vm.value, "answer", $$v);},expression:"value.answer"}},[_c('Row',{style:({'display':(_vm.isMobile()?'inline-block':'flex')}),attrs:{"type":_vm.flexOrBlock,"justify":"start","gutter":60}},_vm._l((_vm.question.choices),function(choice){return _c('Col',{key:choice.id,class:_vm.optionLayout,style:({'display':(_vm.isMobile()?'inline-block':'flex')})},[_c('Radio',{key:choice.id,style:({'display':(_vm.isMobile()?'inline-block':'flex'),'align-items':(_vm.isMobile()?'':'center')}),attrs:{"disabled":_vm.question.options.readonly || _vm.question.options.disabled,"label":choice.id},nativeOn:{"click":function($event){return _vm.toggleAnswer($event, choice.id, _vm.question.options.disabled)}}},[(_vm.haveStar(choice))?_c('span',[_c('Icon',{attrs:{"type":"md-star","color":"orange","size":16}})],1):_vm._e(),_vm._v(" "),_c('span',[_vm._v(_vm._s(_vm.i18nText(choice.text)))])]),_vm._v(" "),_vm._l((_vm.value.inputAnswers),function(inputAnswer,inputIndex){return _c('div',{key:inputIndex},[(
|
|
695
|
+
choice.id === inputAnswer.choiceId && choice.id === _vm.value.answer
|
|
696
|
+
)?_c('FormItem',{attrs:{"prop":_vm.inputAnswerProp(inputIndex),"rules":[
|
|
697
|
+
{
|
|
698
|
+
required: true,
|
|
699
|
+
message: _vm.t('survey_response.question.choice_required'),
|
|
700
|
+
},
|
|
701
|
+
{
|
|
702
|
+
type: 'string',
|
|
703
|
+
min: _vm.question.options.inputMinLength,
|
|
704
|
+
max: 999,
|
|
705
|
+
message: _vm.t('survey_response.question.input_text_limit', [
|
|
706
|
+
_vm.question.options.inputMinLength ]),
|
|
707
|
+
trigger: 'blur',
|
|
708
|
+
} ]}},[_c('Span',[_vm._v("\n "+_vm._s(inputAnswer.inputText))])],1):_vm._e()],1)})],2)}),1)],1)],1)};
|
|
669
709
|
var __vue_staticRenderFns__$d = [];
|
|
670
710
|
|
|
671
711
|
/* style */
|
|
672
712
|
const __vue_inject_styles__$d = function (inject) {
|
|
673
713
|
if (!inject) return
|
|
674
|
-
inject("data-v-
|
|
714
|
+
inject("data-v-25eb6794_0", { source: ".choice-title[data-v-25eb6794]{margin-left:8px;margin-right:8px}", map: undefined, media: undefined });
|
|
675
715
|
|
|
676
716
|
};
|
|
677
717
|
/* scoped */
|
|
678
|
-
const __vue_scope_id__$d = "data-v-
|
|
718
|
+
const __vue_scope_id__$d = "data-v-25eb6794";
|
|
679
719
|
/* module identifier */
|
|
680
720
|
const __vue_module_identifier__$d = undefined;
|
|
681
721
|
/* functional template */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wg-npm/survey-response",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.158",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"lint-fix": "eslint \"**/*.ts\" \"**/*.vue\" --fix --no-error-on-unmatched-pattern"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@wg-npm/survey-core": "0.5.
|
|
16
|
-
"@wg-npm/survey-service-api": "0.5.
|
|
15
|
+
"@wg-npm/survey-core": "0.5.158",
|
|
16
|
+
"@wg-npm/survey-service-api": "0.5.158",
|
|
17
17
|
"axios": "^0.19.2",
|
|
18
18
|
"deepmerge": "^4.2.2",
|
|
19
19
|
"lodash": "^4.17.15",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"@typescript-eslint/parser": "^3.6.0",
|
|
35
35
|
"@vue/eslint-config-prettier": "^6.0.0",
|
|
36
36
|
"@vue/eslint-config-typescript": "^5.0.2",
|
|
37
|
-
"@wg-npm/survey-core": "0.5.
|
|
38
|
-
"@wg-npm/survey-service-api": "0.5.
|
|
37
|
+
"@wg-npm/survey-core": "0.5.158",
|
|
38
|
+
"@wg-npm/survey-service-api": "0.5.158",
|
|
39
39
|
"acorn": "^7.3.1",
|
|
40
40
|
"axios": "^0.19.2",
|
|
41
41
|
"babelrc-rollup": "^3.0.0",
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="question-title">
|
|
3
|
-
<span v-if="question.type !== 'text_title'" class="pr-sm">
|
|
2
|
+
<div class="question-title" :style="{'display':(isMobile()?'inline-block':'')}">
|
|
3
|
+
<span v-if="question.type !== 'text_title'" class="pr-sm" :style="{'display':(isMobile()?'inline-block':'')}">
|
|
4
4
|
<label v-if="question.options.required" class="require-label">*</label>
|
|
5
5
|
<label v-if="question.header.number" class="number"
|
|
6
|
-
|
|
6
|
+
>{{ question.header.number }}.</label
|
|
7
7
|
>
|
|
8
8
|
</span>
|
|
9
9
|
|
|
10
|
-
<div class="flex" v-for="(title, index) in getTitle(question)" :key="index">
|
|
10
|
+
<div class="flex" v-for="(title, index) in getTitle(question)" :key="index" :style="{'display':(isMobile()?'inline-block':'')}">
|
|
11
11
|
<span v-if="title !== ''" class="content">{{ title }}</span>
|
|
12
12
|
<div
|
|
13
13
|
v-for="customTitle in customFilledTitle"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
<span
|
|
17
17
|
class="content"
|
|
18
18
|
v-if="title === '' && index === customTitle.index"
|
|
19
|
-
|
|
19
|
+
>{{ customTitle.title }}</span
|
|
20
20
|
>
|
|
21
21
|
|
|
22
22
|
<div v-else>
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
getShowInput(index, getTitle(question)) &&
|
|
27
27
|
index === customTitle.index
|
|
28
28
|
"
|
|
29
|
-
|
|
29
|
+
>{{ customTitle.title }}</span
|
|
30
30
|
>
|
|
31
31
|
</div>
|
|
32
32
|
</div>
|
|
33
33
|
</div>
|
|
34
34
|
|
|
35
|
-
<span class="options-explain" v-if="haveStar">
|
|
35
|
+
<span class="options-explain" v-if="haveStar" :style="{'display':(isMobile()?'block':'')}">
|
|
36
36
|
<span v-if="isSingleSelection">
|
|
37
37
|
({{
|
|
38
38
|
t(
|
|
@@ -70,65 +70,69 @@
|
|
|
70
70
|
</div>
|
|
71
71
|
</template>
|
|
72
72
|
<script lang="ts">
|
|
73
|
-
import Vue from "vue";
|
|
74
|
-
import
|
|
75
|
-
import {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
73
|
+
import Vue from "vue";
|
|
74
|
+
import OptionLayoutMixin from "../../mixins/option-layout-mixin";
|
|
75
|
+
import { Icon } from "view-design";
|
|
76
|
+
import {
|
|
77
|
+
BaseQuestionModel,
|
|
78
|
+
formatTitle,
|
|
79
|
+
QuestionType,
|
|
80
|
+
showInput
|
|
81
|
+
} from "@wg-npm/survey-core";
|
|
82
|
+
import QuestionMixin from "../../mixins/question-mixin";
|
|
81
83
|
|
|
82
|
-
export default Vue.extend({
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
84
|
+
export default Vue.extend({
|
|
85
|
+
name: "question-title",
|
|
86
|
+
mixins: [OptionLayoutMixin, QuestionMixin],
|
|
87
|
+
components: { Icon },
|
|
88
|
+
inject: ["$rootComponent"],
|
|
89
|
+
props: {
|
|
90
|
+
index: {
|
|
91
|
+
type: Number,
|
|
92
|
+
default: 0
|
|
93
|
+
},
|
|
94
|
+
question: {
|
|
95
|
+
type: Object,
|
|
96
|
+
required: true
|
|
97
|
+
},
|
|
98
|
+
language: {
|
|
99
|
+
type: String
|
|
100
|
+
},
|
|
101
|
+
customQuestion: {
|
|
102
|
+
type: Object,
|
|
103
|
+
required: false
|
|
104
|
+
}
|
|
101
105
|
},
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
+
computed: {
|
|
107
|
+
customFilledTitle() {
|
|
108
|
+
return this.customQuestion?.filledTitle;
|
|
109
|
+
},
|
|
110
|
+
haveStar() {
|
|
111
|
+
return this.question?.options?.starEnabled ?? false;
|
|
112
|
+
},
|
|
113
|
+
isSingleSelection() {
|
|
114
|
+
return this.question.type == QuestionType.SINGLE_SELECTION;
|
|
115
|
+
}
|
|
106
116
|
},
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return showInput(index, formatTitle);
|
|
117
|
-
},
|
|
118
|
-
getTitle(question) {
|
|
119
|
-
return formatTitle(question, this.$rootComponent.currentLanguage);
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
});
|
|
117
|
+
methods: {
|
|
118
|
+
getShowInput(index, formatTitle) {
|
|
119
|
+
return showInput(index, formatTitle);
|
|
120
|
+
},
|
|
121
|
+
getTitle(question) {
|
|
122
|
+
return formatTitle(question, this.$rootComponent.currentLanguage);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|
|
123
126
|
</script>
|
|
124
127
|
|
|
125
128
|
<style lang="less" scoped>
|
|
126
|
-
.flex {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
129
|
+
.flex {
|
|
130
|
+
display: flex;
|
|
131
|
+
align-items: center;
|
|
132
|
+
white-space: nowrap;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.pr-sm {
|
|
136
|
+
padding-right: 4px;
|
|
137
|
+
}
|
|
134
138
|
</style>
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
}"
|
|
10
10
|
>
|
|
11
11
|
<CheckboxGroup v-model="value.answer" @on-change="selChange">
|
|
12
|
-
<Row type="
|
|
12
|
+
<Row :type="flexOrBlock" justify="start" :gutter="60">
|
|
13
13
|
<Col
|
|
14
14
|
v-for="choice in question.choices"
|
|
15
15
|
:key="choice.id"
|
|
16
16
|
:class="optionLayout"
|
|
17
|
-
style="
|
|
17
|
+
:style="flexOrBlockStyle"
|
|
18
18
|
>
|
|
19
19
|
<Checkbox
|
|
20
20
|
:label="choice.id"
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
]"
|
|
56
56
|
>
|
|
57
57
|
<Span v-if="responseStatus=='ENABLED'">
|
|
58
|
-
{{inputAnswer.inputText}}</Span>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
{{ inputAnswer.inputText }}</Span>
|
|
59
|
+
<Input v-if="responseStatus=='DRAFT'"
|
|
60
|
+
v-model.trim="inputAnswer.inputText"
|
|
61
|
+
/>
|
|
62
62
|
|
|
63
63
|
</FormItem>
|
|
64
64
|
</div>
|
|
@@ -68,138 +68,155 @@
|
|
|
68
68
|
</FormItem>
|
|
69
69
|
</template>
|
|
70
70
|
<script lang="ts">
|
|
71
|
-
import Vue from "vue";
|
|
72
|
-
import _ from "lodash";
|
|
73
|
-
import OptionLayoutMixin from "../../../mixins/option-layout-mixin";
|
|
74
|
-
import QuestionMixin from "../../../mixins/question-mixin";
|
|
75
|
-
import {
|
|
76
|
-
FormItem,
|
|
77
|
-
CheckboxGroup,
|
|
78
|
-
Checkbox,
|
|
79
|
-
Row,
|
|
80
|
-
Col,
|
|
81
|
-
Input,
|
|
82
|
-
} from "view-design";
|
|
83
|
-
|
|
84
|
-
export default Vue.extend({
|
|
85
|
-
name: "multi-selection",
|
|
86
|
-
inject: ["responseStatus","$rootComponent"],
|
|
87
|
-
mixins: [OptionLayoutMixin, QuestionMixin],
|
|
88
|
-
components: {
|
|
71
|
+
import Vue from "vue";
|
|
72
|
+
import _ from "lodash";
|
|
73
|
+
import OptionLayoutMixin from "../../../mixins/option-layout-mixin";
|
|
74
|
+
import QuestionMixin from "../../../mixins/question-mixin";
|
|
75
|
+
import {
|
|
89
76
|
FormItem,
|
|
90
77
|
CheckboxGroup,
|
|
91
78
|
Checkbox,
|
|
92
79
|
Row,
|
|
93
80
|
Col,
|
|
94
|
-
Input
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
81
|
+
Input
|
|
82
|
+
} from "view-design";
|
|
83
|
+
|
|
84
|
+
export default Vue.extend({
|
|
85
|
+
name: "multi-selection",
|
|
86
|
+
inject: ["responseStatus", "$rootComponent"],
|
|
87
|
+
mixins: [OptionLayoutMixin, QuestionMixin],
|
|
88
|
+
components: {
|
|
89
|
+
FormItem,
|
|
90
|
+
CheckboxGroup,
|
|
91
|
+
Checkbox,
|
|
92
|
+
Row,
|
|
93
|
+
Col,
|
|
94
|
+
Input
|
|
100
95
|
},
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
96
|
+
props: {
|
|
97
|
+
question: {
|
|
98
|
+
type: Object,
|
|
99
|
+
required: true
|
|
100
|
+
},
|
|
101
|
+
answer: {
|
|
102
|
+
type: Object,
|
|
103
|
+
required: true
|
|
104
|
+
}
|
|
104
105
|
},
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
};
|
|
110
|
-
},
|
|
111
|
-
watch: {
|
|
112
|
-
answer(n) {
|
|
113
|
-
this.value = n;
|
|
106
|
+
data() {
|
|
107
|
+
return {
|
|
108
|
+
value: this.answer
|
|
109
|
+
};
|
|
114
110
|
},
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
? `moreSurveyAnswers[${this.surveyIndex}].answers[${this.index}].inputAnswers[${inputIndex}].inputText`
|
|
120
|
-
: `answers[${this.index}].inputAnswers[${inputIndex}].inputText`;
|
|
111
|
+
watch: {
|
|
112
|
+
answer(n) {
|
|
113
|
+
this.value = n;
|
|
114
|
+
}
|
|
121
115
|
},
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
116
|
+
computed: {
|
|
117
|
+
flexOrBlock() {
|
|
118
|
+
if (this.isMobile()) {
|
|
119
|
+
_.each(document.querySelectorAll(".ivu-radio-group-item") as NodeListOf<HTMLElement>, (ele) => {
|
|
120
|
+
ele.style.display = "inline-block";
|
|
121
|
+
});
|
|
122
|
+
return "inline-block";
|
|
123
|
+
} else {
|
|
124
|
+
_.each(document.querySelectorAll(".ivu-row-flex-start") as NodeListOf<HTMLElement>, (ele) => {
|
|
125
|
+
ele.style.alignItems = "center";
|
|
126
|
+
});
|
|
127
|
+
_.each(document.querySelectorAll(".ivu-radio-group-item") as NodeListOf<HTMLElement>, (ele) => {
|
|
128
|
+
ele.style.display = "flex";
|
|
129
|
+
ele.style.flexDirection = "row";
|
|
130
|
+
});
|
|
131
|
+
return "flex";
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
flexOrBlockStyle() {
|
|
135
|
+
if (this.isMobile()) {
|
|
136
|
+
return "display: inline-block";
|
|
129
137
|
} else {
|
|
130
|
-
|
|
138
|
+
return "display: flex";
|
|
131
139
|
}
|
|
132
|
-
}
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
methods: {
|
|
143
|
+
inputAnswerProp(inputIndex) {
|
|
144
|
+
return this.isMoreSurvey
|
|
145
|
+
? `moreSurveyAnswers[${this.surveyIndex}].answers[${this.index}].inputAnswers[${inputIndex}].inputText`
|
|
146
|
+
: `answers[${this.index}].inputAnswers[${inputIndex}].inputText`;
|
|
147
|
+
},
|
|
148
|
+
setCheckboxStatus() {
|
|
149
|
+
let exclusiveChoiceId = "";
|
|
150
|
+
const notExclusiveChoices = new Array();
|
|
151
|
+
// @ts-ignore
|
|
152
|
+
_.each(this.question.choices, (choice) => {
|
|
153
|
+
if (choice.options.exclusiveEnabled) {
|
|
154
|
+
exclusiveChoiceId = choice.id;
|
|
155
|
+
} else {
|
|
156
|
+
notExclusiveChoices.push(choice);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
133
159
|
|
|
134
|
-
// @ts-ignore
|
|
135
|
-
_.each(notExclusiveChoices, (choice) => {
|
|
136
160
|
// @ts-ignore
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
161
|
+
_.each(notExclusiveChoices, (choice) => {
|
|
162
|
+
// @ts-ignore
|
|
163
|
+
choice.readonly = _.includes(this.value.answer, exclusiveChoiceId);
|
|
164
|
+
});
|
|
165
|
+
},
|
|
166
|
+
selChange(val) {
|
|
167
|
+
let score = 0;
|
|
168
|
+
let minStarCount = 0;
|
|
145
169
|
// @ts-ignore
|
|
146
|
-
_.each(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
170
|
+
_.each(this.question.choices, (choice) => {
|
|
171
|
+
// @ts-ignore
|
|
172
|
+
_.each(val, (id) => {
|
|
173
|
+
if (choice.id == id) {
|
|
174
|
+
if (choice.options.exclusiveEnabled) {
|
|
175
|
+
this.value.answer = [id];
|
|
176
|
+
score = parseInt(choice?.options?.score ?? 0);
|
|
177
|
+
minStarCount = 1;
|
|
178
|
+
} else {
|
|
179
|
+
score += parseInt(choice?.options?.score ?? 0);
|
|
180
|
+
minStarCount++;
|
|
181
|
+
}
|
|
155
182
|
}
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
//处理输入题
|
|
187
|
+
_.forEach(this.value.inputAnswers, (input) => {
|
|
188
|
+
if (!_.includes(val, input.choiceId)) {
|
|
189
|
+
input.inputText = null;
|
|
156
190
|
}
|
|
157
191
|
});
|
|
158
|
-
|
|
192
|
+
this.setCheckboxStatus();
|
|
159
193
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (
|
|
163
|
-
|
|
194
|
+
// @ts-ignore
|
|
195
|
+
this.answer.score = score;
|
|
196
|
+
if (this.question.options.starEnabled) {
|
|
197
|
+
this.answer.star =
|
|
198
|
+
minStarCount >= this.question.options.starMinCount ? 1 : 0;
|
|
164
199
|
}
|
|
165
|
-
});
|
|
166
|
-
this.setCheckboxStatus();
|
|
167
|
-
|
|
168
|
-
// @ts-ignore
|
|
169
|
-
this.answer.score = score;
|
|
170
|
-
if (this.question.options.starEnabled) {
|
|
171
|
-
this.answer.star =
|
|
172
|
-
minStarCount >= this.question.options.starMinCount ? 1 : 0;
|
|
173
200
|
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
});
|
|
201
|
+
}
|
|
202
|
+
});
|
|
177
203
|
</script>
|
|
178
204
|
|
|
179
205
|
<style lang="less" scoped>
|
|
180
|
-
.ivu-row
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
.ivu-checkbox-group-item {
|
|
184
|
-
display: flex;
|
|
185
|
-
flex-direction: row;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
.choice-title {
|
|
189
|
-
margin-left: 8px;
|
|
190
|
-
margin-right: 8px;
|
|
191
|
-
}
|
|
192
|
-
|
|
206
|
+
.ivu-row {
|
|
207
|
+
display: "inline-block";
|
|
208
|
+
}
|
|
193
209
|
|
|
194
|
-
.choice-
|
|
195
|
-
|
|
196
|
-
|
|
210
|
+
.choice-title {
|
|
211
|
+
margin-left: 8px;
|
|
212
|
+
margin-right: 8px;
|
|
213
|
+
}
|
|
197
214
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
215
|
+
.choice-score {
|
|
216
|
+
margin-right: 8px;
|
|
217
|
+
}
|
|
201
218
|
|
|
202
|
-
.ivu-checkbox-wrapper{
|
|
203
|
-
|
|
204
|
-
}
|
|
219
|
+
.ivu-checkbox-wrapper {
|
|
220
|
+
white-space: nowrap;
|
|
221
|
+
}
|
|
205
222
|
</style>
|
|
@@ -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
|
>
|
|
@@ -56,11 +56,13 @@
|
|
|
56
56
|
},
|
|
57
57
|
]"
|
|
58
58
|
>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
<Span>
|
|
60
|
+
{{ inputAnswer.inputText }}</Span>
|
|
61
|
+
<!-- <Span v-if="responseStatus=='ENABLED'">-->
|
|
62
|
+
<!-- {{ inputAnswer.inputText }}</Span>-->
|
|
63
|
+
<!-- <Input v-if="responseStatus=='DRAFT'"-->
|
|
64
|
+
<!-- v-model.trim="inputAnswer.inputText"-->
|
|
65
|
+
<!-- />-->
|
|
64
66
|
</FormItem>
|
|
65
67
|
</div>
|
|
66
68
|
</Col>
|
|
@@ -70,128 +72,126 @@
|
|
|
70
72
|
</template>
|
|
71
73
|
|
|
72
74
|
<script lang="ts">
|
|
73
|
-
import Vue from "vue";
|
|
74
|
-
import OptionLayoutMixin from "../../../mixins/option-layout-mixin";
|
|
75
|
-
import {
|
|
76
|
-
|
|
77
|
-
FormItem,
|
|
78
|
-
Icon,
|
|
79
|
-
Radio,
|
|
80
|
-
RadioGroup,
|
|
81
|
-
Row,
|
|
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: {
|
|
75
|
+
import Vue from "vue";
|
|
76
|
+
import OptionLayoutMixin from "../../../mixins/option-layout-mixin";
|
|
77
|
+
import {
|
|
78
|
+
Col,
|
|
91
79
|
FormItem,
|
|
92
|
-
|
|
80
|
+
Icon,
|
|
93
81
|
Radio,
|
|
82
|
+
RadioGroup,
|
|
94
83
|
Row,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
data() {
|
|
112
|
-
return {
|
|
113
|
-
value: this.answer,
|
|
114
|
-
// @ts-ignore
|
|
115
|
-
choiceClasses: this.buildChoiceClasses(),
|
|
116
|
-
};
|
|
117
|
-
},
|
|
118
|
-
watch: {
|
|
119
|
-
"question.options.layout"() {
|
|
120
|
-
this.choiceClasses = this.buildChoiceClasses();
|
|
121
|
-
},
|
|
122
|
-
answer(n) {
|
|
123
|
-
this.value = n;
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
methods: {
|
|
127
|
-
inputAnswerProp(inputIndex) {
|
|
128
|
-
return this.isMoreSurvey
|
|
129
|
-
? `moreSurveyAnswers[${this.surveyIndex}].answers[${this.index}].inputAnswers[${inputIndex}].inputText`
|
|
130
|
-
: `answers[${this.index}].inputAnswers[${inputIndex}].inputText`;
|
|
131
|
-
},
|
|
132
|
-
selChange(id) {
|
|
133
|
-
// @ts-ignore
|
|
134
|
-
_.each(this.question.choices, (choice) => {
|
|
135
|
-
if (choice.id == id) {
|
|
136
|
-
// @ts-ignore
|
|
137
|
-
this.answer.score = parseInt(choice?.options?.score ?? 0);
|
|
138
|
-
this.answer.star = parseInt(choice?.options?.starCount ?? 0);
|
|
139
|
-
}
|
|
140
|
-
});
|
|
84
|
+
Input
|
|
85
|
+
} from "view-design";
|
|
86
|
+
import _ from "lodash";
|
|
87
|
+
import { SurveyLayout } from "@wg-npm/survey-core";
|
|
88
|
+
import QuestionMixin from "../../../mixins/question-mixin";
|
|
89
|
+
|
|
90
|
+
export default Vue.extend({
|
|
91
|
+
name: "single-selection",
|
|
92
|
+
components: {
|
|
93
|
+
FormItem,
|
|
94
|
+
RadioGroup,
|
|
95
|
+
Radio,
|
|
96
|
+
Row,
|
|
97
|
+
Col,
|
|
98
|
+
Icon,
|
|
99
|
+
Input
|
|
141
100
|
},
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
101
|
+
mixins: [OptionLayoutMixin, QuestionMixin],
|
|
102
|
+
inject: ["responseStatus", "$rootComponent"],
|
|
103
|
+
props: {
|
|
104
|
+
question: {
|
|
105
|
+
type: Object,
|
|
106
|
+
required: true
|
|
107
|
+
},
|
|
108
|
+
answer: {
|
|
109
|
+
type: Object,
|
|
110
|
+
required: true
|
|
111
|
+
}
|
|
149
112
|
},
|
|
150
|
-
|
|
151
|
-
return
|
|
113
|
+
data() {
|
|
114
|
+
return {
|
|
115
|
+
value: this.answer,
|
|
116
|
+
// @ts-ignore
|
|
117
|
+
choiceClasses: this.buildChoiceClasses()
|
|
118
|
+
};
|
|
152
119
|
},
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
this.
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return;
|
|
120
|
+
watch: {
|
|
121
|
+
"question.options.layout"() {
|
|
122
|
+
this.choiceClasses = this.buildChoiceClasses();
|
|
123
|
+
},
|
|
124
|
+
answer(n) {
|
|
125
|
+
this.value = n;
|
|
160
126
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
});
|
|
127
|
+
},
|
|
128
|
+
computed: {
|
|
129
|
+
flexOrBlock() {
|
|
130
|
+
if (this.isMobile()) {
|
|
131
|
+
return "inline-block";
|
|
167
132
|
} else {
|
|
168
|
-
|
|
133
|
+
return "flex";
|
|
169
134
|
}
|
|
170
135
|
}
|
|
171
|
-
this.$emit("singleQuestion", {
|
|
172
|
-
questionId: this.question.id,
|
|
173
|
-
choiceId: this.value.answer,
|
|
174
|
-
});
|
|
175
136
|
},
|
|
176
|
-
|
|
177
|
-
|
|
137
|
+
methods: {
|
|
138
|
+
inputAnswerProp(inputIndex) {
|
|
139
|
+
return this.isMoreSurvey
|
|
140
|
+
? `moreSurveyAnswers[${this.surveyIndex}].answers[${this.index}].inputAnswers[${inputIndex}].inputText`
|
|
141
|
+
: `answers[${this.index}].inputAnswers[${inputIndex}].inputText`;
|
|
142
|
+
},
|
|
143
|
+
selChange(id) {
|
|
144
|
+
// @ts-ignore
|
|
145
|
+
_.each(this.question.choices, (choice) => {
|
|
146
|
+
if (choice.id == id) {
|
|
147
|
+
// @ts-ignore
|
|
148
|
+
this.answer.score = parseInt(choice?.options?.score ?? 0);
|
|
149
|
+
this.answer.star = parseInt(choice?.options?.starCount ?? 0);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
},
|
|
153
|
+
buildChoiceClasses() {
|
|
154
|
+
return [
|
|
155
|
+
`question-choice`,
|
|
156
|
+
`question-choice-${_.lowerCase(
|
|
157
|
+
this.question.options.layout || SurveyLayout.HORIZONTAL
|
|
158
|
+
)}`
|
|
159
|
+
];
|
|
160
|
+
},
|
|
161
|
+
haveStar(choice) {
|
|
162
|
+
return choice.options?.star ?? false;
|
|
163
|
+
},
|
|
164
|
+
toggleAnswer(e, value, disabled) {
|
|
165
|
+
if (
|
|
166
|
+
this.question.options.readonly ||
|
|
167
|
+
disabled ||
|
|
168
|
+
e.target.tagName !== "INPUT"
|
|
169
|
+
) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (this.responseStatus == this.$consts.STATUS_DRAFT) {
|
|
173
|
+
if (this.value.answer && this.value.answer === value) {
|
|
174
|
+
this.value.answer = null;
|
|
175
|
+
_.forEach(this.value.inputAnswers, (input) => {
|
|
176
|
+
input.inputText = null;
|
|
177
|
+
});
|
|
178
|
+
} else {
|
|
179
|
+
this.value.answer = value;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
this.$emit("singleQuestion", {
|
|
183
|
+
questionId: this.question.id,
|
|
184
|
+
choiceId: this.value.answer
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
});
|
|
178
189
|
</script>
|
|
179
190
|
|
|
180
191
|
<style lang="less" scoped>
|
|
181
|
-
.
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
display: flex;
|
|
186
|
-
flex-direction: row;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
.choice-title {
|
|
190
|
-
margin-left: 8px;
|
|
191
|
-
margin-right: 8px;
|
|
192
|
-
}
|
|
192
|
+
.choice-title {
|
|
193
|
+
margin-left: 8px;
|
|
194
|
+
margin-right: 8px;
|
|
195
|
+
}
|
|
193
196
|
|
|
194
|
-
/deep/ .ivu-radio-inner{
|
|
195
|
-
margin-top: 8px;
|
|
196
|
-
}
|
|
197
197
|
</style>
|
|
@@ -2,29 +2,33 @@ import Vue from "vue";
|
|
|
2
2
|
import _ from "lodash";
|
|
3
3
|
|
|
4
4
|
export default Vue.extend({
|
|
5
|
+
props: {
|
|
6
|
+
options: {
|
|
7
|
+
type: Object,
|
|
8
|
+
}
|
|
9
|
+
},
|
|
5
10
|
methods: {
|
|
6
11
|
isMobile() {
|
|
7
|
-
const
|
|
12
|
+
const val = navigator.userAgent.match(
|
|
8
13
|
/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
|
|
9
14
|
);
|
|
10
|
-
return
|
|
15
|
+
return !_.isEmpty(val);
|
|
11
16
|
},
|
|
12
17
|
},
|
|
13
18
|
computed: {
|
|
14
19
|
optionLayout() {
|
|
15
20
|
const globalLayout = _.lowerCase(
|
|
16
21
|
// @ts-ignore
|
|
17
|
-
_.get(this.options, "layout",
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
if (this.isMobile() || "vertical" == globalLayout) {
|
|
21
|
-
return "";
|
|
22
|
-
}
|
|
23
|
-
const questionLayout = _.lowerCase(
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
_.get(this.question.options, "layout", "horizontal")
|
|
22
|
+
_.get(this.options, "layout", "horizontal")
|
|
26
23
|
);
|
|
27
|
-
|
|
24
|
+
// if (this.isMobile() || "vertical" == globalLayout) {
|
|
25
|
+
// return "";
|
|
26
|
+
// }
|
|
27
|
+
// const questionLayout = _.lowerCase(
|
|
28
|
+
// // @ts-ignore
|
|
29
|
+
// _.get(this.question.options, "layout", "horizontal")
|
|
30
|
+
// );
|
|
31
|
+
return `question-choice-${globalLayout}`;
|
|
28
32
|
},
|
|
29
33
|
},
|
|
30
34
|
});
|