@wg-npm/survey-creator 0.3.6202 → 0.3.7684
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.
- package/dist/survey-creator.esm.js +21 -4
- package/package.json +5 -5
- package/src/components/common/question/evaluation/expr-if.vue +118 -110
- package/src/components/common/question/evaluation/star.vue +8 -0
- package/src/components/editor/forms/evaluation/expr/score.vue +4 -3
- package/src/components/survey-creator.vue +1 -1
|
@@ -1612,6 +1612,14 @@ var script$u = Vue.extend({
|
|
|
1612
1612
|
required: true
|
|
1613
1613
|
}
|
|
1614
1614
|
},
|
|
1615
|
+
watch: {
|
|
1616
|
+
item: {
|
|
1617
|
+
handler(val) {
|
|
1618
|
+
this.getDesc();
|
|
1619
|
+
},
|
|
1620
|
+
deep: true
|
|
1621
|
+
}
|
|
1622
|
+
},
|
|
1615
1623
|
methods: {
|
|
1616
1624
|
getDesc() {
|
|
1617
1625
|
let max = this.item.range.max || null;
|
|
@@ -1798,6 +1806,14 @@ var script$t = Vue.extend({
|
|
|
1798
1806
|
return _.cloneDeep(this.$rootComponent.currentSurvey.questions);
|
|
1799
1807
|
},
|
|
1800
1808
|
},
|
|
1809
|
+
watch: {
|
|
1810
|
+
conditions: {
|
|
1811
|
+
handler(val) {
|
|
1812
|
+
this.initialDesc();
|
|
1813
|
+
},
|
|
1814
|
+
deep: true
|
|
1815
|
+
}
|
|
1816
|
+
},
|
|
1801
1817
|
methods: {
|
|
1802
1818
|
getDesc(condition) {
|
|
1803
1819
|
let payload = condition.payload;
|
|
@@ -3181,7 +3197,8 @@ var script$d = Vue.extend({
|
|
|
3181
3197
|
let otherEvaluationItems = _.filter(_.map(this.evaluationItems, (item, index) => {
|
|
3182
3198
|
return _.extend({}, item, { index: index });
|
|
3183
3199
|
}), (item) => item.index != this.itemIndex);
|
|
3184
|
-
|
|
3200
|
+
const conditions = _.flatMap(otherEvaluationItems, item => _.get(item, "conditions", []));
|
|
3201
|
+
return _.filter(conditions, (item) => _.get(item, "type") == "SCORE");
|
|
3185
3202
|
},
|
|
3186
3203
|
},
|
|
3187
3204
|
methods: {
|
|
@@ -3304,11 +3321,11 @@ var __vue_staticRenderFns__$d = [];
|
|
|
3304
3321
|
/* style */
|
|
3305
3322
|
const __vue_inject_styles__$d = function (inject) {
|
|
3306
3323
|
if (!inject) return
|
|
3307
|
-
inject("data-v-
|
|
3324
|
+
inject("data-v-7c338c4d_0", { source: ".label[data-v-7c338c4d]{text-align:right;margin-bottom:24px}[data-v-7c338c4d] .operator .ivu-select-selected-value{height:28px;line-height:28px}", map: undefined, media: undefined });
|
|
3308
3325
|
|
|
3309
3326
|
};
|
|
3310
3327
|
/* scoped */
|
|
3311
|
-
const __vue_scope_id__$d = "data-v-
|
|
3328
|
+
const __vue_scope_id__$d = "data-v-7c338c4d";
|
|
3312
3329
|
/* module identifier */
|
|
3313
3330
|
const __vue_module_identifier__$d = undefined;
|
|
3314
3331
|
/* functional template */
|
|
@@ -4369,7 +4386,7 @@ var script$1 = Vue.extend({
|
|
|
4369
4386
|
}
|
|
4370
4387
|
this.primaryLanguage = _.camelCase(this.currentSurvey.options.primaryLanguage);
|
|
4371
4388
|
if (this.showQuestionWhenPageLoad) {
|
|
4372
|
-
const question = _.
|
|
4389
|
+
const question = _.find(this.currentSurvey?.questions, questions => { return questions.type === this.showQuestionType; });
|
|
4373
4390
|
if (_.isUndefined(question)) {
|
|
4374
4391
|
this.createQuestion(this.showQuestionType);
|
|
4375
4392
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wg-npm/survey-creator",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7684",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"lint-fix": "eslint \"**/*.ts\" \"**/*.vue\" --fix --no-error-on-unmatched-pattern"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@wg-npm/survey-core": "0.3.
|
|
16
|
-
"@wg-npm/survey-service-api": "0.3.
|
|
15
|
+
"@wg-npm/survey-core": "0.3.7684",
|
|
16
|
+
"@wg-npm/survey-service-api": "0.3.7684",
|
|
17
17
|
"axios": "^0.19.2",
|
|
18
18
|
"camelcase": "^6.0.0",
|
|
19
19
|
"deepmerge": "^4.2.2",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"@typescript-eslint/eslint-plugin": "^3.6.0",
|
|
39
39
|
"@typescript-eslint/parser": "^3.6.0",
|
|
40
40
|
"@vue/eslint-config-prettier": "^6.0.0",
|
|
41
|
-
"@wg-npm/survey-core": "0.3.
|
|
42
|
-
"@wg-npm/survey-service-api": "0.3.
|
|
41
|
+
"@wg-npm/survey-core": "0.3.7684",
|
|
42
|
+
"@wg-npm/survey-service-api": "0.3.7684",
|
|
43
43
|
"acorn": "^7.3.1",
|
|
44
44
|
"axios": "^0.19.2",
|
|
45
45
|
"babelrc-rollup": "^3.0.0",
|
|
@@ -1,117 +1,125 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
<Tooltip max-width="200">
|
|
3
|
+
<span v-html="this.descTitle" slot="content"></span>
|
|
4
|
+
<span v-html="this.desc" class="desc"> </span>
|
|
5
|
+
</Tooltip>
|
|
6
6
|
</template>
|
|
7
7
|
|
|
8
8
|
<script lang="ts">
|
|
9
|
-
const SPLIT_LENGTH = 60;
|
|
10
|
-
import Vue from "vue";
|
|
11
|
-
import {
|
|
12
|
-
import LocaleMixin from "../../../../mixins/locale-mixin";
|
|
13
|
-
import _ from "lodash";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
9
|
+
const SPLIT_LENGTH = 60;
|
|
10
|
+
import Vue from "vue";
|
|
11
|
+
import {ExprConditionType} from "@wg-npm/survey-core/src/models";
|
|
12
|
+
import LocaleMixin from "../../../../mixins/locale-mixin";
|
|
13
|
+
import _ from "lodash";
|
|
14
|
+
import {Tooltip} from "view-design";
|
|
15
|
+
import {ExprEvaluationQuestion} from "@wg-npm/survey-core/src/expr-evaluation-question";
|
|
16
16
|
|
|
17
|
-
export default Vue.extend({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
[
|
|
49
|
-
payload.minScore,
|
|
50
|
-
payload.leftOperator,
|
|
51
|
-
payload.rightOperator,
|
|
52
|
-
payload.maxScore,
|
|
53
|
-
]
|
|
54
|
-
);
|
|
55
|
-
} else {
|
|
56
|
-
let numbers = new ExprEvaluationQuestion(
|
|
57
|
-
this.questions,
|
|
58
|
-
payload.scope
|
|
59
|
-
).calculateNumbers();
|
|
60
|
-
let scope = _.join(
|
|
61
|
-
_.map(numbers, (number) => {
|
|
62
|
-
if (_.isArray(_.head(number))) {
|
|
63
|
-
return _.join(
|
|
64
|
-
_.map(number, (e) => _.join(e, "-")),
|
|
65
|
-
", "
|
|
66
|
-
);
|
|
17
|
+
export default Vue.extend({
|
|
18
|
+
name: "expr-if",
|
|
19
|
+
mixins: [LocaleMixin],
|
|
20
|
+
components: {Tooltip},
|
|
21
|
+
inject: ["$rootComponent"],
|
|
22
|
+
data() {
|
|
23
|
+
return {
|
|
24
|
+
desc: "",
|
|
25
|
+
descTitle: "",
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
created() {
|
|
29
|
+
this.initialDesc();
|
|
30
|
+
},
|
|
31
|
+
props: {
|
|
32
|
+
conditions: {
|
|
33
|
+
type: Array,
|
|
34
|
+
required: true,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
computed: {
|
|
38
|
+
questions() {
|
|
39
|
+
return _.cloneDeep(this.$rootComponent.currentSurvey.questions);
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
watch: {
|
|
43
|
+
conditions: {
|
|
44
|
+
handler(val) {
|
|
45
|
+
this.initialDesc();
|
|
46
|
+
},
|
|
47
|
+
deep: true
|
|
67
48
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
49
|
+
},
|
|
50
|
+
methods: {
|
|
51
|
+
getDesc(condition) {
|
|
52
|
+
let payload = condition.payload;
|
|
53
|
+
if (condition.type == ExprConditionType.SCORE) {
|
|
54
|
+
return this.t(
|
|
55
|
+
"survey_creator.question.evaluation.condition.score_template",
|
|
56
|
+
[
|
|
57
|
+
payload.minScore,
|
|
58
|
+
payload.leftOperator,
|
|
59
|
+
payload.rightOperator,
|
|
60
|
+
payload.maxScore,
|
|
61
|
+
]
|
|
62
|
+
);
|
|
63
|
+
} else {
|
|
64
|
+
let numbers = new ExprEvaluationQuestion(
|
|
65
|
+
this.questions,
|
|
66
|
+
payload.scope
|
|
67
|
+
).calculateNumbers();
|
|
68
|
+
let scope = _.join(
|
|
69
|
+
_.map(numbers, (number) => {
|
|
70
|
+
if (_.isArray(_.head(number))) {
|
|
71
|
+
return _.join(
|
|
72
|
+
_.map(number, (e) => _.join(e, "-")),
|
|
73
|
+
", "
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
return _.join(number, "-");
|
|
77
|
+
}),
|
|
78
|
+
", "
|
|
79
|
+
);
|
|
80
|
+
if (condition.type == ExprConditionType.ASSIGN) {
|
|
81
|
+
return this.t(
|
|
82
|
+
"survey_creator.question.evaluation.condition.assign_template",
|
|
83
|
+
[
|
|
84
|
+
scope,
|
|
85
|
+
_.join(payload.values, "、"),
|
|
86
|
+
_.unescape(payload.operator),
|
|
87
|
+
payload.size,
|
|
88
|
+
]
|
|
89
|
+
);
|
|
90
|
+
} else if (condition.type == ExprConditionType.AUTO) {
|
|
91
|
+
return this.t(
|
|
92
|
+
"survey_creator.question.evaluation.condition.auto_template",
|
|
93
|
+
[scope, _.join(payload.values, "、")]
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
return "";
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
getChineseLength(_str) {
|
|
100
|
+
_str = _.trim(_str);
|
|
101
|
+
let strLength = _str.length;
|
|
102
|
+
if (!strLength) {
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
let chinese = _str.match(/[\u4e00-\u9fa5]/g);
|
|
106
|
+
return chinese ? chinese.length : 0;
|
|
107
|
+
},
|
|
108
|
+
initialDesc() {
|
|
109
|
+
let desc = "";
|
|
110
|
+
let ds = _.map(this.conditions, (c) => {
|
|
111
|
+
return this.getDesc(c);
|
|
112
|
+
});
|
|
113
|
+
desc = _.join(ds, "<br>");
|
|
114
|
+
this.desc = desc;
|
|
115
|
+
let strLength = desc.length;
|
|
116
|
+
let cLength = this.getChineseLength(desc.substring(0, SPLIT_LENGTH));
|
|
117
|
+
if (strLength > SPLIT_LENGTH) {
|
|
118
|
+
this.desc =
|
|
119
|
+
desc.substring(0, SPLIT_LENGTH - _.ceil(cLength / 2)) + "...";
|
|
120
|
+
}
|
|
121
|
+
this.descTitle = desc;
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
});
|
|
117
125
|
</script>
|
|
@@ -164,9 +164,9 @@ export default Vue.extend({
|
|
|
164
164
|
}),
|
|
165
165
|
(item) => item.index != this.itemIndex
|
|
166
166
|
);
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
(item) => item
|
|
167
|
+
const conditions = _.flatMap(otherEvaluationItems, item=>_.get(item,"conditions",[]));
|
|
168
|
+
return _.filter(conditions,
|
|
169
|
+
(item) => _.get(item,"type") == ExprConditionType.SCORE
|
|
170
170
|
);
|
|
171
171
|
},
|
|
172
172
|
},
|
|
@@ -184,6 +184,7 @@ export default Vue.extend({
|
|
|
184
184
|
})
|
|
185
185
|
);
|
|
186
186
|
},
|
|
187
|
+
//todo 此功能暂未启用
|
|
187
188
|
getUsableRanges() {
|
|
188
189
|
let usedRange = _.map(this.otherConditions, (item) => {
|
|
189
190
|
return [item.payload.minScore, item.payload.maxScore];
|
|
@@ -194,7 +194,7 @@
|
|
|
194
194
|
this.primaryLanguage = _.camelCase(this.currentSurvey.options.primaryLanguage);
|
|
195
195
|
|
|
196
196
|
if (this.showQuestionWhenPageLoad) {
|
|
197
|
-
const question = _.
|
|
197
|
+
const question = _.find(this.currentSurvey?.questions, questions=> { return questions.type === this.showQuestionType})
|
|
198
198
|
if (_.isUndefined(question)) {
|
|
199
199
|
this.createQuestion(this.showQuestionType)
|
|
200
200
|
} else {
|