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