@wg-npm/survey-response 1.78.511940 → 1.78.511944

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.
@@ -1,7 +1,7 @@
1
1
  import Vue from 'vue';
2
2
  import _ from 'lodash';
3
- import { Row, Input as Input$1, Icon, FormItem, CheckboxGroup, Checkbox, Col, RadioGroup, Radio, InputNumber, Tooltip as Tooltip$1, Card, Slider, Form, Message } from 'view-design';
4
- import { CUSTOM_INPUT_REG, formatTitle, translate } from '@wg-npm/survey-core';
3
+ import { Row, Input as Input$1, Icon, FormItem, InputNumber, CheckboxGroup, Checkbox, Col, RadioGroup, Radio, Tooltip as Tooltip$1, Card, Slider, Form, Message } from 'view-design';
4
+ import { CUSTOM_INPUT_REG, BaseQuestionModel, formatTitle, translate } from '@wg-npm/survey-core';
5
5
  import deepmerge from 'deepmerge';
6
6
 
7
7
  var script = Vue.extend({
@@ -291,7 +291,7 @@ var QuestionMixin = Vue.extend({
291
291
 
292
292
  var script$2 = Vue.extend({
293
293
  name: "question-title",
294
- components: { Icon, QuestionTitleDynamic: __vue_component__$1 },
294
+ components: { Icon, QuestionTitleDynamic: __vue_component__$1, FormItem, InputNumber },
295
295
  mixins: [OptionLayoutMixin, QuestionMixin],
296
296
  inject: ["$rootComponent"],
297
297
  props: {
@@ -310,6 +310,11 @@ var script$2 = Vue.extend({
310
310
  type: Object,
311
311
  required: false,
312
312
  },
313
+ answer: {
314
+ type: Object,
315
+ required: false,
316
+ default: null,
317
+ },
313
318
  },
314
319
  computed: {
315
320
  customFilledTitle() {
@@ -321,11 +326,63 @@ var script$2 = Vue.extend({
321
326
  isSingleSelection() {
322
327
  return this.question.type == "SINGLE_SELECTION";
323
328
  },
329
+ isTitleScoringEnabled() {
330
+ return (this.question.type === "MATRIX" &&
331
+ !!this.question.options?.titleScoringEnabled);
332
+ },
333
+ isTitleRequired() {
334
+ return !!this.question.options?.required;
335
+ },
336
+ answerTitleProp() {
337
+ return this.isMoreSurvey
338
+ ?
339
+ `moreSurveyAnswers[${this.surveyIndex}].answers[${this.index}].titleScore`
340
+ : `answers[${this.index}].titleScore`;
341
+ },
342
+ questionTypeDesc() {
343
+ const type = this.question.type;
344
+ if (type === "TEXT_TITLE") {
345
+ return "";
346
+ }
347
+ const typeName = this.t(`survey_creator.question.types.${type}`, this.$rootComponent.currentLanguage);
348
+ if (type === "SINGLE_SELECTION" ||
349
+ type === "MULTI_SELECTION" ||
350
+ type === "MATRIX") {
351
+ const maxScore = BaseQuestionModel.getMaxScore(this.question);
352
+ const label = this.t("survey_creator.question.max_score", this.$rootComponent.currentLanguage);
353
+ return `${typeName}(${label}${maxScore})`;
354
+ }
355
+ if (type === "SCORING") {
356
+ const range = BaseQuestionModel.getScoreRange(this.question);
357
+ const label = this.t("survey_creator.question.scoring.scoreRange", this.$rootComponent.currentLanguage);
358
+ return `${typeName}(${label}${range})`;
359
+ }
360
+ return typeName;
361
+ },
324
362
  },
325
363
  methods: {
326
364
  getTitle(question) {
327
365
  return formatTitle(question, this.$rootComponent.currentLanguage);
328
366
  },
367
+ validateTitleScore(rule, value, callback) {
368
+ if (value === null || value === undefined) {
369
+ callback();
370
+ return;
371
+ }
372
+ const min = this.question.options.scoreMin;
373
+ const max = this.question.options.scoreMax;
374
+ if (min !== null && min !== undefined && value < min) {
375
+ const tip = this.t("survey_response.question.matrix_title_score_range_tip");
376
+ callback(new Error(tip.replace("{0}", min).replace("{1}", max)));
377
+ return;
378
+ }
379
+ if (max !== null && max !== undefined && value > max) {
380
+ const tip = this.t("survey_response.question.matrix_title_score_range_tip");
381
+ callback(new Error(tip.replace("{0}", min).replace("{1}", max)));
382
+ return;
383
+ }
384
+ callback();
385
+ },
329
386
  },
330
387
  });
331
388
 
@@ -333,13 +390,20 @@ var script$2 = Vue.extend({
333
390
  const __vue_script__$2 = script$2;
334
391
 
335
392
  /* template */
336
- var __vue_render__$1 = 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.question)?_c('question-title-dynamic',{attrs:{"splitedTitles":_vm.getTitle(_vm.question),"customFilledTitle":_vm.customFilledTitle}}):_vm._e(),_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(
393
+ var __vue_render__$1 = 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.question)?_c('question-title-dynamic',{attrs:{"customFilledTitle":_vm.customFilledTitle,"splitedTitles":_vm.getTitle(_vm.question)}}):_vm._e(),_vm._v(" "),(_vm.questionTypeDesc)?_c('span',{staticClass:"options-explain pl-sm"},[_vm._v("\n "+_vm._s(_vm.questionTypeDesc)+"\n ")]):_vm._e(),_vm._v(" "),(_vm.isTitleScoringEnabled && _vm.answer)?_c('FormItem',{staticClass:"title-score-form-item",attrs:{"prop":_vm.answerTitleProp,"rules":[
394
+ {
395
+ required: _vm.isTitleRequired && !_vm.question.options.disabled,
396
+ message: _vm.t('survey_response.question.question_required'),
397
+ },
398
+ { validator: _vm.validateTitleScore } ]}},[_c('InputNumber',{staticClass:"title-score-input",attrs:{"disabled":_vm.question.options.disabled,"max":_vm.question.options.scoreMax != null
399
+ ? _vm.question.options.scoreMax
400
+ : _vm.question.options.score || 100,"min":_vm.question.options.scoreMin != null ? _vm.question.options.scoreMin : 0,"placeholder":_vm.t('survey_response.question.matrix_title_score_placeholder')},model:{value:(_vm.answer.titleScore),callback:function ($$v) {_vm.$set(_vm.answer, "titleScore", $$v);},expression:"answer.titleScore"}})],1):_vm._e(),_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(
337
401
  "survey_creator.question.star_single",
338
402
  _vm.$rootComponent.currentLanguage
339
- ))+"\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(
403
+ ))+"\n "),_c('span',[_c('Icon',{attrs:{"size":16,"color":"orange","type":"md-star"}})],1),_vm._v(")\n ")]):_c('span',[_vm._v("\n (\n "+_vm._s(_vm.t(
340
404
  "survey_creator.question.star_single",
341
405
  _vm.$rootComponent.currentLanguage
342
- ))+"\n "),_c('Icon',{attrs:{"type":"md-star","color":"orange","size":16}}),_vm._v("\n "+_vm._s(_vm.t(
406
+ ))+"\n "),_c('Icon',{attrs:{"size":16,"color":"orange","type":"md-star"}}),_vm._v("\n "+_vm._s(_vm.t(
343
407
  "survey_creator.question.star_multi_prefix",
344
408
  _vm.$rootComponent.currentLanguage
345
409
  ))+"\n "+_vm._s(_vm.question.options.starMinCount)+"\n "+_vm._s(_vm.t(
@@ -351,11 +415,11 @@ var __vue_staticRenderFns__$1 = [];
351
415
  /* style */
352
416
  const __vue_inject_styles__$2 = function (inject) {
353
417
  if (!inject) return
354
- inject("data-v-bf231d5a_0", { source: ".flex[data-v-bf231d5a]{display:flex;align-items:center;white-space:nowrap}.pr-sm[data-v-bf231d5a]{padding-right:4px}", map: undefined, media: undefined });
418
+ inject("data-v-bf2c6078_0", { source: ".question-title[data-v-bf2c6078]{display:flex;align-items:center;flex-wrap:wrap}.pr-sm[data-v-bf2c6078]{padding-right:4px}.pl-sm[data-v-bf2c6078]{padding-left:4px}.title-score-form-item[data-v-bf2c6078]{margin-bottom:0}.title-score-form-item .title-score-input[data-v-bf2c6078]{margin-left:12px;width:120px}", map: undefined, media: undefined });
355
419
 
356
420
  };
357
421
  /* scoped */
358
- const __vue_scope_id__$2 = "data-v-bf231d5a";
422
+ const __vue_scope_id__$2 = "data-v-bf2c6078";
359
423
  /* module identifier */
360
424
  const __vue_module_identifier__$2 = undefined;
361
425
  /* functional template */
@@ -484,12 +548,19 @@ var __vue_render__$2 = function () {var _vm=this;var _h=_vm.$createElement;var _
484
548
  type: 'array',
485
549
  min: 1,
486
550
  message: _vm.t('survey_response.question.question_required'),
487
- }}},[_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',{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('Checkbox',{key:choice.id,style:({
551
+ }}},[_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',{style:({ display: _vm.isMobile() ? 'inline-block' : 'flex' }),attrs:{"gutter":60,"type":_vm.flexOrBlock,"justify":"start"}},_vm._l((_vm.question.choices),function(choice){return _c('Col',{key:choice.id,class:_vm.optionLayout,style:({ display: _vm.isMobile() ? 'inline-block' : 'flex' })},[_c('Checkbox',{key:choice.id,style:({
488
552
  display: _vm.isMobile() ? 'inline-block' : 'flex',
489
553
  'align-items': _vm.isMobile() ? '' : 'center',
490
- }),attrs:{"label":choice.id,"disabled":_vm.question.options.readonly ||
554
+ }),attrs:{"disabled":_vm.question.options.readonly ||
491
555
  choice.readonly ||
492
- _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},[(
556
+ _vm.question.options.disabled,"label":choice.id}},[_c('span',[_vm._v(_vm._s(_vm.i18nText(choice.text)))]),_vm._v(" "),(
557
+ _vm.options &&
558
+ _vm.options.showChoiceScore &&
559
+ _vm.question.options.scoringEnabled
560
+ )?_c('span',{staticClass:"options-explain"},[_vm._v("\n ("+_vm._s((choice.options && choice.options.score) || 0)+"\n "+_vm._s(_vm.t(
561
+ "survey_creator.question.scores",
562
+ _vm.$rootComponent.currentLanguage
563
+ ))+")\n ")]):_vm._e()]),_vm._v(" "),_vm._l((_vm.value.inputAnswers),function(inputAnswer,inputIndex){return _c('div',{key:inputIndex},[(
493
564
  choice.id === inputAnswer.choiceId &&
494
565
  _vm.value.answer.includes(choice.id)
495
566
  )?_c('FormItem',{attrs:{"prop":_vm.inputAnswerProp(inputIndex),"rules":[
@@ -510,11 +581,11 @@ var __vue_staticRenderFns__$2 = [];
510
581
  /* style */
511
582
  const __vue_inject_styles__$3 = function (inject) {
512
583
  if (!inject) return
513
- inject("data-v-aff37854_0", { source: ".choice-title[data-v-aff37854]{margin-left:8px;margin-right:8px}.choice-score[data-v-aff37854]{margin-right:8px}.ivu-checkbox-wrapper[data-v-aff37854]{white-space:nowrap}", map: undefined, media: undefined });
584
+ inject("data-v-4754c81a_0", { source: ".choice-title[data-v-4754c81a]{margin-left:8px;margin-right:8px}.options-explain[data-v-4754c81a]{margin-left:4px;color:#9ea7b4;font-size:12px}.ivu-checkbox-wrapper[data-v-4754c81a]{white-space:nowrap}", map: undefined, media: undefined });
514
585
 
515
586
  };
516
587
  /* scoped */
517
- const __vue_scope_id__$3 = "data-v-aff37854";
588
+ const __vue_scope_id__$3 = "data-v-4754c81a";
518
589
  /* module identifier */
519
590
  const __vue_module_identifier__$3 = undefined;
520
591
  /* functional template */
@@ -16361,6 +16432,7 @@ var defaultLang = {
16361
16432
  input_text_limit: "输入项字数不少于{0}字",
16362
16433
  choice_required: "此项必填",
16363
16434
  matrix_title_score: "分数",
16435
+ matrix_title_score_placeholder: "请输入评分",
16364
16436
  matrix_title_score_range_tip: "请输入{0}到{1}之间的分值",
16365
16437
  },
16366
16438
  },
@@ -17082,10 +17154,17 @@ var __vue_render__$5 = function () {var _vm=this;var _h=_vm.$createElement;var _
17082
17154
  required: _vm.question.options.required && !_vm.question.options.disabled,
17083
17155
  message: _vm.t('survey_response.question.question_required'),
17084
17156
  validator: _vm.customRequiredValidator,
17085
- }}},[_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:({
17157
+ }}},[_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:{"gutter":60,"type":_vm.flexOrBlock,"justify":"start"}},_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:({
17086
17158
  display: _vm.isMobile() ? 'inline-block' : 'flex',
17087
17159
  'align-items': _vm.isMobile() ? '' : 'center',
17088
- }),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},[(
17160
+ }),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:{"size":16,"color":"orange","type":"md-star"}})],1):_vm._e(),_vm._v(" "),_c('span',[_vm._v(_vm._s(_vm.i18nText(choice.text)))]),_vm._v(" "),(
17161
+ _vm.options &&
17162
+ _vm.options.showChoiceScore &&
17163
+ _vm.question.options.scoringEnabled
17164
+ )?_c('span',{staticClass:"options-explain"},[_vm._v("\n ("+_vm._s((choice.options && choice.options.score) || 0)+"\n "+_vm._s(_vm.t(
17165
+ "survey_creator.question.scores",
17166
+ _vm.$rootComponent.currentLanguage
17167
+ ))+")\n ")]):_vm._e()]),_vm._v(" "),_vm._l((_vm.value.inputAnswers),function(inputAnswer,inputIndex){return _c('div',{key:inputIndex},[(
17089
17168
  choice.id === inputAnswer.choiceId && choice.id === _vm.value.answer
17090
17169
  )?_c('FormItem',{attrs:{"prop":_vm.inputAnswerProp(inputIndex),"rules":[
17091
17170
  {
@@ -17105,11 +17184,11 @@ var __vue_staticRenderFns__$5 = [];
17105
17184
  /* style */
17106
17185
  const __vue_inject_styles__$6 = function (inject) {
17107
17186
  if (!inject) return
17108
- inject("data-v-dbceb2be_0", { source: ".choice-title[data-v-dbceb2be]{margin-left:8px;margin-right:8px}", map: undefined, media: undefined });
17187
+ inject("data-v-7562e82a_0", { source: ".choice-title[data-v-7562e82a]{margin-left:8px;margin-right:8px}.options-explain[data-v-7562e82a]{margin-left:4px;color:#9ea7b4;font-size:12px}", map: undefined, media: undefined });
17109
17188
 
17110
17189
  };
17111
17190
  /* scoped */
17112
- const __vue_scope_id__$6 = "data-v-dbceb2be";
17191
+ const __vue_scope_id__$6 = "data-v-7562e82a";
17113
17192
  /* module identifier */
17114
17193
  const __vue_module_identifier__$6 = undefined;
17115
17194
  /* functional template */
@@ -17143,7 +17222,6 @@ var script$7 = Vue.extend({
17143
17222
  Radio,
17144
17223
  Row,
17145
17224
  Col,
17146
- InputNumber,
17147
17225
  },
17148
17226
  props: {
17149
17227
  question: {
@@ -17173,24 +17251,22 @@ var script$7 = Vue.extend({
17173
17251
  this.value = n;
17174
17252
  this.initData();
17175
17253
  },
17254
+ "value.titleScore"() {
17255
+ this.selChange();
17256
+ },
17176
17257
  },
17177
17258
  computed: {
17178
17259
  isTitleScoringEnabled() {
17179
17260
  return !!_.get(this.question, "options.titleScoringEnabled", false);
17180
17261
  },
17181
- isTitleRequired() {
17182
- return !!_.get(this.question, "options.required", false);
17183
- },
17184
17262
  isSubRequired() {
17185
17263
  const opts = this.question.options;
17186
17264
  return opts.subRequired !== undefined
17187
17265
  ? !!opts.subRequired
17188
17266
  : !!opts.required;
17189
17267
  },
17190
- answerTitleProp() {
17191
- return this.isMoreSurvey
17192
- ? `moreSurveyAnswers[${this.surveyIndex}].answers[${this.index}].titleScore`
17193
- : `answers[${this.index}].titleScore`;
17268
+ choiceMaxScore() {
17269
+ return (_.max(this.question.choices.map((choice) => parseFloat(choice?.options?.score || 0))) || 0);
17194
17270
  },
17195
17271
  },
17196
17272
  methods: {
@@ -17221,25 +17297,6 @@ var script$7 = Vue.extend({
17221
17297
  this.value.answer.push(_answer);
17222
17298
  });
17223
17299
  },
17224
- validateTitleScore(rule, value, callback) {
17225
- if (value === null || value === undefined) {
17226
- callback();
17227
- return;
17228
- }
17229
- const min = this.question.options.scoreMin;
17230
- const max = this.question.options.scoreMax;
17231
- if (min !== null && min !== undefined && value < min) {
17232
- const tip = this.t("survey_response.question.matrix_title_score_range_tip");
17233
- callback(new Error(tip.replace("{0}", min).replace("{1}", max)));
17234
- return;
17235
- }
17236
- if (max !== null && max !== undefined && value > max) {
17237
- const tip = this.t("survey_response.question.matrix_title_score_range_tip");
17238
- callback(new Error(tip.replace("{0}", min).replace("{1}", max)));
17239
- return;
17240
- }
17241
- callback();
17242
- },
17243
17300
  selChange() {
17244
17301
  let score = 0;
17245
17302
  if (this.isTitleScoringEnabled && this.value.titleScore != null) {
@@ -17271,29 +17328,34 @@ var script$7 = Vue.extend({
17271
17328
  const __vue_script__$7 = script$7;
17272
17329
 
17273
17330
  /* template */
17274
- var __vue_render__$6 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[(_vm.isTitleScoringEnabled)?_c('div',{staticClass:"title-score-section"},[_c('FormItem',{attrs:{"prop":_vm.answerTitleProp,"rules":[
17275
- {
17276
- required: _vm.isTitleRequired && !_vm.question.options.disabled,
17277
- message: _vm.t('survey_response.question.question_required'),
17278
- },
17279
- { validator: _vm.validateTitleScore } ]}},[_c('div',{staticClass:"title-score-input-row"},[_c('span',{staticClass:"title-score-label"},[_vm._v(_vm._s(_vm.t('survey_response.question.matrix_title_score'))+":")]),_vm._v(" "),_c('InputNumber',{attrs:{"min":_vm.question.options.scoreMin != null ? _vm.question.options.scoreMin : 0,"max":_vm.question.options.scoreMax != null ? _vm.question.options.scoreMax : (_vm.question.options.score || 100),"disabled":_vm.question.options.disabled},on:{"on-change":_vm.selChange},model:{value:(_vm.value.titleScore),callback:function ($$v) {_vm.$set(_vm.value, "titleScore", $$v);},expression:"value.titleScore"}})],1)])],1):_vm._e(),_vm._v(" "),_vm._l((_vm.question.subQuestions),function(subQuestion,subIndex){return _c('div',{key:subIndex,staticClass:"sub-question"},[(_vm.isSubRequired)?_c('label',{staticClass:"require-label"},[_vm._v("*")]):_vm._e(),_vm._v(" "),_c('span',{staticClass:"number"},[_vm._v("\n "+_vm._s(_vm.question.header.number)+"-"+_vm._s(subQuestion.number)+".")]),_vm._v(" "),_c('span',{staticClass:"title"},[_vm._v(" "+_vm._s(_vm.i18nText(subQuestion.text))+" ")]),_vm._v(" "),_c('FormItem',{attrs:{"prop":_vm.answerProp(subIndex),"rules":{
17331
+ var __vue_render__$6 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',_vm._l((_vm.question.subQuestions),function(subQuestion,subIndex){return _c('div',{key:subIndex,staticClass:"sub-question"},[(_vm.isSubRequired)?_c('label',{staticClass:"require-label"},[_vm._v("*")]):_vm._e(),_vm._v(" "),_c('span',{staticClass:"number"},[_vm._v("\n "+_vm._s(_vm.question.header.number)+"-"+_vm._s(subQuestion.number)+".")]),_vm._v(" "),_c('span',{staticClass:"title"},[_vm._v(" "+_vm._s(_vm.i18nText(subQuestion.text))+" ")]),_vm._v(" "),(_vm.question.options.scoringEnabled && _vm.choiceMaxScore)?_c('span',{staticClass:"options-explain"},[_vm._v("\n ("+_vm._s(_vm.t(
17332
+ "survey_creator.question.max_score",
17333
+ _vm.$rootComponent.currentLanguage
17334
+ ))+_vm._s(_vm.choiceMaxScore)+")\n ")]):_vm._e(),_vm._v(" "),_c('FormItem',{attrs:{"prop":_vm.answerProp(subIndex),"rules":{
17280
17335
  required: _vm.isSubRequired && !_vm.question.options.disabled,
17281
17336
  message: _vm.t('survey_response.question.question_required'),
17282
- }}},[_c('RadioGroup',{on:{"on-change":_vm.selChange},model:{value:(_vm.value.answer[subIndex].answer),callback:function ($$v) {_vm.$set(_vm.value.answer[subIndex], "answer", $$v);},expression:"value.answer[subIndex].answer"}},[_c('Row',{attrs:{"type":"flex","justify":"start","gutter":60}},_vm._l((_vm.question.choices),function(choice){return _c('Col',{key:choice.id,class:_vm.optionLayout},[_c('Radio',{key:choice.id,attrs:{"label":choice.id,"disabled":subQuestion.options.readonly || _vm.question.options.disabled},nativeOn:{"click":function($event){return _vm.toggleAnswer(
17337
+ }}},[_c('RadioGroup',{on:{"on-change":_vm.selChange},model:{value:(_vm.value.answer[subIndex].answer),callback:function ($$v) {_vm.$set(_vm.value.answer[subIndex], "answer", $$v);},expression:"value.answer[subIndex].answer"}},[_c('Row',{attrs:{"gutter":60,"justify":"start","type":"flex"}},_vm._l((_vm.question.choices),function(choice){return _c('Col',{key:choice.id,class:_vm.optionLayout},[_c('Radio',{key:choice.id,attrs:{"disabled":subQuestion.options.readonly || _vm.question.options.disabled,"label":choice.id},nativeOn:{"click":function($event){return _vm.toggleAnswer(
17283
17338
  choice.id,
17284
17339
  subIndex,
17285
17340
  subQuestion.options.readonly || _vm.question.options.disabled
17286
- )}}},[_c('span',[_vm._v(_vm._s(_vm.i18nText(choice.text)))])])],1)}),1)],1)],1)],1)})],2)};
17341
+ )}}},[_c('span',[_vm._v(_vm._s(_vm.i18nText(choice.text)))]),_vm._v(" "),(
17342
+ _vm.options &&
17343
+ _vm.options.showChoiceScore &&
17344
+ _vm.question.options.scoringEnabled
17345
+ )?_c('span',{staticClass:"options-explain"},[_vm._v("\n ("+_vm._s((choice.options && choice.options.score) || 0)+"\n "+_vm._s(_vm.t(
17346
+ "survey_creator.question.scores",
17347
+ _vm.$rootComponent.currentLanguage
17348
+ ))+")\n ")]):_vm._e()])],1)}),1)],1)],1)],1)}),0)};
17287
17349
  var __vue_staticRenderFns__$6 = [];
17288
17350
 
17289
17351
  /* style */
17290
17352
  const __vue_inject_styles__$7 = function (inject) {
17291
17353
  if (!inject) return
17292
- inject("data-v-02dfeb56_0", { source: ".require-label[data-v-02dfeb56]{color:#ed4014}.title-score-section[data-v-02dfeb56]{margin-bottom:12px}.title-score-section .title-score-input-row[data-v-02dfeb56]{display:flex;align-items:center;gap:8px}.title-score-section .title-score-input-row .title-score-label[data-v-02dfeb56]{font-size:14px;color:#515a6e;white-space:nowrap}", map: undefined, media: undefined });
17354
+ inject("data-v-6fac9370_0", { source: ".require-label[data-v-6fac9370]{color:#ed4014}.options-explain[data-v-6fac9370]{margin-left:4px;color:#9ea7b4;font-size:12px}", map: undefined, media: undefined });
17293
17355
 
17294
17356
  };
17295
17357
  /* scoped */
17296
- const __vue_scope_id__$7 = "data-v-02dfeb56";
17358
+ const __vue_scope_id__$7 = "data-v-6fac9370";
17297
17359
  /* module identifier */
17298
17360
  const __vue_module_identifier__$7 = undefined;
17299
17361
  /* functional template */
@@ -18451,6 +18513,7 @@ var script$i = Vue.extend({
18451
18513
  },
18452
18514
  options: {
18453
18515
  type: Object,
18516
+ default: () => { },
18454
18517
  },
18455
18518
  size: {
18456
18519
  type: String,
@@ -18556,7 +18619,7 @@ var script$i = Vue.extend({
18556
18619
  const __vue_script__$i = script$i;
18557
18620
 
18558
18621
  /* template */
18559
- var __vue_render__$h = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (!_vm.emptyQuestions)?_c('div',{staticClass:"survey-response-wrapper"},[_c('Form',{ref:"responseForm",attrs:{"model":_vm.response,"disabled":_vm.readonly}},_vm._l((_vm.sortQuestions),function(question,index){return _c('div',{key:index,staticClass:"question"},[_c('question-title',{attrs:{"question":question,"index":index}}),_vm._v(" "),_c('question-body',{attrs:{"question":_vm.calculateQuestion(question, question.originalIndex),"answer":_vm.response.answers[question.originalIndex],"index":question.originalIndex,"options":_vm.options,"readonly":_vm.readonly},on:{"singleQuestion":_vm.handleSelected}})],1)}),0)],1):_c('empty-question')};
18622
+ var __vue_render__$h = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (!_vm.emptyQuestions)?_c('div',{staticClass:"survey-response-wrapper"},[_c('Form',{ref:"responseForm",attrs:{"disabled":_vm.readonly,"model":_vm.response}},_vm._l((_vm.sortQuestions),function(question,index){return _c('div',{key:index,staticClass:"question"},[_c('question-title',{attrs:{"answer":_vm.response.answers[question.originalIndex],"index":question.originalIndex,"question":question}}),_vm._v(" "),_c('question-body',{attrs:{"answer":_vm.response.answers[question.originalIndex],"index":question.originalIndex,"options":_vm.options,"question":_vm.calculateQuestion(question, question.originalIndex),"readonly":_vm.readonly},on:{"singleQuestion":_vm.handleSelected}})],1)}),0)],1):_c('empty-question')};
18560
18623
  var __vue_staticRenderFns__$h = [];
18561
18624
 
18562
18625
  /* style */
@@ -18743,7 +18806,9 @@ var script$j = Vue.extend({
18743
18806
  const __vue_script__$j = script$j;
18744
18807
 
18745
18808
  /* template */
18746
- var __vue_render__$i = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (!_vm.emptyQuestions)?_c('div',{staticClass:"survey-response-wrapper"},[_c('Form',{ref:"responseForm",attrs:{"model":_vm.responseSurveyAnswers,"disabled":_vm.readonly}},_vm._l((_vm.surveys),function(survey,surveyIndex){return _c('div',{key:surveyIndex},_vm._l((_vm.getFilterSortQuestions(survey.id)),function(question,index){return _c('div',{key:index,staticClass:"question"},[_c('question-title',{attrs:{"question":question,"custom-question":_vm.getCustomQuestion(question.id),"index":index}}),_vm._v(" "),_c('question-body',{attrs:{"question":_vm.calculateQuestion(question, question.originalIndex),"answer":_vm.responseSurveyAnswers.moreSurveyAnswers[surveyIndex].answers[
18809
+ var __vue_render__$i = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (!_vm.emptyQuestions)?_c('div',{staticClass:"survey-response-wrapper"},[_c('Form',{ref:"responseForm",attrs:{"model":_vm.responseSurveyAnswers,"disabled":_vm.readonly}},_vm._l((_vm.surveys),function(survey,surveyIndex){return _c('div',{key:surveyIndex},_vm._l((_vm.getFilterSortQuestions(survey.id)),function(question,index){return _c('div',{key:index,staticClass:"question"},[_c('question-title',{attrs:{"question":question,"custom-question":_vm.getCustomQuestion(question.id),"index":question.originalIndex,"survey-index":surveyIndex,"is-more-survey":true,"answer":_vm.responseSurveyAnswers.moreSurveyAnswers[surveyIndex].answers[
18810
+ question.originalIndex
18811
+ ]}}),_vm._v(" "),_c('question-body',{attrs:{"question":_vm.calculateQuestion(question, question.originalIndex),"answer":_vm.responseSurveyAnswers.moreSurveyAnswers[surveyIndex].answers[
18747
18812
  question.originalIndex
18748
18813
  ],"index":question.originalIndex,"survey":survey,"survey-index":surveyIndex,"is-more-survey":true,"options":_vm.options,"readonly":_vm.readonly},on:{"singleQuestion":_vm.handleSelected}})],1)}),0)}),0)],1):_c('empty-question')};
18749
18814
  var __vue_staticRenderFns__$i = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wg-npm/survey-response",
3
- "version": "1.78.511940",
3
+ "version": "1.78.511944",
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": "1.78.511940",
16
- "@wg-npm/survey-service-api": "1.78.511940",
15
+ "@wg-npm/survey-core": "1.78.511944",
16
+ "@wg-npm/survey-service-api": "1.78.511944",
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": "1.78.511940",
38
- "@wg-npm/survey-service-api": "1.78.511940",
37
+ "@wg-npm/survey-core": "1.78.511944",
38
+ "@wg-npm/survey-service-api": "1.78.511944",
39
39
  "acorn": "^7.3.1",
40
40
  "axios": "^0.19.2",
41
41
  "babelrc-rollup": "^3.0.0",
@@ -72,7 +72,7 @@
72
72
  "publishConfig": {
73
73
  "access": "public"
74
74
  },
75
- "gitHead": "3a04b43e5f25768662fe9b63fa38b6e76e24bc4a",
75
+ "gitHead": "cff0ee830e5b7a7789ccc6cc43c51d190c096169",
76
76
  "rollup": {
77
77
  "external": [
78
78
  "vue",
@@ -14,7 +14,14 @@
14
14
  <question-title
15
15
  :question="question"
16
16
  :custom-question="getCustomQuestion(question.id)"
17
- :index="index"
17
+ :index="question.originalIndex"
18
+ :survey-index="surveyIndex"
19
+ :is-more-survey="true"
20
+ :answer="
21
+ responseSurveyAnswers.moreSurveyAnswers[surveyIndex].answers[
22
+ question.originalIndex
23
+ ]
24
+ "
18
25
  >
19
26
  </question-title>
20
27
  <question-body
@@ -8,13 +8,43 @@
8
8
  </span>
9
9
  <question-title-dynamic
10
10
  v-if="question"
11
- :splitedTitles="getTitle(question)"
12
11
  :customFilledTitle="customFilledTitle"
12
+ :splitedTitles="getTitle(question)"
13
13
  ></question-title-dynamic>
14
+ <span v-if="questionTypeDesc" class="options-explain pl-sm">
15
+ {{ questionTypeDesc }}
16
+ </span>
17
+ <FormItem
18
+ v-if="isTitleScoringEnabled && answer"
19
+ :prop="answerTitleProp"
20
+ :rules="[
21
+ {
22
+ required: isTitleRequired && !question.options.disabled,
23
+ message: t('survey_response.question.question_required'),
24
+ },
25
+ { validator: validateTitleScore },
26
+ ]"
27
+ class="title-score-form-item"
28
+ >
29
+ <InputNumber
30
+ v-model="answer.titleScore"
31
+ :disabled="question.options.disabled"
32
+ :max="
33
+ question.options.scoreMax != null
34
+ ? question.options.scoreMax
35
+ : question.options.score || 100
36
+ "
37
+ :min="question.options.scoreMin != null ? question.options.scoreMin : 0"
38
+ :placeholder="
39
+ t('survey_response.question.matrix_title_score_placeholder')
40
+ "
41
+ class="title-score-input"
42
+ />
43
+ </FormItem>
14
44
  <span
15
- class="options-explain"
16
45
  v-if="haveStar"
17
46
  :style="{ display: isMobile() ? 'block' : '' }"
47
+ class="options-explain"
18
48
  >
19
49
  <span v-if="isSingleSelection">
20
50
  ({{
@@ -23,7 +53,7 @@
23
53
  $rootComponent.currentLanguage
24
54
  )
25
55
  }}
26
- <span> <Icon type="md-star" color="orange" :size="16" /> </span>)
56
+ <span> <Icon :size="16" color="orange" type="md-star" /> </span>)
27
57
  </span>
28
58
  <span v-else>
29
59
  (
@@ -33,7 +63,7 @@
33
63
  $rootComponent.currentLanguage
34
64
  )
35
65
  }}
36
- <Icon type="md-star" color="orange" :size="16" />
66
+ <Icon :size="16" color="orange" type="md-star" />
37
67
  {{
38
68
  t(
39
69
  `survey_creator.question.star_multi_prefix`,
@@ -54,15 +84,19 @@
54
84
  </template>
55
85
  <script lang="ts">
56
86
  import Vue from "vue";
57
- import { Icon } from "view-design";
58
- import { formatTitle, QuestionType } from "@wg-npm/survey-core";
87
+ import { FormItem, Icon, InputNumber } from "view-design";
88
+ import {
89
+ BaseQuestionModel,
90
+ formatTitle,
91
+ QuestionType,
92
+ } from "@wg-npm/survey-core";
59
93
  import OptionLayoutMixin from "../../mixins/option-layout-mixin";
60
94
  import QuestionTitleDynamic from "./question-title-dynamic.vue";
61
95
  import QuestionMixin from "../../mixins/question-mixin";
62
96
 
63
97
  export default Vue.extend({
64
98
  name: "question-title",
65
- components: { Icon, QuestionTitleDynamic },
99
+ components: { Icon, QuestionTitleDynamic, FormItem, InputNumber },
66
100
  mixins: [OptionLayoutMixin, QuestionMixin],
67
101
  inject: ["$rootComponent"],
68
102
  props: {
@@ -81,6 +115,11 @@ export default Vue.extend({
81
115
  type: Object,
82
116
  required: false,
83
117
  },
118
+ answer: {
119
+ type: Object,
120
+ required: false,
121
+ default: null,
122
+ },
84
123
  },
85
124
  computed: {
86
125
  customFilledTitle() {
@@ -92,22 +131,111 @@ export default Vue.extend({
92
131
  isSingleSelection() {
93
132
  return this.question.type == QuestionType.SINGLE_SELECTION;
94
133
  },
134
+ isTitleScoringEnabled() {
135
+ return (
136
+ this.question.type === QuestionType.MATRIX &&
137
+ !!this.question.options?.titleScoringEnabled
138
+ );
139
+ },
140
+ isTitleRequired() {
141
+ return !!this.question.options?.required;
142
+ },
143
+ answerTitleProp() {
144
+ // @ts-ignore
145
+ return this.isMoreSurvey
146
+ ? // @ts-ignore
147
+ `moreSurveyAnswers[${this.surveyIndex}].answers[${this.index}].titleScore`
148
+ : `answers[${this.index}].titleScore`;
149
+ },
150
+ questionTypeDesc() {
151
+ const type = this.question.type;
152
+ if (type === QuestionType.TEXT_TITLE) {
153
+ return "";
154
+ }
155
+ // @ts-ignore
156
+ const typeName = this.t(
157
+ `survey_creator.question.types.${type}`,
158
+ this.$rootComponent.currentLanguage
159
+ );
160
+ if (
161
+ type === QuestionType.SINGLE_SELECTION ||
162
+ type === QuestionType.MULTI_SELECTION ||
163
+ type === QuestionType.MATRIX
164
+ ) {
165
+ const maxScore = BaseQuestionModel.getMaxScore(this.question);
166
+ // @ts-ignore
167
+ const label = this.t(
168
+ "survey_creator.question.max_score",
169
+ this.$rootComponent.currentLanguage
170
+ );
171
+ return `${typeName}(${label}${maxScore})`;
172
+ }
173
+ if (type === QuestionType.SCORING) {
174
+ const range = BaseQuestionModel.getScoreRange(this.question);
175
+ // @ts-ignore
176
+ const label = this.t(
177
+ "survey_creator.question.scoring.scoreRange",
178
+ this.$rootComponent.currentLanguage
179
+ );
180
+ return `${typeName}(${label}${range})`;
181
+ }
182
+ return typeName;
183
+ },
95
184
  },
96
185
  methods: {
97
186
  getTitle(question) {
98
187
  return formatTitle(question, this.$rootComponent.currentLanguage);
99
188
  },
189
+ validateTitleScore(rule, value, callback) {
190
+ if (value === null || value === undefined) {
191
+ callback();
192
+ return;
193
+ }
194
+ const min = this.question.options.scoreMin;
195
+ const max = this.question.options.scoreMax;
196
+ if (min !== null && min !== undefined && value < min) {
197
+ // @ts-ignore
198
+ const tip = this.t(
199
+ "survey_response.question.matrix_title_score_range_tip"
200
+ );
201
+ callback(new Error(tip.replace("{0}", min).replace("{1}", max)));
202
+ return;
203
+ }
204
+ if (max !== null && max !== undefined && value > max) {
205
+ // @ts-ignore
206
+ const tip = this.t(
207
+ "survey_response.question.matrix_title_score_range_tip"
208
+ );
209
+ callback(new Error(tip.replace("{0}", min).replace("{1}", max)));
210
+ return;
211
+ }
212
+ callback();
213
+ },
100
214
  },
101
215
  });
102
216
  </script>
103
217
 
104
218
  <style lang="less" scoped>
105
- .flex {
219
+ .question-title {
106
220
  display: flex;
107
221
  align-items: center;
108
- white-space: nowrap;
222
+ flex-wrap: wrap;
109
223
  }
224
+
110
225
  .pr-sm {
111
226
  padding-right: 4px;
112
227
  }
228
+
229
+ .pl-sm {
230
+ padding-left: 4px;
231
+ }
232
+
233
+ .title-score-form-item {
234
+ margin-bottom: 0;
235
+
236
+ .title-score-input {
237
+ margin-left: 12px;
238
+ width: 120px;
239
+ }
240
+ }
113
241
  </style>
@@ -1,30 +1,5 @@
1
1
  <template>
2
2
  <div>
3
- <!-- Main title score input (when titleScoringEnabled) -->
4
- <div v-if="isTitleScoringEnabled" class="title-score-section">
5
- <FormItem
6
- :prop="answerTitleProp"
7
- :rules="[
8
- {
9
- required: isTitleRequired && !question.options.disabled,
10
- message: t('survey_response.question.question_required'),
11
- },
12
- { validator: validateTitleScore },
13
- ]"
14
- >
15
- <div class="title-score-input-row">
16
- <span class="title-score-label">{{ t('survey_response.question.matrix_title_score') }}:</span>
17
- <InputNumber
18
- v-model="value.titleScore"
19
- :min="question.options.scoreMin != null ? question.options.scoreMin : 0"
20
- :max="question.options.scoreMax != null ? question.options.scoreMax : (question.options.score || 100)"
21
- :disabled="question.options.disabled"
22
- @on-change="selChange"
23
- />
24
- </div>
25
- </FormItem>
26
- </div>
27
-
28
3
  <div
29
4
  v-for="(subQuestion, subIndex) in question.subQuestions"
30
5
  :key="subIndex"
@@ -35,6 +10,17 @@
35
10
  {{ question.header.number }}-{{ subQuestion.number }}.</span
36
11
  >
37
12
  <span class="title"> {{ i18nText(subQuestion.text) }} </span>
13
+ <span
14
+ v-if="question.options.scoringEnabled && choiceMaxScore"
15
+ class="options-explain"
16
+ >
17
+ ({{
18
+ t(
19
+ "survey_creator.question.max_score",
20
+ $rootComponent.currentLanguage
21
+ )
22
+ }}{{ choiceMaxScore }})
23
+ </span>
38
24
  <FormItem
39
25
  :prop="answerProp(subIndex)"
40
26
  :rules="{
@@ -46,15 +32,18 @@
46
32
  v-model="value.answer[subIndex].answer"
47
33
  @on-change="selChange"
48
34
  >
49
- <Row type="flex" justify="start" :gutter="60">
35
+ <Row :gutter="60" justify="start" type="flex">
50
36
  <Col
51
37
  v-for="choice in question.choices"
52
38
  :key="choice.id"
53
39
  :class="optionLayout"
54
40
  >
55
41
  <Radio
56
- :label="choice.id"
57
42
  :key="choice.id"
43
+ :disabled="
44
+ subQuestion.options.readonly || question.options.disabled
45
+ "
46
+ :label="choice.id"
58
47
  @click.native="
59
48
  toggleAnswer(
60
49
  choice.id,
@@ -62,11 +51,24 @@
62
51
  subQuestion.options.readonly || question.options.disabled
63
52
  )
64
53
  "
65
- :disabled="
66
- subQuestion.options.readonly || question.options.disabled
67
- "
68
54
  >
69
55
  <span>{{ i18nText(choice.text) }}</span>
56
+ <span
57
+ v-if="
58
+ options &&
59
+ options.showChoiceScore &&
60
+ question.options.scoringEnabled
61
+ "
62
+ class="options-explain"
63
+ >
64
+ ({{ (choice.options && choice.options.score) || 0 }}
65
+ {{
66
+ t(
67
+ "survey_creator.question.scores",
68
+ $rootComponent.currentLanguage
69
+ )
70
+ }})
71
+ </span>
70
72
  </Radio>
71
73
  </Col>
72
74
  </Row>
@@ -81,7 +83,7 @@ import Vue from "vue";
81
83
  import _ from "lodash";
82
84
  import OptionLayoutMixin from "../../../mixins/option-layout-mixin";
83
85
  import LocaleMixin from "../../../mixins/locale-mixin";
84
- import { FormItem, RadioGroup, Radio, Row, Col, InputNumber } from "view-design";
86
+ import { Col, FormItem, Radio, RadioGroup, Row } from "view-design";
85
87
 
86
88
  export default Vue.extend({
87
89
  name: "matrix",
@@ -94,7 +96,6 @@ export default Vue.extend({
94
96
  Radio,
95
97
  Row,
96
98
  Col,
97
- InputNumber,
98
99
  },
99
100
  props: {
100
101
  question: {
@@ -124,27 +125,29 @@ export default Vue.extend({
124
125
  this.value = n;
125
126
  this.initData();
126
127
  },
128
+ "value.titleScore"() {
129
+ this.selChange();
130
+ },
127
131
  },
128
132
  computed: {
129
133
  isTitleScoringEnabled() {
130
134
  // @ts-ignore
131
135
  return !!_.get(this.question, "options.titleScoringEnabled", false);
132
136
  },
133
- isTitleRequired() {
134
- // @ts-ignore
135
- return !!_.get(this.question, "options.required", false);
136
- },
137
137
  isSubRequired() {
138
138
  const opts = this.question.options;
139
- // subRequired is the new field; fall back to required for backward compat
140
139
  return opts.subRequired !== undefined
141
140
  ? !!opts.subRequired
142
141
  : !!opts.required;
143
142
  },
144
- answerTitleProp() {
145
- return this.isMoreSurvey
146
- ? `moreSurveyAnswers[${this.surveyIndex}].answers[${this.index}].titleScore`
147
- : `answers[${this.index}].titleScore`;
143
+ choiceMaxScore() {
144
+ return (
145
+ _.max(
146
+ (this.question.choices as any[]).map((choice) =>
147
+ parseFloat(choice?.options?.score || 0)
148
+ )
149
+ ) || 0
150
+ );
148
151
  },
149
152
  },
150
153
  methods: {
@@ -154,7 +157,6 @@ export default Vue.extend({
154
157
  : `answers[${this.index}].answer[${subIndex}].answer`;
155
158
  },
156
159
  initData() {
157
- // Init main title score field
158
160
  if (this.isTitleScoringEnabled && this.value.titleScore === undefined) {
159
161
  this.$set(this.value, "titleScore", null);
160
162
  }
@@ -183,33 +185,11 @@ export default Vue.extend({
183
185
  this.value.answer.push(_answer);
184
186
  });
185
187
  },
186
- validateTitleScore(rule, value, callback) {
187
- if (value === null || value === undefined) {
188
- callback();
189
- return;
190
- }
191
- const min = this.question.options.scoreMin;
192
- const max = this.question.options.scoreMax;
193
- if (min !== null && min !== undefined && value < min) {
194
- const tip = this.t("survey_response.question.matrix_title_score_range_tip");
195
- callback(new Error(tip.replace("{0}", min).replace("{1}", max)));
196
- return;
197
- }
198
- if (max !== null && max !== undefined && value > max) {
199
- const tip = this.t("survey_response.question.matrix_title_score_range_tip");
200
- callback(new Error(tip.replace("{0}", min).replace("{1}", max)));
201
- return;
202
- }
203
- callback();
204
- },
205
-
206
188
  selChange() {
207
189
  let score = 0;
208
- // Add main title score
209
190
  if (this.isTitleScoringEnabled && this.value.titleScore != null) {
210
191
  score += parseFloat(this.value.titleScore) || 0;
211
192
  }
212
- // Add sub-question choice scores
213
193
  // @ts-ignore
214
194
  _.each(this.value.answer, (sub_answer, index) => {
215
195
  // @ts-ignore
@@ -237,24 +217,14 @@ export default Vue.extend({
237
217
  });
238
218
  </script>
239
219
 
240
- <style scoped lang="less">
220
+ <style lang="less" scoped>
241
221
  .require-label {
242
222
  color: #ed4014;
243
223
  }
244
224
 
245
- .title-score-section {
246
- margin-bottom: 12px;
247
-
248
- .title-score-input-row {
249
- display: flex;
250
- align-items: center;
251
- gap: 8px;
252
-
253
- .title-score-label {
254
- font-size: 14px;
255
- color: #515a6e;
256
- white-space: nowrap;
257
- }
258
- }
225
+ .options-explain {
226
+ margin-left: 4px;
227
+ color: #9ea7b4;
228
+ font-size: 12px;
259
229
  }
260
230
  </style>
@@ -10,10 +10,10 @@
10
10
  >
11
11
  <CheckboxGroup v-model="value.answer" @on-change="selChange">
12
12
  <Row
13
- :type="flexOrBlock"
14
- justify="start"
15
13
  :gutter="60"
16
14
  :style="{ display: isMobile() ? 'inline-block' : 'flex' }"
15
+ :type="flexOrBlock"
16
+ justify="start"
17
17
  >
18
18
  <Col
19
19
  v-for="choice in question.choices"
@@ -22,19 +22,35 @@
22
22
  :style="{ display: isMobile() ? 'inline-block' : 'flex' }"
23
23
  >
24
24
  <Checkbox
25
- :style="{
26
- display: isMobile() ? 'inline-block' : 'flex',
27
- 'align-items': isMobile() ? '' : 'center',
28
- }"
29
- :label="choice.id"
30
25
  :key="choice.id"
31
26
  :disabled="
32
27
  question.options.readonly ||
33
28
  choice.readonly ||
34
29
  question.options.disabled
35
30
  "
31
+ :label="choice.id"
32
+ :style="{
33
+ display: isMobile() ? 'inline-block' : 'flex',
34
+ 'align-items': isMobile() ? '' : 'center',
35
+ }"
36
36
  >
37
37
  <span>{{ i18nText(choice.text) }}</span>
38
+ <span
39
+ v-if="
40
+ options &&
41
+ options.showChoiceScore &&
42
+ question.options.scoringEnabled
43
+ "
44
+ class="options-explain"
45
+ >
46
+ ({{ (choice.options && choice.options.score) || 0 }}
47
+ {{
48
+ t(
49
+ "survey_creator.question.scores",
50
+ $rootComponent.currentLanguage
51
+ )
52
+ }})
53
+ </span>
38
54
  </Checkbox>
39
55
 
40
56
  <div
@@ -83,12 +99,12 @@ import _ from "lodash";
83
99
  import OptionLayoutMixin from "../../../mixins/option-layout-mixin";
84
100
  import QuestionMixin from "../../../mixins/question-mixin";
85
101
  import {
86
- FormItem,
87
- CheckboxGroup,
88
102
  Checkbox,
89
- Row,
103
+ CheckboxGroup,
90
104
  Col,
105
+ FormItem,
91
106
  Input,
107
+ Row,
92
108
  } from "view-design";
93
109
 
94
110
  export default Vue.extend({
@@ -201,8 +217,10 @@ export default Vue.extend({
201
217
  margin-right: 8px;
202
218
  }
203
219
 
204
- .choice-score {
205
- margin-right: 8px;
220
+ .options-explain {
221
+ margin-left: 4px;
222
+ color: #9ea7b4;
223
+ font-size: 12px;
206
224
  }
207
225
 
208
226
  .ivu-checkbox-wrapper {
@@ -9,14 +9,14 @@
9
9
  >
10
10
  <RadioGroup
11
11
  v-model="value.answer"
12
- @on-change="selChange"
13
12
  class="question-choice"
13
+ @on-change="selChange"
14
14
  >
15
15
  <Row
16
- :type="flexOrBlock"
17
- justify="start"
18
16
  :gutter="60"
19
17
  :style="{ display: isMobile() ? 'inline-block' : 'flex' }"
18
+ :type="flexOrBlock"
19
+ justify="start"
20
20
  >
21
21
  <Col
22
22
  v-for="choice in question.choices"
@@ -25,21 +25,37 @@
25
25
  :style="{ display: isMobile() ? 'inline-block' : 'flex' }"
26
26
  >
27
27
  <Radio
28
+ :key="choice.id"
29
+ :disabled="question.options.readonly || question.options.disabled"
30
+ :label="choice.id"
28
31
  :style="{
29
32
  display: isMobile() ? 'inline-block' : 'flex',
30
33
  'align-items': isMobile() ? '' : 'center',
31
34
  }"
32
- :disabled="question.options.readonly || question.options.disabled"
33
- :label="choice.id"
34
- :key="choice.id"
35
35
  @click.native="
36
36
  toggleAnswer($event, choice.id, question.options.disabled)
37
37
  "
38
38
  >
39
39
  <span v-if="haveStar(choice)">
40
- <Icon type="md-star" color="orange" :size="16" />
40
+ <Icon :size="16" color="orange" type="md-star" />
41
41
  </span>
42
42
  <span>{{ i18nText(choice.text) }}</span>
43
+ <span
44
+ v-if="
45
+ options &&
46
+ options.showChoiceScore &&
47
+ question.options.scoringEnabled
48
+ "
49
+ class="options-explain"
50
+ >
51
+ ({{ (choice.options && choice.options.score) || 0 }}
52
+ {{
53
+ t(
54
+ "survey_creator.question.scores",
55
+ $rootComponent.currentLanguage
56
+ )
57
+ }})
58
+ </span>
43
59
  </Radio>
44
60
  <div
45
61
  v-for="(inputAnswer, inputIndex) in value.inputAnswers"
@@ -217,4 +233,10 @@ export default Vue.extend({
217
233
  margin-left: 8px;
218
234
  margin-right: 8px;
219
235
  }
236
+
237
+ .options-explain {
238
+ margin-left: 4px;
239
+ color: #9ea7b4;
240
+ font-size: 12px;
241
+ }
220
242
  </style>
@@ -1,17 +1,21 @@
1
1
  <template>
2
2
  <div v-if="!emptyQuestions" class="survey-response-wrapper">
3
- <Form ref="responseForm" :model="response" :disabled="readonly">
3
+ <Form ref="responseForm" :disabled="readonly" :model="response">
4
4
  <div
5
- :key="index"
6
5
  v-for="(question, index) in sortQuestions"
6
+ :key="index"
7
7
  class="question"
8
8
  >
9
- <question-title :question="question" :index="index"></question-title>
9
+ <question-title
10
+ :answer="response.answers[question.originalIndex]"
11
+ :index="question.originalIndex"
12
+ :question="question"
13
+ ></question-title>
10
14
  <question-body
11
- :question="calculateQuestion(question, question.originalIndex)"
12
15
  :answer="response.answers[question.originalIndex]"
13
16
  :index="question.originalIndex"
14
17
  :options="options"
18
+ :question="calculateQuestion(question, question.originalIndex)"
15
19
  :readonly="readonly"
16
20
  @singleQuestion="handleSelected"
17
21
  >
@@ -62,6 +66,7 @@ export default Vue.extend({
62
66
  },
63
67
  options: {
64
68
  type: Object,
69
+ default: () => {},
65
70
  },
66
71
  size: {
67
72
  type: String,
@@ -29,6 +29,7 @@ export default {
29
29
  "The number of characters in the entry should not be less than{0}",
30
30
  choice_required: "This item is required",
31
31
  matrix_title_score: "Score",
32
+ matrix_title_score_placeholder: "Please enter score",
32
33
  matrix_title_score_range_tip: "Please enter a value between {0} and {1}",
33
34
  },
34
35
  },
@@ -27,6 +27,7 @@ export default {
27
27
  input_text_limit: "输入项字数不少于{0}字",
28
28
  choice_required: "此项必填",
29
29
  matrix_title_score: "分数",
30
+ matrix_title_score_placeholder: "请输入评分",
30
31
  matrix_title_score_range_tip: "请输入{0}到{1}之间的分值",
31
32
  },
32
33
  },