@wg-npm/survey-creator 0.3.7731 → 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,80 +3202,27 @@ 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
|
-
|
|
3265
|
-
if (this.checkValueInOtherRange(value, type)) {
|
|
3266
|
-
return true;
|
|
3267
|
-
}
|
|
3268
|
-
let leftScore = _.get(this.value, "minScore", 0);
|
|
3269
|
-
let rightScore = _.get(this.value, "maxScore", this.totalScore);
|
|
3270
|
-
if (leftScore != null && type == "left" && value >= rightScore) {
|
|
3271
|
-
return true;
|
|
3272
|
-
}
|
|
3273
|
-
if (rightScore != null && type == "right" && value <= leftScore) {
|
|
3274
|
-
return true;
|
|
3275
|
-
}
|
|
3276
|
-
},
|
|
3277
|
-
checkValueInOtherRange(value, type) {
|
|
3221
|
+
resetScoreOptions(options, type) {
|
|
3278
3222
|
debugger;
|
|
3223
|
+
if (this.otherConditions.length == 0) {
|
|
3224
|
+
return;
|
|
3225
|
+
}
|
|
3279
3226
|
let otherRange = _.map(this.otherConditions, (item) => {
|
|
3280
3227
|
return {
|
|
3281
3228
|
min: _.get(item, "payload.minScore", 0),
|
|
@@ -3284,17 +3231,19 @@ var script$d = Vue.extend({
|
|
|
3284
3231
|
});
|
|
3285
3232
|
let currentValue = this.value;
|
|
3286
3233
|
let currentTotalScore = this.totalScore;
|
|
3287
|
-
|
|
3288
|
-
let
|
|
3289
|
-
|
|
3290
|
-
|
|
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
|
+
};
|
|
3291
3245
|
});
|
|
3292
3246
|
},
|
|
3293
|
-
generateExpr() {
|
|
3294
|
-
let minScore = this.value.minScore;
|
|
3295
|
-
let maxScore = this.value.maxScore;
|
|
3296
|
-
return `${minScore} ${this.value.leftOperator} score and score ${this.value.rightOperator} ${maxScore}`;
|
|
3297
|
-
},
|
|
3298
3247
|
},
|
|
3299
3248
|
});
|
|
3300
3249
|
|
|
@@ -3307,7 +3256,7 @@ var __vue_render__$d = function () {var _vm=this;var _h=_vm.$createElement;var _
|
|
|
3307
3256
|
type: 'number',
|
|
3308
3257
|
trigger: 'change',
|
|
3309
3258
|
message: _vm.t('survey_creator.question.scoreRequiredTip'),
|
|
3310
|
-
}}},[_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.
|
|
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":{
|
|
3311
3260
|
required: true,
|
|
3312
3261
|
trigger: 'change',
|
|
3313
3262
|
message: _vm.t('survey_creator.question.notEmpty'),
|
|
@@ -3320,17 +3269,17 @@ var __vue_render__$d = function () {var _vm=this;var _h=_vm.$createElement;var _
|
|
|
3320
3269
|
type: 'number',
|
|
3321
3270
|
trigger: 'change',
|
|
3322
3271
|
message: _vm.t('survey_creator.question.scoreRequiredTip'),
|
|
3323
|
-
}}},[_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.
|
|
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)};
|
|
3324
3273
|
var __vue_staticRenderFns__$d = [];
|
|
3325
3274
|
|
|
3326
3275
|
/* style */
|
|
3327
3276
|
const __vue_inject_styles__$d = function (inject) {
|
|
3328
3277
|
if (!inject) return
|
|
3329
|
-
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 });
|
|
3330
3279
|
|
|
3331
3280
|
};
|
|
3332
3281
|
/* scoped */
|
|
3333
|
-
const __vue_scope_id__$d = "data-v-
|
|
3282
|
+
const __vue_scope_id__$d = "data-v-29fedcdf";
|
|
3334
3283
|
/* module identifier */
|
|
3335
3284
|
const __vue_module_identifier__$d = undefined;
|
|
3336
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",
|
|
@@ -18,12 +18,13 @@
|
|
|
18
18
|
<Select
|
|
19
19
|
v-model="value.minScore"
|
|
20
20
|
:placeholder="t('survey_creator.question.selectScore')"
|
|
21
|
+
@on-change="resetScoreOptions(leftScores,'left')"
|
|
21
22
|
>
|
|
22
23
|
<Option
|
|
23
|
-
v-for="score in
|
|
24
|
-
:value="score"
|
|
25
|
-
:key="score"
|
|
26
|
-
:disabled="
|
|
24
|
+
v-for="score in leftScores"
|
|
25
|
+
:value="score.value"
|
|
26
|
+
:key="score.value"
|
|
27
|
+
:disabled="score.disabled"
|
|
27
28
|
>
|
|
28
29
|
{{ score }}
|
|
29
30
|
</Option>
|
|
@@ -98,12 +99,13 @@
|
|
|
98
99
|
<Select
|
|
99
100
|
v-model="value.maxScore"
|
|
100
101
|
:placeholder="t('survey_creator.question.selectScore')"
|
|
102
|
+
@on-change="resetScoreOptions(rightScores,'right')"
|
|
101
103
|
>
|
|
102
104
|
<Option
|
|
103
|
-
v-for="score in
|
|
104
|
-
:value="score"
|
|
105
|
-
:key="score"
|
|
106
|
-
:disabled="
|
|
105
|
+
v-for="score in rightScores"
|
|
106
|
+
:value="score.value"
|
|
107
|
+
:key="score.value"
|
|
108
|
+
:disabled="score.disabled"
|
|
107
109
|
>
|
|
108
110
|
{{ score }}
|
|
109
111
|
</Option>
|
|
@@ -144,19 +146,19 @@
|
|
|
144
146
|
data() {
|
|
145
147
|
return {
|
|
146
148
|
operators: ["<=", "<"],
|
|
149
|
+
leftScores: [],
|
|
150
|
+
rightScores: []
|
|
147
151
|
};
|
|
148
152
|
},
|
|
149
153
|
created() {
|
|
150
154
|
this.value.leftOperator = _.unescape(this.value.leftOperator);
|
|
151
155
|
this.value.rightOperator = _.unescape(this.value.rightOperator);
|
|
156
|
+
this.createInitScoresOption()
|
|
152
157
|
},
|
|
153
158
|
computed: {
|
|
154
159
|
totalScore() {
|
|
155
160
|
return this.$rootComponent.currentSurvey.statistics.maxScore;
|
|
156
161
|
},
|
|
157
|
-
scores() {
|
|
158
|
-
return _.range(1, this.totalScore + 1, 1);
|
|
159
|
-
},
|
|
160
162
|
otherConditions() {
|
|
161
163
|
let otherEvaluationItems = _.filter(
|
|
162
164
|
_.map(this.evaluationItems, (item, index) => {
|
|
@@ -171,80 +173,27 @@
|
|
|
171
173
|
},
|
|
172
174
|
},
|
|
173
175
|
methods: {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
+
createInitScoresOption() {
|
|
177
|
+
this.leftScores = _.map(_.range(1, this.totalScore + 1, 1), function (num) {
|
|
176
178
|
return {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
});
|
|
181
|
-
return _.head(
|
|
182
|
-
_.filter(otherRange, function (o) {
|
|
183
|
-
return value > o.min && value < o.max;
|
|
184
|
-
})
|
|
185
|
-
);
|
|
186
|
-
},
|
|
187
|
-
//todo 此功能暂未启用
|
|
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]);
|
|
179
|
+
value: num,
|
|
180
|
+
label: num,
|
|
181
|
+
disabled: false
|
|
204
182
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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]);
|
|
183
|
+
})
|
|
184
|
+
this.rightScores = _.map(_.range(1, this.totalScore + 1, 1), function (num) {
|
|
185
|
+
return {
|
|
186
|
+
value: num,
|
|
187
|
+
label: num,
|
|
188
|
+
disabled: false
|
|
229
189
|
}
|
|
230
|
-
|
|
231
|
-
}
|
|
190
|
+
})
|
|
232
191
|
},
|
|
233
|
-
|
|
234
|
-
if (this.checkValueInOtherRange(value, type)) {
|
|
235
|
-
return true;
|
|
236
|
-
}
|
|
237
|
-
let leftScore = _.get(this.value, "minScore", 0);
|
|
238
|
-
let rightScore = _.get(this.value, "maxScore", this.totalScore);
|
|
239
|
-
if (leftScore != null && type == "left" && value >= rightScore) {
|
|
240
|
-
return true;
|
|
241
|
-
}
|
|
242
|
-
if (rightScore != null && type == "right" && value <= leftScore) {
|
|
243
|
-
return true;
|
|
244
|
-
}
|
|
245
|
-
},
|
|
246
|
-
checkValueInOtherRange(value, type) {
|
|
192
|
+
resetScoreOptions(options, type) {
|
|
247
193
|
debugger
|
|
194
|
+
if (this.otherConditions.length == 0) {
|
|
195
|
+
return
|
|
196
|
+
}
|
|
248
197
|
let otherRange = _.map(this.otherConditions, (item) => {
|
|
249
198
|
return {
|
|
250
199
|
min: _.get(item, "payload.minScore", 0),
|
|
@@ -255,17 +204,18 @@
|
|
|
255
204
|
let currentValue = this.value;
|
|
256
205
|
let currentTotalScore = this.totalScore;
|
|
257
206
|
|
|
258
|
-
|
|
259
|
-
let
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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
|
+
})
|
|
269
219
|
},
|
|
270
220
|
},
|
|
271
221
|
});
|