@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.
@@ -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
- return _.filter(_.flatMap(otherEvaluationItems, "conditions"), (item) => item.type == "SCORE");
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-34509240_0", { source: ".label[data-v-34509240]{text-align:right;margin-bottom:24px}[data-v-34509240] .operator .ivu-select-selected-value{height:28px;line-height:28px}", map: undefined, media: undefined });
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-34509240";
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 = _.findLast(this.currentSurvey?.questions, questions => { return questions.type === this.showQuestionType; });
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.6202",
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.6202",
16
- "@wg-npm/survey-service-api": "0.3.6202",
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.6202",
42
- "@wg-npm/survey-service-api": "0.3.6202",
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
- <Tooltip max-width="200">
3
- <span v-html="this.descTitle" slot="content"></span>
4
- <span v-html="this.desc" class="desc"> </span>
5
- </Tooltip>
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 { 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";
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
- 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
- methods: {
43
- getDesc(condition) {
44
- let payload = condition.payload;
45
- if (condition.type == ExprConditionType.SCORE) {
46
- return this.t(
47
- "survey_creator.question.evaluation.condition.score_template",
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
- return _.join(number, "-");
69
- }),
70
- ", "
71
- );
72
- if (condition.type == ExprConditionType.ASSIGN) {
73
- return this.t(
74
- "survey_creator.question.evaluation.condition.assign_template",
75
- [
76
- scope,
77
- _.join(payload.values, "、"),
78
- _.unescape(payload.operator),
79
- payload.size,
80
- ]
81
- );
82
- } else if (condition.type == ExprConditionType.AUTO) {
83
- return this.t(
84
- "survey_creator.question.evaluation.condition.auto_template",
85
- [scope, _.join(payload.values, "、")]
86
- );
87
- }
88
- return "";
89
- }
90
- },
91
- getChineseLength(_str) {
92
- _str = _.trim(_str);
93
- let strLength = _str.length;
94
- if (!strLength) {
95
- return 0;
96
- }
97
- let chinese = _str.match(/[\u4e00-\u9fa5]/g);
98
- return chinese ? chinese.length : 0;
99
- },
100
- initialDesc() {
101
- let desc = "";
102
- let ds = _.map(this.conditions, (c) => {
103
- return this.getDesc(c);
104
- });
105
- desc = _.join(ds, "<br>");
106
- this.desc = desc;
107
- let strLength = desc.length;
108
- let cLength = this.getChineseLength(desc.substring(0, SPLIT_LENGTH));
109
- if (strLength > SPLIT_LENGTH) {
110
- this.desc =
111
- desc.substring(0, SPLIT_LENGTH - _.ceil(cLength / 2)) + "...";
112
- }
113
- this.descTitle = desc;
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>
@@ -15,6 +15,14 @@
15
15
  required: true
16
16
  }
17
17
  },
18
+ watch: {
19
+ item: {
20
+ handler(val) {
21
+ this.getDesc();
22
+ },
23
+ deep: true
24
+ }
25
+ },
18
26
  methods: {
19
27
  getDesc() {
20
28
  let max = this.item.range.max || null;
@@ -164,9 +164,9 @@ export default Vue.extend({
164
164
  }),
165
165
  (item) => item.index != this.itemIndex
166
166
  );
167
- return _.filter(
168
- _.flatMap(otherEvaluationItems, "conditions"),
169
- (item) => item.type == ExprConditionType.SCORE
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 = _.findLast(this.currentSurvey?.questions, questions=> { return questions.type === this.showQuestionType})
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 {