3f535f30
杨鑫
'初始'
|
1
2
3
4
5
6
|
<template>
<view class="questionnaire">
<!-- 单选问题 -->
<view style="padding:20px;background-color: #f6f6f6;">
<view>
|
bc51a62b
杨鑫
'最新'
|
7
8
|
<h2
style="color: #000;overflow: hidden; text-overflow: ellipsis; display: -webkit-box;-webkit-box-orient: vertical;word-break: break-all;text-align:center">
|
be060284
杨鑫
'最新'
|
9
10
|
{{ wenjuan.title }}
</h2>
|
8dca79c8
杨鑫
1
|
11
12
|
<!-- <h5 style="padding: 10px 0;color: #000;">请您认真作答以下题目</h5> height: 200px;-->
<view class="" style="padding: 10px 0; ">
|
be060284
杨鑫
'最新'
|
13
|
<image :src="this.$hostUrl + wenjuan.coverImage" mode="scaleToFill"
|
8dca79c8
杨鑫
1
|
14
|
style="width:100%;border-radius: 10px;"></image>
|
3f535f30
杨鑫
'初始'
|
15
16
17
18
|
</view>
</view>
<view style="padding: 15px;background-color: #fff;border-radius: 10px;">
<view>
|
be060284
杨鑫
'最新'
|
19
|
<!-- <u-parse :content="wenjuan.remarks"></u-parse> -->
|
bc51a62b
杨鑫
'最新'
|
20
21
22
|
<rich-text :nodes="wenjuan.remarks"></rich-text>
<!-- {{wenjuan.remarks}} -->
<!-- <view>
|
3f535f30
杨鑫
'初始'
|
23
24
|
<view style="display:flex;padding:10px 0;justify-content: space-between;">
<view style="display:flex;">
|
3f535f30
杨鑫
'初始'
|
25
26
27
28
29
30
|
{{wenjuan.createUser}}
</view>
<view>
{{wenjuan.createTime}}
</view>
</view>
|
bc51a62b
杨鑫
'最新'
|
31
32
|
</view> -->
<!-- <view>预计答题时间:{{this.wenjuan.estimatedTime}}分钟</view> -->
|
3f535f30
杨鑫
'初始'
|
33
34
|
</view>
</view>
|
be060284
杨鑫
'最新'
|
35
|
<view class="question" v-for="(item, index) in wenjuan.question" style="">
|
bc51a62b
杨鑫
'最新'
|
36
37
|
<p class="question-title"
style="font-weight:600;overflow: hidden; text-overflow: ellipsis; display: -webkit-box;-webkit-box-orient: vertical;word-break: break-all;">
|
be060284
杨鑫
'最新'
|
38
39
40
|
<span v-if="item.required == '必填'" style="color: red;">*</span>{{ index }}.<span
style="color:#0FBB59;padding:0 3px;">({{ item.type }})</span>
{{ item.title }}
|
3f535f30
杨鑫
'初始'
|
41
42
|
</p>
<view>
|
be060284
杨鑫
'最新'
|
43
|
|
3f535f30
杨鑫
'初始'
|
44
45
46
47
48
49
50
51
52
53
|
<!-- <radio-group @change="radioChange" v-model="item.choose"
v-if="item.type =='单选'" >
<label :class="item.choose == val ?'option green':'option gary' " :key="val.answer" v-for="(val, idx) in item.options">
<view>
<radio :value="val.answer" activeBackgroundColor="#E5FFF0"
activeBorderColor="#4FCF86" iconColor="#0FBB59" />
</view>
<view>{{val.answer}}</view>
</label>
</radio-group> -->
|
be060284
杨鑫
'最新'
|
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
<u-radio-group v-model="item.choose" v-if="item.type == '单选'" style="width: 100%;">
<view v-if="item.layoutType != 2">
<u-radio v-for="(val, idx) in item.options" style="width: 100%;"
:class="val.answer == item.choose ? 'option green' : 'option gary'" :name="val.answer"
:disabled="item.disabled" :key="idx" :label-disabled="false" active-color="#4FCF86">
{{ val.answer }}
</u-radio>
</view>
<view v-else-if="item.layoutType == 2" class="myMultiple">
<div v-for="(val, idx) in item.options"
:class="['myOption gary', { optionActive: item.choose == val.answer }]" :key="idx"
@click="chooseAnswerOne(item.options, val, idx)">
<p class="chooseTag" v-if="item.choose == val.answer"><u-icon name="checkbox-mark"
color="#fff" size="8pt"></u-icon></p>
{{ val.answer }}
</div>
</view>
|
bc51a62b
杨鑫
'最新'
|
71
72
|
</u-radio-group>
|
be060284
杨鑫
'最新'
|
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
<u-checkbox-group v-model="item.choose" v-if="item.type == '多选'" style="width: 100%;">
<view v-if="item.layoutType != 2">
<u-checkbox v-for="(val, idx) in item.options" style="width: 100%;"
:class="val.disabled ? 'option green' : 'option gary'" v-model="val.disabled"
:label-disabled="false" :name="val.answer" :key="idx" active-color="#4FCF86"
@change="chooseAnswer(val,idx,item,index)">{{ val.answer }}</u-checkbox>
</view>
<view v-else-if="item.layoutType == 2" class="myMultiple">
<div v-for="(val, index) in item.options"
:class="['myOption gary', { optionActive: val.disabled == true }]" :key="index"
@click="chooseAnswerMore(val,index,item)">
<p class="chooseTag" v-if="val.disabled == true"><u-icon name="checkbox-mark"
color="#fff" size="8pt"></u-icon></p>
{{ val.answer }}
</div>
</view>
|
bc51a62b
杨鑫
'最新'
|
89
|
</u-checkbox-group>
|
3f535f30
杨鑫
'初始'
|
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
<!-- <checkbox-group @change="checkboxChange(index,$event,item,idx)"
v-model="item.choose"
>
<label :class="item.choose == val.answer ?'option green':'option gary' " >
<view style="margin-bottom:5px;">
<checkbox :name="val.answer" activeBackgroundColor="#E5FFF0"
activeBorderColor="#4FCF86" iconColor="#0FBB59" />
<span>{{val.answer}}</span >
</view>
</label>
</checkbox-group> -->
|
be060284
杨鑫
'最新'
|
104
|
<view v-if="item.type == '文本'">
|
bc51a62b
杨鑫
'最新'
|
105
|
<u-input type="textarea" v-model="item.choose" placeholder="请输入" :border="true"></u-input>
|
3f535f30
杨鑫
'初始'
|
106
107
108
109
110
|
</view>
</view>
</view>
<!-- 文本填写问题 -->
|
cffd42c7
杨鑫
'最新H5'
|
111
|
<view class="">
|
3f535f30
杨鑫
'初始'
|
112
113
|
<!-- <p class="question-title">您的建议:</p >
<textarea v-model="suggestion"></textarea> -->
|
bc51a62b
杨鑫
'最新'
|
114
115
|
<u-form labelPosition="left" :model="model1" :rules="rules" ref="uForm" validate-on-rule-change="false"
style="background-color:#fff;border-radius: 10px;">
|
be060284
杨鑫
'最新'
|
116
|
<u-form-item label="姓名" prop="name" borderBottom ref="item1" v-if="wenjuan.needName == '必填'"
|
bc51a62b
杨鑫
'最新'
|
117
118
|
style="padding:10px 20px 0;">
<u-input v-model="model1.name" placeholder="请输入姓名"></u-input>
|
3f535f30
杨鑫
'初始'
|
119
|
</u-form-item>
|
be060284
杨鑫
'最新'
|
120
|
<u-form-item label="电话" prop="phone" borderBottom v-if="wenjuan.needPhone == '必填'"
|
a18f16a9
杨鑫
提交1
|
121
|
style="padding: 10px 20px;">
|
2d521f7d
杨鑫
最新2
|
122
|
<u-input v-model="model1.phone" :maxlength="11" placeholder="请输入电话"></u-input>
|
3f535f30
杨鑫
'初始'
|
123
|
</u-form-item>
|
be060284
杨鑫
'最新'
|
124
|
<u-form-item label="性别" prop="sexl" borderBottom v-if="wenjuan.needGender == '必填'"
|
a18f16a9
杨鑫
提交1
|
125
|
style="padding: 10px 20px;">
|
3f535f30
杨鑫
'初始'
|
126
127
|
<!-- <u-input v-model="model1.sexl" placeholder="请输入性别"></u-input> -->
<u-radio-group v-model="model1.sexl">
|
bc51a62b
杨鑫
'最新'
|
128
129
|
<u-radio active-color="#0FBB59" @change="radioChange" v-for="(item, index) in SexList"
:key="index" :name="item.name" :disabled="item.disabled">
|
be060284
杨鑫
'最新'
|
130
|
{{ item.name }}
|
bc51a62b
杨鑫
'最新'
|
131
132
|
</u-radio>
</u-radio-group>
|
3f535f30
杨鑫
'初始'
|
133
134
|
</u-form-item>
|
bc51a62b
杨鑫
'最新'
|
135
|
|
be060284
杨鑫
'最新'
|
136
|
<view v-if="wenjuan.needOpinion == '必填'" style="padding:0 20px 10px 20px;">
|
bc51a62b
杨鑫
'最新'
|
137
138
139
140
141
142
|
<view style="margin-bottom:10px;">意见</view>
<u-input v-model="model1.opinion" type="textarea" :border="true" :maxlength="maxLength" />
<div class="char-count" style="font-size:12px;">
{{ currentLength }} / {{ maxLength }}
</div>
|
cffd42c7
杨鑫
'最新H5'
|
143
|
</view>
|
bc51a62b
杨鑫
'最新'
|
144
|
|
3f535f30
杨鑫
'初始'
|
145
146
147
148
149
150
151
|
</u-form>
</view>
<button class="submit-btn" @click="submit">提交问卷</button>
</view>
<u-mask :show="show">
|
bc51a62b
杨鑫
'最新'
|
152
153
154
155
|
<view class="warp">
<view class="rect" @tap.stop>
<image src="../../static/images/tijiao.png" style="position: absolute;top:40%;width:80%;left:10%"
mode="aspectFit"></image>
|
3f535f30
杨鑫
'初始'
|
156
|
</view>
|
bc51a62b
杨鑫
'最新'
|
157
158
159
160
|
</view>
</u-mask>
|
3f535f30
杨鑫
'初始'
|
161
162
163
164
165
166
167
168
169
170
|
<u-toast ref="uToast" />
</view>
</template>
<script>
const NET = require('@/utils/request')
const API = require('@/config/api')
export default {
data() {
return {
|
bc51a62b
杨鑫
'最新'
|
171
172
|
show: false,
maxLength: 500, // 假设最大字数为500
|
3f535f30
杨鑫
'初始'
|
173
174
175
|
suggestion: '',
model1: {
name: '',
|
bc51a62b
杨鑫
'最新'
|
176
|
phone: '',
|
cffd42c7
杨鑫
'最新H5'
|
177
|
sexl: '',
|
bc51a62b
杨鑫
'最新'
|
178
|
opinion: '',
|
be060284
杨鑫
'最新'
|
179
|
socialSecurityCardNumber: ''
|
3f535f30
杨鑫
'初始'
|
180
181
182
183
184
185
|
},
wenjuan: {
},
wentile: [],
rules: {
|
bc51a62b
杨鑫
'最新'
|
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
name: [{
type: 'string',
required: true,
message: '请填写姓名',
trigger: ['blur', 'change']
}],
phone: [{
required: true,
message: '请输入电话'
},
{
type: 'number',
message: '必须为数字值'
}
|
3f535f30
杨鑫
'初始'
|
200
201
202
203
204
205
206
207
208
209
210
|
],
},
current: [],
pageTime: null,
duoxuan: [],
danAnswers: [],
selectedAnswers: [],
panduanId: [],
wenjuanIds: '',
scoreList: [],
|
bc51a62b
杨鑫
'最新'
|
211
212
213
214
215
216
217
218
|
SexList: [{
name: '男',
disabled: false
},
{
name: '女',
disabled: false
},
|
3f535f30
杨鑫
'初始'
|
219
|
],
|
bc51a62b
杨鑫
'最新'
|
220
|
timeLeft: null,
|
be060284
杨鑫
'最新'
|
221
222
223
224
225
226
|
token: '',
myChoose: {},
myChooseItem: [
],
panduan: false
|
3f535f30
杨鑫
'初始'
|
227
228
|
};
},
|
bc51a62b
杨鑫
'最新'
|
229
230
231
232
233
|
computed: {
currentLength() {
return this.model1.opinion.length;
}
},
|
3f535f30
杨鑫
'初始'
|
234
|
onLoad(options) {
|
cdf6c4c9
杨鑫
最新
|
235
236
237
|
uni.setNavigationBarTitle({
title: '问卷调查'
});
|
be060284
杨鑫
'最新'
|
238
|
if (options.ids != '') {
|
bc51a62b
杨鑫
'最新'
|
239
240
241
242
243
244
245
246
|
if (options.src && options.token) {
this.token = options.token
let obj = {
token: options.token
}
NET.request(API.jietoken, obj, 'get').then(res => {
if (typeof res.data == 'string') {
|
be060284
杨鑫
'最新'
|
247
|
|
bc51a62b
杨鑫
'最新'
|
248
249
250
|
if (JSON.parse(res.data).phone) {
this.model1.phone = Number(JSON.parse(res.data).phone)
}
|
be060284
杨鑫
'最新'
|
251
252
253
254
255
256
257
258
259
|
if (JSON.parse(res.data).aac003Mask) {
this.model1.name = JSON.parse(res.data).aac003Mask
}
if (JSON.parse(res.data).aac004) {
this.model1.sexl = JSON.parse(res.data).aac004
this.panduan = true
}
if (JSON.parse(res.data).aac002Mask) {
this.model1.socialSecurityCardNumber = JSON.parse(res.data).aac002Mask
|
bc51a62b
杨鑫
'最新'
|
260
|
}
|
ab818baa
杨鑫
'1'
|
261
|
}
|
bc51a62b
杨鑫
'最新'
|
262
263
264
265
266
267
268
|
})
// if (options.token != undefined) {}
} else if (options.phone != undefined) {
this.model1.phone = options.phone
|
ab818baa
杨鑫
'1'
|
269
|
}
|
bc51a62b
杨鑫
'最新'
|
270
|
|
3f535f30
杨鑫
'初始'
|
271
272
273
|
this.wenjuanIds = options.ids
NET.request(API.wenjuanList, {
id: options.ids,
|
82b7d84f
杨鑫
'z问卷'
|
274
|
// reviewStatus: '3',
|
3f535f30
杨鑫
'初始'
|
275
|
}, 'post').then(res => {
|
bc51a62b
杨鑫
'最新'
|
276
277
278
|
if (res.data.id) {
this.wenjuan = res.data
this.wenjuan.question = JSON.parse(res.data.question)
|
be060284
杨鑫
'最新'
|
279
280
281
282
283
284
285
286
287
|
//检查this.wenjuan.question这个list的每个里面是否有maxChoose参数,没有的话就加一个
// this.wenjuan.question.forEach(item => {
// console.log(item)
// if (!item.maxChoose) {
// item.maxChoose = 0
// }
// })
|
bc51a62b
杨鑫
'最新'
|
288
289
290
|
this.timeLeft = parseInt(this.wenjuan.estimatedTime, 10) * 60; // 将分钟转换为秒
this.updateCountdownDisplay()
|
be060284
杨鑫
'最新'
|
291
292
293
294
295
296
|
if (res.data.reviewStatus == '5' || res.data.reviewStatus == '4') {
uni.reLaunch({
url: `/pages_category_page1/question/succe?flag=3`
})
}
|
bc51a62b
杨鑫
'最新'
|
297
298
299
300
301
302
|
} else {
uni.reLaunch({
url: `/pages_category_page1/question/succe?flag=1`
})
}
|
ab818baa
杨鑫
'1'
|
303
|
|
3f535f30
杨鑫
'初始'
|
304
305
306
307
308
|
// if (res.data.cereQuestionManagements.length > 0) {
// for (let i = 0; i < res.data.cereQuestionManagements.length; i++) {
// this.$set(res.data.cereQuestionManagements[i], 'value', [])
// }
// }
|
bc51a62b
杨鑫
'最新'
|
309
|
|
3f535f30
杨鑫
'初始'
|
310
|
// this.wentile = res.data.cereQuestionManagements
|
bc51a62b
杨鑫
'最新'
|
311
|
|
3f535f30
杨鑫
'初始'
|
312
313
314
315
316
|
// this.wenjuan.cereQuestionManagements.map(item => {
// item.optionSettings = JSON.parse(item.optionSettings)
// item.score = JSON.parse(item.score)
// })
|
bc51a62b
杨鑫
'最新'
|
317
318
|
})
|
be060284
杨鑫
'最新'
|
319
|
} else {
|
bc51a62b
杨鑫
'最新'
|
320
321
|
uni.reLaunch({
url: `/pages_category_page1/question/succe?flag=1`
|
3f535f30
杨鑫
'初始'
|
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
|
})
}
// 设置倒计时定时器
// const countdownInterval = setInterval(() => {
// if (this.timeLeft > 0) {
// this.timeLeft--;
// this.updateCountdownDisplay();
// } else {
// clearInterval(countdownInterval);
// location.reload(true);
// // console.log('倒计时结束');
// // 这里可以添加倒计时结束时的处理代码
// }
// }, 1000); // 每秒更新一次
this.pageTime = this.getCurrentTimestamp()
},
watch: {},
methods: {
|
be060284
杨鑫
'最新'
|
341
|
|
3f535f30
杨鑫
'初始'
|
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
|
// 获取时间
currentTime() {
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1; // 月份从0~11,所以加一
let day = date.getDate();
let hours = date.getHours();
let minutes = date.getMinutes();
let seconds = date.getSeconds();
// 为月、日、小时、分钟和秒添加前导零(如果需要)
month = month < 10 ? '0' + month : month;
day = day < 10 ? '0' + day : day;
hours = hours < 10 ? '0' + hours : hours;
minutes = minutes < 10 ? '0' + minutes : minutes;
seconds = seconds < 10 ? '0' + seconds : seconds;
// 返回格式化的日期和时间字符串
return `${year}-${month}-${day} ${hours}:${minutes}`;
},
|
bc51a62b
杨鑫
'最新'
|
362
363
364
365
366
367
368
369
370
371
372
|
updateCountdownDisplay() {
const minutes = Math.floor(this.timeLeft / 60);
const seconds = this.timeLeft % 60;
// console.log(`${minutes} 分 ${seconds} 秒`);
// 这里可以替换为更新DOM元素的代码
},
// formatTime(seconds) {
// const minutes = Math.floor(seconds / 60);
// const remainingSeconds = seconds % 60;
// return `${minutes}分${remainingSeconds < 10 ? '0' : ''}${remainingSeconds}秒`;
// },
|
3f535f30
杨鑫
'初始'
|
373
374
375
376
|
getCurrentTimestamp() {
let Times = Date.now();
return Times // 或者 new Date().getTime();
},
|
bc51a62b
杨鑫
'最新'
|
377
378
|
checkRequiredQuestions(qust) {
for (let key in qust) {
|
be060284
杨鑫
'最新'
|
379
|
|
bc51a62b
杨鑫
'最新'
|
380
381
382
|
let question = qust[key];
if (question.required === '必填') {
if (question.type === '文本' || question.type === '单选') {
|
be060284
杨鑫
'最新'
|
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
|
if(Array.isArray(question.choose)) {
if (question.choose.length>0 && question.choose[0]) {
} else{
this.$refs.uToast.show({
title: '请填写所有必填题目',
})
return false; // 返回false表示有未填写的必填题目
}
} else{
if (question.choose === '') {
this.$refs.uToast.show({
title: '请填写所有必填题目',
})
return false; // 返回false表示有未填写的必填题目
}
|
bc51a62b
杨鑫
'最新'
|
402
403
404
405
406
407
408
409
410
411
|
}
} else if (question.type === '多选') {
let hasEnabledOption = question.options.some(option => option.disabled);
if (!hasEnabledOption) {
this.$refs.uToast.show({
title: '请填写所有必填题目',
})
|
be060284
杨鑫
'最新'
|
412
|
|
bc51a62b
杨鑫
'最新'
|
413
414
415
416
417
418
419
|
return false; // 返回false表示有未填写的必填题目
}
}
}
}
return true; // 返回true表示所有必填题目都已填写
},
|
3f535f30
杨鑫
'初始'
|
420
|
submit() {
|
3f535f30
杨鑫
'初始'
|
421
422
|
let putTime = this.getCurrentTimestamp() - this.pageTime
putTime = (putTime / 1000).toFixed(2)
|
bc51a62b
杨鑫
'最新'
|
423
424
425
|
if (!this.checkRequiredQuestions(this.wenjuan.question)) {
return
}
|
bc51a62b
杨鑫
'最新'
|
426
|
if (this.model1.name == '' && this.wenjuan.needName == '必填') {
|
3f535f30
杨鑫
'初始'
|
427
428
429
430
431
|
this.$refs.uToast.show({
title: '请输入姓名',
})
return;
}
|
bc51a62b
杨鑫
'最新'
|
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
|
if (this.wenjuan.needName == '不填' && this.token == '') {
this.model1.name = '匿名'
}
if (this.model1.phone == '' && this.wenjuan.needPhone == '必填') {
this.$refs.uToast.show({
title: '电话号码不能为空'
});
return;
}
if (this.wenjuan.needPhone == '必填' && this.isChineseOrPunctuation(this.model1.phone)) {
this.$refs.uToast.show({
title: '请输入电话且不能包含汉字或标点特殊符号',
})
return;
|
cffd42c7
杨鑫
'最新H5'
|
448
|
}
|
bc51a62b
杨鑫
'最新'
|
449
450
451
452
|
// if(this.wenjuan.needPhone =='不填' && this.wenjuan.fillingConditions == '可重复填写'){
// this.model1.phone = ''
// }
|
be060284
杨鑫
'最新'
|
453
|
|
bc51a62b
杨鑫
'最新'
|
454
|
if (this.model1.sexl != '男' && this.model1.sexl != '女' && this.wenjuan.needGender == '必填') {
|
3f535f30
杨鑫
'初始'
|
455
456
457
458
459
|
this.$refs.uToast.show({
title: '请选择性别',
})
return;
}
|
be060284
杨鑫
'最新'
|
460
|
if (this.wenjuan.needGender == '不填' && this.panduan == false) {
|
bc51a62b
杨鑫
'最新'
|
461
462
463
464
465
466
467
468
469
470
471
472
|
this.model1.sexl = '未知'
}
if (this.model1.opinion == '' && this.wenjuan.needOpinion == '必填') {
this.$refs.uToast.show({
title: '请输入意见',
})
return;
}
|
3f535f30
杨鑫
'初始'
|
473
474
475
476
477
478
479
480
481
482
483
484
|
// JSON.stringify(danAnswers)
// let array = this.danAnswers.concat(this.selectedAnswers)
// obj.answerOptions = JSON.stringify(array)
var arr = []
// for (let i = 0; i < this.wentile.length; i++) {
// var info = {
// id: "",
// value: [],
// cores:0,
// }
// if (this.wentile[i].questionType == '单选' || this.wentile[i].questionType == '文本' ) {
|
bc51a62b
杨鑫
'最新'
|
485
|
|
3f535f30
杨鑫
'初始'
|
486
487
488
489
|
// info.id = this.wentile[i].id
// info.value = this.wentile[i].value
// let index =this.wentile[i].value
// if(this.wentile[i].score){
|
bc51a62b
杨鑫
'最新'
|
490
|
|
3f535f30
杨鑫
'初始'
|
491
492
|
// for (const key in this.wentile[i].score) {
// if (this.wentile[i].score.hasOwnProperty(key)) { // 确保只获取对象自身的属性,而不是继承的属性
|
bc51a62b
杨鑫
'最新'
|
493
|
|
3f535f30
杨鑫
'初始'
|
494
495
496
497
498
499
500
501
502
|
// if(key == index){
// info.cores = this.wentile[i].score[key]; // 设置 info.cores 为当前键对应的值
// break; // 如果找到了匹配的键,可以提前退出循环
// }
// }
// }
// }
// // console.log(this.wentile[i].cores[index])
// // info.cores.this.wentile[i].value =
|
bc51a62b
杨鑫
'最新'
|
503
|
|
3f535f30
杨鑫
'初始'
|
504
|
// arr.push(info)
|
bc51a62b
杨鑫
'最新'
|
505
506
507
|
|
3f535f30
杨鑫
'初始'
|
508
509
510
511
512
513
|
// // if (this.wentile[i].value != '' && this.wentile[i].value != null && this.wentile[i].value !=
// // undefined) {
// // info.id = this.wentile[i].id
// // info.value = this.wentile[i].value
// // let index =this.wentile[i].value
// // if(this.wentile[i].score){
|
bc51a62b
杨鑫
'最新'
|
514
|
|
3f535f30
杨鑫
'初始'
|
515
516
|
// // for (const key in this.wentile[i].score) {
// // if (this.wentile[i].score.hasOwnProperty(key)) { // 确保只获取对象自身的属性,而不是继承的属性
|
bc51a62b
杨鑫
'最新'
|
517
|
|
3f535f30
杨鑫
'初始'
|
518
519
520
521
522
523
524
525
526
|
// // if(key == index){
// // info.cores = this.wentile[i].score[key]; // 设置 info.cores 为当前键对应的值
// // break; // 如果找到了匹配的键,可以提前退出循环
// // }
// // }
// // }
// // }
// // // console.log(this.wentile[i].cores[index])
// // // info.cores.this.wentile[i].value =
|
bc51a62b
杨鑫
'最新'
|
527
|
|
3f535f30
杨鑫
'初始'
|
528
|
// // arr.push(info)
|
bc51a62b
杨鑫
'最新'
|
529
|
|
3f535f30
杨鑫
'初始'
|
530
531
532
533
534
535
536
537
|
// // }
// } else {
// if (this.wentile[i].value.length > 0) {
// info.id = this.wentile[i].id
// info.value = this.wentile[i].value
// let index =this.wentile[i].value
// console.log(this.wentile[i].score);
// if(this.wentile[i].score){
|
bc51a62b
杨鑫
'最新'
|
538
|
|
3f535f30
杨鑫
'初始'
|
539
540
541
542
543
544
545
|
// for (const key in this.wentile[i].score) {
// if (this.wentile[i].score.hasOwnProperty(key)) { // 确保只获取对象自身的属性,而不是继承的属性
// console.log('1111111111111111111',key,index)
// for(let j=0;j<index.length;j++){
// if(key == index[j]){
// console.log(info.cores,this.wentile[i].score[key])
// info.cores += this.wentile[i].score[key]; // 设置 info.cores 为当前键对应的值
|
bc51a62b
杨鑫
'最新'
|
546
|
|
3f535f30
杨鑫
'初始'
|
547
548
|
// }
// }
|
bc51a62b
杨鑫
'最新'
|
549
|
|
3f535f30
杨鑫
'初始'
|
550
551
552
553
|
// }
// }
// }
// arr.push(info)
|
bc51a62b
杨鑫
'最新'
|
554
|
|
3f535f30
杨鑫
'初始'
|
555
556
|
// }
// }
|
bc51a62b
杨鑫
'最新'
|
557
|
|
3f535f30
杨鑫
'初始'
|
558
559
|
// }
|
be060284
杨鑫
'最新'
|
560
|
// console.log(this.wenjuan)
|
bc51a62b
杨鑫
'最新'
|
561
|
|
3f535f30
杨鑫
'初始'
|
562
563
564
565
566
567
568
569
570
571
572
|
// let obj = {
// questionnaireId: this.wenjuanIds,
// userName: this.model1.name,
// contactNumber: this.model1.phone,
// gender: this.model1.sexl,
// responseTime: putTime,
// opinion:this.model1.opinion,
// createTime: this.currentTime(),
// answerOptions: {},
// answeringScore: '',
// questionnaireScore: null,
|
bc51a62b
杨鑫
'最新'
|
573
|
|
3f535f30
杨鑫
'初始'
|
574
|
// }
|
bc51a62b
杨鑫
'最新'
|
575
576
|
// obj.answeringScore = []
|
3f535f30
杨鑫
'初始'
|
577
578
579
580
581
582
583
584
|
// for(let i=0;i<arr.length;i++){
// console.log()
// if(arr[i].cores ==null){
// obj.answerOptions[i+1] = arr[i].value
// }else{
// obj.questionnaireScore +=arr[i].cores
// obj.answeringScore.push(arr[i].cores)
// if(typeof arr[i].value !='string'){
|
bc51a62b
杨鑫
'最新'
|
585
|
|
3f535f30
杨鑫
'初始'
|
586
587
588
589
590
591
|
// arr[i].value.sort((a, b) => a - b)
// obj.answerOptions[i+1] = arr[i].value.join(',')
// }else{
// obj.answerOptions[i+1]=arr[i].value
// }
// }
|
bc51a62b
杨鑫
'最新'
|
592
593
|
|
3f535f30
杨鑫
'初始'
|
594
595
596
|
// }
// obj.answerOptions= JSON.stringify(obj.answerOptions)
// obj.answeringScore = obj.answeringScore.join(',')
|
bc51a62b
杨鑫
'最新'
|
597
598
599
|
var obj = {
...this.wenjuan
|
3f535f30
杨鑫
'初始'
|
600
|
}
|
bc51a62b
杨鑫
'最新'
|
601
602
603
|
for (var key in obj.question) {
|
be060284
杨鑫
'最新'
|
604
|
// console.log(obj.question[key])
|
bc51a62b
杨鑫
'最新'
|
605
606
607
608
609
610
611
612
613
614
615
616
617
|
if (obj.question[key].type == '多选') {
obj.question[key].choose = []
obj.question[key].options.map(res => {
if (res.disabled) {
obj.question[key].choose.push(res.answer)
}
})
obj.question[key].choose = obj.question[key].choose.join(',')
}
}
const result = Object.keys(obj.question).reduce((acc, key) => {
const question = obj.question[key];
|
be060284
杨鑫
'最新'
|
618
619
620
621
622
623
|
let chooseAnswers = []
if (!Array.isArray(question.choose)) {
chooseAnswers = question.choose.split(",");
} else{
chooseAnswers = question.choose;
}
|
bc51a62b
杨鑫
'最新'
|
624
625
626
627
628
629
630
631
632
633
|
const indexes = chooseAnswers.map((choose) => {
const optionIndex = question.options.findIndex(
(option) => option.answer === choose
);
return optionIndex >= 0 ? optionIndex + 1 : null; // 序号从1开始
});
acc[key] = indexes.filter((index) => index !== null).join(","); // 只保留有效序号
return acc;
}, {});
|
bc51a62b
杨鑫
'最新'
|
634
635
636
637
|
// 计算总分数
const totalScore = Object.keys(obj.question).reduce((sum, key) => {
const question = obj.question[key]
if (question.type === "单选" || question.type === "多选") {
|
be060284
杨鑫
'最新'
|
638
639
640
641
642
643
644
|
// const chooseAnswers = question.choose.split(","); // 多选时拆分答案
let chooseAnswers = []
if (!Array.isArray(question.choose)) {
chooseAnswers = question.choose.split(",");
} else{
chooseAnswers = question.choose;
}
|
bc51a62b
杨鑫
'最新'
|
645
646
647
648
649
650
651
652
653
654
655
656
657
658
|
chooseAnswers.forEach((choose) => {
const matchedOption = question.options.find(
(option) => option.answer === choose
);
if (matchedOption) {
sum += parseFloat(matchedOption.score || 0); // 累加分数
}
});
}
return sum;
}, 0);
// console.log(obj.question,totalScore,result)
// return
|
3f535f30
杨鑫
'初始'
|
659
|
obj.questionnaireId = this.wenjuanIds
|
bc51a62b
杨鑫
'最新'
|
660
661
662
663
664
665
666
667
668
|
obj.userName = this.model1.name
obj.contactNumber = this.model1.phone
obj.gender = this.model1.sexl
obj.responseTime = putTime
obj.answerOptions = JSON.stringify(result)
obj.createTime = this.currentTime()
obj.opinion = this.model1.opinion
obj.questionnaireScore = totalScore
|
3f535f30
杨鑫
'初始'
|
669
670
671
672
673
674
675
676
677
678
679
|
// let obj = {
// questionnaireId: this.wenjuanIds,
// userName: this.model1.name,
// contactNumber: this.model1.phone,
// gender: this.model1.sexl,
// responseTime: putTime,
// opinion:this.model1.opinion,
// createTime: this.currentTime(),
// answerOptions: {},
// answeringScore: '',
// questionnaireScore: null,
|
bc51a62b
杨鑫
'最新'
|
680
|
|
3f535f30
杨鑫
'初始'
|
681
|
// }
|
be060284
杨鑫
'最新'
|
682
|
|
bc51a62b
杨鑫
'最新'
|
683
684
685
686
687
688
689
690
|
obj.question = JSON.stringify(obj.question)
let tijiaoObj = {
questionnaireId: this.wenjuanIds,
userName: this.model1.name,
contactNumber: this.model1.phone,
gender: this.model1.sexl,
responseTime: putTime,
answerOptions: JSON.stringify(result),
|
be060284
杨鑫
'最新'
|
691
|
socialSecurityCardNumber: this.model1.socialSecurityCardNumber,
|
bc51a62b
杨鑫
'最新'
|
692
693
694
695
|
createTime: this.currentTime(),
opinion: this.model1.opinion,
questionnaireScore: totalScore,
question: obj.question
|
3f535f30
杨鑫
'初始'
|
696
|
}
|
bc51a62b
杨鑫
'最新'
|
697
|
|
be060284
杨鑫
'最新'
|
698
699
700
701
|
// console.log(result)
// console.log(JSON.stringify(result))
// console.log(tijiaoObj)
|
95f61c80
杨鑫
'最新'
|
702
|
// console.log(this.wenjuan)
|
be060284
杨鑫
'最新'
|
703
|
// return
|
bc51a62b
杨鑫
'最新'
|
704
705
706
|
NET.request(API.wenjuanUp, tijiaoObj, 'post').then(res => {
// this.show =true
|
95f61c80
杨鑫
'最新'
|
707
|
|
bc51a62b
杨鑫
'最新'
|
708
709
710
711
712
713
714
715
|
if (res.data == 'false') {
uni.reLaunch({
url: `/pages_category_page1/question/succe?chonfu=true`
})
} else {
uni.reLaunch({
url: `/pages_category_page1/question/succe?ids=${this.wenjuanIds}`
})
|
2d521f7d
杨鑫
最新2
|
716
717
718
|
if(this.model1.phone !='' && this.wenjuan.rewardForParticipation !=''){
// window.location.replace( `https://jy.scjysm.asia:18086/h5-web/#/activity/pages/lottery/index?detailId=${this.wenjuan.rewardForParticipation}&style=${this.wenjuan.actStyle}&phone=${this.model1.phone}`)
window.location.replace( `https://zhgw-uat.028wlkj.com/liuliang/h5-web/#/activity/pages/lottery/index?detailId=${this.wenjuan.rewardForParticipation}&style=${this.wenjuan.actStyle}&phone=${this.model1.phone}`)
|
95f61c80
杨鑫
'最新'
|
719
|
}
|
2d521f7d
杨鑫
最新2
|
720
721
722
723
|
// if(this.wenjuan.rewardForParticipation !=''){
// }
|
bc51a62b
杨鑫
'最新'
|
724
725
726
727
|
}
})
|
3f535f30
杨鑫
'初始'
|
728
729
|
},
|
bc51a62b
杨鑫
'最新'
|
730
731
732
733
|
isChineseOrPunctuation(str) {
const regex = /[^\d]/;
return regex.test(str);
},
|
3f535f30
杨鑫
'初始'
|
734
735
736
737
|
// radioChange(index, e, item, idx) {
// console.log(index, e, item, idx)
|
bc51a62b
杨鑫
'最新'
|
738
|
|
3f535f30
杨鑫
'初始'
|
739
740
|
// // item.value = idx;
// // this.$forceUpdate();
|
bc51a62b
杨鑫
'最新'
|
741
|
|
3f535f30
杨鑫
'初始'
|
742
743
|
// },
radioChange(ind) {
|
7ab02d9a
杨鑫
问卷完成,最新
|
744
745
746
747
748
749
750
751
|
// console.log(index, e, item, idx)
// console.error(this.items)
// for (let i = 0; i < this.items.length; i++) {
// if (this.items[i].value === evt.detail.value) {
// this.current = i;
// break;
// }
// }
|
3f535f30
杨鑫
'初始'
|
752
753
|
// item.value = idx;
// this.$forceUpdate();
|
bc51a62b
杨鑫
'最新'
|
754
|
|
3f535f30
杨鑫
'初始'
|
755
756
|
},
checkboxChange(index, e, item, idx) {
|
bc51a62b
杨鑫
'最新'
|
757
758
759
760
761
762
763
764
|
// const index1 = item.value.indexOf(idx)
// if (index1 !== -1) {
// item.value.splice(index1, 1);
// } else {
// item.value.push(idx)
// }
// this.$forceUpdate();
|
3f535f30
杨鑫
'初始'
|
765
|
},
|
be060284
杨鑫
'最新'
|
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
|
chooseAnswerOne(options, chooseItem, idx) {
options.forEach(item => {
item.disabled = false
})
// this.wenjuan.question[idx].choose = chooseItem.answer
for (let key in this.wenjuan.question) {
this.wenjuan.question[key].options.map(res => {
if (res.answer == chooseItem.answer) {
this.wenjuan.question[key].choose = chooseItem.answer
}
})
}
// console.error({
// ...this.myChoose
// })
// console.error({
// ...chooseItem
// })
// this.myChoose = {
// ...this.myChoose,
// ...chooseItem
// }
chooseItem.disabled = true
},
chooseAnswer(val,idx,item,index) {
if (item.maxChoose && item.maxChoose > 0) {
// 获取当前题目的已选中选项数量
const selectedCount = item.options.filter(option => option.disabled).length;
// 如果已选中到达 maxChoose,并且当前项未被选中,则不允许选择
if (selectedCount > item.maxChoose ) {
uni.showToast({
title: `最多只能选择 ${item.maxChoose} 个选项`,
icon: 'none',
duration: 2000
});
// item.disabled = false
this.wenjuan.question[Number(index)].options[idx].disabled = false
return;
}
}
},
chooseAnswerMore(chooseItem, idx, item) {
// item.maxChoose =2
if (item.maxChoose && item.maxChoose > 0) {
// 获取当前题目的已选中选项数量
const selectedCount = item.options.filter(option => option.disabled).length;
// 如果已选中到达 maxChoose,并且当前项未被选中,则不允许选择
if (selectedCount >= item.maxChoose && !chooseItem.disabled) {
uni.showToast({
title: `最多只能选择 ${item.maxChoose} 个选项`,
icon: 'none',
duration: 2000
});
return;
}
}
if (chooseItem.disabled) {
chooseItem.disabled = false
for (let key in this.wenjuan.question) {
if (typeof this.wenjuan.question[key].choose === 'string') {
this.wenjuan.question[key].choose = this.wenjuan.question[key].choose.split(',');
}
this.wenjuan.question[key].choose = this.wenjuan.question[key].choose.filter(
answer => answer !== chooseItem.answer
)
this.wenjuan.question[key].choose.join(',')
}
} else {
for (let key in this.wenjuan.question) {
if (typeof this.wenjuan.question[key].choose === 'string') {
this.wenjuan.question[key].choose = this.wenjuan.question[key].choose.split(',');
}
this.wenjuan.question[key].options.map(res => {
if (res.answer == chooseItem.answer) {
this.wenjuan.question[key].choose.push(chooseItem.answer)
}
})
this.wenjuan.question[key].choose.join(',')
}
chooseItem.disabled = true
}
}
|
3f535f30
杨鑫
'初始'
|
857
858
|
}
|
be060284
杨鑫
'最新'
|
859
|
}
|
3f535f30
杨鑫
'初始'
|
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
|
</script>
<style>
/* 整体页面背景渐变颜色设置 */
body {
background: linear-gradient(to bottom, #e9f2f8, #d0e0ea);
font-family: Arial, sans-serif;
line-height: 1.6;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
margin: 0;
padding: 0;
}
.question {
background-color: white;
padding: 15px;
margin: 10px 0;
border-radius: 10px;
}
/* 问卷容器样式,确保宽度自适应且不超出屏幕,设置内边距和背景等 */
.questionnaire {
width: 100%;
max-width: 600px;
flex-grow: 1;
|
be060284
杨鑫
'最新'
|
889
|
margin: auto;
|
3f535f30
杨鑫
'初始'
|
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
|
/* padding: 30px; */
background-color: white;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
border-radius: 5px;
box-sizing: border-box;
}
/* 页面标题样式,设置背景色、文字颜色、宽度及内边距等 */
h3 {
text-align: center;
color: #000;
/* background-color: #007BFF; */
margin: 0;
padding: 10px 0;
width: 100%;
box-sizing: border-box;
}
/* 问题标题样式,设置字体大小、颜色及下边框 */
.question-title {
font-size: 18px;
color: #000;
margin-bottom: 10px;
}
/* 选项样式,设置列表样式及光标样式 */
.option {
list-style-type: none;
margin: 0;
|
3f535f30
杨鑫
'初始'
|
919
920
921
922
923
|
cursor: pointer;
display: flex;
align-items: center;
margin-bottom: 10px;
color: black;
|
be060284
杨鑫
'最新'
|
924
|
padding: 10px 20px;
|
3f535f30
杨鑫
'初始'
|
925
926
|
border-radius: 3px;
transition: background-color 0.3s ease;
|
be060284
杨鑫
'最新'
|
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
|
margin-right: 10px;
font-size: 15px;
font-weight: 500;
.u-radio__label {
color: #000000;
font-size: 15px;
font-weight: 500;
}
}
.myOption {
margin: 0;
cursor: pointer;
display: flex;
align-items: center;
margin-bottom: 10px;
padding: 15px 20px;
border-radius: 3px;
transition: background-color 0.3s ease;
margin-right: 10px;
font-size: 16px;
color: #000;
font-family: 'Alibaba PuHuiTi 2.0-55 Regular';
letter-spacing: 1px;
overflow: hidden;
position: relative;
.chooseTag {
position: absolute;
top: 0;
right: 0;
width: 20px;
height: 20px;
background-color: #0fbb59;
border-radius: 0 0 0 20px;
display: flex;
align-items: center;
justify-content: center;
.u-icon__icon {
margin-left: 4px;
margin-bottom: 2px;
}
}
|
3f535f30
杨鑫
'初始'
|
972
973
974
|
}
.green {
|
be060284
杨鑫
'最新'
|
975
976
977
978
979
|
background-color: #cff4de;
.u-radio__label {
color: #12ad55;
}
|
3f535f30
杨鑫
'初始'
|
980
981
982
|
}
.gary {
|
be060284
杨鑫
'最新'
|
983
|
|
3f535f30
杨鑫
'初始'
|
984
|
background-color: #f5f5f5;
|
be060284
杨鑫
'最新'
|
985
986
987
988
989
990
|
}
.optionActive {
background-color: #cff4de;
color: #12ad55;
|
3f535f30
杨鑫
'初始'
|
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
|
}
/* 文本域样式,设置宽度、高度、边框及内边距 */
textarea {
width: 100%;
height: 100px;
border: 1px solid #ccc;
border-radius: 3px;
padding: 10px;
resize: vertical;
box-sizing: border-box;
}
/* 提交按钮样式,设置背景色、颜色、边框、内边距、光标及过渡效果 */
.submit-btn {
background-color: #3F9B6A;
color: white;
border: none;
padding: 0px 20px;
border-radius: 3px;
cursor: pointer;
margin-top: 20px;
transition: background-color 0.3s ease;
width: 100%;
box-sizing: border-box;
}
/* 提交按钮悬停效果,改变背景色 */
.submit-btn:hover {
background-color: #3F9B6A;
}
.uni-checkbox-input {
width: 15px;
height: 15px;
}
.uni-radio-input {
width: 15px;
height: 15px;
}
|
bc51a62b
杨鑫
'最新'
|
1033
|
|
3f535f30
杨鑫
'初始'
|
1034
|
::v-deep .u-radio__label {
|
bc51a62b
杨鑫
'最新'
|
1035
1036
1037
1038
|
white-space: normal !important;
/* 允许文本换行 */
word-break: break-all !important;
/* 当内容过长时,自动换行 */
|
3f535f30
杨鑫
'初始'
|
1039
|
}
|
be060284
杨鑫
'最新'
|
1040
1041
1042
1043
1044
1045
1046
|
::v-deep .myMultiple {
display: flex;
width: 100%;
flex-wrap: wrap;
}
|
3f535f30
杨鑫
'初始'
|
1047
|
</style>
|