@wg-npm/survey-creator 0.3.3810 → 0.3.4062

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
 
@@ -64,6 +64,8 @@ var defaultLang = {
64
64
  sub_questions: "子题",
65
65
  score: "分值",
66
66
  scores: "分",
67
+ totalScores: "总分",
68
+ selectScore: "请选择分值",
67
69
  questionRequired: "此题必填",
68
70
  titleRequiredTip: "请填写题目名称",
69
71
  textTitleRequiredTip: "请填写文字说明",
@@ -150,7 +152,7 @@ var defaultLang = {
150
152
  other: "其他",
151
153
  assign_template: `{0} 项为 {1} {2} {3}项`,
152
154
  auto_template: `{0} 项为 {1}`,
153
- score_template: `总分数范围为: {0}{1}{2}分`,
155
+ score_template: `总分数范围为: {0}{1} 总分 {2}{3}`,
154
156
  },
155
157
  },
156
158
  },
@@ -1800,7 +1802,12 @@ var script$t = Vue.extend({
1800
1802
  getDesc(condition) {
1801
1803
  let payload = condition.payload;
1802
1804
  if (condition.type == "SCORE") {
1803
- return this.t("survey_creator.question.evaluation.condition.score_template", [payload.minScore, payload.operator, payload.maxScore]);
1805
+ return this.t("survey_creator.question.evaluation.condition.score_template", [
1806
+ payload.minScore,
1807
+ payload.leftOperator,
1808
+ payload.rightOperator,
1809
+ payload.maxScore,
1810
+ ]);
1804
1811
  }
1805
1812
  else {
1806
1813
  let numbers = new ExprEvaluationQuestion(this.questions, payload.scope).calculateNumbers();
@@ -3102,17 +3109,17 @@ var script$e = Vue.extend({
3102
3109
  const __vue_script__$e = script$e;
3103
3110
 
3104
3111
  /* 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)};
3112
+ 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
3113
  var __vue_staticRenderFns__$e = [];
3107
3114
 
3108
3115
  /* style */
3109
3116
  const __vue_inject_styles__$e = function (inject) {
3110
3117
  if (!inject) return
3111
- inject("data-v-1b7846c4_0", { source: ".label[data-v-1b7846c4]{text-align:right;margin-bottom:24px}", map: undefined, media: undefined });
3118
+ inject("data-v-647dceac_0", { source: ".label[data-v-647dceac]{text-align:right;margin-bottom:24px}", map: undefined, media: undefined });
3112
3119
 
3113
3120
  };
3114
3121
  /* scoped */
3115
- const __vue_scope_id__$e = "data-v-1b7846c4";
3122
+ const __vue_scope_id__$e = "data-v-647dceac";
3116
3123
  /* module identifier */
3117
3124
  const __vue_module_identifier__$e = undefined;
3118
3125
  /* functional template */
@@ -3138,6 +3145,7 @@ var __vue_staticRenderFns__$e = [];
3138
3145
 
3139
3146
  var Auto = __vue_component__$e;
3140
3147
 
3148
+ Vue.prototype.$Message = Message;
3141
3149
  var script$d = Vue.extend({
3142
3150
  name: "score",
3143
3151
  mixins: [ExprMixin, LocaleMixin],
@@ -3154,19 +3162,110 @@ var script$d = Vue.extend({
3154
3162
  operators: ["<=", "<"],
3155
3163
  };
3156
3164
  },
3165
+ created() { },
3157
3166
  computed: {
3158
3167
  totalScore() {
3159
3168
  return this.$rootComponent.currentSurvey.statistics.maxScore;
3160
3169
  },
3170
+ scores() {
3171
+ return _.range(1, this.totalScore + 1, 1);
3172
+ },
3173
+ otherConditions() {
3174
+ let otherEvaluationItems = _.filter(_.map(this.evaluationItems, (item, index) => {
3175
+ return _.extend({}, item, { index: index });
3176
+ }), (item) => item.index != this.itemIndex);
3177
+ return _.filter(_.flatMap(otherEvaluationItems, "conditions"), (item) => item.type == "SCORE");
3178
+ },
3161
3179
  },
3162
3180
  methods: {
3181
+ getSelectedRangeByValue(value, ranges) {
3182
+ let otherRange = _.map(ranges, (item) => {
3183
+ return {
3184
+ min: _.get(item, "payload.minScore"),
3185
+ max: _.get(item, "payload.maxScore"),
3186
+ };
3187
+ });
3188
+ return _.head(_.filter(otherRange, function (o) {
3189
+ return value > o.min && value < o.max;
3190
+ }));
3191
+ },
3192
+ getUsableRanges() {
3193
+ let usedRange = _.map(this.otherConditions, (item) => {
3194
+ return [item.payload.minScore, item.payload.maxScore];
3195
+ });
3196
+ let globalMin = 0;
3197
+ let globalMax = this.totalScore;
3198
+ let usableRange = new Array();
3199
+ if (usedRange.length == 1) {
3200
+ let first = usedRange[0][0] - 1;
3201
+ if (usedRange[0][0] !== 0) {
3202
+ let item = [0, first];
3203
+ usableRange.push(item);
3204
+ }
3205
+ if (usedRange[length - 1][1] != globalMax) {
3206
+ usableRange.push([usedRange[length - 1][1], globalMax]);
3207
+ }
3208
+ return usableRange;
3209
+ }
3210
+ else {
3211
+ let other = usedRange.reduce((a, v) => {
3212
+ if (typeof a[0] == "number") {
3213
+ if (a[0] != globalMin) {
3214
+ return [
3215
+ [0, a[0]],
3216
+ [a[1], v[0]],
3217
+ [v[1], v[1]],
3218
+ ];
3219
+ }
3220
+ else {
3221
+ return [
3222
+ [a[1], v[0]],
3223
+ [v[1], v[1]],
3224
+ ];
3225
+ }
3226
+ }
3227
+ else {
3228
+ a[a.length - 1][1] = v[0];
3229
+ if (a.length != usedRange.length)
3230
+ a.push([v[1], v[1]]);
3231
+ }
3232
+ return a;
3233
+ });
3234
+ if (usedRange[length - 1][1] != globalMax) {
3235
+ other.push([usedRange[length - 1][1], globalMax]);
3236
+ }
3237
+ return other;
3238
+ }
3239
+ },
3240
+ disabledScoreOption(value, type) {
3241
+ if (this.checkValueInOtherRange(value)) {
3242
+ return true;
3243
+ }
3244
+ let currentMin = _.get(this.value, "minScore", 0);
3245
+ let currentMax = _.get(this.value, "maxScore", this.totalScore);
3246
+ _.get(this.value, "maxScore", this.totalScore);
3247
+ if (type == "left" && value >= currentMax) {
3248
+ return true;
3249
+ }
3250
+ if (type == "right" && value <= currentMin) {
3251
+ return true;
3252
+ }
3253
+ },
3254
+ checkValueInOtherRange(value) {
3255
+ let otherRange = _.map(this.otherConditions, (item) => {
3256
+ return {
3257
+ min: _.get(item, "payload.minScore", 0),
3258
+ max: _.get(item, "payload.maxScore", 0),
3259
+ };
3260
+ });
3261
+ return _.some(otherRange, function (o) {
3262
+ return value >= o.min && value <= o.max;
3263
+ });
3264
+ },
3163
3265
  generateExpr() {
3164
3266
  let minScore = this.value.minScore;
3165
3267
  let maxScore = this.value.maxScore;
3166
- return `${minScore} ${this.value.operator} $score ${this.value.operator} ${maxScore}`;
3167
- },
3168
- rangeChange() {
3169
- console.log("222");
3268
+ return `${minScore} ${this.value.leftOperator} score and score ${this.value.rightOperator} ${maxScore}`;
3170
3269
  },
3171
3270
  },
3172
3271
  });
@@ -3179,31 +3278,31 @@ var __vue_render__$d = function () {var _vm=this;var _h=_vm.$createElement;var _
3179
3278
  required: true,
3180
3279
  type: 'number',
3181
3280
  trigger: 'change',
3182
- min: 0,
3183
- max: this.totalScore,
3184
- message: _vm.t('分值不能为空'),
3185
- }}},[_c('InputNumber',{attrs:{"min":0,"max":_vm.value.maxScore,"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.rangeChange},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":{
3281
+ message: _vm.t('survey_creator.question.scoreRequiredTip'),
3282
+ }}},[_c('Select',{attrs:{"placeholder":_vm.t('survey_creator.question.selectScore')},model:{value:(_vm.value.minScore),callback:function ($$v) {_vm.$set(_vm.value, "minScore", $$v);},expression:"value.minScore"}},_vm._l((_vm.scores),function(score){return _c('Option',{key:score,attrs:{"value":score,"disabled":_vm.disabledScoreOption(score, 'left')}},[_vm._v("\n "+_vm._s(score)+"\n ")])}),1)],1)],1),_vm._v(" "),_c('Col',{staticClass:"label",attrs:{"span":1}},[_vm._v("\n "+_vm._s(_vm.t("survey_creator.question.scores"))+"\n ")]),_vm._v(" "),_c('Col',{attrs:{"span":2}},[_c('FormItem',{attrs:{"prop":("evaluationItems[" + _vm.itemIndex + "].conditions[" + _vm.index + "].payload.leftOperator"),"rules":{
3186
3283
  required: true,
3187
3284
  trigger: 'change',
3188
3285
  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":2}},[_c('FormItem',{attrs:{"prop":("evaluationItems[" + _vm.itemIndex + "].conditions[" + _vm.index + "].payload.maxScore"),"rules":{
3286
+ }}},[_c('Select',{attrs:{"placeholder":_vm.t('survey_creator.question.evaluation.condition.operator')},model:{value:(_vm.value.leftOperator),callback:function ($$v) {_vm.$set(_vm.value, "leftOperator", $$v);},expression:"value.leftOperator"}},_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',{staticClass:"label"},[_vm._v("\n "+_vm._s(_vm.t("survey_creator.question.totalScores"))+"\n ")]),_vm._v(" "),_c('Col',{attrs:{"span":2}},[_c('FormItem',{attrs:{"prop":("evaluationItems[" + _vm.itemIndex + "].conditions[" + _vm.index + "].payload.rightOperator"),"rules":{
3287
+ required: true,
3288
+ trigger: 'change',
3289
+ message: _vm.t('survey_creator.question.notEmpty'),
3290
+ }}},[_c('Select',{attrs:{"placeholder":_vm.t('survey_creator.question.evaluation.condition.operator')},model:{value:(_vm.value.rightOperator),callback:function ($$v) {_vm.$set(_vm.value, "rightOperator", $$v);},expression:"value.rightOperator"}},_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":{
3190
3291
  required: true,
3191
3292
  type: 'number',
3192
3293
  trigger: 'change',
3193
- min: 0,
3194
- max: this.totalScore,
3195
- message: _vm.t('分值不能为空'),
3196
- }}},[_c('InputNumber',{attrs:{"min":_vm.value.minScore,"max":_vm.totalScore,"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.rangeChange},model:{value:(_vm.value.maxScore),callback:function ($$v) {_vm.$set(_vm.value, "maxScore", $$v);},expression:"value.maxScore"}})],1)],1)],1)};
3294
+ message: _vm.t('survey_creator.question.scoreRequiredTip'),
3295
+ }}},[_c('Select',{attrs:{"placeholder":_vm.t('survey_creator.question.selectScore')},model:{value:(_vm.value.maxScore),callback:function ($$v) {_vm.$set(_vm.value, "maxScore", $$v);},expression:"value.maxScore"}},_vm._l((_vm.scores),function(score){return _c('Option',{key:score,attrs:{"value":score,"disabled":_vm.disabledScoreOption(score, 'right')}},[_vm._v("\n "+_vm._s(score)+"\n ")])}),1)],1)],1),_vm._v(" "),_c('Col',{staticClass:"label",attrs:{"span":1}},[_vm._v("\n "+_vm._s(_vm.t("survey_creator.question.scores"))+"\n ")])],1)};
3197
3296
  var __vue_staticRenderFns__$d = [];
3198
3297
 
3199
3298
  /* style */
3200
3299
  const __vue_inject_styles__$d = function (inject) {
3201
3300
  if (!inject) return
3202
- inject("data-v-632eb362_0", { source: ".label[data-v-632eb362]{text-align:right;margin-bottom:24px}", map: undefined, media: undefined });
3301
+ inject("data-v-0d3d3556_0", { source: ".label[data-v-0d3d3556]{text-align:right;margin-bottom:24px}", map: undefined, media: undefined });
3203
3302
 
3204
3303
  };
3205
3304
  /* scoped */
3206
- const __vue_scope_id__$d = "data-v-632eb362";
3305
+ const __vue_scope_id__$d = "data-v-0d3d3556";
3207
3306
  /* module identifier */
3208
3307
  const __vue_module_identifier__$d = undefined;
3209
3308
  /* functional template */
@@ -3351,6 +3450,9 @@ var script$b = Vue.extend({
3351
3450
  };
3352
3451
  },
3353
3452
  computed: {
3453
+ totalScore() {
3454
+ return this.$rootComponent.currentSurvey.statistics.maxScore;
3455
+ },
3354
3456
  deletable() {
3355
3457
  return (_.size(_.filter(this.evaluationItems, (item) => item.type == "IF")) > 1);
3356
3458
  },
@@ -3385,20 +3487,17 @@ var script$b = Vue.extend({
3385
3487
  buildPayloadByType(type) {
3386
3488
  if (type == "SCORE") {
3387
3489
  return {
3388
- payload: {
3389
- minScore: 0,
3390
- operator: "<",
3391
- maxScore: 0,
3392
- },
3490
+ minScore: null,
3491
+ leftOperator: "<",
3492
+ rightOperator: "<",
3493
+ maxScore: null,
3393
3494
  };
3394
3495
  }
3395
3496
  return {
3396
- payload: {
3397
- scope: [],
3398
- operator: "=",
3399
- values: [],
3400
- size: 0,
3401
- },
3497
+ scope: [],
3498
+ operator: "=",
3499
+ values: [],
3500
+ size: 0,
3402
3501
  };
3403
3502
  },
3404
3503
  removeCondition(index) {
@@ -3425,11 +3524,11 @@ var __vue_staticRenderFns__$b = [];
3425
3524
  /* style */
3426
3525
  const __vue_inject_styles__$b = function (inject) {
3427
3526
  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 });
3527
+ inject("data-v-bb232856_0", { source: ".mt-base[data-v-bb232856]{margin-top:12px}.action[data-v-bb232856]{float:right}.input[data-v-bb232856]{width:100px}.label[data-v-bb232856]{text-align:right;padding-right:4px}.text[data-v-bb232856]{background-color:#ebf7ff;height:32px;padding:8px 18px;font-weight:500;color:#515a6e}[data-v-bb232856] .ivu-card .ivu-form-item{margin-bottom:4px;margin-top:0}[data-v-bb232856] .ivu-card .ivu-form-item-error{margin-bottom:24px;margin-top:0}", map: undefined, media: undefined });
3429
3528
 
3430
3529
  };
3431
3530
  /* scoped */
3432
- const __vue_scope_id__$b = "data-v-25df9b0d";
3531
+ const __vue_scope_id__$b = "data-v-bb232856";
3433
3532
  /* module identifier */
3434
3533
  const __vue_module_identifier__$b = undefined;
3435
3534
  /* functional template */
@@ -3583,11 +3682,17 @@ var __vue_staticRenderFns__$9 = [];
3583
3682
  var script$8 = Vue.extend({
3584
3683
  name: "evaluation-form",
3585
3684
  components: {
3586
- Form, FormItem, Row,
3587
- Col, draggable, Option,
3588
- Select, Checkbox, Input,
3685
+ Form,
3686
+ FormItem,
3687
+ Row,
3688
+ Col,
3689
+ draggable,
3690
+ Option,
3691
+ Select,
3692
+ Checkbox,
3693
+ Input,
3589
3694
  ["STAR"]: Star,
3590
- ["EXPR"]: Expr
3695
+ ["EXPR"]: Expr,
3591
3696
  },
3592
3697
  mixins: [questionFormMixin],
3593
3698
  data() {
@@ -3595,7 +3700,7 @@ var script$8 = Vue.extend({
3595
3700
  labelWidth: 80,
3596
3701
  layoutOptions: ["HORIZONTAL", "VERTICAL"],
3597
3702
  evaluationTypes: ["STAR", "EXPR"],
3598
- realColumns: []
3703
+ realColumns: [],
3599
3704
  };
3600
3705
  },
3601
3706
  created() {
@@ -3603,33 +3708,41 @@ var script$8 = Vue.extend({
3603
3708
  },
3604
3709
  methods: {
3605
3710
  initData() {
3606
- this.editQuestion.evaluationItems || this.$set(this.editQuestion, "evaluationItems", []);
3607
- this.editQuestion.options.evaluationType || this.$set(this.editQuestion.options, "evaluationType", "STAR");
3711
+ this.editQuestion.evaluationItems ||
3712
+ this.$set(this.editQuestion, "evaluationItems", []);
3713
+ this.editQuestion.options.evaluationType ||
3714
+ this.$set(this.editQuestion.options, "evaluationType", "STAR");
3608
3715
  },
3609
3716
  onChange(value) {
3610
3717
  if (value == "EXPR") {
3611
- _.forEach(this.editQuestion.evaluationItems, item => _.set(item, "type", "IF"));
3718
+ _.forEach(this.editQuestion.evaluationItems, (item, index) => {
3719
+ _.set(item, "type", "IF");
3720
+ _.set(item, "index", index);
3721
+ });
3612
3722
  _.set(this.editQuestion.evaluationItems[_.size(this.editQuestion.evaluationItems) - 1], "type", "ELSE");
3613
3723
  }
3614
- }
3615
- }
3724
+ },
3725
+ },
3616
3726
  });
3617
3727
 
3618
3728
  /* script */
3619
3729
  const __vue_script__$8 = script$8;
3620
3730
 
3621
3731
  /* 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)};
3732
+ 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":{
3733
+ required: true,
3734
+ message: _vm.t('survey_creator.question.titleRequiredTip'),
3735
+ },"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
3736
  var __vue_staticRenderFns__$8 = [];
3624
3737
 
3625
3738
  /* style */
3626
3739
  const __vue_inject_styles__$8 = function (inject) {
3627
3740
  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 });
3741
+ 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
3742
 
3630
3743
  };
3631
3744
  /* scoped */
3632
- const __vue_scope_id__$8 = "data-v-09a54a16";
3745
+ const __vue_scope_id__$8 = "data-v-bed219c8";
3633
3746
  /* module identifier */
3634
3747
  const __vue_module_identifier__$8 = undefined;
3635
3748
  /* functional template */
@@ -4492,6 +4605,7 @@ class SurveyCreatorPlugin {
4492
4605
  Vue.$surveyLanguage = options.locale;
4493
4606
  Vue.component('survey-creator', SurveyCreator);
4494
4607
  Vue.component('survey-previewer', SurveyPreviewer);
4608
+ Vue.component("question-edit-drawer", QuestionEditDrawer);
4495
4609
  }
4496
4610
  }
4497
4611
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wg-npm/survey-creator",
3
- "version": "0.3.3810",
3
+ "version": "0.3.4062",
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.3810",
16
- "@wg-npm/survey-service-api": "0.3.3810",
15
+ "@wg-npm/survey-core": "0.3.4062",
16
+ "@wg-npm/survey-service-api": "0.3.4062",
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.3810",
42
- "@wg-npm/survey-service-api": "0.3.3810",
41
+ "@wg-npm/survey-core": "0.3.4062",
42
+ "@wg-npm/survey-service-api": "0.3.4062",
43
43
  "acorn": "^7.3.1",
44
44
  "axios": "^0.19.2",
45
45
  "babelrc-rollup": "^3.0.0",
@@ -45,7 +45,12 @@ export default Vue.extend({
45
45
  if (condition.type == ExprConditionType.SCORE) {
46
46
  return this.t(
47
47
  "survey_creator.question.evaluation.condition.score_template",
48
- [payload.minScore, payload.operator, payload.maxScore]
48
+ [
49
+ payload.minScore,
50
+ payload.leftOperator,
51
+ payload.rightOperator,
52
+ payload.maxScore,
53
+ ]
49
54
  );
50
55
  } else {
51
56
  let numbers = new ExprEvaluationQuestion(
@@ -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`"
@@ -157,6 +157,9 @@ export default Vue.extend({
157
157
  };
158
158
  },
159
159
  computed: {
160
+ totalScore() {
161
+ return this.$rootComponent.currentSurvey.statistics.maxScore;
162
+ },
160
163
  deletable() {
161
164
  return (
162
165
  _.size(
@@ -202,20 +205,17 @@ export default Vue.extend({
202
205
  buildPayloadByType(type) {
203
206
  if (type == ExprConditionType.SCORE) {
204
207
  return {
205
- payload: {
206
- minScore: 0,
207
- operator: "<",
208
- maxScore: 0,
209
- },
208
+ minScore: null,
209
+ leftOperator: "<",
210
+ rightOperator: "<",
211
+ maxScore: null,
210
212
  };
211
213
  }
212
214
  return {
213
- payload: {
214
- scope: [],
215
- operator: "=",
216
- values: [],
217
- size: 0,
218
- },
215
+ scope: [],
216
+ operator: "=",
217
+ values: [],
218
+ size: 0,
219
219
  };
220
220
  },
221
221
  removeCondition(index) {
@@ -12,29 +12,30 @@
12
12
  required: true,
13
13
  type: 'number',
14
14
  trigger: 'change',
15
- min: 0,
16
- max: this.totalScore,
17
- message: t('分值不能为空'),
15
+ message: t('survey_creator.question.scoreRequiredTip'),
18
16
  }"
19
17
  >
20
- <InputNumber
18
+ <Select
21
19
  v-model="value.minScore"
22
- :min="0"
23
- :max="value.maxScore"
24
- :formatter="
25
- (value) => `${value}${t('survey_creator.question.scores')}`
26
- "
27
- :parser="
28
- (value) =>
29
- value.replace(`${t('survey_creator.question.scores')}`, '')
30
- "
31
- @on-change="rangeChange"
32
- ></InputNumber>
20
+ :placeholder="t('survey_creator.question.selectScore')"
21
+ >
22
+ <Option
23
+ v-for="score in scores"
24
+ :value="score"
25
+ :key="score"
26
+ :disabled="disabledScoreOption(score, 'left')"
27
+ >
28
+ {{ score }}
29
+ </Option>
30
+ </Select>
33
31
  </FormItem>
34
32
  </Col>
35
- <Col :span="3">
33
+ <Col class="label" :span="1">
34
+ {{ t("survey_creator.question.scores") }}
35
+ </Col>
36
+ <Col :span="2">
36
37
  <FormItem
37
- :prop="`evaluationItems[${itemIndex}].conditions[${index}].payload.operator`"
38
+ :prop="`evaluationItems[${itemIndex}].conditions[${index}].payload.leftOperator`"
38
39
  :rules="{
39
40
  required: true,
40
41
  trigger: 'change',
@@ -42,7 +43,7 @@
42
43
  }"
43
44
  >
44
45
  <Select
45
- v-model="value.operator"
46
+ v-model="value.leftOperator"
46
47
  :placeholder="
47
48
  t('survey_creator.question.evaluation.condition.operator')
48
49
  "
@@ -57,41 +58,81 @@
57
58
  </Select>
58
59
  </FormItem>
59
60
  </Col>
61
+ <Col class="label">
62
+ {{ t("survey_creator.question.totalScores") }}
63
+ </Col>
60
64
  <Col :span="2">
65
+ <FormItem
66
+ :prop="`evaluationItems[${itemIndex}].conditions[${index}].payload.rightOperator`"
67
+ :rules="{
68
+ required: true,
69
+ trigger: 'change',
70
+ message: t('survey_creator.question.notEmpty'),
71
+ }"
72
+ >
73
+ <Select
74
+ v-model="value.rightOperator"
75
+ :placeholder="
76
+ t('survey_creator.question.evaluation.condition.operator')
77
+ "
78
+ >
79
+ <Option
80
+ v-for="(operator, index) in operators"
81
+ :value="operator"
82
+ :key="index"
83
+ >
84
+ {{ operator }}
85
+ </Option>
86
+ </Select>
87
+ </FormItem>
88
+ </Col>
89
+ <Col :span="3">
61
90
  <FormItem
62
91
  :prop="`evaluationItems[${itemIndex}].conditions[${index}].payload.maxScore`"
63
92
  :rules="{
64
93
  required: true,
65
94
  type: 'number',
66
95
  trigger: 'change',
67
- min: 0,
68
- max: this.totalScore,
69
- message: t('分值不能为空'),
96
+ message: t('survey_creator.question.scoreRequiredTip'),
70
97
  }"
71
98
  >
72
- <InputNumber
99
+ <Select
73
100
  v-model="value.maxScore"
74
- :min="value.minScore"
75
- :max="totalScore"
76
- :formatter="
77
- (value) => `${value}${t('survey_creator.question.scores')}`
78
- "
79
- :parser="
80
- (value) =>
81
- value.replace(`${t('survey_creator.question.scores')}`, '')
82
- "
83
- @on-change="rangeChange"
84
- ></InputNumber>
101
+ :placeholder="t('survey_creator.question.selectScore')"
102
+ >
103
+ <Option
104
+ v-for="score in scores"
105
+ :value="score"
106
+ :key="score"
107
+ :disabled="disabledScoreOption(score, 'right')"
108
+ >
109
+ {{ score }}
110
+ </Option>
111
+ </Select>
85
112
  </FormItem>
86
113
  </Col>
114
+ <Col class="label" :span="1">
115
+ {{ t("survey_creator.question.scores") }}
116
+ </Col>
87
117
  </Row>
88
118
  </template>
89
119
  <script lang="ts">
90
120
  import Vue from "vue";
91
- import { Row, Col, Select, Option, FormItem, InputNumber } from "view-design";
121
+ import {
122
+ Col,
123
+ FormItem,
124
+ InputNumber,
125
+ Message,
126
+ Option,
127
+ Row,
128
+ Select,
129
+ } from "view-design";
92
130
  import _ from "lodash";
93
131
  import ExprMixin from "./expr-mixin";
94
132
  import LocaleMixin from "../../../../../mixins/locale-mixin";
133
+ import { ExprConditionType } from "@wg-npm/survey-core/src/models";
134
+
135
+ Vue.prototype.$Message = Message;
95
136
 
96
137
  export default Vue.extend({
97
138
  name: "score",
@@ -109,19 +150,115 @@ export default Vue.extend({
109
150
  operators: ["<=", "<"],
110
151
  };
111
152
  },
153
+ created() {},
112
154
  computed: {
113
155
  totalScore() {
114
156
  return this.$rootComponent.currentSurvey.statistics.maxScore;
115
157
  },
158
+ scores() {
159
+ return _.range(1, this.totalScore + 1, 1);
160
+ },
161
+ otherConditions() {
162
+ let otherEvaluationItems = _.filter(
163
+ _.map(this.evaluationItems, (item, index) => {
164
+ return _.extend({}, item, { index: index });
165
+ }),
166
+ (item) => item.index != this.itemIndex
167
+ );
168
+ return _.filter(
169
+ _.flatMap(otherEvaluationItems, "conditions"),
170
+ (item) => item.type == ExprConditionType.SCORE
171
+ );
172
+ },
116
173
  },
117
174
  methods: {
175
+ getSelectedRangeByValue(value, ranges) {
176
+ let otherRange = _.map(ranges, (item) => {
177
+ return {
178
+ min: _.get(item, "payload.minScore"),
179
+ max: _.get(item, "payload.maxScore"),
180
+ };
181
+ });
182
+ return _.head(
183
+ _.filter(otherRange, function (o) {
184
+ return value > o.min && value < o.max;
185
+ })
186
+ );
187
+ },
188
+ getUsableRanges() {
189
+ let usedRange = _.map(this.otherConditions, (item) => {
190
+ return [item.payload.minScore, item.payload.maxScore];
191
+ });
192
+ let globalMin = 0;
193
+ let globalMax = this.totalScore;
194
+ // arr must sorted asc
195
+ let usableRange = new Array();
196
+ if (usedRange.length == 1) {
197
+ let first = usedRange[0][0] - 1;
198
+ if (usedRange[0][0] !== 0) {
199
+ let item = [0, first];
200
+ usableRange.push(item);
201
+ }
202
+ if (usedRange[length - 1][1] != globalMax) {
203
+ usableRange.push([usedRange[length - 1][1], globalMax]);
204
+ }
205
+ return usableRange;
206
+ } else {
207
+ let other = usedRange.reduce((a, v) => {
208
+ if (typeof a[0] == "number") {
209
+ if (a[0] != globalMin) {
210
+ return [
211
+ [0, a[0]],
212
+ [a[1], v[0]],
213
+ [v[1], v[1]],
214
+ ];
215
+ } else {
216
+ return [
217
+ [a[1], v[0]],
218
+ [v[1], v[1]],
219
+ ];
220
+ }
221
+ } else {
222
+ a[a.length - 1][1] = v[0];
223
+ if (a.length != usedRange.length) a.push([v[1], v[1]]);
224
+ }
225
+ return a;
226
+ });
227
+ if (usedRange[length - 1][1] != globalMax) {
228
+ other.push([usedRange[length - 1][1], globalMax]);
229
+ }
230
+ return other;
231
+ }
232
+ },
233
+ disabledScoreOption(value, type) {
234
+ if (this.checkValueInOtherRange(value)) {
235
+ return true;
236
+ }
237
+ let currentMin = _.get(this.value, "minScore", 0);
238
+ let currentMax = _.get(this.value, "maxScore", this.totalScore);
239
+ _.get(this.value, "maxScore", this.totalScore);
240
+ if (type == "left" && value >= currentMax) {
241
+ return true;
242
+ }
243
+ if (type == "right" && value <= currentMin) {
244
+ return true;
245
+ }
246
+ },
247
+ checkValueInOtherRange(value) {
248
+ let otherRange = _.map(this.otherConditions, (item) => {
249
+ return {
250
+ min: _.get(item, "payload.minScore", 0),
251
+ max: _.get(item, "payload.maxScore", 0),
252
+ };
253
+ });
254
+ return _.some(otherRange, function (o) {
255
+ return value >= o.min && value <= o.max;
256
+ });
257
+ },
118
258
  generateExpr() {
119
259
  let minScore = this.value.minScore;
120
260
  let maxScore = this.value.maxScore;
121
- return `${minScore} ${this.value.operator} $score ${this.value.operator} ${maxScore}`;
122
- },
123
- rangeChange() {
124
- console.log("222");
261
+ return `${minScore} ${this.value.leftOperator} score and score ${this.value.rightOperator} ${maxScore}`;
125
262
  },
126
263
  },
127
264
  });
@@ -131,4 +268,4 @@ export default Vue.extend({
131
268
  text-align: right;
132
269
  margin-bottom: 24px;
133
270
  }
134
- </style>
271
+ </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
@@ -1,8 +1,8 @@
1
1
  import {VueConstructor as _Vue} from 'vue';
2
2
  import SurveyCreator from './components/survey-creator.vue';
3
+ import QuestionEditDrawer from "./components/editor/question-edit-drawer.vue";
3
4
  import SurveyPreviewer from './components/survey-previewer.vue';
4
5
  import locale from './locale';
5
-
6
6
  export class SurveyCreatorOptions {
7
7
  locale: any;
8
8
  i18n: any;
@@ -15,6 +15,7 @@ export default class SurveyCreatorPlugin {
15
15
  Vue.$surveyLanguage = options.locale;
16
16
  Vue.component('survey-creator', SurveyCreator);
17
17
  Vue.component('survey-previewer', SurveyPreviewer);
18
+ Vue.component("question-edit-drawer", QuestionEditDrawer)
18
19
  }
19
20
  }
20
21
 
@@ -58,6 +58,8 @@ export default {
58
58
  sub_questions: "Sub Question",
59
59
  score: "Score",
60
60
  scores: "Score",
61
+ totalScores: "Total Score",
62
+ selectScore: "Please Input Score",
61
63
  questionRequired: "Required",
62
64
  titleRequiredTip: "Please Input Question Title",
63
65
  scoreRequiredTip: "Score Required",
@@ -144,7 +146,7 @@ export default {
144
146
  other: "Other",
145
147
  assign_template: `{0} questions answer is {1} count {2} {3}`,
146
148
  auto_template: `{0} questions answer is {1}`,
147
- score_template: `总分数范围为:{0}{1}, {2}`,
149
+ score_template: `Total Score Range: {0}{1} Total Score {2}{3}`,
148
150
  },
149
151
  },
150
152
  },
@@ -58,6 +58,8 @@ export default {
58
58
  sub_questions: "子题",
59
59
  score: "分值",
60
60
  scores: "分",
61
+ totalScores: "总分",
62
+ selectScore: "请选择分值",
61
63
  questionRequired: "此题必填",
62
64
  titleRequiredTip: "请填写题目名称",
63
65
  textTitleRequiredTip: "请填写文字说明",
@@ -144,7 +146,7 @@ export default {
144
146
  other: "其他",
145
147
  assign_template: `{0} 项为 {1} {2} {3}项`,
146
148
  auto_template: `{0} 项为 {1}`,
147
- score_template: `总分数范围为: {0}{1}{2}分`,
149
+ score_template: `总分数范围为: {0}{1} 总分 {2}{3}`,
148
150
  },
149
151
  },
150
152
  },