@wg-npm/survey-creator 0.3.7724 → 0.3.7731

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,15 +3274,20 @@ 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),
3282
3282
  max: _.get(item, "payload.maxScore", 0),
3283
3283
  };
3284
3284
  });
3285
+ let currentValue = this.value;
3286
+ let currentTotalScore = this.totalScore;
3285
3287
  return _.some(otherRange, function (o) {
3286
- return value >= o.min && value <= o.max;
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;
3287
3291
  });
3288
3292
  },
3289
3293
  generateExpr() {
@@ -3298,35 +3302,35 @@ var script$d = Vue.extend({
3298
3302
  const __vue_script__$d = script$d;
3299
3303
 
3300
3304
  /* 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)};
3305
+ 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":{
3306
+ required: true,
3307
+ type: 'number',
3308
+ trigger: 'change',
3309
+ 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":{
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.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":{
3315
+ required: true,
3316
+ trigger: 'change',
3317
+ message: _vm.t('survey_creator.question.notEmpty'),
3318
+ }}},[_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":{
3319
+ required: true,
3320
+ type: 'number',
3321
+ trigger: 'change',
3322
+ 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)};
3320
3324
  var __vue_staticRenderFns__$d = [];
3321
3325
 
3322
3326
  /* style */
3323
3327
  const __vue_inject_styles__$d = function (inject) {
3324
3328
  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 });
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 });
3326
3330
 
3327
3331
  };
3328
3332
  /* scoped */
3329
- const __vue_scope_id__$d = "data-v-1411052e";
3333
+ const __vue_scope_id__$d = "data-v-83ab61b4";
3330
3334
  /* module identifier */
3331
3335
  const __vue_module_identifier__$d = undefined;
3332
3336
  /* functional template */
@@ -3462,14 +3466,6 @@ var script$b = Vue.extend({
3462
3466
  required: true,
3463
3467
  },
3464
3468
  },
3465
- watch: {
3466
- "exprConditionType": {
3467
- handler(newValue, oldValue) {
3468
- debugger;
3469
- this.evaluationItems[this.position].conditions = [];
3470
- }
3471
- },
3472
- },
3473
3469
  data() {
3474
3470
  return {
3475
3471
  evaluationItems: this.value,
@@ -3556,11 +3552,11 @@ var __vue_staticRenderFns__$b = [];
3556
3552
  /* style */
3557
3553
  const __vue_inject_styles__$b = function (inject) {
3558
3554
  if (!inject) return
3559
- inject("data-v-975e9c18_0", { source: ".mt-base[data-v-975e9c18]{margin-top:12px}.action[data-v-975e9c18]{float:right}.input[data-v-975e9c18]{width:100px}.label[data-v-975e9c18]{text-align:right;padding-right:4px}.text[data-v-975e9c18]{background-color:#ebf7ff;height:32px;padding:8px 18px;font-weight:500;color:#515a6e}[data-v-975e9c18] .ivu-card .ivu-form-item{margin-bottom:4px;margin-top:0}[data-v-975e9c18] .ivu-card .ivu-form-item-error{margin-bottom:24px;margin-top:0}", map: undefined, media: undefined });
3555
+ 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 });
3560
3556
 
3561
3557
  };
3562
3558
  /* scoped */
3563
- const __vue_scope_id__$b = "data-v-975e9c18";
3559
+ const __vue_scope_id__$b = "data-v-7d7d66ce";
3564
3560
  /* module identifier */
3565
3561
  const __vue_module_identifier__$b = undefined;
3566
3562
  /* functional template */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wg-npm/survey-creator",
3
- "version": "0.3.7724",
3
+ "version": "0.3.7731",
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.7724",
16
- "@wg-npm/survey-service-api": "0.3.7724",
15
+ "@wg-npm/survey-core": "0.3.7731",
16
+ "@wg-npm/survey-service-api": "0.3.7731",
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.7724",
42
- "@wg-npm/survey-service-api": "0.3.7724",
41
+ "@wg-npm/survey-core": "0.3.7731",
42
+ "@wg-npm/survey-service-api": "0.3.7731",
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(newValue, oldValue) {
151
- debugger
152
- this.evaluationItems[this.position].conditions = [];
153
- }
154
- },
155
- },
156
148
  data() {
157
149
  return {
158
150
  evaluationItems: this.value,
@@ -1,277 +1,285 @@
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
+ let currentValue = this.value;
256
+ let currentTotalScore = this.totalScore;
257
+
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}`;
269
+ },
270
+ },
271
+ });
265
272
  </script>
266
273
  <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
- }
274
+ .label {
275
+ text-align: right;
276
+ margin-bottom: 24px;
277
+ }
278
+
279
+ /deep/ .operator {
280
+ .ivu-select-selected-value {
281
+ height: 28px;
282
+ line-height: 28px;
283
+ }
284
+ }
277
285
  </style>