@wg-npm/survey-creator 0.3.7729 → 0.3.7740
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,97 +3202,43 @@ 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
|
-
},
|
|
3264
|
-
disabledScoreOption(value, type) {
|
|
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
3220
|
},
|
|
3277
|
-
|
|
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),
|
|
3282
3229
|
max: _.get(item, "payload.maxScore", 0),
|
|
3283
3230
|
};
|
|
3284
3231
|
});
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3232
|
+
let currentValue = this.value;
|
|
3233
|
+
let currentTotalScore = this.totalScore;
|
|
3234
|
+
_.forEach(options, function (o) {
|
|
3235
|
+
o.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
|
+
});
|
|
3289
3240
|
});
|
|
3290
3241
|
},
|
|
3291
|
-
generateExpr() {
|
|
3292
|
-
let minScore = this.value.minScore;
|
|
3293
|
-
let maxScore = this.value.maxScore;
|
|
3294
|
-
return `${minScore} ${this.value.leftOperator} score and score ${this.value.rightOperator} ${maxScore}`;
|
|
3295
|
-
},
|
|
3296
3242
|
},
|
|
3297
3243
|
});
|
|
3298
3244
|
|
|
@@ -3305,7 +3251,7 @@ var __vue_render__$d = function () {var _vm=this;var _h=_vm.$createElement;var _
|
|
|
3305
3251
|
type: 'number',
|
|
3306
3252
|
trigger: 'change',
|
|
3307
3253
|
message: _vm.t('survey_creator.question.scoreRequiredTip'),
|
|
3308
|
-
}}},[_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.
|
|
3254
|
+
}}},[_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":{
|
|
3309
3255
|
required: true,
|
|
3310
3256
|
trigger: 'change',
|
|
3311
3257
|
message: _vm.t('survey_creator.question.notEmpty'),
|
|
@@ -3318,17 +3264,17 @@ var __vue_render__$d = function () {var _vm=this;var _h=_vm.$createElement;var _
|
|
|
3318
3264
|
type: 'number',
|
|
3319
3265
|
trigger: 'change',
|
|
3320
3266
|
message: _vm.t('survey_creator.question.scoreRequiredTip'),
|
|
3321
|
-
}}},[_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.
|
|
3267
|
+
}}},[_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)};
|
|
3322
3268
|
var __vue_staticRenderFns__$d = [];
|
|
3323
3269
|
|
|
3324
3270
|
/* style */
|
|
3325
3271
|
const __vue_inject_styles__$d = function (inject) {
|
|
3326
3272
|
if (!inject) return
|
|
3327
|
-
inject("data-v-
|
|
3273
|
+
inject("data-v-8241c82a_0", { source: ".label[data-v-8241c82a]{text-align:right;margin-bottom:24px}[data-v-8241c82a] .operator .ivu-select-selected-value{height:28px;line-height:28px}", map: undefined, media: undefined });
|
|
3328
3274
|
|
|
3329
3275
|
};
|
|
3330
3276
|
/* scoped */
|
|
3331
|
-
const __vue_scope_id__$d = "data-v-
|
|
3277
|
+
const __vue_scope_id__$d = "data-v-8241c82a";
|
|
3332
3278
|
/* module identifier */
|
|
3333
3279
|
const __vue_module_identifier__$d = undefined;
|
|
3334
3280
|
/* 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.7740",
|
|
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.7740",
|
|
16
|
+
"@wg-npm/survey-service-api": "0.3.7740",
|
|
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.7740",
|
|
42
|
+
"@wg-npm/survey-service-api": "0.3.7740",
|
|
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);
|
|
179
|
+
value: num,
|
|
180
|
+
label: num,
|
|
181
|
+
disabled: false
|
|
201
182
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
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]);
|
|
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
|
-
}
|
|
232
|
-
},
|
|
233
|
-
disabledScoreOption(value, type) {
|
|
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
|
-
}
|
|
190
|
+
})
|
|
245
191
|
},
|
|
246
|
-
|
|
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),
|
|
@@ -252,17 +201,16 @@
|
|
|
252
201
|
};
|
|
253
202
|
});
|
|
254
203
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
let condition_b = type == "left" ? value >= _.get(this.value, "minScore", 0) : value <= _.get(this.value, "maxScore", this.totalScore)
|
|
204
|
+
let currentValue = this.value;
|
|
205
|
+
let currentTotalScore = this.totalScore;
|
|
258
206
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
207
|
+
_.forEach(options, function (o) {
|
|
208
|
+
o.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
|
+
})
|
|
266
214
|
},
|
|
267
215
|
},
|
|
268
216
|
});
|