@wg-npm/survey-creator 1.78.3091408 → 1.78.4031900
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.
|
@@ -92,6 +92,9 @@ var defaultLang = {
|
|
|
92
92
|
inputEnabledTip: "用户选中该项后可输入",
|
|
93
93
|
textTitleRequiredTip: "请填写文字说明",
|
|
94
94
|
scoreRequiredTip: "分值不能为空",
|
|
95
|
+
scoreExceedTotalTip: "分数不能超过总分",
|
|
96
|
+
minScoreGreaterThanMaxTip: "最小分值不能大于最大分值",
|
|
97
|
+
maxScoreLessThanMinTip: "最大分值不能小于最小分值",
|
|
95
98
|
subQuestionRequiredTip: "子題不能为空",
|
|
96
99
|
optionalRequiredTip: "选项不能为空",
|
|
97
100
|
commitRequiredTip: "描述不能为空",
|
|
@@ -20383,7 +20386,6 @@ var script$z = Vue.extend({
|
|
|
20383
20386
|
Select,
|
|
20384
20387
|
Option,
|
|
20385
20388
|
FormItem,
|
|
20386
|
-
InputNumber,
|
|
20387
20389
|
},
|
|
20388
20390
|
data() {
|
|
20389
20391
|
return {
|
|
@@ -20438,7 +20440,101 @@ var script$z = Vue.extend({
|
|
|
20438
20440
|
};
|
|
20439
20441
|
});
|
|
20440
20442
|
},
|
|
20441
|
-
|
|
20443
|
+
resetLeftScoreOptions() {
|
|
20444
|
+
this.resetScoreOptions(this.leftScores, "left");
|
|
20445
|
+
},
|
|
20446
|
+
resetRightScoreOptions() {
|
|
20447
|
+
this.resetScoreOptions(this.rightScores, "right");
|
|
20448
|
+
},
|
|
20449
|
+
getScoreOptions(type) {
|
|
20450
|
+
return type === "left" ? this.leftScores : this.rightScores;
|
|
20451
|
+
},
|
|
20452
|
+
getScoreValue(type) {
|
|
20453
|
+
return type === "left" ? this.value.minScore : this.value.maxScore;
|
|
20454
|
+
},
|
|
20455
|
+
getScoreSelectRef(type) {
|
|
20456
|
+
return type === "left"
|
|
20457
|
+
? this.$refs.leftScoreSelect
|
|
20458
|
+
: this.$refs.rightScoreSelect;
|
|
20459
|
+
},
|
|
20460
|
+
findAvailableScoreOptionByValue(options, value) {
|
|
20461
|
+
return _$1.find(options, (option) => {
|
|
20462
|
+
return !option.disabled && option.value === value;
|
|
20463
|
+
});
|
|
20464
|
+
},
|
|
20465
|
+
findMatchedScoreOption(options, query) {
|
|
20466
|
+
const normalizedQuery = String(query == null ? "" : query).trim();
|
|
20467
|
+
const enabledOptions = _$1.filter(options, (option) => !option.disabled);
|
|
20468
|
+
if (!enabledOptions.length) {
|
|
20469
|
+
return null;
|
|
20470
|
+
}
|
|
20471
|
+
if (!normalizedQuery) {
|
|
20472
|
+
return enabledOptions[0];
|
|
20473
|
+
}
|
|
20474
|
+
return (_$1.find(enabledOptions, (option) => String(option.value) === normalizedQuery) ||
|
|
20475
|
+
_$1.find(enabledOptions, (option) => String(option.value).indexOf(normalizedQuery) === 0) ||
|
|
20476
|
+
null);
|
|
20477
|
+
},
|
|
20478
|
+
updateScoreSelectFocus(type, targetValue, fallbackToFirst = false) {
|
|
20479
|
+
const select = this.getScoreSelectRef(type);
|
|
20480
|
+
if (!select) {
|
|
20481
|
+
return;
|
|
20482
|
+
}
|
|
20483
|
+
const matchedOption = targetValue;
|
|
20484
|
+
if (!matchedOption) {
|
|
20485
|
+
if (!fallbackToFirst) {
|
|
20486
|
+
select.focusIndex = -1;
|
|
20487
|
+
return;
|
|
20488
|
+
}
|
|
20489
|
+
const firstEnabledOption = _$1.find(this.getScoreOptions(type), (option) => !option.disabled);
|
|
20490
|
+
if (!firstEnabledOption) {
|
|
20491
|
+
select.focusIndex = -1;
|
|
20492
|
+
return;
|
|
20493
|
+
}
|
|
20494
|
+
return this.updateScoreSelectFocus(type, firstEnabledOption, false);
|
|
20495
|
+
}
|
|
20496
|
+
const focusIndex = _$1.findIndex(select.flatOptions, (option) => {
|
|
20497
|
+
const propsData = option &&
|
|
20498
|
+
option.componentOptions &&
|
|
20499
|
+
option.componentOptions.propsData;
|
|
20500
|
+
return propsData && propsData.value === matchedOption.value;
|
|
20501
|
+
});
|
|
20502
|
+
if (focusIndex === -1) {
|
|
20503
|
+
if (fallbackToFirst) {
|
|
20504
|
+
const firstEnabledOption = _$1.find(this.getScoreOptions(type), (option) => !option.disabled);
|
|
20505
|
+
const matchedValue = matchedOption ? matchedOption.value : null;
|
|
20506
|
+
if (firstEnabledOption && firstEnabledOption.value !== matchedValue) {
|
|
20507
|
+
this.updateScoreSelectFocus(type, firstEnabledOption, false);
|
|
20508
|
+
}
|
|
20509
|
+
}
|
|
20510
|
+
return;
|
|
20511
|
+
}
|
|
20512
|
+
select.focusIndex = focusIndex;
|
|
20513
|
+
},
|
|
20514
|
+
handleScoreSelectOpenChange(type, visible) {
|
|
20515
|
+
if (type === "left") {
|
|
20516
|
+
this.resetLeftScoreOptions();
|
|
20517
|
+
}
|
|
20518
|
+
else {
|
|
20519
|
+
this.resetRightScoreOptions();
|
|
20520
|
+
}
|
|
20521
|
+
if (!visible) {
|
|
20522
|
+
return;
|
|
20523
|
+
}
|
|
20524
|
+
const currentValue = this.getScoreValue(type);
|
|
20525
|
+
const currentOption = this.findAvailableScoreOptionByValue(this.getScoreOptions(type), currentValue);
|
|
20526
|
+
this.$nextTick(() => {
|
|
20527
|
+
this.updateScoreSelectFocus(type, currentOption, true);
|
|
20528
|
+
});
|
|
20529
|
+
},
|
|
20530
|
+
handleScoreQueryChange(type, query) {
|
|
20531
|
+
const options = this.getScoreOptions(type);
|
|
20532
|
+
const matchedOption = this.findMatchedScoreOption(options, query);
|
|
20533
|
+
this.$nextTick(() => {
|
|
20534
|
+
this.updateScoreSelectFocus(type, matchedOption, false);
|
|
20535
|
+
});
|
|
20536
|
+
},
|
|
20537
|
+
resetScoreOptions(options, type) {
|
|
20442
20538
|
let otherRange = _$1.map(this.otherConditions, (item) => {
|
|
20443
20539
|
return {
|
|
20444
20540
|
min: _$1.get(item, "payload.minScore", 0),
|
|
@@ -20448,11 +20544,19 @@ var script$z = Vue.extend({
|
|
|
20448
20544
|
let currentMinScore = this.value.minScore == null ? 0 : this.value.minScore;
|
|
20449
20545
|
let currentMaxScore = this.value.maxScore == null ? this.totalScore : this.value.maxScore;
|
|
20450
20546
|
_$1.forEach(options, function (o) {
|
|
20451
|
-
|
|
20547
|
+
let disabledByOtherRange = _$1.some(otherRange, function (or) {
|
|
20452
20548
|
let condition_a = o.value >= or.min && o.value <= or.max;
|
|
20453
20549
|
let condition_b = o.value >= currentMinScore && o.value <= currentMaxScore;
|
|
20454
20550
|
return condition_a && condition_b;
|
|
20455
20551
|
});
|
|
20552
|
+
let disabledByCurrentRange = false;
|
|
20553
|
+
if (type === "left" && currentMaxScore != null) {
|
|
20554
|
+
disabledByCurrentRange = o.value > currentMaxScore;
|
|
20555
|
+
}
|
|
20556
|
+
if (type === "right" && currentMinScore != null) {
|
|
20557
|
+
disabledByCurrentRange = o.value < currentMinScore;
|
|
20558
|
+
}
|
|
20559
|
+
o.disabled = disabledByOtherRange || disabledByCurrentRange;
|
|
20456
20560
|
});
|
|
20457
20561
|
},
|
|
20458
20562
|
generateExpr() {
|
|
@@ -20460,6 +20564,58 @@ var script$z = Vue.extend({
|
|
|
20460
20564
|
let maxScore = this.value.maxScore;
|
|
20461
20565
|
return `${minScore} ${this.value.leftOperator} score and score ${this.value.rightOperator} ${maxScore}`;
|
|
20462
20566
|
},
|
|
20567
|
+
validateMinScore(rule, value, callback) {
|
|
20568
|
+
if (value == null || value === '') {
|
|
20569
|
+
callback(new Error(this.t('survey_creator.question.scoreRequiredTip')));
|
|
20570
|
+
return;
|
|
20571
|
+
}
|
|
20572
|
+
if (value < 1) {
|
|
20573
|
+
callback(new Error(this.t('survey_creator.question.scoreRequiredTip')));
|
|
20574
|
+
return;
|
|
20575
|
+
}
|
|
20576
|
+
if (value > this.totalScore) {
|
|
20577
|
+
callback(new Error(`${this.t('survey_creator.question.scoreExceedTotalTip')} ${this.totalScore}`));
|
|
20578
|
+
return;
|
|
20579
|
+
}
|
|
20580
|
+
if (this.value.maxScore != null && value > this.value.maxScore) {
|
|
20581
|
+
callback(new Error(this.t('survey_creator.question.minScoreGreaterThanMaxTip')));
|
|
20582
|
+
return;
|
|
20583
|
+
}
|
|
20584
|
+
callback();
|
|
20585
|
+
},
|
|
20586
|
+
validateMaxScore(rule, value, callback) {
|
|
20587
|
+
if (value == null || value === '') {
|
|
20588
|
+
callback(new Error(this.t('survey_creator.question.scoreRequiredTip')));
|
|
20589
|
+
return;
|
|
20590
|
+
}
|
|
20591
|
+
if (value < 1) {
|
|
20592
|
+
callback(new Error(this.t('survey_creator.question.scoreRequiredTip')));
|
|
20593
|
+
return;
|
|
20594
|
+
}
|
|
20595
|
+
if (value > this.totalScore) {
|
|
20596
|
+
callback(new Error(`${this.t('survey_creator.question.scoreExceedTotalTip')} ${this.totalScore}`));
|
|
20597
|
+
return;
|
|
20598
|
+
}
|
|
20599
|
+
if (this.value.minScore != null && value < this.value.minScore) {
|
|
20600
|
+
callback(new Error(this.t('survey_creator.question.maxScoreLessThanMinTip')));
|
|
20601
|
+
return;
|
|
20602
|
+
}
|
|
20603
|
+
callback();
|
|
20604
|
+
},
|
|
20605
|
+
handleMinScoreChange(value) {
|
|
20606
|
+
if (this.value.maxScore != null && value > this.value.maxScore) {
|
|
20607
|
+
this.value.maxScore = value;
|
|
20608
|
+
}
|
|
20609
|
+
this.resetLeftScoreOptions();
|
|
20610
|
+
this.resetRightScoreOptions();
|
|
20611
|
+
},
|
|
20612
|
+
handleMaxScoreChange(value) {
|
|
20613
|
+
if (this.value.minScore != null && value < this.value.minScore) {
|
|
20614
|
+
this.value.maxScore = this.value.minScore;
|
|
20615
|
+
}
|
|
20616
|
+
this.resetLeftScoreOptions();
|
|
20617
|
+
this.resetRightScoreOptions();
|
|
20618
|
+
},
|
|
20463
20619
|
},
|
|
20464
20620
|
});
|
|
20465
20621
|
|
|
@@ -20467,12 +20623,18 @@ var script$z = Vue.extend({
|
|
|
20467
20623
|
const __vue_script__$z = script$z;
|
|
20468
20624
|
|
|
20469
20625
|
/* template */
|
|
20470
|
-
var __vue_render__$y = 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":
|
|
20471
|
-
|
|
20472
|
-
|
|
20473
|
-
|
|
20474
|
-
|
|
20475
|
-
|
|
20626
|
+
var __vue_render__$y = 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":[
|
|
20627
|
+
{
|
|
20628
|
+
required: true,
|
|
20629
|
+
type: 'number',
|
|
20630
|
+
trigger: 'change',
|
|
20631
|
+
message: _vm.t('survey_creator.question.scoreRequiredTip'),
|
|
20632
|
+
},
|
|
20633
|
+
{
|
|
20634
|
+
validator: _vm.validateMinScore,
|
|
20635
|
+
trigger: 'change',
|
|
20636
|
+
}
|
|
20637
|
+
]}},[_c('Select',{ref:"leftScoreSelect",attrs:{"filterable":"","placeholder":_vm.t('survey_creator.question.selectScore')},on:{"on-open-change":function($event){return _vm.handleScoreSelectOpenChange('left', $event)},"on-change":_vm.handleMinScoreChange,"on-query-change":function($event){return _vm.handleScoreQueryChange('left', $event)}},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,"label":String(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":{
|
|
20476
20638
|
required: true,
|
|
20477
20639
|
trigger: 'change',
|
|
20478
20640
|
message: _vm.t('survey_creator.question.notEmpty'),
|
|
@@ -20480,22 +20642,28 @@ var __vue_render__$y = function () {var _vm=this;var _h=_vm.$createElement;var _
|
|
|
20480
20642
|
required: true,
|
|
20481
20643
|
trigger: 'change',
|
|
20482
20644
|
message: _vm.t('survey_creator.question.notEmpty'),
|
|
20483
|
-
}}},[_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":
|
|
20484
|
-
|
|
20485
|
-
|
|
20486
|
-
|
|
20487
|
-
|
|
20488
|
-
|
|
20645
|
+
}}},[_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":[
|
|
20646
|
+
{
|
|
20647
|
+
required: true,
|
|
20648
|
+
type: 'number',
|
|
20649
|
+
trigger: 'change',
|
|
20650
|
+
message: _vm.t('survey_creator.question.scoreRequiredTip'),
|
|
20651
|
+
},
|
|
20652
|
+
{
|
|
20653
|
+
validator: _vm.validateMaxScore,
|
|
20654
|
+
trigger: 'change',
|
|
20655
|
+
}
|
|
20656
|
+
]}},[_c('Select',{ref:"rightScoreSelect",attrs:{"filterable":"","placeholder":_vm.t('survey_creator.question.selectScore')},on:{"on-open-change":function($event){return _vm.handleScoreSelectOpenChange('right', $event)},"on-change":_vm.handleMaxScoreChange,"on-query-change":function($event){return _vm.handleScoreQueryChange('right', $event)}},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,"label":String(score.value),"disabled":score.disabled}},[_vm._v("\n "+_vm._s(score.value)+"\n ")])}),1)],1)],1)],1)};
|
|
20489
20657
|
var __vue_staticRenderFns__$y = [];
|
|
20490
20658
|
|
|
20491
20659
|
/* style */
|
|
20492
20660
|
const __vue_inject_styles__$z = function (inject) {
|
|
20493
20661
|
if (!inject) return
|
|
20494
|
-
inject("data-v-
|
|
20662
|
+
inject("data-v-514fa778_0", { source: ".label[data-v-514fa778]{text-align:right;margin-bottom:24px}[data-v-514fa778] .operator .ivu-select-selected-value{height:28px;line-height:28px}", map: undefined, media: undefined });
|
|
20495
20663
|
|
|
20496
20664
|
};
|
|
20497
20665
|
/* scoped */
|
|
20498
|
-
const __vue_scope_id__$z = "data-v-
|
|
20666
|
+
const __vue_scope_id__$z = "data-v-514fa778";
|
|
20499
20667
|
/* module identifier */
|
|
20500
20668
|
const __vue_module_identifier__$z = undefined;
|
|
20501
20669
|
/* functional template */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wg-npm/survey-creator",
|
|
3
|
-
"version": "1.78.
|
|
3
|
+
"version": "1.78.04031900",
|
|
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": "1.78.
|
|
16
|
-
"@wg-npm/survey-service-api": "1.78.
|
|
15
|
+
"@wg-npm/survey-core": "1.78.04031900",
|
|
16
|
+
"@wg-npm/survey-service-api": "1.78.04031900",
|
|
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": "1.78.
|
|
42
|
-
"@wg-npm/survey-service-api": "1.78.
|
|
41
|
+
"@wg-npm/survey-core": "1.78.04031900",
|
|
42
|
+
"@wg-npm/survey-service-api": "1.78.04031900",
|
|
43
43
|
"acorn": "^7.3.1",
|
|
44
44
|
"axios": "^0.19.2",
|
|
45
45
|
"babelrc-rollup": "^3.0.0",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"publishConfig": {
|
|
80
80
|
"access": "public"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "6ffca5612664222a83c5f7cc934558799eeeb523",
|
|
83
83
|
"rollup": {
|
|
84
84
|
"external": [
|
|
85
85
|
"vue",
|
|
@@ -8,22 +8,33 @@
|
|
|
8
8
|
<Col :span="4">
|
|
9
9
|
<FormItem
|
|
10
10
|
:prop="`evaluationItems[${itemIndex}].conditions[${index}].payload.minScore`"
|
|
11
|
-
:rules="
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
:rules="[
|
|
12
|
+
{
|
|
13
|
+
required: true,
|
|
14
|
+
type: 'number',
|
|
15
|
+
trigger: 'change',
|
|
16
|
+
message: t('survey_creator.question.scoreRequiredTip'),
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
validator: validateMinScore,
|
|
20
|
+
trigger: 'change',
|
|
21
|
+
}
|
|
22
|
+
]"
|
|
17
23
|
>
|
|
18
24
|
<Select
|
|
25
|
+
ref="leftScoreSelect"
|
|
19
26
|
v-model="value.minScore"
|
|
27
|
+
filterable
|
|
20
28
|
:placeholder="t('survey_creator.question.selectScore')"
|
|
21
|
-
@on-open-change="
|
|
29
|
+
@on-open-change="handleScoreSelectOpenChange('left', $event)"
|
|
30
|
+
@on-change="handleMinScoreChange"
|
|
31
|
+
@on-query-change="handleScoreQueryChange('left', $event)"
|
|
22
32
|
>
|
|
23
33
|
<Option
|
|
24
34
|
v-for="score in leftScores"
|
|
25
35
|
:value="score.value"
|
|
26
36
|
:key="score.value"
|
|
37
|
+
:label="String(score.value)"
|
|
27
38
|
:disabled="score.disabled"
|
|
28
39
|
>
|
|
29
40
|
{{ score.value }}
|
|
@@ -89,22 +100,33 @@
|
|
|
89
100
|
<Col :span="4">
|
|
90
101
|
<FormItem
|
|
91
102
|
:prop="`evaluationItems[${itemIndex}].conditions[${index}].payload.maxScore`"
|
|
92
|
-
:rules="
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
103
|
+
:rules="[
|
|
104
|
+
{
|
|
105
|
+
required: true,
|
|
106
|
+
type: 'number',
|
|
107
|
+
trigger: 'change',
|
|
108
|
+
message: t('survey_creator.question.scoreRequiredTip'),
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
validator: validateMaxScore,
|
|
112
|
+
trigger: 'change',
|
|
113
|
+
}
|
|
114
|
+
]"
|
|
98
115
|
>
|
|
99
116
|
<Select
|
|
117
|
+
ref="rightScoreSelect"
|
|
100
118
|
v-model="value.maxScore"
|
|
119
|
+
filterable
|
|
101
120
|
:placeholder="t('survey_creator.question.selectScore')"
|
|
102
|
-
@on-open-change="
|
|
121
|
+
@on-open-change="handleScoreSelectOpenChange('right', $event)"
|
|
122
|
+
@on-change="handleMaxScoreChange"
|
|
123
|
+
@on-query-change="handleScoreQueryChange('right', $event)"
|
|
103
124
|
>
|
|
104
125
|
<Option
|
|
105
126
|
v-for="score in rightScores"
|
|
106
127
|
:value="score.value"
|
|
107
128
|
:key="score.value"
|
|
129
|
+
:label="String(score.value)"
|
|
108
130
|
:disabled="score.disabled"
|
|
109
131
|
>
|
|
110
132
|
{{ score.value }}
|
|
@@ -116,15 +138,7 @@
|
|
|
116
138
|
</template>
|
|
117
139
|
<script lang="ts">
|
|
118
140
|
import Vue from "vue";
|
|
119
|
-
import {
|
|
120
|
-
Col,
|
|
121
|
-
FormItem,
|
|
122
|
-
InputNumber,
|
|
123
|
-
Message,
|
|
124
|
-
Option,
|
|
125
|
-
Row,
|
|
126
|
-
Select,
|
|
127
|
-
} from "view-design";
|
|
141
|
+
import { Col, FormItem, Message, Option, Row, Select } from "view-design";
|
|
128
142
|
import _ from "lodash";
|
|
129
143
|
import ExprMixin from "./expr-mixin";
|
|
130
144
|
import LocaleMixin from "../../../../../mixins/locale-mixin";
|
|
@@ -141,7 +155,6 @@ export default Vue.extend({
|
|
|
141
155
|
Select,
|
|
142
156
|
Option,
|
|
143
157
|
FormItem,
|
|
144
|
-
InputNumber,
|
|
145
158
|
},
|
|
146
159
|
data() {
|
|
147
160
|
return {
|
|
@@ -216,7 +229,130 @@ export default Vue.extend({
|
|
|
216
229
|
}
|
|
217
230
|
);
|
|
218
231
|
},
|
|
219
|
-
|
|
232
|
+
resetLeftScoreOptions() {
|
|
233
|
+
this.resetScoreOptions(this.leftScores, "left");
|
|
234
|
+
},
|
|
235
|
+
resetRightScoreOptions() {
|
|
236
|
+
this.resetScoreOptions(this.rightScores, "right");
|
|
237
|
+
},
|
|
238
|
+
getScoreOptions(type): any[] {
|
|
239
|
+
return type === "left" ? this.leftScores : this.rightScores;
|
|
240
|
+
},
|
|
241
|
+
getScoreValue(type) {
|
|
242
|
+
return type === "left" ? this.value.minScore : this.value.maxScore;
|
|
243
|
+
},
|
|
244
|
+
getScoreSelectRef(type) {
|
|
245
|
+
return type === "left"
|
|
246
|
+
? this.$refs.leftScoreSelect
|
|
247
|
+
: this.$refs.rightScoreSelect;
|
|
248
|
+
},
|
|
249
|
+
findAvailableScoreOptionByValue(options: any[], value) {
|
|
250
|
+
return _.find(options, (option: any) => {
|
|
251
|
+
return !option.disabled && option.value === value;
|
|
252
|
+
});
|
|
253
|
+
},
|
|
254
|
+
findMatchedScoreOption(options: any[], query) {
|
|
255
|
+
const normalizedQuery = String(query == null ? "" : query).trim();
|
|
256
|
+
const enabledOptions = _.filter(options, (option: any) => !option.disabled);
|
|
257
|
+
|
|
258
|
+
if (!enabledOptions.length) {
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (!normalizedQuery) {
|
|
263
|
+
return enabledOptions[0];
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return (
|
|
267
|
+
_.find(
|
|
268
|
+
enabledOptions,
|
|
269
|
+
(option: any) => String(option.value) === normalizedQuery
|
|
270
|
+
) ||
|
|
271
|
+
_.find(
|
|
272
|
+
enabledOptions,
|
|
273
|
+
(option: any) => String(option.value).indexOf(normalizedQuery) === 0
|
|
274
|
+
) ||
|
|
275
|
+
null
|
|
276
|
+
);
|
|
277
|
+
},
|
|
278
|
+
updateScoreSelectFocus(type, targetValue: any, fallbackToFirst = false) {
|
|
279
|
+
const select = this.getScoreSelectRef(type);
|
|
280
|
+
if (!select) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const matchedOption = targetValue;
|
|
285
|
+
|
|
286
|
+
if (!matchedOption) {
|
|
287
|
+
if (!fallbackToFirst) {
|
|
288
|
+
select.focusIndex = -1;
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const firstEnabledOption = _.find(
|
|
293
|
+
this.getScoreOptions(type),
|
|
294
|
+
(option: any) => !option.disabled
|
|
295
|
+
);
|
|
296
|
+
if (!firstEnabledOption) {
|
|
297
|
+
select.focusIndex = -1;
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
return this.updateScoreSelectFocus(type, firstEnabledOption, false);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const focusIndex = _.findIndex(select.flatOptions, (option) => {
|
|
304
|
+
const propsData =
|
|
305
|
+
option &&
|
|
306
|
+
option.componentOptions &&
|
|
307
|
+
option.componentOptions.propsData;
|
|
308
|
+
return propsData && propsData.value === matchedOption.value;
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
if (focusIndex === -1) {
|
|
312
|
+
if (fallbackToFirst) {
|
|
313
|
+
const firstEnabledOption: any = _.find(
|
|
314
|
+
this.getScoreOptions(type),
|
|
315
|
+
(option: any) => !option.disabled
|
|
316
|
+
);
|
|
317
|
+
const matchedValue = matchedOption ? matchedOption.value : null;
|
|
318
|
+
if (firstEnabledOption && firstEnabledOption.value !== matchedValue) {
|
|
319
|
+
this.updateScoreSelectFocus(type, firstEnabledOption, false);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
select.focusIndex = focusIndex;
|
|
326
|
+
},
|
|
327
|
+
handleScoreSelectOpenChange(type, visible) {
|
|
328
|
+
if (type === "left") {
|
|
329
|
+
this.resetLeftScoreOptions();
|
|
330
|
+
} else {
|
|
331
|
+
this.resetRightScoreOptions();
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
if (!visible) {
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
const currentValue = this.getScoreValue(type);
|
|
339
|
+
const currentOption = this.findAvailableScoreOptionByValue(
|
|
340
|
+
this.getScoreOptions(type),
|
|
341
|
+
currentValue
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
this.$nextTick(() => {
|
|
345
|
+
this.updateScoreSelectFocus(type, currentOption, true);
|
|
346
|
+
});
|
|
347
|
+
},
|
|
348
|
+
handleScoreQueryChange(type, query) {
|
|
349
|
+
const options = this.getScoreOptions(type);
|
|
350
|
+
const matchedOption = this.findMatchedScoreOption(options, query);
|
|
351
|
+
this.$nextTick(() => {
|
|
352
|
+
this.updateScoreSelectFocus(type, matchedOption, false);
|
|
353
|
+
});
|
|
354
|
+
},
|
|
355
|
+
resetScoreOptions(options, type) {
|
|
220
356
|
let otherRange = _.map(this.otherConditions, (item) => {
|
|
221
357
|
return {
|
|
222
358
|
// @ts-ignore
|
|
@@ -232,13 +368,23 @@ export default Vue.extend({
|
|
|
232
368
|
this.value.maxScore == null ? this.totalScore : this.value.maxScore;
|
|
233
369
|
|
|
234
370
|
_.forEach(options, function (o) {
|
|
235
|
-
|
|
371
|
+
let disabledByOtherRange = _.some(otherRange, function (or) {
|
|
236
372
|
let condition_a = o.value >= or.min && o.value <= or.max;
|
|
237
373
|
let condition_b =
|
|
238
374
|
o.value >= currentMinScore && o.value <= currentMaxScore;
|
|
239
375
|
|
|
240
376
|
return condition_a && condition_b;
|
|
241
377
|
});
|
|
378
|
+
|
|
379
|
+
let disabledByCurrentRange = false;
|
|
380
|
+
if (type === "left" && currentMaxScore != null) {
|
|
381
|
+
disabledByCurrentRange = o.value > currentMaxScore;
|
|
382
|
+
}
|
|
383
|
+
if (type === "right" && currentMinScore != null) {
|
|
384
|
+
disabledByCurrentRange = o.value < currentMinScore;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
o.disabled = disabledByOtherRange || disabledByCurrentRange;
|
|
242
388
|
});
|
|
243
389
|
},
|
|
244
390
|
generateExpr() {
|
|
@@ -246,6 +392,70 @@ export default Vue.extend({
|
|
|
246
392
|
let maxScore = this.value.maxScore;
|
|
247
393
|
return `${minScore} ${this.value.leftOperator} score and score ${this.value.rightOperator} ${maxScore}`;
|
|
248
394
|
},
|
|
395
|
+
validateMinScore(rule, value, callback) {
|
|
396
|
+
if (value == null || value === '') {
|
|
397
|
+
callback(new Error(this.t('survey_creator.question.scoreRequiredTip')));
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
if (value < 1) {
|
|
401
|
+
callback(new Error(this.t('survey_creator.question.scoreRequiredTip')));
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
if (value > this.totalScore) {
|
|
405
|
+
callback(
|
|
406
|
+
new Error(
|
|
407
|
+
`${this.t('survey_creator.question.scoreExceedTotalTip')} ${this.totalScore}`
|
|
408
|
+
)
|
|
409
|
+
);
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
if (this.value.maxScore != null && value > this.value.maxScore) {
|
|
413
|
+
callback(
|
|
414
|
+
new Error(this.t('survey_creator.question.minScoreGreaterThanMaxTip'))
|
|
415
|
+
);
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
callback();
|
|
419
|
+
},
|
|
420
|
+
validateMaxScore(rule, value, callback) {
|
|
421
|
+
if (value == null || value === '') {
|
|
422
|
+
callback(new Error(this.t('survey_creator.question.scoreRequiredTip')));
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
if (value < 1) {
|
|
426
|
+
callback(new Error(this.t('survey_creator.question.scoreRequiredTip')));
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
if (value > this.totalScore) {
|
|
430
|
+
callback(
|
|
431
|
+
new Error(
|
|
432
|
+
`${this.t('survey_creator.question.scoreExceedTotalTip')} ${this.totalScore}`
|
|
433
|
+
)
|
|
434
|
+
);
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
if (this.value.minScore != null && value < this.value.minScore) {
|
|
438
|
+
callback(
|
|
439
|
+
new Error(this.t('survey_creator.question.maxScoreLessThanMinTip'))
|
|
440
|
+
);
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
callback();
|
|
444
|
+
},
|
|
445
|
+
handleMinScoreChange(value) {
|
|
446
|
+
if (this.value.maxScore != null && value > this.value.maxScore) {
|
|
447
|
+
this.value.maxScore = value;
|
|
448
|
+
}
|
|
449
|
+
this.resetLeftScoreOptions();
|
|
450
|
+
this.resetRightScoreOptions();
|
|
451
|
+
},
|
|
452
|
+
handleMaxScoreChange(value) {
|
|
453
|
+
if (this.value.minScore != null && value < this.value.minScore) {
|
|
454
|
+
this.value.maxScore = this.value.minScore;
|
|
455
|
+
}
|
|
456
|
+
this.resetLeftScoreOptions();
|
|
457
|
+
this.resetRightScoreOptions();
|
|
458
|
+
},
|
|
249
459
|
},
|
|
250
460
|
});
|
|
251
461
|
</script>
|
package/src/locale/lang/en-US.ts
CHANGED
|
@@ -89,6 +89,9 @@ export default {
|
|
|
89
89
|
titleRequiredTip: "Please Input Question",
|
|
90
90
|
inputEnabledTip: "The user can enter after selecting this item",
|
|
91
91
|
scoreRequiredTip: "Score Required",
|
|
92
|
+
scoreExceedTotalTip: "Score cannot exceed total score",
|
|
93
|
+
minScoreGreaterThanMaxTip: "Minimum score cannot be greater than maximum score",
|
|
94
|
+
maxScoreLessThanMinTip: "Maximum score cannot be less than minimum score",
|
|
92
95
|
subQuestionRequiredTip: "Sub Question Required",
|
|
93
96
|
optionalRequiredTip: "Optional Required",
|
|
94
97
|
commitRequiredTip: "Commit Required",
|
package/src/locale/lang/zh-CN.ts
CHANGED
|
@@ -88,6 +88,9 @@ export default {
|
|
|
88
88
|
inputEnabledTip: "用户选中该项后可输入",
|
|
89
89
|
textTitleRequiredTip: "请填写文字说明",
|
|
90
90
|
scoreRequiredTip: "分值不能为空",
|
|
91
|
+
scoreExceedTotalTip: "分数不能超过总分",
|
|
92
|
+
minScoreGreaterThanMaxTip: "最小分值不能大于最大分值",
|
|
93
|
+
maxScoreLessThanMinTip: "最大分值不能小于最小分值",
|
|
91
94
|
subQuestionRequiredTip: "子題不能为空",
|
|
92
95
|
optionalRequiredTip: "选项不能为空",
|
|
93
96
|
commitRequiredTip: "描述不能为空",
|