@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wg-npm/survey-creator",
3
- "version": "0.3.13",
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.13",
16
- "@wg-npm/survey-service-api": "0.3.13",
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.13",
42
- "@wg-npm/survey-service-api": "0.3.13",
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
- 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, "-")), ", ");
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 _.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, "、")]);
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, '<br>')
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 = desc.substring(0, SPLIT_LENGTH - _.ceil(cLength / 2)) + "..."
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.question') }}
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
- <component :is="type" v-model="value" :question="question" @expr="expr" :evaluation-items="evaluationItems"
3
- :item-index="itemIndex" :index="index"/>
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
- 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";
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
- 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
- })
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>