@wg-npm/survey-creator 0.3.377-8.develop → 0.3.496-8.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 +674 -811
- package/package.json +5 -5
- package/src/components/common/question/evaluation/expr-if.vue +30 -55
- package/src/components/common/question/evaluation.vue +6 -3
- 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/components/editor/forms/evaluation-form.vue +4 -1
- package/src/components/editor/forms/fill-blank-form.vue +6 -0
- package/src/components/editor/forms/matrix-form.vue +6 -0
- package/src/components/editor/forms/multi-selection-form.vue +4 -0
- package/src/components/editor/forms/short-answer-form.vue +7 -1
- package/src/components/editor/forms/single-selection-form.vue +4 -0
- 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/styles/components/survey-creator.less +9 -0
- package/src/styles/components/survey-preview.less +10 -0
- package/src/components/editor/forms/evaluation/expr/score.vue +0 -135
|
@@ -1,269 +1,181 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
</
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
{{ t("survey_creator.common.delete") }}
|
|
19
|
-
</a>
|
|
20
|
-
<Row type="flex" justify="start" align="middle">
|
|
21
|
-
<Col :span="22">
|
|
2
|
+
<Card dis-hover>
|
|
3
|
+
<Row type="flex" :gutter="6" slot="title">
|
|
4
|
+
<Col>
|
|
5
|
+
<div class="text">
|
|
6
|
+
{{t('survey_creator.question.evaluation.condition.if') }}
|
|
7
|
+
</div>
|
|
8
|
+
</Col>
|
|
9
|
+
<Col>
|
|
10
|
+
<Button type="primary" icon="md-add" @click="onAdd">
|
|
11
|
+
{{t('survey_creator.question.evaluation.condition.add_if_template') }}
|
|
12
|
+
</Button>
|
|
13
|
+
</Col>
|
|
14
|
+
</Row>
|
|
15
|
+
<a href="#" slot="extra" @click.prevent="onDelete" v-show="deletable">
|
|
16
|
+
{{t('survey_creator.common.delete') }}
|
|
17
|
+
</a>
|
|
22
18
|
<Row type="flex" justify="start" align="middle">
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
19
|
+
<Col :span="22">
|
|
20
|
+
<Row type="flex" justify="start" align="middle">
|
|
21
|
+
<Col class="label">
|
|
22
|
+
<Icon type="ios-arrow-forward" color="#2d8cf0"/>
|
|
23
|
+
{{t('survey_creator.question.evaluation.condition.requirements') }}
|
|
24
|
+
</Col>
|
|
25
|
+
<Col :span="16">
|
|
26
|
+
<Select v-model="exprConditionType">
|
|
27
|
+
<Option v-for="type in exprConditionTypes" :value="type" :key="type">
|
|
28
|
+
{{ t(`survey_creator.question.evaluation.condition.type.${type}`) }}
|
|
29
|
+
</Option>
|
|
30
|
+
</Select>
|
|
31
|
+
</Col>
|
|
32
|
+
</Row>
|
|
33
|
+
</Col>
|
|
34
|
+
<Col :span="2">
|
|
35
|
+
<Button icon="md-add" class="action" @click="addCondition"></Button>
|
|
36
|
+
</Col>
|
|
37
|
+
</Row>
|
|
38
|
+
<Row type="flex" justify="space-between" align="middle"
|
|
39
|
+
v-for="(condition, index) in evaluationItems[position].conditions" :key="index" class="mt-base">
|
|
40
|
+
<Col :span="22">
|
|
41
|
+
<condition :key="index" :index="index" :type="condition.type" v-model="condition.payload" @expr="expr"
|
|
42
|
+
:question="question" :evaluation-items="evaluationItems" :item-index="position"/>
|
|
43
|
+
</Col>
|
|
44
|
+
<Col :span="2">
|
|
45
|
+
<Button icon="md-remove" class="action" style="margin-bottom: 24px;"
|
|
46
|
+
@click="removeCondition(index)"></Button>
|
|
47
|
+
</Col>
|
|
40
48
|
</Row>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
type="flex"
|
|
53
|
-
justify="space-between"
|
|
54
|
-
align="middle"
|
|
55
|
-
v-for="(condition, index) in evaluationItems[position].conditions"
|
|
56
|
-
:key="index"
|
|
57
|
-
class="mt-base"
|
|
58
|
-
>
|
|
59
|
-
<Col :span="22">
|
|
60
|
-
<condition
|
|
61
|
-
:key="index"
|
|
62
|
-
:index="index"
|
|
63
|
-
:type="condition.type"
|
|
64
|
-
v-model="condition.payload"
|
|
65
|
-
@expr="expr"
|
|
66
|
-
:question="question"
|
|
67
|
-
:evaluation-items="evaluationItems"
|
|
68
|
-
:item-index="position"
|
|
69
|
-
/>
|
|
70
|
-
</Col>
|
|
71
|
-
<Col :span="2">
|
|
72
|
-
<Button
|
|
73
|
-
icon="md-remove"
|
|
74
|
-
class="action"
|
|
75
|
-
style="margin-bottom: 24px"
|
|
76
|
-
@click="removeCondition(index)"
|
|
77
|
-
></Button>
|
|
78
|
-
</Col>
|
|
79
|
-
</Row>
|
|
80
|
-
<Row type="flex" justify="end" align="middle" class="mt-base">
|
|
81
|
-
<Col>
|
|
82
|
-
<FormItem
|
|
83
|
-
:prop="'evaluationItems[' + position + '].text.' + primaryLanguage"
|
|
84
|
-
:rules="{
|
|
85
|
-
required: true,
|
|
86
|
-
message: t(
|
|
87
|
-
'survey_creator.question.evaluation.condition.evaluation_require_tip'
|
|
88
|
-
),
|
|
89
|
-
}"
|
|
90
|
-
>{{
|
|
91
|
-
t("survey_creator.question.evaluation.condition.evaluation_label")
|
|
92
|
-
}}
|
|
93
|
-
<Input
|
|
94
|
-
class="input"
|
|
95
|
-
v-model.trim="evaluationItems[position].text[primaryLanguage]"
|
|
96
|
-
/>
|
|
97
|
-
</FormItem>
|
|
98
|
-
</Col>
|
|
99
|
-
</Row>
|
|
100
|
-
</Card>
|
|
49
|
+
<Row type="flex" justify="end" align="middle" class="mt-base">
|
|
50
|
+
<Col>
|
|
51
|
+
<FormItem
|
|
52
|
+
:prop="'evaluationItems[' + position + '].text.' + primaryLanguage"
|
|
53
|
+
:rules="{required: true, message: t('survey_creator.question.evaluation.condition.evaluation_require_tip')}"
|
|
54
|
+
>{{t('survey_creator.question.evaluation.condition.evaluation_label') }}
|
|
55
|
+
<Input class="input" v-model.trim="evaluationItems[position].text[primaryLanguage]"/>
|
|
56
|
+
</FormItem>
|
|
57
|
+
</Col>
|
|
58
|
+
</Row>
|
|
59
|
+
</Card>
|
|
101
60
|
</template>
|
|
102
61
|
<script lang="ts">
|
|
103
|
-
import Vue from "vue";
|
|
104
|
-
import QuestionFormMixin from "../../../../../mixins/question-form-mixin";
|
|
105
|
-
import {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
} from "@wg-npm/survey-core/src/models";
|
|
109
|
-
import {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
Col,
|
|
113
|
-
Button,
|
|
114
|
-
Select,
|
|
115
|
-
Option,
|
|
116
|
-
Icon,
|
|
117
|
-
FormItem,
|
|
118
|
-
Input,
|
|
119
|
-
} from "view-design";
|
|
120
|
-
import Condition from "./condition.vue";
|
|
121
|
-
import _ from "lodash";
|
|
62
|
+
import Vue from "vue";
|
|
63
|
+
import QuestionFormMixin from "../../../../../mixins/question-form-mixin";
|
|
64
|
+
import {
|
|
65
|
+
ExprConditionType,
|
|
66
|
+
ExprEvaluationItemType
|
|
67
|
+
} from "@wg-npm/survey-core/src/models";
|
|
68
|
+
import {Card, Row, Col, Button, Select, Option, Icon, FormItem, Input} from "view-design";
|
|
69
|
+
import Condition from "./condition.vue"
|
|
70
|
+
import _ from "lodash";
|
|
122
71
|
|
|
123
|
-
export default Vue.extend({
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
},
|
|
148
|
-
data() {
|
|
149
|
-
return {
|
|
150
|
-
evaluationItems: this.value,
|
|
151
|
-
exprConditionType: ExprConditionType.AUTO,
|
|
152
|
-
exprConditionTypes: [
|
|
153
|
-
ExprConditionType.AUTO,
|
|
154
|
-
ExprConditionType.ASSIGN,
|
|
155
|
-
ExprConditionType.SCORE,
|
|
156
|
-
],
|
|
157
|
-
};
|
|
158
|
-
},
|
|
159
|
-
computed: {
|
|
160
|
-
deletable() {
|
|
161
|
-
return (
|
|
162
|
-
_.size(
|
|
163
|
-
_.filter(
|
|
164
|
-
this.evaluationItems,
|
|
165
|
-
(item) => item.type == ExprEvaluationItemType.IF
|
|
166
|
-
)
|
|
167
|
-
) > 1
|
|
168
|
-
);
|
|
169
|
-
},
|
|
170
|
-
disableAddConditionBtn() {
|
|
171
|
-
let conditions = this.evaluationItems[this.position].conditions;
|
|
172
|
-
let scoreConditions = _.size(
|
|
173
|
-
_.filter(conditions, (item) => item.type == ExprConditionType.SCORE)
|
|
174
|
-
);
|
|
175
|
-
return (
|
|
176
|
-
this.exprConditionType == ExprConditionType.SCORE && scoreConditions > 0
|
|
177
|
-
);
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
methods: {
|
|
181
|
-
onAdd() {
|
|
182
|
-
this.evaluationItems.splice(this.position + 1, 0, {
|
|
183
|
-
id: `Evaluation-Item-${_.now()}-${_.random(0, 9999999)}`,
|
|
184
|
-
type: ExprEvaluationItemType.IF,
|
|
185
|
-
text: {
|
|
186
|
-
"zh-CN": "",
|
|
72
|
+
export default Vue.extend({
|
|
73
|
+
name: "if",
|
|
74
|
+
mixins: [QuestionFormMixin],
|
|
75
|
+
components: {
|
|
76
|
+
Card,
|
|
77
|
+
Row,
|
|
78
|
+
Col,
|
|
79
|
+
Select,
|
|
80
|
+
Option,
|
|
81
|
+
Button,
|
|
82
|
+
Icon,
|
|
83
|
+
Condition,
|
|
84
|
+
FormItem,
|
|
85
|
+
Input
|
|
86
|
+
},
|
|
87
|
+
props: {
|
|
88
|
+
value: {
|
|
89
|
+
type: Array,
|
|
90
|
+
required: true
|
|
91
|
+
},
|
|
92
|
+
position: {
|
|
93
|
+
type: Number,
|
|
94
|
+
required: true
|
|
95
|
+
}
|
|
187
96
|
},
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
addCondition() {
|
|
195
|
-
this.evaluationItems[this.position].conditions ||
|
|
196
|
-
this.$set(this.evaluationItems[this.position], "conditions", []);
|
|
197
|
-
this.evaluationItems[this.position].conditions.push({
|
|
198
|
-
type: this.exprConditionType,
|
|
199
|
-
payload: this.buildPayloadByType(this.exprConditionType),
|
|
200
|
-
});
|
|
201
|
-
},
|
|
202
|
-
buildPayloadByType(type) {
|
|
203
|
-
if (type == ExprConditionType.SCORE) {
|
|
204
|
-
return {
|
|
205
|
-
payload: {
|
|
206
|
-
minScore: 0,
|
|
207
|
-
operator: "<",
|
|
208
|
-
maxScore: 0,
|
|
209
|
-
},
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
return {
|
|
213
|
-
payload: {
|
|
214
|
-
scope: [],
|
|
215
|
-
operator: "=",
|
|
216
|
-
values: [],
|
|
217
|
-
size: 0,
|
|
97
|
+
data() {
|
|
98
|
+
return {
|
|
99
|
+
evaluationItems: this.value,
|
|
100
|
+
exprConditionType: ExprConditionType.AUTO,
|
|
101
|
+
exprConditionTypes: [ExprConditionType.AUTO, ExprConditionType.ASSIGN]
|
|
102
|
+
};
|
|
218
103
|
},
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
104
|
+
computed: {
|
|
105
|
+
deletable() {
|
|
106
|
+
return _.size(_.filter(this.evaluationItems, item => item.type == ExprEvaluationItemType.IF)) > 1;
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
methods: {
|
|
110
|
+
onAdd() {
|
|
111
|
+
this.evaluationItems.splice(this.position + 1, 0, {
|
|
112
|
+
"id": `Evaluation-Item-${_.now()}-${_.random(0, 9999999)}`,
|
|
113
|
+
"type": ExprEvaluationItemType.IF,
|
|
114
|
+
"text": {
|
|
115
|
+
"zh-CN": ""
|
|
116
|
+
},
|
|
117
|
+
"conditions": []
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
onDelete() {
|
|
121
|
+
this.evaluationItems.splice(this.position, 1);
|
|
122
|
+
},
|
|
123
|
+
addCondition() {
|
|
124
|
+
this.evaluationItems[this.position].conditions || this.$set(this.evaluationItems[this.position], "conditions", []);
|
|
125
|
+
this.evaluationItems[this.position].conditions.push({
|
|
126
|
+
type: this.exprConditionType,
|
|
127
|
+
payload: {
|
|
128
|
+
scope: [],
|
|
129
|
+
operator: "=",
|
|
130
|
+
values: [],
|
|
131
|
+
size: 0
|
|
132
|
+
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
removeCondition(index) {
|
|
137
|
+
this.evaluationItems[this.position].conditions.splice(index, 1);
|
|
138
|
+
},
|
|
139
|
+
expr(index, value) {
|
|
140
|
+
_.set(this.evaluationItems[this.position].conditions[index], "expr", value);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
})
|
|
233
144
|
</script>
|
|
234
145
|
<style scoped lang="less">
|
|
235
|
-
.mt-base {
|
|
236
|
-
|
|
237
|
-
}
|
|
146
|
+
.mt-base {
|
|
147
|
+
margin-top: 12px;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.action {
|
|
151
|
+
float: right;
|
|
152
|
+
}
|
|
238
153
|
|
|
239
|
-
.
|
|
240
|
-
|
|
241
|
-
}
|
|
154
|
+
.input {
|
|
155
|
+
width: 100px;
|
|
156
|
+
}
|
|
242
157
|
|
|
243
|
-
.
|
|
244
|
-
|
|
245
|
-
|
|
158
|
+
.label {
|
|
159
|
+
text-align: right;
|
|
160
|
+
padding-right: 4px;
|
|
161
|
+
}
|
|
246
162
|
|
|
247
|
-
.
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
163
|
+
.text {
|
|
164
|
+
background-color: #ebf7ff;
|
|
165
|
+
height: 32px;
|
|
166
|
+
padding: 8px 18px;
|
|
167
|
+
font-weight: 500;
|
|
168
|
+
color: #515a6e;
|
|
169
|
+
}
|
|
251
170
|
|
|
252
|
-
.
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
font-weight: 500;
|
|
257
|
-
color: #515a6e;
|
|
258
|
-
}
|
|
171
|
+
/deep/ .ivu-card .ivu-form-item {
|
|
172
|
+
margin-bottom: 4px;
|
|
173
|
+
margin-top: 0;
|
|
174
|
+
}
|
|
259
175
|
|
|
260
|
-
/deep/ .ivu-card .ivu-form-item {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
176
|
+
/deep/ .ivu-card .ivu-form-item-error {
|
|
177
|
+
margin-bottom: 24px;
|
|
178
|
+
margin-top: 0;
|
|
264
179
|
|
|
265
|
-
|
|
266
|
-
margin-bottom: 24px;
|
|
267
|
-
margin-top: 0;
|
|
268
|
-
}
|
|
180
|
+
}
|
|
269
181
|
</style>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<Form ref="questionForm" :model="editQuestion" :label-colon="false">
|
|
3
3
|
<Form-item
|
|
4
4
|
:prop="'header.text.' + primaryLanguage"
|
|
5
|
-
:rules="{required: true,
|
|
5
|
+
:rules="{required: true,
|
|
6
6
|
message: t('survey_creator.question.titleRequiredTip')}"
|
|
7
7
|
>
|
|
8
8
|
<label slot="label">
|
|
@@ -37,3 +37,9 @@
|
|
|
37
37
|
mixins: [questionFormMixin]
|
|
38
38
|
});
|
|
39
39
|
</script>
|
|
40
|
+
|
|
41
|
+
<style scoped lang="less">
|
|
42
|
+
/deep/ .ivu-form-item {
|
|
43
|
+
width: 100%;
|
|
44
|
+
}
|
|
45
|
+
</style>
|