@wg-npm/survey-creator 0.3.377-8.develop → 0.3.4004

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,6 +1,6 @@
1
1
  import Vue from 'vue';
2
2
  import _ from 'lodash';
3
- import { Dropdown, DropdownMenu, DropdownItem, Button, Row, Col, Icon, Tooltip, Radio, RadioGroup, Checkbox, CheckboxGroup, Input, Divider, Card, Form, FormItem, ButtonGroup, Select, Option, InputNumber, Table, OptionGroup, Drawer, Modal, Tabs, TabPane, Scroll } from 'view-design';
3
+ import { Dropdown, DropdownMenu, DropdownItem, Button, Row, Col, Icon, Tooltip, Radio, RadioGroup, Checkbox, CheckboxGroup, Input, Divider, Card, Form, FormItem, ButtonGroup, Select, Option, InputNumber, Table, OptionGroup, Message, Drawer, Modal, Tabs, TabPane, Scroll } from 'view-design';
4
4
  import deepmerge from 'deepmerge';
5
5
  import draggable from 'vuedraggable';
6
6
 
@@ -150,7 +150,7 @@ var defaultLang = {
150
150
  other: "其他",
151
151
  assign_template: `{0} 项为 {1} {2} {3}项`,
152
152
  auto_template: `{0} 项为 {1}`,
153
- score_template: `总分数范围为: {0}分{1}, {2}分`,
153
+ score_template: `总分数范围为: {0}分{1}{2}分`,
154
154
  },
155
155
  },
156
156
  },
@@ -292,7 +292,7 @@ class QuestionFactory {
292
292
  }
293
293
 
294
294
  createQuestion(questionType) {
295
- let creator = this.creatorHash[questionType];
295
+ const creator = this.creatorHash[questionType];
296
296
  return creator(this.locale);
297
297
  }
298
298
 
@@ -377,7 +377,7 @@ class BaseQuestionModel {
377
377
  } else if (question.type == "MULTI_SELECTION") {
378
378
  return _.sumBy(question.choices, item => parseFloat(_.get(item, "options.score") || 0));
379
379
  } else if (question.type == "MATRIX") {
380
- let score = _.max(_.map(question.choices, choice => parseFloat(_.get(choice, "options.score", 0) || 0)));
380
+ const score = _.max(_.map(question.choices, choice => parseFloat(_.get(choice, "options.score", 0) || 0)));
381
381
 
382
382
  return score * question.subQuestions.length;
383
383
  }
@@ -401,7 +401,7 @@ class BaseQuestionModel {
401
401
 
402
402
  static calculationAllQuestionCount(questions) {
403
403
  let count = 0;
404
- let exclude = ["TEXT_TITLE"];
404
+ const exclude = ["TEXT_TITLE"];
405
405
 
406
406
  _.forEach(questions, question => {
407
407
  if (!_.includes(exclude, question.type)) {
@@ -491,7 +491,7 @@ class QuestionMatrixModel extends BaseQuestionModel {
491
491
  }
492
492
 
493
493
  static getNumber(preNumber, question) {
494
- let number = preNumber + 1;
494
+ const number = preNumber + 1;
495
495
 
496
496
  _.forEach(question.subQuestions, (sq, index) => {
497
497
  sq.number = index + 1;
@@ -509,17 +509,17 @@ const EN_US = _.camelCase("en-US");
509
509
  const ZH_TW = _.camelCase("zh-TW");
510
510
 
511
511
  function getValue(obj, locale) {
512
- let value = _.get(obj, _.camelCase(locale), '');
512
+ const value = _.get(obj, _.camelCase(locale), "");
513
513
 
514
514
  if (!_.isEmpty(value)) {
515
515
  return value;
516
516
  }
517
517
 
518
- return _.get(obj, locale, '');
518
+ return _.get(obj, locale, "");
519
519
  }
520
520
 
521
521
  function translate(obj, locale, prettyMath = false) {
522
- let value = getValue(obj, locale);
522
+ const value = getValue(obj, locale);
523
523
 
524
524
  if (!_.isEmpty(value) || !prettyMath) {
525
525
  return value;
@@ -3102,17 +3102,17 @@ var script$e = Vue.extend({
3102
3102
  const __vue_script__$e = script$e;
3103
3103
 
3104
3104
  /* template */
3105
- var __vue_render__$e = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('Row',{attrs:{"type":"flex","justify":"start","gutter":6,"align":"middle"}},[_c('Col',{staticClass:"label"},[_vm._v("\n "+_vm._s(_vm.t('survey_creator.question.evaluation.condition.type.SCORE'))+"\n ")]),_vm._v(" "),_c('Col',{attrs:{"span":5}},[_c('FormItem',{attrs:{"prop":("evaluationItems[" + _vm.itemIndex + "].conditions[" + _vm.index + "].payload.scope"),"rules":{ required: true, type: 'array', trigger: 'change', min: 1, message: _vm.t('survey_creator.question.notEmpty') }}},[_c('question-select',{attrs:{"question":_vm.question},model:{value:(_vm.value.scope),callback:function ($$v) {_vm.$set(_vm.value, "scope", $$v);},expression:"value.scope"}})],1)],1),_vm._v(" "),_c('Col',{staticClass:"label"},[_vm._v("\n "+_vm._s(_vm.t('survey_creator.question.evaluation.condition.question_result'))+"\n ")]),_vm._v(" "),_c('Col',{attrs:{"span":8}},[_c('FormItem',{attrs:{"prop":("evaluationItems[" + _vm.itemIndex + "].conditions[" + _vm.index + "].payload.values"),"rules":{ required: true, type: 'array', trigger: 'change', min: 1, message: _vm.t('survey_creator.question.notEmpty') }}},[_c('Select',{attrs:{"placeholder":_vm.t('survey_creator.question.evaluation.condition.choose_result'),"max-tag-count":1,"multiple":""},model:{value:(_vm.value.values),callback:function ($$v) {_vm.$set(_vm.value, "values", $$v);},expression:"value.values"}},_vm._l((_vm.choices),function(choice,index){return _c('Option',{key:index,attrs:{"value":choice}},[_vm._v("\n "+_vm._s(choice)+"\n ")])}),1)],1)],1)],1)};
3105
+ var __vue_render__$e = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('Row',{attrs:{"type":"flex","justify":"start","gutter":6,"align":"middle"}},[_c('Col',{staticClass:"label"},[_vm._v("\n "+_vm._s(_vm.t('survey_creator.question.evaluation.condition.question'))+"\n ")]),_vm._v(" "),_c('Col',{attrs:{"span":5}},[_c('FormItem',{attrs:{"prop":("evaluationItems[" + _vm.itemIndex + "].conditions[" + _vm.index + "].payload.scope"),"rules":{ required: true, type: 'array', trigger: 'change', min: 1, message: _vm.t('survey_creator.question.notEmpty') }}},[_c('question-select',{attrs:{"question":_vm.question},model:{value:(_vm.value.scope),callback:function ($$v) {_vm.$set(_vm.value, "scope", $$v);},expression:"value.scope"}})],1)],1),_vm._v(" "),_c('Col',{staticClass:"label"},[_vm._v("\n "+_vm._s(_vm.t('survey_creator.question.evaluation.condition.question_result'))+"\n ")]),_vm._v(" "),_c('Col',{attrs:{"span":8}},[_c('FormItem',{attrs:{"prop":("evaluationItems[" + _vm.itemIndex + "].conditions[" + _vm.index + "].payload.values"),"rules":{ required: true, type: 'array', trigger: 'change', min: 1, message: _vm.t('survey_creator.question.notEmpty') }}},[_c('Select',{attrs:{"placeholder":_vm.t('survey_creator.question.evaluation.condition.choose_result'),"max-tag-count":1,"multiple":""},model:{value:(_vm.value.values),callback:function ($$v) {_vm.$set(_vm.value, "values", $$v);},expression:"value.values"}},_vm._l((_vm.choices),function(choice,index){return _c('Option',{key:index,attrs:{"value":choice}},[_vm._v("\n "+_vm._s(choice)+"\n ")])}),1)],1)],1)],1)};
3106
3106
  var __vue_staticRenderFns__$e = [];
3107
3107
 
3108
3108
  /* style */
3109
3109
  const __vue_inject_styles__$e = function (inject) {
3110
3110
  if (!inject) return
3111
- inject("data-v-1b7846c4_0", { source: ".label[data-v-1b7846c4]{text-align:right;margin-bottom:24px}", map: undefined, media: undefined });
3111
+ inject("data-v-647dceac_0", { source: ".label[data-v-647dceac]{text-align:right;margin-bottom:24px}", map: undefined, media: undefined });
3112
3112
 
3113
3113
  };
3114
3114
  /* scoped */
3115
- const __vue_scope_id__$e = "data-v-1b7846c4";
3115
+ const __vue_scope_id__$e = "data-v-647dceac";
3116
3116
  /* module identifier */
3117
3117
  const __vue_module_identifier__$e = undefined;
3118
3118
  /* functional template */
@@ -3138,6 +3138,7 @@ var __vue_staticRenderFns__$e = [];
3138
3138
 
3139
3139
  var Auto = __vue_component__$e;
3140
3140
 
3141
+ Vue.prototype.$Message = Message;
3141
3142
  var script$d = Vue.extend({
3142
3143
  name: "score",
3143
3144
  mixins: [ExprMixin, LocaleMixin],
@@ -3147,28 +3148,145 @@ var script$d = Vue.extend({
3147
3148
  Select,
3148
3149
  Option,
3149
3150
  FormItem,
3150
- InputNumber,
3151
+ InputNumber
3151
3152
  },
3152
3153
  data() {
3153
3154
  return {
3154
- operators: ["<=", "<"],
3155
+ leftMin: 0,
3156
+ leftMax: 0,
3157
+ rightMin: 0,
3158
+ rightMax: 0,
3159
+ operators: ["<=", "<"]
3155
3160
  };
3156
3161
  },
3162
+ created() {
3163
+ this.leftMax = this.totalScore - 1;
3164
+ this.rightMax = this.totalScore;
3165
+ },
3157
3166
  computed: {
3158
3167
  totalScore() {
3159
3168
  return this.$rootComponent.currentSurvey.statistics.maxScore;
3160
3169
  },
3170
+ otherConditions() {
3171
+ let otherEvaluationItems = _.filter(_.map(this.evaluationItems, (item, index) => {
3172
+ return _.extend({}, item, { index: index });
3173
+ }), (item) => item.index != this.itemIndex);
3174
+ return _.filter(_.flatMap(otherEvaluationItems, "conditions"), (item) => item.type == "SCORE");
3175
+ },
3176
+ otherMin() {
3177
+ _.min(_.map(this.otherConditions, (item) => _.get(item, "payload.minScore", 0)));
3178
+ },
3179
+ otherMax() {
3180
+ _.max(_.map(this.otherConditions, (item) => _.get(item, "payload.maxScore", 0)));
3181
+ },
3161
3182
  },
3162
3183
  methods: {
3184
+ checkValueInOtherRange(value, conditions) {
3185
+ let otherRange = _.map(conditions, (item) => {
3186
+ return {
3187
+ min: _.get(item, "payload.minScore"),
3188
+ max: _.get(item, "payload.maxScore"),
3189
+ };
3190
+ });
3191
+ return _.some(otherRange, function (o) {
3192
+ return value >= o.min && value <= o.max;
3193
+ });
3194
+ },
3163
3195
  generateExpr() {
3164
3196
  let minScore = this.value.minScore;
3165
3197
  let maxScore = this.value.maxScore;
3166
- return `$totalScore ${minScore} ${this.value.operator} ${maxScore}`;
3198
+ return `${minScore} ${this.value.operator} score and score ${this.value.operator} ${maxScore}`;
3167
3199
  },
3168
- rangeChange() {
3169
- console.log("222");
3200
+ leftChange(value) {
3201
+ this.rangeChange(value, "left");
3170
3202
  },
3171
- },
3203
+ rightChange(value) {
3204
+ this.rangeChange(value, "right");
3205
+ },
3206
+ rangeChange(value, type) {
3207
+ let valueInOtherRange = this.checkValueInOtherRange(value, this.otherConditions);
3208
+ let usableRanges = this.getUsableRanges();
3209
+ let firstUsableRange = usableRanges[0];
3210
+ let valueInRange = this.getSelectedRangeByValue(value, usableRanges);
3211
+ let currentRange = valueInOtherRange ? firstUsableRange : valueInRange;
3212
+ let min = valueInOtherRange ? firstUsableRange[0] : _.get(valueInRange, 'min', 0);
3213
+ let max = valueInOtherRange ? firstUsableRange[1] : _.get(currentRange, 'max', this.totalScore);
3214
+ if (valueInOtherRange) {
3215
+ this.$Message.error("该值在其他区间范围内,请重新输入");
3216
+ this.$set(this.value, "minScore", min);
3217
+ this.$set(this.value, "maxScore", max);
3218
+ this.rightMin = min;
3219
+ this.rightMax = max;
3220
+ this.leftMin = min;
3221
+ this.leftMax = max;
3222
+ }
3223
+ else {
3224
+ if (type == "left") {
3225
+ this.rightMin = value + 1;
3226
+ this.rightMax = max;
3227
+ }
3228
+ if (type == "right") {
3229
+ this.leftMin = min;
3230
+ this.leftMax = value - 1;
3231
+ }
3232
+ }
3233
+ },
3234
+ getSelectedRangeByValue(value, ranges) {
3235
+ let otherRange = _.map(ranges, (item) => {
3236
+ return {
3237
+ min: _.get(item, "payload.minScore"),
3238
+ max: _.get(item, "payload.maxScore"),
3239
+ };
3240
+ });
3241
+ return _.head(_.filter(otherRange, function (o) {
3242
+ return value > o.min && value < o.max;
3243
+ }));
3244
+ },
3245
+ getUsableRanges() {
3246
+ let usedRange = _.map(this.otherConditions, (item) => {
3247
+ return [item.payload.minScore, item.payload.maxScore];
3248
+ });
3249
+ let globalMin = 0;
3250
+ let globalMax = this.totalScore;
3251
+ let usableRange = new Array();
3252
+ if (usedRange.length == 1) {
3253
+ let first = usedRange[0][0] - 1;
3254
+ if (usedRange[0][0] !== 0) {
3255
+ let item = [0, first];
3256
+ usableRange.push(item);
3257
+ }
3258
+ }
3259
+ else {
3260
+ let other = usedRange.reduce((a, v) => {
3261
+ if (typeof a[0] == "number") {
3262
+ if (a[0] != globalMin) {
3263
+ return [
3264
+ [0, a[0]],
3265
+ [a[1], v[0]],
3266
+ [v[1], v[1]],
3267
+ ];
3268
+ }
3269
+ else {
3270
+ return [
3271
+ [a[1], v[0]],
3272
+ [v[1], v[1]],
3273
+ ];
3274
+ }
3275
+ }
3276
+ else {
3277
+ a[a.length - 1][1] = v[0];
3278
+ if (a.length != usedRange.length)
3279
+ a.push([v[1], v[1]]);
3280
+ }
3281
+ return a;
3282
+ });
3283
+ if (usedRange[length - 1][1] != globalMax) {
3284
+ other.push([usedRange[length - 1][1], globalMax]);
3285
+ }
3286
+ }
3287
+ return usableRange;
3288
+ },
3289
+ }
3172
3290
  });
3173
3291
 
3174
3292
  /* script */
@@ -3176,34 +3294,34 @@ const __vue_script__$d = script$d;
3176
3294
 
3177
3295
  /* template */
3178
3296
  var __vue_render__$d = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('Row',{attrs:{"type":"flex","justify":"start","gutter":6,"align":"middle"}},[_c('Col',{staticClass:"label"},[_vm._v("\n "+_vm._s(_vm.t("survey_creator.question.evaluation.condition.score_condition_title"))+"\n ")]),_vm._v(" "),_c('Col',{attrs:{"span":3}},[_c('FormItem',{attrs:{"prop":("evaluationItems[" + _vm.itemIndex + "].conditions[" + _vm.index + "].payload.minScore"),"rules":{
3179
- required: true,
3180
- type: 'number',
3181
- trigger: 'change',
3182
- min: 0,
3183
- max: this.totalScore,
3184
- message: _vm.t('分值不能为空'),
3185
- }}},[_c('InputNumber',{attrs:{"min":0,"max":_vm.value.maxScore},on:{"on-change":_vm.rangeChange},model:{value:(_vm.value.minScore),callback:function ($$v) {_vm.$set(_vm.value, "minScore", $$v);},expression:"value.minScore"}})],1)],1),_vm._v(" "),_c('Col',{staticClass:"label"},[_vm._v("\n "+_vm._s(_vm.t("survey_creator.question.scores"))+"\n ")]),_vm._v(" "),_c('Col',{attrs:{"span":3}},[_c('FormItem',{attrs:{"prop":("evaluationItems[" + _vm.itemIndex + "].conditions[" + _vm.index + "].payload.operator"),"rules":{
3297
+ min:_vm.leftMin,
3298
+ max:_vm.leftMax,
3299
+ required: true,
3300
+ type: 'number',
3301
+ trigger: 'change',
3302
+ message: _vm.t('分值不正确'),
3303
+ }}},[_c('InputNumber',{attrs:{"active-change":false,"min":_vm.leftMin,"max":_vm.leftMax,"formatter":function (value) { return ("" + value + (_vm.t('survey_creator.question.scores'))); },"parser":function (value) { return value.replace(("" + (_vm.t('survey_creator.question.scores'))), ''); }},on:{"on-change":_vm.leftChange},model:{value:(_vm.value.minScore),callback:function ($$v) {_vm.$set(_vm.value, "minScore", $$v);},expression:"value.minScore"}})],1)],1),_vm._v(" "),_c('Col',{attrs:{"span":3}},[_c('FormItem',{attrs:{"prop":("evaluationItems[" + _vm.itemIndex + "].conditions[" + _vm.index + "].payload.operator"),"rules":{
3186
3304
  required: true,
3187
3305
  trigger: 'change',
3188
3306
  message: _vm.t('survey_creator.question.notEmpty'),
3189
- }}},[_c('Select',{attrs:{"placeholder":_vm.t('survey_creator.question.evaluation.condition.operator')},model:{value:(_vm.value.operator),callback:function ($$v) {_vm.$set(_vm.value, "operator", $$v);},expression:"value.operator"}},_vm._l((_vm.operators),function(operator,index){return _c('Option',{key:index,attrs:{"value":operator}},[_vm._v("\n "+_vm._s(operator)+"\n ")])}),1)],1)],1),_vm._v(" "),_c('Col',{attrs:{"span":3}},[_c('FormItem',{attrs:{"prop":("evaluationItems[" + _vm.itemIndex + "].conditions[" + _vm.index + "].payload.maxScore"),"rules":{
3307
+ }}},[_c('Select',{attrs:{"placeholder":_vm.t('survey_creator.question.evaluation.condition.operator')},model:{value:(_vm.value.operator),callback:function ($$v) {_vm.$set(_vm.value, "operator", $$v);},expression:"value.operator"}},_vm._l((_vm.operators),function(operator,index){return _c('Option',{key:index,attrs:{"value":operator}},[_vm._v("\n "+_vm._s(operator)+"\n ")])}),1)],1)],1),_vm._v(" "),_c('Col',{attrs:{"span":2}},[_c('FormItem',{attrs:{"prop":("evaluationItems[" + _vm.itemIndex + "].conditions[" + _vm.index + "].payload.maxScore"),"rules":{
3308
+ min:_vm.rightMin,
3309
+ max:_vm.rightMax,
3190
3310
  required: true,
3191
3311
  type: 'number',
3192
3312
  trigger: 'change',
3193
- min: 0,
3194
- max: this.totalScore,
3195
- message: _vm.t('分值不能为空'),
3196
- }}},[_c('InputNumber',{attrs:{"min":_vm.value.minScore,"max":_vm.totalScore},on:{"on-change":_vm.rangeChange},model:{value:(_vm.value.maxScore),callback:function ($$v) {_vm.$set(_vm.value, "maxScore", $$v);},expression:"value.maxScore"}})],1)],1),_vm._v(" "),_c('Col',{staticClass:"label"},[_vm._v("\n "+_vm._s(_vm.t("survey_creator.question.scores"))+"\n ")])],1)};
3313
+ message: _vm.t('分值不正确'),
3314
+ }}},[_c('InputNumber',{attrs:{"active-change":false,"min":_vm.rightMin,"max":_vm.rightMax,"formatter":function (value) { return ("" + value + (_vm.t('survey_creator.question.scores'))); },"parser":function (value) { return value.replace(("" + (_vm.t('survey_creator.question.scores'))), ''); }},on:{"on-change":_vm.rightChange},model:{value:(_vm.value.maxScore),callback:function ($$v) {_vm.$set(_vm.value, "maxScore", $$v);},expression:"value.maxScore"}})],1)],1)],1)};
3197
3315
  var __vue_staticRenderFns__$d = [];
3198
3316
 
3199
3317
  /* style */
3200
3318
  const __vue_inject_styles__$d = function (inject) {
3201
3319
  if (!inject) return
3202
- inject("data-v-595ef9bc_0", { source: ".label[data-v-595ef9bc]{text-align:right;margin-bottom:24px}", map: undefined, media: undefined });
3320
+ inject("data-v-2e725872_0", { source: ".label[data-v-2e725872]{text-align:right;margin-bottom:24px}", map: undefined, media: undefined });
3203
3321
 
3204
3322
  };
3205
3323
  /* scoped */
3206
- const __vue_scope_id__$d = "data-v-595ef9bc";
3324
+ const __vue_scope_id__$d = "data-v-2e725872";
3207
3325
  /* module identifier */
3208
3326
  const __vue_module_identifier__$d = undefined;
3209
3327
  /* functional template */
@@ -3385,20 +3503,16 @@ var script$b = Vue.extend({
3385
3503
  buildPayloadByType(type) {
3386
3504
  if (type == "SCORE") {
3387
3505
  return {
3388
- payload: {
3389
- minScore: 0,
3390
- operator: "<",
3391
- maxScore: 0,
3392
- },
3506
+ minScore: 0,
3507
+ operator: "<",
3508
+ maxScore: 0,
3393
3509
  };
3394
3510
  }
3395
3511
  return {
3396
- payload: {
3397
- scope: [],
3398
- operator: "=",
3399
- values: [],
3400
- size: 0,
3401
- },
3512
+ scope: [],
3513
+ operator: "=",
3514
+ values: [],
3515
+ size: 0,
3402
3516
  };
3403
3517
  },
3404
3518
  removeCondition(index) {
@@ -3425,11 +3539,11 @@ var __vue_staticRenderFns__$b = [];
3425
3539
  /* style */
3426
3540
  const __vue_inject_styles__$b = function (inject) {
3427
3541
  if (!inject) return
3428
- inject("data-v-25df9b0d_0", { source: ".mt-base[data-v-25df9b0d]{margin-top:12px}.action[data-v-25df9b0d]{float:right}.input[data-v-25df9b0d]{width:100px}.label[data-v-25df9b0d]{text-align:right;padding-right:4px}.text[data-v-25df9b0d]{background-color:#ebf7ff;height:32px;padding:8px 18px;font-weight:500;color:#515a6e}[data-v-25df9b0d] .ivu-card .ivu-form-item{margin-bottom:4px;margin-top:0}[data-v-25df9b0d] .ivu-card .ivu-form-item-error{margin-bottom:24px;margin-top:0}", map: undefined, media: undefined });
3542
+ inject("data-v-199a51dd_0", { source: ".mt-base[data-v-199a51dd]{margin-top:12px}.action[data-v-199a51dd]{float:right}.input[data-v-199a51dd]{width:100px}.label[data-v-199a51dd]{text-align:right;padding-right:4px}.text[data-v-199a51dd]{background-color:#ebf7ff;height:32px;padding:8px 18px;font-weight:500;color:#515a6e}[data-v-199a51dd] .ivu-card .ivu-form-item{margin-bottom:4px;margin-top:0}[data-v-199a51dd] .ivu-card .ivu-form-item-error{margin-bottom:24px;margin-top:0}", map: undefined, media: undefined });
3429
3543
 
3430
3544
  };
3431
3545
  /* scoped */
3432
- const __vue_scope_id__$b = "data-v-25df9b0d";
3546
+ const __vue_scope_id__$b = "data-v-199a51dd";
3433
3547
  /* module identifier */
3434
3548
  const __vue_module_identifier__$b = undefined;
3435
3549
  /* functional template */
@@ -3583,11 +3697,17 @@ var __vue_staticRenderFns__$9 = [];
3583
3697
  var script$8 = Vue.extend({
3584
3698
  name: "evaluation-form",
3585
3699
  components: {
3586
- Form, FormItem, Row,
3587
- Col, draggable, Option,
3588
- Select, Checkbox, Input,
3700
+ Form,
3701
+ FormItem,
3702
+ Row,
3703
+ Col,
3704
+ draggable,
3705
+ Option,
3706
+ Select,
3707
+ Checkbox,
3708
+ Input,
3589
3709
  ["STAR"]: Star,
3590
- ["EXPR"]: Expr
3710
+ ["EXPR"]: Expr,
3591
3711
  },
3592
3712
  mixins: [questionFormMixin],
3593
3713
  data() {
@@ -3595,7 +3715,7 @@ var script$8 = Vue.extend({
3595
3715
  labelWidth: 80,
3596
3716
  layoutOptions: ["HORIZONTAL", "VERTICAL"],
3597
3717
  evaluationTypes: ["STAR", "EXPR"],
3598
- realColumns: []
3718
+ realColumns: [],
3599
3719
  };
3600
3720
  },
3601
3721
  created() {
@@ -3603,33 +3723,41 @@ var script$8 = Vue.extend({
3603
3723
  },
3604
3724
  methods: {
3605
3725
  initData() {
3606
- this.editQuestion.evaluationItems || this.$set(this.editQuestion, "evaluationItems", []);
3607
- this.editQuestion.options.evaluationType || this.$set(this.editQuestion.options, "evaluationType", "STAR");
3726
+ this.editQuestion.evaluationItems ||
3727
+ this.$set(this.editQuestion, "evaluationItems", []);
3728
+ this.editQuestion.options.evaluationType ||
3729
+ this.$set(this.editQuestion.options, "evaluationType", "STAR");
3608
3730
  },
3609
3731
  onChange(value) {
3610
3732
  if (value == "EXPR") {
3611
- _.forEach(this.editQuestion.evaluationItems, item => _.set(item, "type", "IF"));
3733
+ _.forEach(this.editQuestion.evaluationItems, (item, index) => {
3734
+ _.set(item, "type", "IF");
3735
+ _.set(item, "index", index);
3736
+ });
3612
3737
  _.set(this.editQuestion.evaluationItems[_.size(this.editQuestion.evaluationItems) - 1], "type", "ELSE");
3613
3738
  }
3614
- }
3615
- }
3739
+ },
3740
+ },
3616
3741
  });
3617
3742
 
3618
3743
  /* script */
3619
3744
  const __vue_script__$8 = script$8;
3620
3745
 
3621
3746
  /* template */
3622
- var __vue_render__$8 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('Form',{ref:"questionForm",attrs:{"model":_vm.editQuestion,"label-colon":false}},[_c('Row',[_c('Form-item',{attrs:{"prop":'header.text.' + _vm.primaryLanguage,"rules":{required: true, message: _vm.t('survey_creator.question.titleRequiredTip')},"label":_vm.t('survey_creator.page.question')}},[_c('Checkbox',{model:{value:(_vm.editQuestion.options.required),callback:function ($$v) {_vm.$set(_vm.editQuestion.options, "required", $$v);},expression:"editQuestion.options.required"}},[_vm._v(_vm._s(_vm.t('survey_creator.question.questionRequired'))+"\n ")]),_vm._v(" "),_c('Row',[_c('Col',{attrs:{"span":23,"offset":-1}},[_c('Input',{attrs:{"placeholder":_vm.t('survey_creator.question.titleRequiredTip')},model:{value:(_vm.editQuestion.header.text[_vm.primaryLanguage]),callback:function ($$v) {_vm.$set(_vm.editQuestion.header.text, _vm.primaryLanguage, (typeof $$v === 'string'? $$v.trim(): $$v));},expression:"editQuestion.header.text[primaryLanguage]"}})],1)],1)],1)],1),_vm._v(" "),_c('Row',[_c('Form-item',{attrs:{"label":_vm.t('survey_creator.question.evaluation.selectedType'),"label-width":_vm.labelWidth}},[_c('Select',{staticStyle:{"width":"200px"},on:{"on-change":_vm.onChange},model:{value:(_vm.editQuestion.options.evaluationType),callback:function ($$v) {_vm.$set(_vm.editQuestion.options, "evaluationType", $$v);},expression:"editQuestion.options.evaluationType"}},_vm._l((_vm.evaluationTypes),function(item){return _c('Option',{key:item,attrs:{"value":item}},[_vm._v(_vm._s(_vm.t(("survey_creator.question.evaluation.type." + item)))+"\n ")])}),1)],1)],1),_vm._v(" "),_c(_vm.editQuestion.options.evaluationType,{tag:"component",attrs:{"question":_vm.question},model:{value:(_vm.editQuestion.evaluationItems),callback:function ($$v) {_vm.$set(_vm.editQuestion, "evaluationItems", $$v);},expression:"editQuestion.evaluationItems"}})],1)};
3747
+ var __vue_render__$8 = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('Form',{ref:"questionForm",attrs:{"model":_vm.editQuestion,"label-colon":false}},[_c('Row',[_c('Form-item',{attrs:{"prop":'header.text.' + _vm.primaryLanguage,"rules":{
3748
+ required: true,
3749
+ message: _vm.t('survey_creator.question.titleRequiredTip'),
3750
+ },"label":_vm.t('survey_creator.page.question')}},[_c('Checkbox',{model:{value:(_vm.editQuestion.options.required),callback:function ($$v) {_vm.$set(_vm.editQuestion.options, "required", $$v);},expression:"editQuestion.options.required"}},[_vm._v(_vm._s(_vm.t("survey_creator.question.questionRequired"))+"\n ")]),_vm._v(" "),_c('Row',[_c('Col',{attrs:{"span":23,"offset":-1}},[_c('Input',{attrs:{"placeholder":_vm.t('survey_creator.question.titleRequiredTip')},model:{value:(_vm.editQuestion.header.text[_vm.primaryLanguage]),callback:function ($$v) {_vm.$set(_vm.editQuestion.header.text, _vm.primaryLanguage, (typeof $$v === 'string'? $$v.trim(): $$v));},expression:"editQuestion.header.text[primaryLanguage]"}})],1)],1)],1)],1),_vm._v(" "),_c('Row',[_c('Form-item',{attrs:{"label":_vm.t('survey_creator.question.evaluation.selectedType'),"label-width":_vm.labelWidth}},[_c('Select',{staticStyle:{"width":"200px"},on:{"on-change":_vm.onChange},model:{value:(_vm.editQuestion.options.evaluationType),callback:function ($$v) {_vm.$set(_vm.editQuestion.options, "evaluationType", $$v);},expression:"editQuestion.options.evaluationType"}},_vm._l((_vm.evaluationTypes),function(item){return _c('Option',{key:item,attrs:{"value":item}},[_vm._v(_vm._s(_vm.t(("survey_creator.question.evaluation.type." + item)))+"\n ")])}),1)],1)],1),_vm._v(" "),_c(_vm.editQuestion.options.evaluationType,{tag:"component",attrs:{"question":_vm.question},model:{value:(_vm.editQuestion.evaluationItems),callback:function ($$v) {_vm.$set(_vm.editQuestion, "evaluationItems", $$v);},expression:"editQuestion.evaluationItems"}})],1)};
3623
3751
  var __vue_staticRenderFns__$8 = [];
3624
3752
 
3625
3753
  /* style */
3626
3754
  const __vue_inject_styles__$8 = function (inject) {
3627
3755
  if (!inject) return
3628
- inject("data-v-09a54a16_0", { source: "[data-v-09a54a16] .ivu-table-cell-slot .ivu-form-item{margin-bottom:4px;margin-top:0}[data-v-09a54a16] .ivu-table-cell-slot .ivu-form-item-error{margin-bottom:24px;margin-top:0}", map: undefined, media: undefined });
3756
+ inject("data-v-bed219c8_0", { source: "[data-v-bed219c8] .ivu-table-cell-slot .ivu-form-item{margin-bottom:4px;margin-top:0}[data-v-bed219c8] .ivu-table-cell-slot .ivu-form-item-error{margin-bottom:24px;margin-top:0}", map: undefined, media: undefined });
3629
3757
 
3630
3758
  };
3631
3759
  /* scoped */
3632
- const __vue_scope_id__$8 = "data-v-09a54a16";
3760
+ const __vue_scope_id__$8 = "data-v-bed219c8";
3633
3761
  /* module identifier */
3634
3762
  const __vue_module_identifier__$8 = undefined;
3635
3763
  /* functional template */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wg-npm/survey-creator",
3
- "version": "0.3.3778.develop",
3
+ "version": "0.3.4004",
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.3.3778.develop",
16
- "@wg-npm/survey-service-api": "0.3.3778.develop",
15
+ "@wg-npm/survey-core": "0.3.4004",
16
+ "@wg-npm/survey-service-api": "0.3.4004",
17
17
  "axios": "^0.19.2",
18
18
  "camelcase": "^6.0.0",
19
19
  "deepmerge": "^4.2.2",
@@ -38,8 +38,8 @@
38
38
  "@typescript-eslint/eslint-plugin": "^3.6.0",
39
39
  "@typescript-eslint/parser": "^3.6.0",
40
40
  "@vue/eslint-config-prettier": "^6.0.0",
41
- "@wg-npm/survey-core": "0.3.3778.develop",
42
- "@wg-npm/survey-service-api": "0.3.3778.develop",
41
+ "@wg-npm/survey-core": "0.3.4004",
42
+ "@wg-npm/survey-service-api": "0.3.4004",
43
43
  "acorn": "^7.3.1",
44
44
  "axios": "^0.19.2",
45
45
  "babelrc-rollup": "^3.0.0",
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <Row type="flex" justify="start" :gutter="6" align="middle">
3
3
  <Col class="label">
4
- {{t('survey_creator.question.evaluation.condition.type.SCORE') }}
4
+ {{t('survey_creator.question.evaluation.condition.question') }}
5
5
  </Col>
6
6
  <Col :span="5">
7
7
  <FormItem :prop="`evaluationItems[${itemIndex}].conditions[${index}].payload.scope`"
@@ -202,20 +202,16 @@ export default Vue.extend({
202
202
  buildPayloadByType(type) {
203
203
  if (type == ExprConditionType.SCORE) {
204
204
  return {
205
- payload: {
206
- minScore: 0,
207
- operator: "<",
208
- maxScore: 0,
209
- },
205
+ minScore: 0,
206
+ operator: "<",
207
+ maxScore: 0,
210
208
  };
211
209
  }
212
210
  return {
213
- payload: {
214
- scope: [],
215
- operator: "=",
216
- values: [],
217
- size: 0,
218
- },
211
+ scope: [],
212
+ operator: "=",
213
+ values: [],
214
+ size: 0,
219
215
  };
220
216
  },
221
217
  removeCondition(index) {
@@ -7,83 +7,96 @@
7
7
  </Col>
8
8
  <Col :span="3">
9
9
  <FormItem
10
- :prop="`evaluationItems[${itemIndex}].conditions[${index}].payload.minScore`"
11
- :rules="{
12
- required: true,
13
- type: 'number',
14
- trigger: 'change',
15
- min: 0,
16
- max: this.totalScore,
17
- message: t('分值不能为空'),
18
- }"
10
+ :prop="`evaluationItems[${itemIndex}].conditions[${index}].payload.minScore`"
11
+ :rules="{
12
+ min:leftMin,
13
+ max:leftMax,
14
+ required: true,
15
+ type: 'number',
16
+ trigger: 'change',
17
+ message: t('分值不正确'),
18
+ }"
19
19
  >
20
20
  <InputNumber
21
- v-model="value.minScore"
22
- :min="0"
23
- :max="value.maxScore"
24
- @on-change="rangeChange"
21
+ v-model="value.minScore"
22
+ :active-change="false"
23
+ :min="leftMin"
24
+ :max="leftMax"
25
+ :formatter="
26
+ (value) => `${value}${t('survey_creator.question.scores')}`
27
+ "
28
+ :parser="
29
+ (value) =>
30
+ value.replace(`${t('survey_creator.question.scores')}`, '')
31
+ "
32
+ @on-change="leftChange"
25
33
  ></InputNumber>
26
34
  </FormItem>
27
35
  </Col>
28
- <Col class="label">
29
- {{ t("survey_creator.question.scores") }}
30
- </Col>
31
36
  <Col :span="3">
32
37
  <FormItem
33
- :prop="`evaluationItems[${itemIndex}].conditions[${index}].payload.operator`"
34
- :rules="{
38
+ :prop="`evaluationItems[${itemIndex}].conditions[${index}].payload.operator`"
39
+ :rules="{
35
40
  required: true,
36
41
  trigger: 'change',
37
42
  message: t('survey_creator.question.notEmpty'),
38
43
  }"
39
44
  >
40
45
  <Select
41
- v-model="value.operator"
42
- :placeholder="
46
+ v-model="value.operator"
47
+ :placeholder="
43
48
  t('survey_creator.question.evaluation.condition.operator')
44
49
  "
45
50
  >
46
51
  <Option
47
- v-for="(operator, index) in operators"
48
- :value="operator"
49
- :key="index"
52
+ v-for="(operator, index) in operators"
53
+ :value="operator"
54
+ :key="index"
50
55
  >
51
56
  {{ operator }}
52
57
  </Option>
53
58
  </Select>
54
59
  </FormItem>
55
60
  </Col>
56
- <Col :span="3">
61
+ <Col :span="2">
57
62
  <FormItem
58
- :prop="`evaluationItems[${itemIndex}].conditions[${index}].payload.maxScore`"
59
- :rules="{
63
+ :prop="`evaluationItems[${itemIndex}].conditions[${index}].payload.maxScore`"
64
+ :rules="{
65
+ min:rightMin,
66
+ max:rightMax,
60
67
  required: true,
61
68
  type: 'number',
62
69
  trigger: 'change',
63
- min: 0,
64
- max: this.totalScore,
65
- message: t('分值不能为空'),
70
+ message: t('分值不正确'),
66
71
  }"
67
72
  >
68
73
  <InputNumber
69
- v-model="value.maxScore"
70
- :min="value.minScore"
71
- :max="totalScore"
72
- @on-change="rangeChange"
74
+ :active-change="false"
75
+ v-model="value.maxScore"
76
+ :min="rightMin"
77
+ :max="rightMax"
78
+ :formatter="
79
+ (value) => `${value}${t('survey_creator.question.scores')}`
80
+ "
81
+ :parser="
82
+ (value) =>
83
+ value.replace(`${t('survey_creator.question.scores')}`, '')
84
+ "
85
+ @on-change="rightChange"
73
86
  ></InputNumber>
74
87
  </FormItem>
75
88
  </Col>
76
- <Col class="label">
77
- {{ t("survey_creator.question.scores") }}
78
- </Col>
79
89
  </Row>
80
90
  </template>
81
91
  <script lang="ts">
82
92
  import Vue from "vue";
83
- import { Row, Col, Select, Option, FormItem, InputNumber } from "view-design";
93
+ import {Col, FormItem, InputNumber, Message, Option, Row, Select} from "view-design";
84
94
  import _ from "lodash";
85
95
  import ExprMixin from "./expr-mixin";
86
96
  import LocaleMixin from "../../../../../mixins/locale-mixin";
97
+ import {ExprConditionType} from "@wg-npm/survey-core/src/models";
98
+
99
+ Vue.prototype.$Message = Message;
87
100
 
88
101
  export default Vue.extend({
89
102
  name: "score",
@@ -94,37 +107,173 @@ export default Vue.extend({
94
107
  Select,
95
108
  Option,
96
109
  FormItem,
97
- InputNumber,
110
+ InputNumber
98
111
  },
99
112
  data() {
113
+ const validateScore = (rule, value, callback) => {
114
+ let checkfunc = function checkValueInRange(value) {
115
+ let otherRange = _.map(this.otherConditions, (item) => {
116
+ return {
117
+ min: _.get(item, "payload.minScore"),
118
+ max: _.get(item, "payload.maxScore"),
119
+ };
120
+ });
121
+ return _.some(otherRange, function (o) {
122
+ return value > o.min && value < o.max;
123
+ });
124
+ };
125
+ let rangeInValid = checkfunc(value);
126
+ if (value === "") {
127
+ callback(new Error("分值不能为空"));
128
+ } else {
129
+ if (rangeInValid) {
130
+ callback(new Error("分值在别的条件中已存在"));
131
+ }
132
+ callback();
133
+ }
134
+ };
100
135
  return {
101
- operators: ["<=", "<"],
136
+ leftMin: 0,
137
+ leftMax: 0,
138
+ rightMin: 0,
139
+ rightMax: 0,
140
+ operators: ["<=", "<"]
102
141
  };
103
142
  },
143
+ created() {
144
+ this.leftMax = this.totalScore - 1;
145
+ this.rightMax = this.totalScore;
146
+ },
104
147
  computed: {
105
148
  totalScore() {
106
149
  return this.$rootComponent.currentSurvey.statistics.maxScore;
107
150
  },
151
+ otherConditions() {
152
+ let otherEvaluationItems = _.filter(
153
+ _.map(this.evaluationItems, (item, index) => {
154
+ return _.extend({}, item, {index: index});
155
+ }),
156
+ (item) => item.index != this.itemIndex
157
+ );
158
+ return _.filter(
159
+ _.flatMap(otherEvaluationItems, "conditions"),
160
+ (item) => item.type == ExprConditionType.SCORE
161
+ );
162
+ },
163
+ otherMin() {
164
+ _.min(
165
+ _.map(this.otherConditions, (item) => _.get(item, "payload.minScore", 0))
166
+ );
167
+ },
168
+ otherMax() {
169
+ _.max(
170
+ _.map(this.otherConditions, (item) => _.get(item, "payload.maxScore", 0))
171
+ );
172
+ },
108
173
  },
109
174
  methods: {
175
+ checkValueInOtherRange(value, conditions) {
176
+ let otherRange = _.map(conditions, (item) => {
177
+ return {
178
+ min: _.get(item, "payload.minScore"),
179
+ max: _.get(item, "payload.maxScore"),
180
+ };
181
+ });
182
+ return _.some(otherRange, function (o) {
183
+ return value >= o.min && value <= o.max;
184
+ });
185
+ },
110
186
  generateExpr() {
111
- // let ids = `${_.map(this.value.scope, (e) => {
112
- // return `"` + e + `"`;
113
- // })}`;
114
- // let answers = `${_.map(this.value.values, (e) => {
115
- // return `"` + e + `"`;
116
- // })}`;
117
- // return `$count($[id in [${ids}]][answer in [${answers}]]) = ${_.size(
118
- // this.value.scope
119
- // )}`;
120
187
  let minScore = this.value.minScore;
121
188
  let maxScore = this.value.maxScore;
122
- return `$totalScore ${minScore} ${this.value.operator} ${maxScore}`;
189
+ return `${minScore} ${this.value.operator} score and score ${this.value.operator} ${maxScore}`;
123
190
  },
124
- rangeChange() {
125
- console.log("222");
191
+ leftChange(value) {
192
+ this.rangeChange(value, "left");
126
193
  },
127
- },
194
+ rightChange(value) {
195
+ this.rangeChange(value, "right");
196
+ },
197
+ rangeChange(value, type) {
198
+ let valueInOtherRange = this.checkValueInOtherRange(value, this.otherConditions);
199
+ let usableRanges = this.getUsableRanges();
200
+ let firstUsableRange = usableRanges[0];
201
+ let valueInRange = this.getSelectedRangeByValue(value, usableRanges);
202
+ let currentRange = valueInOtherRange ? firstUsableRange : valueInRange;
203
+ let min = valueInOtherRange ? firstUsableRange[0] : _.get(valueInRange, 'min', 0);
204
+ let max = valueInOtherRange ? firstUsableRange[1] : _.get(currentRange, 'max', this.totalScore);
205
+ if (valueInOtherRange) {
206
+ this.$Message.error("该值在其他区间范围内,请重新输入");
207
+ this.$set(this.value, "minScore", min);
208
+ this.$set(this.value, "maxScore", max);
209
+ this.rightMin = min;
210
+ this.rightMax = max;
211
+ this.leftMin = min;
212
+ this.leftMax = max;
213
+ } else {
214
+ if (type == "left") {
215
+ this.rightMin = value + 1;
216
+ this.rightMax = max;
217
+ }
218
+ if (type == "right") {
219
+ this.leftMin = min;
220
+ this.leftMax = value - 1;
221
+ }
222
+ }
223
+ },
224
+ getSelectedRangeByValue(value, ranges) {
225
+ let otherRange = _.map(ranges, (item) => {
226
+ return {
227
+ min: _.get(item, "payload.minScore"),
228
+ max: _.get(item, "payload.maxScore"),
229
+ };
230
+ });
231
+ return _.head(_.filter(otherRange, function (o) {
232
+ return value > o.min && value < o.max;
233
+ }));
234
+ },
235
+ getUsableRanges() {
236
+ let usedRange = _.map(this.otherConditions, (item) => {
237
+ return [item.payload.minScore, item.payload.maxScore];
238
+ });
239
+ let globalMin = 0;
240
+ let globalMax = this.totalScore;
241
+ // arr must sorted asc
242
+ let usableRange = new Array();
243
+ if (usedRange.length == 1) {
244
+ let first = usedRange[0][0] -1
245
+ if (usedRange[0][0] !== 0) {
246
+ let item = [0, first]
247
+ usableRange.push(item)
248
+ }
249
+ } else {
250
+ let other = usedRange.reduce((a, v) => {
251
+ if (typeof a[0] == "number") {
252
+ if (a[0] != globalMin) {
253
+ return [
254
+ [0, a[0]],
255
+ [a[1], v[0]],
256
+ [v[1], v[1]],
257
+ ];
258
+ } else {
259
+ return [
260
+ [a[1], v[0]],
261
+ [v[1], v[1]],
262
+ ];
263
+ }
264
+ } else {
265
+ a[a.length - 1][1] = v[0];
266
+ if (a.length != usedRange.length) a.push([v[1], v[1]]);
267
+ }
268
+ return a;
269
+ });
270
+ if (usedRange[length - 1][1] != globalMax) {
271
+ other.push([usedRange[length - 1][1], globalMax]);
272
+ }
273
+ }
274
+ return usableRange;
275
+ },
276
+ }
128
277
  });
129
278
  </script>
130
279
  <style scoped lang="less">
@@ -132,4 +281,4 @@ export default Vue.extend({
132
281
  text-align: right;
133
282
  margin-bottom: 24px;
134
283
  }
135
- </style>
284
+ </style>
@@ -1,103 +1,135 @@
1
1
  <template>
2
- <Form ref="questionForm" :model="editQuestion" :label-colon="false">
2
+ <Form ref="questionForm" :model="editQuestion" :label-colon="false">
3
+ <Row>
4
+ <Form-item
5
+ :prop="'header.text.' + primaryLanguage"
6
+ :rules="{
7
+ required: true,
8
+ message: t('survey_creator.question.titleRequiredTip'),
9
+ }"
10
+ :label="t('survey_creator.page.question')"
11
+ >
12
+ <Checkbox v-model="editQuestion.options.required"
13
+ >{{ t("survey_creator.question.questionRequired") }}
14
+ </Checkbox>
3
15
  <Row>
4
- <Form-item
5
- :prop="'header.text.' + primaryLanguage"
6
- :rules="{required: true, message: t('survey_creator.question.titleRequiredTip')}"
7
- :label="t('survey_creator.page.question')"
8
- >
9
- <Checkbox
10
- v-model="editQuestion.options.required"
11
- >{{t('survey_creator.question.questionRequired')}}
12
- </Checkbox>
13
- <Row>
14
- <Col :span="23" :offset="-1">
15
- <Input
16
- v-model.trim="editQuestion.header.text[primaryLanguage]"
17
- :placeholder="t('survey_creator.question.titleRequiredTip')"
18
- />
19
- </Col>
20
- </Row>
21
- </Form-item>
16
+ <Col :span="23" :offset="-1">
17
+ <Input
18
+ v-model.trim="editQuestion.header.text[primaryLanguage]"
19
+ :placeholder="t('survey_creator.question.titleRequiredTip')"
20
+ />
21
+ </Col>
22
22
  </Row>
23
- <Row>
24
- <Form-item :label="t('survey_creator.question.evaluation.selectedType')" :label-width="labelWidth">
25
- <Select v-model="editQuestion.options.evaluationType" style="width:200px" @on-change="onChange">
26
- <Option v-for="item in evaluationTypes" :value="item" :key="item">{{
27
- t(`survey_creator.question.evaluation.type.${item}`)
28
- }}
29
- </Option>
30
- </Select>
31
- </Form-item>
32
- </Row>
33
- <component
34
- :is="editQuestion.options.evaluationType"
35
- v-model="editQuestion.evaluationItems"
36
- :question="question"
37
- ></component>
38
- </Form>
23
+ </Form-item>
24
+ </Row>
25
+ <Row>
26
+ <Form-item
27
+ :label="t('survey_creator.question.evaluation.selectedType')"
28
+ :label-width="labelWidth"
29
+ >
30
+ <Select
31
+ v-model="editQuestion.options.evaluationType"
32
+ style="width: 200px"
33
+ @on-change="onChange"
34
+ >
35
+ <Option v-for="item in evaluationTypes" :value="item" :key="item"
36
+ >{{ t(`survey_creator.question.evaluation.type.${item}`) }}
37
+ </Option>
38
+ </Select>
39
+ </Form-item>
40
+ </Row>
41
+ <component
42
+ :is="editQuestion.options.evaluationType"
43
+ v-model="editQuestion.evaluationItems"
44
+ :question="question"
45
+ ></component>
46
+ </Form>
39
47
  </template>
40
48
  <script lang="ts">
41
- import Vue from "vue";
42
- import _ from "lodash";
43
- import {
44
- Col, Form, FormItem,
45
- Row, Select, Checkbox,
46
- Option, Input
47
- } from "view-design";
48
- import {SurveyLayout, EvaluationType,} from "@wg-npm/survey-core";
49
- import draggable from "vuedraggable";
50
- import questionFormMixin from "../../../mixins/question-form-mixin";
51
- import Star from "./evaluation/star.vue";
52
- import Expr from "./evaluation/expr.vue";
53
- import {ExprEvaluationItemType} from "@wg-npm/survey-core/src/models";
49
+ import Vue from "vue";
50
+ import _ from "lodash";
51
+ import {
52
+ Col,
53
+ Form,
54
+ FormItem,
55
+ Row,
56
+ Select,
57
+ Checkbox,
58
+ Option,
59
+ Input,
60
+ } from "view-design";
61
+ import {SurveyLayout, EvaluationType} from "@wg-npm/survey-core";
62
+ import draggable from "vuedraggable";
63
+ import questionFormMixin from "../../../mixins/question-form-mixin";
64
+ import Star from "./evaluation/star.vue";
65
+ import Expr from "./evaluation/expr.vue";
66
+ import {ExprEvaluationItemType} from "@wg-npm/survey-core/src/models";
54
67
 
55
- export default Vue.extend({
56
- name: "evaluation-form",
57
- components: {
58
- Form, FormItem, Row,
59
- Col, draggable, Option,
60
- Select, Checkbox, Input,
61
- [EvaluationType.STAR]: Star,
62
- [EvaluationType.EXPR]: Expr
63
- },
64
- mixins: [questionFormMixin],
65
- data() {
66
- return {
67
- labelWidth: 80,
68
- layoutOptions: [SurveyLayout.HORIZONTAL, SurveyLayout.VERTICAL],
69
- evaluationTypes: [EvaluationType.STAR, EvaluationType.EXPR],
70
- realColumns: []
71
- };
72
- },
73
- created() {
74
- this.initData();
75
- },
76
- methods: {
77
- initData() {
78
- this.editQuestion.evaluationItems || this.$set(this.editQuestion, "evaluationItems", []);
79
- this.editQuestion.options.evaluationType || this.$set(this.editQuestion.options, "evaluationType", EvaluationType.STAR);
80
- },
81
- onChange(value) {
82
- if (value == EvaluationType.EXPR) {
83
- _.forEach(this.editQuestion.evaluationItems, item => _.set(item, "type", ExprEvaluationItemType.IF));
84
- _.set(this.editQuestion.evaluationItems[_.size(this.editQuestion.evaluationItems) - 1], "type", ExprEvaluationItemType.ELSE);
85
- }
86
- }
87
- }
88
- })
89
- ;
68
+ export default Vue.extend({
69
+ name: "evaluation-form",
70
+ components: {
71
+ Form,
72
+ FormItem,
73
+ Row,
74
+ Col,
75
+ draggable,
76
+ Option,
77
+ Select,
78
+ Checkbox,
79
+ Input,
80
+ [EvaluationType.STAR]: Star,
81
+ [EvaluationType.EXPR]: Expr,
82
+ },
83
+ mixins: [questionFormMixin],
84
+ data() {
85
+ return {
86
+ labelWidth: 80,
87
+ layoutOptions: [SurveyLayout.HORIZONTAL, SurveyLayout.VERTICAL],
88
+ evaluationTypes: [EvaluationType.STAR, EvaluationType.EXPR],
89
+ realColumns: [],
90
+ };
91
+ },
92
+ created() {
93
+ this.initData();
94
+ },
95
+ methods: {
96
+ initData() {
97
+ this.editQuestion.evaluationItems ||
98
+ this.$set(this.editQuestion, "evaluationItems", []);
99
+ this.editQuestion.options.evaluationType ||
100
+ this.$set(
101
+ this.editQuestion.options,
102
+ "evaluationType",
103
+ EvaluationType.STAR
104
+ );
105
+ },
106
+ onChange(value) {
107
+ if (value == EvaluationType.EXPR) {
108
+ _.forEach(this.editQuestion.evaluationItems, (item, index) => {
109
+ _.set(item, "type", ExprEvaluationItemType.IF);
110
+ _.set(item, "index", index);
111
+ });
112
+ _.set(
113
+ this.editQuestion.evaluationItems[
114
+ _.size(this.editQuestion.evaluationItems) - 1
115
+ ],
116
+ "type",
117
+ ExprEvaluationItemType.ELSE
118
+ );
119
+ }
120
+ },
121
+ },
122
+ });
90
123
  </script>
91
124
 
92
125
  <style scoped lang="less">
93
- /deep/ .ivu-table-cell-slot .ivu-form-item {
94
- margin-bottom: 4px;
95
- margin-top: 0;
96
- }
97
-
98
- /deep/ .ivu-table-cell-slot .ivu-form-item-error {
99
- margin-bottom: 24px;
100
- margin-top: 0;
126
+ /deep/ .ivu-table-cell-slot .ivu-form-item {
127
+ margin-bottom: 4px;
128
+ margin-top: 0;
129
+ }
101
130
 
102
- }
131
+ /deep/ .ivu-table-cell-slot .ivu-form-item-error {
132
+ margin-bottom: 24px;
133
+ margin-top: 0;
134
+ }
103
135
  </style>
package/src/index.ts CHANGED
@@ -2,7 +2,6 @@ import {VueConstructor as _Vue} from 'vue';
2
2
  import SurveyCreator from './components/survey-creator.vue';
3
3
  import SurveyPreviewer from './components/survey-previewer.vue';
4
4
  import locale from './locale';
5
-
6
5
  export class SurveyCreatorOptions {
7
6
  locale: any;
8
7
  i18n: any;
@@ -144,7 +144,7 @@ export default {
144
144
  other: "其他",
145
145
  assign_template: `{0} 项为 {1} {2} {3}项`,
146
146
  auto_template: `{0} 项为 {1}`,
147
- score_template: `总分数范围为: {0}分{1}, {2}分`,
147
+ score_template: `总分数范围为: {0}分{1}{2}分`,
148
148
  },
149
149
  },
150
150
  },