@wg-npm/survey-creator 0.3.7720 → 0.3.7729

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.
@@ -3262,8 +3262,7 @@ var script$d = Vue.extend({
3262
3262
  }
3263
3263
  },
3264
3264
  disabledScoreOption(value, type) {
3265
- debugger;
3266
- if (this.checkValueInOtherRange(value)) {
3265
+ if (this.checkValueInOtherRange(value, type)) {
3267
3266
  return true;
3268
3267
  }
3269
3268
  let leftScore = _.get(this.value, "minScore", 0);
@@ -3275,7 +3274,8 @@ var script$d = Vue.extend({
3275
3274
  return true;
3276
3275
  }
3277
3276
  },
3278
- checkValueInOtherRange(value) {
3277
+ checkValueInOtherRange(value, type) {
3278
+ debugger;
3279
3279
  let otherRange = _.map(this.otherConditions, (item) => {
3280
3280
  return {
3281
3281
  min: _.get(item, "payload.minScore", 0),
@@ -3283,7 +3283,9 @@ var script$d = Vue.extend({
3283
3283
  };
3284
3284
  });
3285
3285
  return _.some(otherRange, function (o) {
3286
- return value >= o.min && value <= o.max;
3286
+ let condition_a = value >= o.min && value <= o.max;
3287
+ let condition_b = type == "left" ? value >= _.get(this.value, "minScore", 0) : value <= _.get(this.value, "maxScore", this.totalScore);
3288
+ return condition_a && condition_b;
3287
3289
  });
3288
3290
  },
3289
3291
  generateExpr() {
@@ -3298,35 +3300,35 @@ var script$d = Vue.extend({
3298
3300
  const __vue_script__$d = script$d;
3299
3301
 
3300
3302
  /* 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 "+_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":{
3302
- required: true,
3303
- type: 'number',
3304
- trigger: 'change',
3305
- message: _vm.t('survey_creator.question.scoreRequiredTip'),
3306
- }}},[_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":{
3307
- required: true,
3308
- trigger: 'change',
3309
- message: _vm.t('survey_creator.question.notEmpty'),
3310
- }}},[_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":{
3311
- required: true,
3312
- trigger: 'change',
3313
- message: _vm.t('survey_creator.question.notEmpty'),
3314
- }}},[_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":{
3315
- required: true,
3316
- type: 'number',
3317
- trigger: 'change',
3318
- message: _vm.t('survey_creator.question.scoreRequiredTip'),
3319
- }}},[_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)};
3303
+ 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":{
3304
+ required: true,
3305
+ type: 'number',
3306
+ trigger: 'change',
3307
+ 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.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":{
3309
+ required: true,
3310
+ trigger: 'change',
3311
+ message: _vm.t('survey_creator.question.notEmpty'),
3312
+ }}},[_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":{
3313
+ required: true,
3314
+ trigger: 'change',
3315
+ message: _vm.t('survey_creator.question.notEmpty'),
3316
+ }}},[_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":{
3317
+ required: true,
3318
+ type: 'number',
3319
+ trigger: 'change',
3320
+ 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.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)};
3320
3322
  var __vue_staticRenderFns__$d = [];
3321
3323
 
3322
3324
  /* style */
3323
3325
  const __vue_inject_styles__$d = function (inject) {
3324
3326
  if (!inject) return
3325
- inject("data-v-1411052e_0", { source: ".label[data-v-1411052e]{text-align:right;margin-bottom:24px}[data-v-1411052e] .operator .ivu-select-selected-value{height:28px;line-height:28px}", map: undefined, media: undefined });
3327
+ inject("data-v-3760b41f_0", { source: ".label[data-v-3760b41f]{text-align:right;margin-bottom:24px}[data-v-3760b41f] .operator .ivu-select-selected-value{height:28px;line-height:28px}", map: undefined, media: undefined });
3326
3328
 
3327
3329
  };
3328
3330
  /* scoped */
3329
- const __vue_scope_id__$d = "data-v-1411052e";
3331
+ const __vue_scope_id__$d = "data-v-3760b41f";
3330
3332
  /* module identifier */
3331
3333
  const __vue_module_identifier__$d = undefined;
3332
3334
  /* functional template */
@@ -3462,13 +3464,6 @@ var script$b = Vue.extend({
3462
3464
  required: true,
3463
3465
  },
3464
3466
  },
3465
- watch: {
3466
- "exprConditionType"() {
3467
- {
3468
- this.evaluationItems = [];
3469
- }
3470
- },
3471
- },
3472
3467
  data() {
3473
3468
  return {
3474
3469
  evaluationItems: this.value,
@@ -3555,11 +3550,11 @@ var __vue_staticRenderFns__$b = [];
3555
3550
  /* style */
3556
3551
  const __vue_inject_styles__$b = function (inject) {
3557
3552
  if (!inject) return
3558
- inject("data-v-cb7e5044_0", { source: ".mt-base[data-v-cb7e5044]{margin-top:12px}.action[data-v-cb7e5044]{float:right}.input[data-v-cb7e5044]{width:100px}.label[data-v-cb7e5044]{text-align:right;padding-right:4px}.text[data-v-cb7e5044]{background-color:#ebf7ff;height:32px;padding:8px 18px;font-weight:500;color:#515a6e}[data-v-cb7e5044] .ivu-card .ivu-form-item{margin-bottom:4px;margin-top:0}[data-v-cb7e5044] .ivu-card .ivu-form-item-error{margin-bottom:24px;margin-top:0}", map: undefined, media: undefined });
3553
+ inject("data-v-7d7d66ce_0", { source: ".mt-base[data-v-7d7d66ce]{margin-top:12px}.action[data-v-7d7d66ce]{float:right}.input[data-v-7d7d66ce]{width:100px}.label[data-v-7d7d66ce]{text-align:right;padding-right:4px}.text[data-v-7d7d66ce]{background-color:#ebf7ff;height:32px;padding:8px 18px;font-weight:500;color:#515a6e}[data-v-7d7d66ce] .ivu-card .ivu-form-item{margin-bottom:4px;margin-top:0}[data-v-7d7d66ce] .ivu-card .ivu-form-item-error{margin-bottom:24px;margin-top:0}", map: undefined, media: undefined });
3559
3554
 
3560
3555
  };
3561
3556
  /* scoped */
3562
- const __vue_scope_id__$b = "data-v-cb7e5044";
3557
+ const __vue_scope_id__$b = "data-v-7d7d66ce";
3563
3558
  /* module identifier */
3564
3559
  const __vue_module_identifier__$b = undefined;
3565
3560
  /* functional template */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wg-npm/survey-creator",
3
- "version": "0.3.7720",
3
+ "version": "0.3.7729",
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.7720",
16
- "@wg-npm/survey-service-api": "0.3.7720",
15
+ "@wg-npm/survey-core": "0.3.7729",
16
+ "@wg-npm/survey-service-api": "0.3.7729",
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.7720",
42
- "@wg-npm/survey-service-api": "0.3.7720",
41
+ "@wg-npm/survey-core": "0.3.7729",
42
+ "@wg-npm/survey-service-api": "0.3.7729",
43
43
  "acorn": "^7.3.1",
44
44
  "axios": "^0.19.2",
45
45
  "babelrc-rollup": "^3.0.0",
@@ -145,14 +145,6 @@
145
145
  required: true,
146
146
  },
147
147
  },
148
- watch: {
149
- "exprConditionType"() {
150
- handler: {
151
- this.evaluationItems = [];
152
- }
153
- deep: true;
154
- },
155
- },
156
148
  data() {
157
149
  return {
158
150
  evaluationItems: this.value,
@@ -1,277 +1,282 @@
1
1
  <template>
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="{
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
- <Select
19
- v-model="value.minScore"
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>
31
- </FormItem>
32
- </Col>
33
- <Col :span="3">
34
- <FormItem
35
- :prop="`evaluationItems[${itemIndex}].conditions[${index}].payload.leftOperator`"
36
- :rules="{
17
+ >
18
+ <Select
19
+ v-model="value.minScore"
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>
31
+ </FormItem>
32
+ </Col>
33
+ <Col :span="3">
34
+ <FormItem
35
+ :prop="`evaluationItems[${itemIndex}].conditions[${index}].payload.leftOperator`"
36
+ :rules="{
37
37
  required: true,
38
38
  trigger: 'change',
39
39
  message: t('survey_creator.question.notEmpty'),
40
40
  }"
41
- >
42
- <Select
43
- class="operator"
44
- v-model="value.leftOperator"
45
- :placeholder="
41
+ >
42
+ <Select
43
+ class="operator"
44
+ v-model="value.leftOperator"
45
+ :placeholder="
46
46
  t('survey_creator.question.evaluation.condition.operator')
47
47
  "
48
- >
49
- <Option
50
- v-for="(operator, index) in operators"
51
- :value="operator"
52
- :key="index"
53
- >
54
- {{ operator }}
55
- </Option>
56
- </Select>
57
- </FormItem>
58
- </Col>
59
- <Col class="label">
60
- {{ t("survey_creator.question.totalScores") }}
61
- </Col>
62
- <Col :span="3">
63
- <FormItem
64
- :prop="`evaluationItems[${itemIndex}].conditions[${index}].payload.rightOperator`"
65
- :rules="{
48
+ >
49
+ <Option
50
+ v-for="(operator, index) in operators"
51
+ :value="operator"
52
+ :key="index"
53
+ >
54
+ {{ operator }}
55
+ </Option>
56
+ </Select>
57
+ </FormItem>
58
+ </Col>
59
+ <Col class="label">
60
+ {{ t("survey_creator.question.totalScores") }}
61
+ </Col>
62
+ <Col :span="3">
63
+ <FormItem
64
+ :prop="`evaluationItems[${itemIndex}].conditions[${index}].payload.rightOperator`"
65
+ :rules="{
66
66
  required: true,
67
67
  trigger: 'change',
68
68
  message: t('survey_creator.question.notEmpty'),
69
69
  }"
70
- >
71
- <Select
72
- class="operator"
73
- v-model="value.rightOperator"
74
- :placeholder="
70
+ >
71
+ <Select
72
+ class="operator"
73
+ v-model="value.rightOperator"
74
+ :placeholder="
75
75
  t('survey_creator.question.evaluation.condition.operator')
76
76
  "
77
- >
78
- <Option
79
- v-for="(operator, index) in operators"
80
- :value="operator"
81
- :key="index"
82
- >
83
- {{ operator }}
84
- </Option>
85
- </Select>
86
- </FormItem>
87
- </Col>
88
- <Col :span="4">
89
- <FormItem
90
- :prop="`evaluationItems[${itemIndex}].conditions[${index}].payload.maxScore`"
91
- :rules="{
77
+ >
78
+ <Option
79
+ v-for="(operator, index) in operators"
80
+ :value="operator"
81
+ :key="index"
82
+ >
83
+ {{ operator }}
84
+ </Option>
85
+ </Select>
86
+ </FormItem>
87
+ </Col>
88
+ <Col :span="4">
89
+ <FormItem
90
+ :prop="`evaluationItems[${itemIndex}].conditions[${index}].payload.maxScore`"
91
+ :rules="{
92
92
  required: true,
93
93
  type: 'number',
94
94
  trigger: 'change',
95
95
  message: t('survey_creator.question.scoreRequiredTip'),
96
96
  }"
97
- >
98
- <Select
99
- v-model="value.maxScore"
100
- :placeholder="t('survey_creator.question.selectScore')"
101
- >
102
- <Option
103
- v-for="score in scores"
104
- :value="score"
105
- :key="score"
106
- :disabled="disabledScoreOption(score, 'right')"
107
- >
108
- {{ score }}
109
- </Option>
110
- </Select>
111
- </FormItem>
112
- </Col>
113
- </Row>
97
+ >
98
+ <Select
99
+ v-model="value.maxScore"
100
+ :placeholder="t('survey_creator.question.selectScore')"
101
+ >
102
+ <Option
103
+ v-for="score in scores"
104
+ :value="score"
105
+ :key="score"
106
+ :disabled="disabledScoreOption(score, 'right')"
107
+ >
108
+ {{ score }}
109
+ </Option>
110
+ </Select>
111
+ </FormItem>
112
+ </Col>
113
+ </Row>
114
114
  </template>
115
115
  <script lang="ts">
116
- import Vue from "vue";
117
- import {
118
- Col,
119
- FormItem,
120
- InputNumber,
121
- Message,
122
- Option,
123
- Row,
124
- Select,
125
- } from "view-design";
126
- import _ from "lodash";
127
- import ExprMixin from "./expr-mixin";
128
- import LocaleMixin from "../../../../../mixins/locale-mixin";
129
- import { ExprConditionType } from "@wg-npm/survey-core/src/models";
116
+ import Vue from "vue";
117
+ import {
118
+ Col,
119
+ FormItem,
120
+ InputNumber,
121
+ Message,
122
+ Option,
123
+ Row,
124
+ Select,
125
+ } from "view-design";
126
+ import _ from "lodash";
127
+ import ExprMixin from "./expr-mixin";
128
+ import LocaleMixin from "../../../../../mixins/locale-mixin";
129
+ import {ExprConditionType} from "@wg-npm/survey-core/src/models";
130
130
 
131
- Vue.prototype.$Message = Message;
131
+ Vue.prototype.$Message = Message;
132
132
 
133
- export default Vue.extend({
134
- name: "score",
135
- mixins: [ExprMixin, LocaleMixin],
136
- components: {
137
- Row,
138
- Col,
139
- Select,
140
- Option,
141
- FormItem,
142
- InputNumber,
143
- },
144
- data() {
145
- return {
146
- operators: ["<=", "<"],
147
- };
148
- },
149
- created() {
150
- this.value.leftOperator = _.unescape(this.value.leftOperator);
151
- this.value.rightOperator = _.unescape(this.value.rightOperator);
152
- },
153
- computed: {
154
- totalScore() {
155
- return this.$rootComponent.currentSurvey.statistics.maxScore;
156
- },
157
- scores() {
158
- return _.range(1, this.totalScore + 1, 1);
159
- },
160
- otherConditions() {
161
- let otherEvaluationItems = _.filter(
162
- _.map(this.evaluationItems, (item, index) => {
163
- return _.extend({}, item, { index: index });
164
- }),
165
- (item) => item.index != this.itemIndex
166
- );
167
- const conditions = _.flatMap(otherEvaluationItems, item=>_.get(item,"conditions",[]));
168
- return _.filter(conditions,
169
- (item) => _.get(item,"type") == ExprConditionType.SCORE
170
- );
171
- },
172
- },
173
- methods: {
174
- getSelectedRangeByValue(value, ranges) {
175
- let otherRange = _.map(ranges, (item) => {
176
- return {
177
- min: _.get(item, "payload.minScore"),
178
- max: _.get(item, "payload.maxScore"),
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]);
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
- 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
- });
133
+ export default Vue.extend({
134
+ name: "score",
135
+ mixins: [ExprMixin, LocaleMixin],
136
+ components: {
137
+ Row,
138
+ Col,
139
+ Select,
140
+ Option,
141
+ FormItem,
142
+ InputNumber,
143
+ },
144
+ data() {
145
+ return {
146
+ operators: ["<=", "<"],
147
+ };
148
+ },
149
+ created() {
150
+ this.value.leftOperator = _.unescape(this.value.leftOperator);
151
+ this.value.rightOperator = _.unescape(this.value.rightOperator);
152
+ },
153
+ computed: {
154
+ totalScore() {
155
+ return this.$rootComponent.currentSurvey.statistics.maxScore;
156
+ },
157
+ scores() {
158
+ return _.range(1, this.totalScore + 1, 1);
159
+ },
160
+ otherConditions() {
161
+ let otherEvaluationItems = _.filter(
162
+ _.map(this.evaluationItems, (item, index) => {
163
+ return _.extend({}, item, {index: index});
164
+ }),
165
+ (item) => item.index != this.itemIndex
166
+ );
167
+ const conditions = _.flatMap(otherEvaluationItems, item => _.get(item, "conditions", []));
168
+ return _.filter(conditions,
169
+ (item) => _.get(item, "type") == ExprConditionType.SCORE
170
+ );
171
+ },
172
+ },
173
+ methods: {
174
+ getSelectedRangeByValue(value, ranges) {
175
+ let otherRange = _.map(ranges, (item) => {
176
+ return {
177
+ min: _.get(item, "payload.minScore"),
178
+ max: _.get(item, "payload.maxScore"),
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]);
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, 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) {
247
+ debugger
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
+
255
+ return _.some(otherRange, function (o) {
256
+ let condition_a = value >= o.min && value <= o.max;
257
+ let condition_b = type == "left" ? value >= _.get(this.value, "minScore", 0) : value <= _.get(this.value, "maxScore", this.totalScore)
258
+
259
+ return condition_a && condition_b;
260
+ });
261
+ },
262
+ generateExpr() {
263
+ let minScore = this.value.minScore;
264
+ let maxScore = this.value.maxScore;
265
+ return `${minScore} ${this.value.leftOperator} score and score ${this.value.rightOperator} ${maxScore}`;
266
+ },
267
+ },
268
+ });
265
269
  </script>
266
270
  <style scoped lang="less">
267
- .label {
268
- text-align: right;
269
- margin-bottom: 24px;
270
- }
271
- /deep/ .operator {
272
- .ivu-select-selected-value {
273
- height: 28px;
274
- line-height: 28px;
275
- }
276
- }
271
+ .label {
272
+ text-align: right;
273
+ margin-bottom: 24px;
274
+ }
275
+
276
+ /deep/ .operator {
277
+ .ivu-select-selected-value {
278
+ height: 28px;
279
+ line-height: 28px;
280
+ }
281
+ }
277
282
  </style>