@wg-npm/survey-creator 0.3.13 → 0.3.377-8.develop
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 +893 -667
- package/package.json +5 -5
- package/src/components/common/question/evaluation/expr-if.vue +55 -30
- package/src/components/editor/forms/evaluation/expr/auto.vue +1 -1
- package/src/components/editor/forms/evaluation/expr/condition.vue +61 -48
- package/src/components/editor/forms/evaluation/expr/if.vue +252 -164
- package/src/components/editor/forms/evaluation/expr/score.vue +135 -0
- package/src/locale/index.ts +1 -1
- package/src/locale/lang/en-US.ts +174 -170
- package/src/locale/lang/zh-CN.ts +174 -171
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.3778.develop",
|
|
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.3778.develop",
|
|
16
|
+
"@wg-npm/survey-service-api": "0.3.3778.develop",
|
|
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.3778.develop",
|
|
42
|
+
"@wg-npm/survey-service-api": "0.3.3778.develop",
|
|
43
43
|
"acorn": "^7.3.1",
|
|
44
44
|
"axios": "^0.19.2",
|
|
45
45
|
"babelrc-rollup": "^3.0.0",
|
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<Tooltip max-width="200">
|
|
3
3
|
<span v-html="this.descTitle" slot="content"></span>
|
|
4
|
-
<span v-html="this.desc" class="desc">
|
|
5
|
-
</span>
|
|
4
|
+
<span v-html="this.desc" class="desc"> </span>
|
|
6
5
|
</Tooltip>
|
|
7
6
|
</template>
|
|
8
7
|
|
|
9
8
|
<script lang="ts">
|
|
10
9
|
const SPLIT_LENGTH = 60;
|
|
11
10
|
import Vue from "vue";
|
|
12
|
-
import {ExprConditionType} from "@wg-npm/survey-core/src/models";
|
|
11
|
+
import { ExprConditionType } from "@wg-npm/survey-core/src/models";
|
|
13
12
|
import LocaleMixin from "../../../../mixins/locale-mixin";
|
|
14
13
|
import _ from "lodash";
|
|
15
|
-
import {Tooltip} from "view-design";
|
|
16
|
-
import {ExprEvaluationQuestion} from "@wg-npm/survey-core/src/expr-evaluation-question";
|
|
17
|
-
|
|
14
|
+
import { Tooltip } from "view-design";
|
|
15
|
+
import { ExprEvaluationQuestion } from "@wg-npm/survey-core/src/expr-evaluation-question";
|
|
18
16
|
|
|
19
17
|
export default Vue.extend({
|
|
20
18
|
name: "expr-if",
|
|
21
19
|
mixins: [LocaleMixin],
|
|
22
|
-
components: {Tooltip},
|
|
20
|
+
components: { Tooltip },
|
|
23
21
|
inject: ["$rootComponent"],
|
|
24
22
|
data() {
|
|
25
23
|
return {
|
|
26
24
|
desc: "",
|
|
27
|
-
descTitle: ""
|
|
28
|
-
}
|
|
25
|
+
descTitle: "",
|
|
26
|
+
};
|
|
29
27
|
},
|
|
30
28
|
created() {
|
|
31
29
|
this.initialDesc();
|
|
@@ -33,31 +31,57 @@ export default Vue.extend({
|
|
|
33
31
|
props: {
|
|
34
32
|
conditions: {
|
|
35
33
|
type: Array,
|
|
36
|
-
required: true
|
|
37
|
-
}
|
|
34
|
+
required: true,
|
|
35
|
+
},
|
|
38
36
|
},
|
|
39
37
|
computed: {
|
|
40
38
|
questions() {
|
|
41
39
|
return _.cloneDeep(this.$rootComponent.currentSurvey.questions);
|
|
42
|
-
}
|
|
40
|
+
},
|
|
43
41
|
},
|
|
44
42
|
methods: {
|
|
45
43
|
getDesc(condition) {
|
|
46
44
|
let payload = condition.payload;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
if (condition.type == ExprConditionType.SCORE) {
|
|
46
|
+
return this.t(
|
|
47
|
+
"survey_creator.question.evaluation.condition.score_template",
|
|
48
|
+
[payload.minScore, payload.operator, payload.maxScore]
|
|
49
|
+
);
|
|
50
|
+
} else {
|
|
51
|
+
let numbers = new ExprEvaluationQuestion(
|
|
52
|
+
this.questions,
|
|
53
|
+
payload.scope
|
|
54
|
+
).calculateNumbers();
|
|
55
|
+
let scope = _.join(
|
|
56
|
+
_.map(numbers, (number) => {
|
|
57
|
+
if (_.isArray(_.head(number))) {
|
|
58
|
+
return _.join(
|
|
59
|
+
_.map(number, (e) => _.join(e, "-")),
|
|
60
|
+
", "
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
return _.join(number, "-");
|
|
64
|
+
}),
|
|
65
|
+
", "
|
|
66
|
+
);
|
|
67
|
+
if (condition.type == ExprConditionType.ASSIGN) {
|
|
68
|
+
return this.t(
|
|
69
|
+
"survey_creator.question.evaluation.condition.assign_template",
|
|
70
|
+
[
|
|
71
|
+
scope,
|
|
72
|
+
_.join(payload.values, "、"),
|
|
73
|
+
_.unescape(payload.operator),
|
|
74
|
+
payload.size,
|
|
75
|
+
]
|
|
76
|
+
);
|
|
77
|
+
} else if (condition.type == ExprConditionType.AUTO) {
|
|
78
|
+
return this.t(
|
|
79
|
+
"survey_creator.question.evaluation.condition.auto_template",
|
|
80
|
+
[scope, _.join(payload.values, "、")]
|
|
81
|
+
);
|
|
51
82
|
}
|
|
52
|
-
return
|
|
53
|
-
}), ", ");
|
|
54
|
-
|
|
55
|
-
if (condition.type == ExprConditionType.ASSIGN) {
|
|
56
|
-
return this.t('survey_creator.question.evaluation.condition.assign_template', [scope, _.join(payload.values, "、"), _.unescape(payload.operator), payload.size]);
|
|
57
|
-
} else if (condition.type == ExprConditionType.AUTO) {
|
|
58
|
-
return this.t('survey_creator.question.evaluation.condition.auto_template', [scope, _.join(payload.values, "、")]);
|
|
83
|
+
return "";
|
|
59
84
|
}
|
|
60
|
-
return "";
|
|
61
85
|
},
|
|
62
86
|
getChineseLength(_str) {
|
|
63
87
|
_str = _.trim(_str);
|
|
@@ -69,19 +93,20 @@ export default Vue.extend({
|
|
|
69
93
|
return chinese ? chinese.length : 0;
|
|
70
94
|
},
|
|
71
95
|
initialDesc() {
|
|
72
|
-
let desc =
|
|
96
|
+
let desc = "";
|
|
73
97
|
let ds = _.map(this.conditions, (c) => {
|
|
74
98
|
return this.getDesc(c);
|
|
75
99
|
});
|
|
76
|
-
desc = _.join(ds,
|
|
100
|
+
desc = _.join(ds, "<br>");
|
|
77
101
|
this.desc = desc;
|
|
78
102
|
let strLength = desc.length;
|
|
79
|
-
let cLength = this.getChineseLength(desc.substring(0, SPLIT_LENGTH))
|
|
103
|
+
let cLength = this.getChineseLength(desc.substring(0, SPLIT_LENGTH));
|
|
80
104
|
if (strLength > SPLIT_LENGTH) {
|
|
81
|
-
this.desc =
|
|
105
|
+
this.desc =
|
|
106
|
+
desc.substring(0, SPLIT_LENGTH - _.ceil(cLength / 2)) + "...";
|
|
82
107
|
}
|
|
83
108
|
this.descTitle = desc;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
109
|
+
},
|
|
110
|
+
},
|
|
86
111
|
});
|
|
87
112
|
</script>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<Row type="flex" justify="start" :gutter="6" align="middle">
|
|
3
3
|
<Col class="label">
|
|
4
|
-
{{t('survey_creator.question.evaluation.condition.
|
|
4
|
+
{{t('survey_creator.question.evaluation.condition.type.SCORE') }}
|
|
5
5
|
</Col>
|
|
6
6
|
<Col :span="5">
|
|
7
7
|
<FormItem :prop="`evaluationItems[${itemIndex}].conditions[${index}].payload.scope`"
|
|
@@ -1,53 +1,66 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
<component
|
|
3
|
+
:is="type"
|
|
4
|
+
v-model="value"
|
|
5
|
+
:question="question"
|
|
6
|
+
@expr="expr"
|
|
7
|
+
:evaluation-items="evaluationItems"
|
|
8
|
+
:item-index="itemIndex"
|
|
9
|
+
:index="index"
|
|
10
|
+
/>
|
|
4
11
|
</template>
|
|
5
12
|
<script lang="ts">
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
import Vue from "vue";
|
|
14
|
+
import QuestionFormMixin from "../../../../../mixins/question-form-mixin";
|
|
15
|
+
import Assign from "./assign.vue";
|
|
16
|
+
import Auto from "./auto.vue";
|
|
17
|
+
import Score from "./score.vue";
|
|
18
|
+
import { ExprConditionType } from "@wg-npm/survey-core/src/models";
|
|
11
19
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
20
|
+
export default Vue.extend({
|
|
21
|
+
name: "condition",
|
|
22
|
+
mixins: [QuestionFormMixin],
|
|
23
|
+
components: {
|
|
24
|
+
ASSIGN: Assign,
|
|
25
|
+
AUTO: Auto,
|
|
26
|
+
SCORE: Score,
|
|
27
|
+
},
|
|
28
|
+
props: {
|
|
29
|
+
type: {
|
|
30
|
+
type: String,
|
|
31
|
+
required: true,
|
|
32
|
+
},
|
|
33
|
+
value: {
|
|
34
|
+
type: Object,
|
|
35
|
+
required: true,
|
|
36
|
+
},
|
|
37
|
+
index: {
|
|
38
|
+
type: Number,
|
|
39
|
+
required: true,
|
|
40
|
+
},
|
|
41
|
+
evaluationItems: {
|
|
42
|
+
type: Array,
|
|
43
|
+
required: true,
|
|
44
|
+
},
|
|
45
|
+
itemIndex: {
|
|
46
|
+
type: Number,
|
|
47
|
+
required: true,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
data() {
|
|
51
|
+
return {
|
|
52
|
+
exprConditionType: ExprConditionType.AUTO,
|
|
53
|
+
exprConditionTypes: [
|
|
54
|
+
ExprConditionType.AUTO,
|
|
55
|
+
ExprConditionType.ASSIGN,
|
|
56
|
+
ExprConditionType.SCORE,
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
methods: {
|
|
61
|
+
expr(value) {
|
|
62
|
+
this.$emit("expr", this.index, value);
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
});
|
|
53
66
|
</script>
|