@wg-npm/survey-creator 0.3.7725 → 0.3.7738
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.
|
@@ -3180,19 +3180,19 @@ var script$d = Vue.extend({
|
|
|
3180
3180
|
data() {
|
|
3181
3181
|
return {
|
|
3182
3182
|
operators: ["<=", "<"],
|
|
3183
|
+
leftScores: [],
|
|
3184
|
+
rightScores: []
|
|
3183
3185
|
};
|
|
3184
3186
|
},
|
|
3185
3187
|
created() {
|
|
3186
3188
|
this.value.leftOperator = _.unescape(this.value.leftOperator);
|
|
3187
3189
|
this.value.rightOperator = _.unescape(this.value.rightOperator);
|
|
3190
|
+
this.createInitScoresOption();
|
|
3188
3191
|
},
|
|
3189
3192
|
computed: {
|
|
3190
3193
|
totalScore() {
|
|
3191
3194
|
return this.$rootComponent.currentSurvey.statistics.maxScore;
|
|
3192
3195
|
},
|
|
3193
|
-
scores() {
|
|
3194
|
-
return _.range(1, this.totalScore + 1, 1);
|
|
3195
|
-
},
|
|
3196
3196
|
otherConditions() {
|
|
3197
3197
|
let otherEvaluationItems = _.filter(_.map(this.evaluationItems, (item, index) => {
|
|
3198
3198
|
return _.extend({}, item, { index: index });
|
|
@@ -3202,95 +3202,48 @@ var script$d = Vue.extend({
|
|
|
3202
3202
|
},
|
|
3203
3203
|
},
|
|
3204
3204
|
methods: {
|
|
3205
|
-
|
|
3206
|
-
|
|
3205
|
+
createInitScoresOption() {
|
|
3206
|
+
this.leftScores = _.map(_.range(1, this.totalScore + 1, 1), function (num) {
|
|
3207
3207
|
return {
|
|
3208
|
-
|
|
3209
|
-
|
|
3208
|
+
value: num,
|
|
3209
|
+
label: num,
|
|
3210
|
+
disabled: false
|
|
3210
3211
|
};
|
|
3211
3212
|
});
|
|
3212
|
-
|
|
3213
|
-
return
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
return [item.payload.minScore, item.payload.maxScore];
|
|
3213
|
+
this.rightScores = _.map(_.range(1, this.totalScore + 1, 1), function (num) {
|
|
3214
|
+
return {
|
|
3215
|
+
value: num,
|
|
3216
|
+
label: num,
|
|
3217
|
+
disabled: false
|
|
3218
|
+
};
|
|
3219
3219
|
});
|
|
3220
|
-
let globalMin = 0;
|
|
3221
|
-
let globalMax = this.totalScore;
|
|
3222
|
-
let usableRange = new Array();
|
|
3223
|
-
if (usedRange.length == 1) {
|
|
3224
|
-
let first = usedRange[0][0] - 1;
|
|
3225
|
-
if (usedRange[0][0] !== 0) {
|
|
3226
|
-
let item = [0, first];
|
|
3227
|
-
usableRange.push(item);
|
|
3228
|
-
}
|
|
3229
|
-
if (usedRange[length - 1][1] != globalMax) {
|
|
3230
|
-
usableRange.push([usedRange[length - 1][1], globalMax]);
|
|
3231
|
-
}
|
|
3232
|
-
return usableRange;
|
|
3233
|
-
}
|
|
3234
|
-
else {
|
|
3235
|
-
let other = usedRange.reduce((a, v) => {
|
|
3236
|
-
if (typeof a[0] == "number") {
|
|
3237
|
-
if (a[0] != globalMin) {
|
|
3238
|
-
return [
|
|
3239
|
-
[0, a[0]],
|
|
3240
|
-
[a[1], v[0]],
|
|
3241
|
-
[v[1], v[1]],
|
|
3242
|
-
];
|
|
3243
|
-
}
|
|
3244
|
-
else {
|
|
3245
|
-
return [
|
|
3246
|
-
[a[1], v[0]],
|
|
3247
|
-
[v[1], v[1]],
|
|
3248
|
-
];
|
|
3249
|
-
}
|
|
3250
|
-
}
|
|
3251
|
-
else {
|
|
3252
|
-
a[a.length - 1][1] = v[0];
|
|
3253
|
-
if (a.length != usedRange.length)
|
|
3254
|
-
a.push([v[1], v[1]]);
|
|
3255
|
-
}
|
|
3256
|
-
return a;
|
|
3257
|
-
});
|
|
3258
|
-
if (usedRange[length - 1][1] != globalMax) {
|
|
3259
|
-
other.push([usedRange[length - 1][1], globalMax]);
|
|
3260
|
-
}
|
|
3261
|
-
return other;
|
|
3262
|
-
}
|
|
3263
3220
|
},
|
|
3264
|
-
|
|
3221
|
+
resetScoreOptions(options, type) {
|
|
3265
3222
|
debugger;
|
|
3266
|
-
if (this.
|
|
3267
|
-
return
|
|
3268
|
-
}
|
|
3269
|
-
let leftScore = _.get(this.value, "minScore", 0);
|
|
3270
|
-
let rightScore = _.get(this.value, "maxScore", this.totalScore);
|
|
3271
|
-
if (leftScore != null && type == "left" && value >= rightScore) {
|
|
3272
|
-
return true;
|
|
3273
|
-
}
|
|
3274
|
-
if (rightScore != null && type == "right" && value <= leftScore) {
|
|
3275
|
-
return true;
|
|
3223
|
+
if (this.otherConditions.length == 0) {
|
|
3224
|
+
return;
|
|
3276
3225
|
}
|
|
3277
|
-
},
|
|
3278
|
-
checkValueInOtherRange(value) {
|
|
3279
3226
|
let otherRange = _.map(this.otherConditions, (item) => {
|
|
3280
3227
|
return {
|
|
3281
3228
|
min: _.get(item, "payload.minScore", 0),
|
|
3282
3229
|
max: _.get(item, "payload.maxScore", 0),
|
|
3283
3230
|
};
|
|
3284
3231
|
});
|
|
3285
|
-
|
|
3286
|
-
|
|
3232
|
+
let currentValue = this.value;
|
|
3233
|
+
let currentTotalScore = this.totalScore;
|
|
3234
|
+
_.map(options, function (o) {
|
|
3235
|
+
let disabled = _.some(otherRange, function (or) {
|
|
3236
|
+
let condition_a = o >= or.min && o <= or.max;
|
|
3237
|
+
let condition_b = type == "left" ? o.value >= _.get(currentValue, "minScore", 0) : o.value <= _.get(currentValue, "maxScore", currentTotalScore);
|
|
3238
|
+
return condition_a && condition_b;
|
|
3239
|
+
});
|
|
3240
|
+
return {
|
|
3241
|
+
value: o.value,
|
|
3242
|
+
label: o.label,
|
|
3243
|
+
disabled: disabled
|
|
3244
|
+
};
|
|
3287
3245
|
});
|
|
3288
3246
|
},
|
|
3289
|
-
generateExpr() {
|
|
3290
|
-
let minScore = this.value.minScore;
|
|
3291
|
-
let maxScore = this.value.maxScore;
|
|
3292
|
-
return `${minScore} ${this.value.leftOperator} score and score ${this.value.rightOperator} ${maxScore}`;
|
|
3293
|
-
},
|
|
3294
3247
|
},
|
|
3295
3248
|
});
|
|
3296
3249
|
|
|
@@ -3298,35 +3251,35 @@ var script$d = Vue.extend({
|
|
|
3298
3251
|
const __vue_script__$d = script$d;
|
|
3299
3252
|
|
|
3300
3253
|
/* template */
|
|
3301
|
-
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
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3254
|
+
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":4}},[_c('FormItem',{attrs:{"prop":("evaluationItems[" + _vm.itemIndex + "].conditions[" + _vm.index + "].payload.minScore"),"rules":{
|
|
3255
|
+
required: true,
|
|
3256
|
+
type: 'number',
|
|
3257
|
+
trigger: 'change',
|
|
3258
|
+
message: _vm.t('survey_creator.question.scoreRequiredTip'),
|
|
3259
|
+
}}},[_c('Select',{attrs:{"placeholder":_vm.t('survey_creator.question.selectScore')},on:{"on-change":function($event){return _vm.resetScoreOptions(_vm.leftScores,'left')}},model:{value:(_vm.value.minScore),callback:function ($$v) {_vm.$set(_vm.value, "minScore", $$v);},expression:"value.minScore"}},_vm._l((_vm.leftScores),function(score){return _c('Option',{key:score.value,attrs:{"value":score.value,"disabled":score.disabled}},[_vm._v("\n "+_vm._s(score)+"\n ")])}),1)],1)],1),_vm._v(" "),_c('Col',{attrs:{"span":3}},[_c('FormItem',{attrs:{"prop":("evaluationItems[" + _vm.itemIndex + "].conditions[" + _vm.index + "].payload.leftOperator"),"rules":{
|
|
3260
|
+
required: true,
|
|
3261
|
+
trigger: 'change',
|
|
3262
|
+
message: _vm.t('survey_creator.question.notEmpty'),
|
|
3263
|
+
}}},[_c('Select',{staticClass:"operator",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":3}},[_c('FormItem',{attrs:{"prop":("evaluationItems[" + _vm.itemIndex + "].conditions[" + _vm.index + "].payload.rightOperator"),"rules":{
|
|
3264
|
+
required: true,
|
|
3265
|
+
trigger: 'change',
|
|
3266
|
+
message: _vm.t('survey_creator.question.notEmpty'),
|
|
3267
|
+
}}},[_c('Select',{staticClass:"operator",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":4}},[_c('FormItem',{attrs:{"prop":("evaluationItems[" + _vm.itemIndex + "].conditions[" + _vm.index + "].payload.maxScore"),"rules":{
|
|
3268
|
+
required: true,
|
|
3269
|
+
type: 'number',
|
|
3270
|
+
trigger: 'change',
|
|
3271
|
+
message: _vm.t('survey_creator.question.scoreRequiredTip'),
|
|
3272
|
+
}}},[_c('Select',{attrs:{"placeholder":_vm.t('survey_creator.question.selectScore')},on:{"on-change":function($event){return _vm.resetScoreOptions(_vm.rightScores,'right')}},model:{value:(_vm.value.maxScore),callback:function ($$v) {_vm.$set(_vm.value, "maxScore", $$v);},expression:"value.maxScore"}},_vm._l((_vm.rightScores),function(score){return _c('Option',{key:score.value,attrs:{"value":score.value,"disabled":score.disabled}},[_vm._v("\n "+_vm._s(score)+"\n ")])}),1)],1)],1)],1)};
|
|
3320
3273
|
var __vue_staticRenderFns__$d = [];
|
|
3321
3274
|
|
|
3322
3275
|
/* style */
|
|
3323
3276
|
const __vue_inject_styles__$d = function (inject) {
|
|
3324
3277
|
if (!inject) return
|
|
3325
|
-
inject("data-v-
|
|
3278
|
+
inject("data-v-29fedcdf_0", { source: ".label[data-v-29fedcdf]{text-align:right;margin-bottom:24px}[data-v-29fedcdf] .operator .ivu-select-selected-value{height:28px;line-height:28px}", map: undefined, media: undefined });
|
|
3326
3279
|
|
|
3327
3280
|
};
|
|
3328
3281
|
/* scoped */
|
|
3329
|
-
const __vue_scope_id__$d = "data-v-
|
|
3282
|
+
const __vue_scope_id__$d = "data-v-29fedcdf";
|
|
3330
3283
|
/* module identifier */
|
|
3331
3284
|
const __vue_module_identifier__$d = undefined;
|
|
3332
3285
|
/* functional template */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wg-npm/survey-creator",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7738",
|
|
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.
|
|
16
|
-
"@wg-npm/survey-service-api": "0.3.
|
|
15
|
+
"@wg-npm/survey-core": "0.3.7738",
|
|
16
|
+
"@wg-npm/survey-service-api": "0.3.7738",
|
|
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.
|
|
42
|
-
"@wg-npm/survey-service-api": "0.3.
|
|
41
|
+
"@wg-npm/survey-core": "0.3.7738",
|
|
42
|
+
"@wg-npm/survey-service-api": "0.3.7738",
|
|
43
43
|
"acorn": "^7.3.1",
|
|
44
44
|
"axios": "^0.19.2",
|
|
45
45
|
"babelrc-rollup": "^3.0.0",
|
|
@@ -1,277 +1,235 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
<Row type="flex" justify="start" :gutter="6" align="middle">
|
|
3
|
+
<Col class="label">
|
|
4
|
+
{{
|
|
5
|
+
t("survey_creator.question.evaluation.condition.score_condition_title")
|
|
6
|
+
}}
|
|
7
|
+
</Col>
|
|
8
|
+
<Col :span="4">
|
|
9
|
+
<FormItem
|
|
10
|
+
:prop="`evaluationItems[${itemIndex}].conditions[${index}].payload.minScore`"
|
|
11
|
+
:rules="{
|
|
12
12
|
required: true,
|
|
13
13
|
type: 'number',
|
|
14
14
|
trigger: 'change',
|
|
15
15
|
message: t('survey_creator.question.scoreRequiredTip'),
|
|
16
16
|
}"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
17
|
+
>
|
|
18
|
+
<Select
|
|
19
|
+
v-model="value.minScore"
|
|
20
|
+
:placeholder="t('survey_creator.question.selectScore')"
|
|
21
|
+
@on-change="resetScoreOptions(leftScores,'left')"
|
|
22
|
+
>
|
|
23
|
+
<Option
|
|
24
|
+
v-for="score in leftScores"
|
|
25
|
+
:value="score.value"
|
|
26
|
+
:key="score.value"
|
|
27
|
+
:disabled="score.disabled"
|
|
28
|
+
>
|
|
29
|
+
{{ score }}
|
|
30
|
+
</Option>
|
|
31
|
+
</Select>
|
|
32
|
+
</FormItem>
|
|
33
|
+
</Col>
|
|
34
|
+
<Col :span="3">
|
|
35
|
+
<FormItem
|
|
36
|
+
:prop="`evaluationItems[${itemIndex}].conditions[${index}].payload.leftOperator`"
|
|
37
|
+
:rules="{
|
|
37
38
|
required: true,
|
|
38
39
|
trigger: 'change',
|
|
39
40
|
message: t('survey_creator.question.notEmpty'),
|
|
40
41
|
}"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
>
|
|
43
|
+
<Select
|
|
44
|
+
class="operator"
|
|
45
|
+
v-model="value.leftOperator"
|
|
46
|
+
:placeholder="
|
|
46
47
|
t('survey_creator.question.evaluation.condition.operator')
|
|
47
48
|
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
49
|
+
>
|
|
50
|
+
<Option
|
|
51
|
+
v-for="(operator, index) in operators"
|
|
52
|
+
:value="operator"
|
|
53
|
+
:key="index"
|
|
54
|
+
>
|
|
55
|
+
{{ operator }}
|
|
56
|
+
</Option>
|
|
57
|
+
</Select>
|
|
58
|
+
</FormItem>
|
|
59
|
+
</Col>
|
|
60
|
+
<Col class="label">
|
|
61
|
+
{{ t("survey_creator.question.totalScores") }}
|
|
62
|
+
</Col>
|
|
63
|
+
<Col :span="3">
|
|
64
|
+
<FormItem
|
|
65
|
+
:prop="`evaluationItems[${itemIndex}].conditions[${index}].payload.rightOperator`"
|
|
66
|
+
:rules="{
|
|
66
67
|
required: true,
|
|
67
68
|
trigger: 'change',
|
|
68
69
|
message: t('survey_creator.question.notEmpty'),
|
|
69
70
|
}"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
>
|
|
72
|
+
<Select
|
|
73
|
+
class="operator"
|
|
74
|
+
v-model="value.rightOperator"
|
|
75
|
+
:placeholder="
|
|
75
76
|
t('survey_creator.question.evaluation.condition.operator')
|
|
76
77
|
"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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="4">
|
|
90
|
+
<FormItem
|
|
91
|
+
:prop="`evaluationItems[${itemIndex}].conditions[${index}].payload.maxScore`"
|
|
92
|
+
:rules="{
|
|
92
93
|
required: true,
|
|
93
94
|
type: 'number',
|
|
94
95
|
trigger: 'change',
|
|
95
96
|
message: t('survey_creator.question.scoreRequiredTip'),
|
|
96
97
|
}"
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
98
|
+
>
|
|
99
|
+
<Select
|
|
100
|
+
v-model="value.maxScore"
|
|
101
|
+
:placeholder="t('survey_creator.question.selectScore')"
|
|
102
|
+
@on-change="resetScoreOptions(rightScores,'right')"
|
|
103
|
+
>
|
|
104
|
+
<Option
|
|
105
|
+
v-for="score in rightScores"
|
|
106
|
+
:value="score.value"
|
|
107
|
+
:key="score.value"
|
|
108
|
+
:disabled="score.disabled"
|
|
109
|
+
>
|
|
110
|
+
{{ score }}
|
|
111
|
+
</Option>
|
|
112
|
+
</Select>
|
|
113
|
+
</FormItem>
|
|
114
|
+
</Col>
|
|
115
|
+
</Row>
|
|
114
116
|
</template>
|
|
115
117
|
<script lang="ts">
|
|
116
|
-
import Vue from "vue";
|
|
117
|
-
import {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
} from "view-design";
|
|
126
|
-
import _ from "lodash";
|
|
127
|
-
import ExprMixin from "./expr-mixin";
|
|
128
|
-
import LocaleMixin from "../../../../../mixins/locale-mixin";
|
|
129
|
-
import {
|
|
118
|
+
import Vue from "vue";
|
|
119
|
+
import {
|
|
120
|
+
Col,
|
|
121
|
+
FormItem,
|
|
122
|
+
InputNumber,
|
|
123
|
+
Message,
|
|
124
|
+
Option,
|
|
125
|
+
Row,
|
|
126
|
+
Select,
|
|
127
|
+
} from "view-design";
|
|
128
|
+
import _ from "lodash";
|
|
129
|
+
import ExprMixin from "./expr-mixin";
|
|
130
|
+
import LocaleMixin from "../../../../../mixins/locale-mixin";
|
|
131
|
+
import {ExprConditionType} from "@wg-npm/survey-core/src/models";
|
|
130
132
|
|
|
131
|
-
Vue.prototype.$Message = Message;
|
|
133
|
+
Vue.prototype.$Message = Message;
|
|
132
134
|
|
|
133
|
-
export default Vue.extend({
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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
|
-
debugger
|
|
235
|
-
if (this.checkValueInOtherRange(value)) {
|
|
236
|
-
return true;
|
|
237
|
-
}
|
|
238
|
-
let leftScore = _.get(this.value, "minScore", 0);
|
|
239
|
-
let rightScore = _.get(this.value, "maxScore", this.totalScore);
|
|
240
|
-
if (leftScore != null && type == "left" && value >= rightScore) {
|
|
241
|
-
return true;
|
|
242
|
-
}
|
|
243
|
-
if (rightScore != null && type == "right" && value <= leftScore) {
|
|
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
|
-
},
|
|
258
|
-
generateExpr() {
|
|
259
|
-
let minScore = this.value.minScore;
|
|
260
|
-
let maxScore = this.value.maxScore;
|
|
261
|
-
return `${minScore} ${this.value.leftOperator} score and score ${this.value.rightOperator} ${maxScore}`;
|
|
262
|
-
},
|
|
263
|
-
},
|
|
264
|
-
});
|
|
135
|
+
export default Vue.extend({
|
|
136
|
+
name: "score",
|
|
137
|
+
mixins: [ExprMixin, LocaleMixin],
|
|
138
|
+
components: {
|
|
139
|
+
Row,
|
|
140
|
+
Col,
|
|
141
|
+
Select,
|
|
142
|
+
Option,
|
|
143
|
+
FormItem,
|
|
144
|
+
InputNumber,
|
|
145
|
+
},
|
|
146
|
+
data() {
|
|
147
|
+
return {
|
|
148
|
+
operators: ["<=", "<"],
|
|
149
|
+
leftScores: [],
|
|
150
|
+
rightScores: []
|
|
151
|
+
};
|
|
152
|
+
},
|
|
153
|
+
created() {
|
|
154
|
+
this.value.leftOperator = _.unescape(this.value.leftOperator);
|
|
155
|
+
this.value.rightOperator = _.unescape(this.value.rightOperator);
|
|
156
|
+
this.createInitScoresOption()
|
|
157
|
+
},
|
|
158
|
+
computed: {
|
|
159
|
+
totalScore() {
|
|
160
|
+
return this.$rootComponent.currentSurvey.statistics.maxScore;
|
|
161
|
+
},
|
|
162
|
+
otherConditions() {
|
|
163
|
+
let otherEvaluationItems = _.filter(
|
|
164
|
+
_.map(this.evaluationItems, (item, index) => {
|
|
165
|
+
return _.extend({}, item, {index: index});
|
|
166
|
+
}),
|
|
167
|
+
(item) => item.index != this.itemIndex
|
|
168
|
+
);
|
|
169
|
+
const conditions = _.flatMap(otherEvaluationItems, item => _.get(item, "conditions", []));
|
|
170
|
+
return _.filter(conditions,
|
|
171
|
+
(item) => _.get(item, "type") == ExprConditionType.SCORE
|
|
172
|
+
);
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
methods: {
|
|
176
|
+
createInitScoresOption() {
|
|
177
|
+
this.leftScores = _.map(_.range(1, this.totalScore + 1, 1), function (num) {
|
|
178
|
+
return {
|
|
179
|
+
value: num,
|
|
180
|
+
label: num,
|
|
181
|
+
disabled: false
|
|
182
|
+
}
|
|
183
|
+
})
|
|
184
|
+
this.rightScores = _.map(_.range(1, this.totalScore + 1, 1), function (num) {
|
|
185
|
+
return {
|
|
186
|
+
value: num,
|
|
187
|
+
label: num,
|
|
188
|
+
disabled: false
|
|
189
|
+
}
|
|
190
|
+
})
|
|
191
|
+
},
|
|
192
|
+
resetScoreOptions(options, type) {
|
|
193
|
+
debugger
|
|
194
|
+
if (this.otherConditions.length == 0) {
|
|
195
|
+
return
|
|
196
|
+
}
|
|
197
|
+
let otherRange = _.map(this.otherConditions, (item) => {
|
|
198
|
+
return {
|
|
199
|
+
min: _.get(item, "payload.minScore", 0),
|
|
200
|
+
max: _.get(item, "payload.maxScore", 0),
|
|
201
|
+
};
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
let currentValue = this.value;
|
|
205
|
+
let currentTotalScore = this.totalScore;
|
|
206
|
+
|
|
207
|
+
_.map(options, function (o) {
|
|
208
|
+
let disabled = _.some(otherRange, function (or) {
|
|
209
|
+
let condition_a = o >= or.min && o <= or.max;
|
|
210
|
+
let condition_b = type == "left" ? o.value >= _.get(currentValue, "minScore", 0) : o.value <= _.get(currentValue, "maxScore", currentTotalScore)
|
|
211
|
+
return condition_a && condition_b;
|
|
212
|
+
})
|
|
213
|
+
return {
|
|
214
|
+
value: o.value,
|
|
215
|
+
label: o.label,
|
|
216
|
+
disabled: disabled
|
|
217
|
+
}
|
|
218
|
+
})
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
});
|
|
265
222
|
</script>
|
|
266
223
|
<style scoped lang="less">
|
|
267
|
-
.label {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
}
|
|
224
|
+
.label {
|
|
225
|
+
text-align: right;
|
|
226
|
+
margin-bottom: 24px;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/deep/ .operator {
|
|
230
|
+
.ivu-select-selected-value {
|
|
231
|
+
height: 28px;
|
|
232
|
+
line-height: 28px;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
277
235
|
</style>
|