@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.
@@ -1,269 +1,181 @@
1
1
  <template>
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
- {{
12
- t("survey_creator.question.evaluation.condition.add_if_template")
13
- }}
14
- </Button>
15
- </Col>
16
- </Row>
17
- <a href="#" slot="extra" @click.prevent="onDelete" v-show="deletable">
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
- <Col class="label">
24
- <Icon type="ios-arrow-forward" color="#2d8cf0" />
25
- {{ t("survey_creator.question.evaluation.condition.requirements") }}
26
- </Col>
27
- <Col :span="16">
28
- <Select v-model="exprConditionType">
29
- <Option
30
- v-for="type in exprConditionTypes"
31
- :value="type"
32
- :key="type"
33
- >
34
- {{
35
- t(`survey_creator.question.evaluation.condition.type.${type}`)
36
- }}
37
- </Option>
38
- </Select>
39
- </Col>
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
- </Col>
42
- <Col :span="2">
43
- <Button
44
- icon="md-add"
45
- :disabled="disableAddConditionBtn"
46
- class="action"
47
- @click="addCondition"
48
- ></Button>
49
- </Col>
50
- </Row>
51
- <Row
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
- ExprConditionType,
107
- ExprEvaluationItemType,
108
- } from "@wg-npm/survey-core/src/models";
109
- import {
110
- Card,
111
- Row,
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
- name: "if",
125
- mixins: [QuestionFormMixin],
126
- components: {
127
- Card,
128
- Row,
129
- Col,
130
- Select,
131
- Option,
132
- Button,
133
- Icon,
134
- Condition,
135
- FormItem,
136
- Input,
137
- },
138
- props: {
139
- value: {
140
- type: Array,
141
- required: true,
142
- },
143
- position: {
144
- type: Number,
145
- required: true,
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
- conditions: [],
189
- });
190
- },
191
- onDelete() {
192
- this.evaluationItems.splice(this.position, 1);
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
- removeCondition(index) {
222
- this.evaluationItems[this.position].conditions.splice(index, 1);
223
- },
224
- expr(index, value) {
225
- _.set(
226
- this.evaluationItems[this.position].conditions[index],
227
- "expr",
228
- value
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
- margin-top: 12px;
237
- }
146
+ .mt-base {
147
+ margin-top: 12px;
148
+ }
149
+
150
+ .action {
151
+ float: right;
152
+ }
238
153
 
239
- .action {
240
- float: right;
241
- }
154
+ .input {
155
+ width: 100px;
156
+ }
242
157
 
243
- .input {
244
- width: 100px;
245
- }
158
+ .label {
159
+ text-align: right;
160
+ padding-right: 4px;
161
+ }
246
162
 
247
- .label {
248
- text-align: right;
249
- padding-right: 4px;
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
- .text {
253
- background-color: #ebf7ff;
254
- height: 32px;
255
- padding: 8px 18px;
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
- margin-bottom: 4px;
262
- margin-top: 0;
263
- }
176
+ /deep/ .ivu-card .ivu-form-item-error {
177
+ margin-bottom: 24px;
178
+ margin-top: 0;
264
179
 
265
- /deep/ .ivu-card .ivu-form-item-error {
266
- margin-bottom: 24px;
267
- margin-top: 0;
268
- }
180
+ }
269
181
  </style>
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import Vue from 'vue'
6
6
  import deepmerge from 'deepmerge';
7
- import defaultLang from './lang/zh-CN'
7
+ import defaultLang from './lang/en-US'
8
8
 
9
9
  let lang = defaultLang;
10
10
  let merged = false;