@wg-npm/survey-creator 0.3.7731 → 0.3.7744

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,79 +3202,35 @@ var script$d = Vue.extend({
3202
3202
  },
3203
3203
  },
3204
3204
  methods: {
3205
- getSelectedRangeByValue(value, ranges) {
3206
- let otherRange = _.map(ranges, (item) => {
3205
+ createInitScoresOption() {
3206
+ let otherRange = _.map(this.otherConditions, (item) => {
3207
3207
  return {
3208
- min: _.get(item, "payload.minScore"),
3209
- max: _.get(item, "payload.maxScore"),
3208
+ min: _.get(item, "payload.minScore", 0),
3209
+ max: _.get(item, "payload.maxScore", 0),
3210
3210
  };
3211
3211
  });
3212
- return _.head(_.filter(otherRange, function (o) {
3213
- return value > o.min && value < o.max;
3214
- }));
3215
- },
3216
- getUsableRanges() {
3217
- let usedRange = _.map(this.otherConditions, (item) => {
3218
- return [item.payload.minScore, item.payload.maxScore];
3212
+ this.leftScores = _.map(_.range(1, this.totalScore + 1, 1), function (num) {
3213
+ let disabled = _.some(otherRange, function (o) {
3214
+ return num >= o.min && num <= o.max;
3215
+ });
3216
+ return {
3217
+ value: num,
3218
+ label: num,
3219
+ disabled: disabled
3220
+ };
3219
3221
  });
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;
3222
+ this.rightScores = _.map(_.range(1, this.totalScore + 1, 1), function (num) {
3223
+ let disabled = _.some(otherRange, function (o) {
3224
+ return num >= o.min && num <= o.max;
3257
3225
  });
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
- }
3226
+ return {
3227
+ value: num,
3228
+ label: num,
3229
+ disabled: disabled
3230
+ };
3231
+ });
3276
3232
  },
3277
- checkValueInOtherRange(value, type) {
3233
+ resetScoreOptions(options, type) {
3278
3234
  debugger;
3279
3235
  let otherRange = _.map(this.otherConditions, (item) => {
3280
3236
  return {
@@ -3284,17 +3240,14 @@ var script$d = Vue.extend({
3284
3240
  });
3285
3241
  let currentValue = this.value;
3286
3242
  let currentTotalScore = this.totalScore;
3287
- return _.some(otherRange, function (o) {
3288
- let condition_a = value >= o.min && value <= o.max;
3289
- let condition_b = type == "left" ? value >= _.get(currentValue, "minScore", 0) : value <= _.get(currentValue, "maxScore", currentTotalScore);
3290
- return condition_a && condition_b;
3243
+ _.forEach(options, function (o) {
3244
+ o.disabled = _.some(otherRange, function (or) {
3245
+ let condition_a = o >= or.min && o <= or.max;
3246
+ let condition_b = type == "left" ? o.value >= _.get(currentValue, "minScore", 0) : o.value <= _.get(currentValue, "maxScore", currentTotalScore);
3247
+ return condition_a && condition_b;
3248
+ });
3291
3249
  });
3292
3250
  },
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
3251
  },
3299
3252
  });
3300
3253
 
@@ -3307,7 +3260,7 @@ var __vue_render__$d = function () {var _vm=this;var _h=_vm.$createElement;var _
3307
3260
  type: 'number',
3308
3261
  trigger: 'change',
3309
3262
  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.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',{attrs:{"span":3}},[_c('FormItem',{attrs:{"prop":("evaluationItems[" + _vm.itemIndex + "].conditions[" + _vm.index + "].payload.leftOperator"),"rules":{
3263
+ }}},[_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.value)+"\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
3264
  required: true,
3312
3265
  trigger: 'change',
3313
3266
  message: _vm.t('survey_creator.question.notEmpty'),
@@ -3320,17 +3273,17 @@ var __vue_render__$d = function () {var _vm=this;var _h=_vm.$createElement;var _
3320
3273
  type: 'number',
3321
3274
  trigger: 'change',
3322
3275
  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.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)],1)};
3276
+ }}},[_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.value)+"\n ")])}),1)],1)],1)],1)};
3324
3277
  var __vue_staticRenderFns__$d = [];
3325
3278
 
3326
3279
  /* style */
3327
3280
  const __vue_inject_styles__$d = function (inject) {
3328
3281
  if (!inject) return
3329
- inject("data-v-83ab61b4_0", { source: ".label[data-v-83ab61b4]{text-align:right;margin-bottom:24px}[data-v-83ab61b4] .operator .ivu-select-selected-value{height:28px;line-height:28px}", map: undefined, media: undefined });
3282
+ inject("data-v-b6aa713e_0", { source: ".label[data-v-b6aa713e]{text-align:right;margin-bottom:24px}[data-v-b6aa713e] .operator .ivu-select-selected-value{height:28px;line-height:28px}", map: undefined, media: undefined });
3330
3283
 
3331
3284
  };
3332
3285
  /* scoped */
3333
- const __vue_scope_id__$d = "data-v-83ab61b4";
3286
+ const __vue_scope_id__$d = "data-v-b6aa713e";
3334
3287
  /* module identifier */
3335
3288
  const __vue_module_identifier__$d = undefined;
3336
3289
  /* functional template */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wg-npm/survey-creator",
3
- "version": "0.3.7731",
3
+ "version": "0.3.7744",
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.7731",
16
- "@wg-npm/survey-service-api": "0.3.7731",
15
+ "@wg-npm/survey-core": "0.3.7744",
16
+ "@wg-npm/survey-service-api": "0.3.7744",
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.7731",
42
- "@wg-npm/survey-service-api": "0.3.7731",
41
+ "@wg-npm/survey-core": "0.3.7744",
42
+ "@wg-npm/survey-service-api": "0.3.7744",
43
43
  "acorn": "^7.3.1",
44
44
  "axios": "^0.19.2",
45
45
  "babelrc-rollup": "^3.0.0",
@@ -18,14 +18,15 @@
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 scores"
24
- :value="score"
25
- :key="score"
26
- :disabled="disabledScoreOption(score, 'left')"
24
+ v-for="score in leftScores"
25
+ :value="score.value"
26
+ :key="score.value"
27
+ :disabled="score.disabled"
27
28
  >
28
- {{ score }}
29
+ {{ score.value }}
29
30
  </Option>
30
31
  </Select>
31
32
  </FormItem>
@@ -98,14 +99,15 @@
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 scores"
104
- :value="score"
105
- :key="score"
106
- :disabled="disabledScoreOption(score, 'right')"
105
+ v-for="score in rightScores"
106
+ :value="score.value"
107
+ :key="score.value"
108
+ :disabled="score.disabled"
107
109
  >
108
- {{ score }}
110
+ {{ score.value }}
109
111
  </Option>
110
112
  </Select>
111
113
  </FormItem>
@@ -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,79 +173,36 @@
171
173
  },
172
174
  },
173
175
  methods: {
174
- getSelectedRangeByValue(value, ranges) {
175
- let otherRange = _.map(ranges, (item) => {
176
+ createInitScoresOption() {
177
+ let otherRange = _.map(this.otherConditions, (item) => {
176
178
  return {
177
- min: _.get(item, "payload.minScore"),
178
- max: _.get(item, "payload.maxScore"),
179
+ min: _.get(item, "payload.minScore", 0),
180
+ max: _.get(item, "payload.maxScore", 0),
179
181
  };
180
182
  });
181
- return _.head(
182
- _.filter(otherRange, function (o) {
183
- return value > o.min && value < o.max;
183
+
184
+ this.leftScores = _.map(_.range(1, this.totalScore + 1, 1), function (num) {
185
+ let disabled = _.some(otherRange, function (o) {
186
+ return num >= o.min && num <= o.max;
184
187
  })
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]);
188
+ return {
189
+ value: num,
190
+ label: num,
191
+ disabled: disabled
204
192
  }
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]);
193
+ })
194
+ this.rightScores = _.map(_.range(1, this.totalScore + 1, 1), function (num) {
195
+ let disabled = _.some(otherRange, function (o) {
196
+ return num >= o.min && num <= o.max;
197
+ })
198
+ return {
199
+ value: num,
200
+ label: num,
201
+ disabled: disabled
229
202
  }
230
- return other;
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
- }
203
+ })
245
204
  },
246
- checkValueInOtherRange(value, type) {
205
+ resetScoreOptions(options, type) {
247
206
  debugger
248
207
  let otherRange = _.map(this.otherConditions, (item) => {
249
208
  return {
@@ -255,17 +214,13 @@
255
214
  let currentValue = this.value;
256
215
  let currentTotalScore = this.totalScore;
257
216
 
258
- return _.some(otherRange, function (o) {
259
- let condition_a = value >= o.min && value <= o.max;
260
- let condition_b = type == "left" ? value >= _.get(currentValue, "minScore", 0) : value <= _.get(currentValue, "maxScore", currentTotalScore)
261
-
262
- return condition_a && condition_b;
263
- });
264
- },
265
- generateExpr() {
266
- let minScore = this.value.minScore;
267
- let maxScore = this.value.maxScore;
268
- return `${minScore} ${this.value.leftOperator} score and score ${this.value.rightOperator} ${maxScore}`;
217
+ _.forEach(options, function (o) {
218
+ o.disabled = _.some(otherRange, function (or) {
219
+ let condition_a = o >= or.min && o <= or.max;
220
+ let condition_b = type == "left" ? o.value >= _.get(currentValue, "minScore", 0) : o.value <= _.get(currentValue, "maxScore", currentTotalScore)
221
+ return condition_a && condition_b;
222
+ })
223
+ })
269
224
  },
270
225
  },
271
226
  });