logDetail.vue
10.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
<template>
<view class="log_detail">
<scroll-view scroll-y="true" style="height: 90%;" :scroll-with-animation="true">
<view class="header_box">
<view class="header">
<view class="avatar">{{getNameLastTwo(detail.studentName)}}</view>
<view class="form_name">
<view class="name">{{overflowHide(detail.studentName, 4)}}</view>
<view class="week">
<!-- <text>{{timeFormat(detail.logTime, 'yyyy年')}}</text> -->
<!-- <text>{{getWeek(detail.logTime)}}</text> -->
<text>{{getCreatedTime(detail)}}</text>
</view>
</view>
<view class="status" :style="{color:'#909097', backgroundColor:'#EAEAEC'}"
v-if="detail.status == 'read'">
<text>已阅</text>
</view>
<view class="status" v-else @click="putLog">
<text>未阅</text>
</view>
</view>
</view>
<view class="content">
<view class="name_time">
<view class="title">{{detail.title}}</view>
<view class="time">创建时间:{{timeFormat(detail.createdTime)}}</view>
</view>
<view class="u-parse">
<u-parse :content="detail.content"></u-parse>
</view>
<view v-if="attachments&&attachments.length>0" class="fj">
<view v-for="(item,index) in attachments " @click="openLink(item)">
<view class="fj_item">
<image class="img" src="/static/img/internship/link.png"></image>
<text class="look">{{item.filename}}</text>
</view>
</view>
</view>
<view v-if="commentList.length>0" class="reply">
<view class="title">评论</view>
<view v-for="(item,index) in commentList" :key="index">
<view v-if="index!=0" class="divide_line_padding"></view>
<view class="list">
<view style="margin-top: 8rpx;" class="userInfo">
<text> {{item.name?item.name:"佚名"}}</text>
<text>({{userType[item.userType]}})</text>
</view>
<view class="replyTime" style="margin-top: 8rpx;">{{timeFormat(item.createdTime)}}</view>
<view class="describe" style="margin-top: 8rpx;">{{item.content}}</view>
<view v-if="false" class="" v-for="(item1,index) in item.replies">
<view class="reply_bg">
{{item1}}
</view>
</view>
</view>
</view>
</view>
</view>
</scroll-view>
<view class="nextPage">
<u-icon name="arrow-down" size="36"></u-icon>
</view>
<view class="footer">
<view class="divide_line"></view>
<input class="uni-input" placeholder="这么精彩,不说点什么吗?" :value="reply" confirm-type="send" @confirm="goReply" />
</view>
</view>
</template>
<script>
import {
mapGetters,
mapState,
mapActions
} from 'vuex'
import {
getLogDetailApi,
putLogReviewApi,
getLogReplyListApi,
postLogReplyApi,
getImgUrlApi,
} from '@/config/api.js';
export default {
data() {
return {
id: "",
formLogId: "",
show: false,
reply: '',
content: "",
style: {
// 字符串的形式
p: 'color: red;font-size:32rpx',
span: 'font-size: 30rpx'
},
detail: {},
userType: {
"student": "学生",
"teacher": "学校",
"company": "企业"
},
commentList: [],
attachments: [],
attachmentsFile: [],
}
},
onLoad(option) {
this.id = option.id;
getLogDetailApi(option.id).then(data => {
if (data) {
this.detail = data
this.handleAttachments()
}
})
this.getCommentList()
},
methods: {
handleAttachments() {
if (this.detail.attachments) {
this.attachments = JSON.parse(this.detail.attachments)
}
// if (this.detail.attachmentsFile) {
// this.attachmentsFile = JSON.parse(this.detail.attachmentsFile)
// }
// this.attachments = this.attachments.concat(this.attachmentsFile)
console.log(this.attachments)
},
getCreatedTime(e) {
console.log(e)
let time = this.$u.timeFormat(e.logTime / 1000, 'yyyy/mm/dd');
if (e.category == "weekly") {
time = new Date(e.logTime).getFullYear() + "年第" + (this.getWeek(e.logTime) + 1) + "周";
} else if (e.category == "monthly") {
time = this.$u.timeFormat(e.logTime / 1000, 'yyyy年mm月');
}
return time
},
getWeek(dt) {
if (dt > 0) {
let d1 = new Date(dt);
let d2 = new Date(dt);
d2.setMonth(0);
d2.setDate(1);
let rq = d1 - d2;
let days = Math.ceil(rq / (24 * 60 * 60 * 1000));
let num = Math.ceil(days / 7);
return num;
} else {
return '';
}
},
getNameLastTwo(value) {
if (value && value.length > 3) {
return value.substring(value.length - 3)
} else {
return value;
}
},
overflowHide(value, num = 4) {
if (value && value.length > num) {
return `${value.slice(0, num)}...`
} else {
return value;
}
},
timeFormat(timestamp, format = 'yyyy-mm-dd') {
return timestamp > 0 ? uni.$u.timeFormat(timestamp, format) : '--'
},
putLog() {
putLogReviewApi({
ids: [this.id]
}).then(data => {
if (data) {
getLogDetailApi(this.id).then(result => {
if (result) {
this.detail = result
}
})
}
})
},
getCommentList() {
getLogReplyListApi({
formLogId: this.id
}).then(data => {
if (data) {
this.commentList = data.records;
}
})
},
goReply(e) { //回复评论
console.log(e)
this.reply = e.target.value
postLogReplyApi({
formLogId: this.id,
content: e.target.value
}).then(data => {
this.reply = ''
this.getCommentList()
})
},
openLink(e) {
var _this = this
uni.showLoading({
title: '努力加载中~',
mask: true
})
getImgUrlApi({
bucket: e.bucket,
filePath: e.object
}).then(data => {
console.log("data...", data)
if (e.mime_type.indexOf("image") != -1) {
_this.openImage(data.url)
} else {
uni.downloadFile({
url: data.url,
success: function(res) {
var filePath = res.tempFilePath;
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function(res) {
console.log('打开文档成功');
},
complete: function() {
uni.hideLoading();
}
});
}
});
}
})
},
openImage(imgPath) {
let array = new Array(1).fill(imgPath);
uni.previewImage({
urls: array,
success(res) {
uni.hideLoading();
console.log('openImage success');
},
fail(res) {
uni.hideLoading();
console.log('openImage fail:', res);
}
});
},
}
}
</script>
<style lang="scss" scoped>
.log_detail {
width: 100%;
// min-height: 100%;
height: 100%;
background-color: #F7F7F7;
.nextPage {
position: fixed;
bottom: 20vh;
right: 30rpx;
background-color: #FFFFFF;
padding: 12rpx;
border-radius: 8rpx;
}
.header_box {
background-color: #FFFFFF;
.header {
display: flex;
flex-flow: row nowrap;
align-items: center;
padding: 52rpx 0;
margin: 0 30rpx;
position: relative;
border-bottom: 2rpx solid #E2E2E8;
background-color: #FFFFFF;
.avatar {
width: 94rpx;
height: 94rpx;
border-radius: 4rpx;
background-color: #06B079;
font-size: 24rpx;
line-height: 94rpx;
color: #FFFFFF;
text-align: center;
}
.form_name {
.name {
font-size: 32rpx;
line-height: 44rpx;
color: #202131;
font-weight: 500;
margin: 0 20rpx;
}
.week {
padding: 8rpx 0 0 0;
font-size: 24rpx;
line-height: 32rpx;
color: #909097;
text {
padding: 8rpx 0 0 20rpx;
}
}
}
.status {
font-size: 24rpx;
line-height: 34rpx;
color: #FFFFFF;
width: 112rpx;
height: 48rpx;
line-height: 48rpx;
text-align: center;
border-radius: 200rpx;
background-color: #06B079;
position: absolute;
top: 74rpx;
right: 0;
}
}
}
.content {
padding: 16rpx 0 150rpx;
.name_time {
background-color: #FFFFFF;
padding: 26rpx 30rpx;
.title {
font-size: 36rpx;
line-height: 50rpx;
color: #06B079;
}
.time {
padding: 6rpx 0 0 0;
font-size: 24rpx;
line-height: 32rpx;
color: #909097;
padding: 0 0 26rpx 0;
}
}
.u-parse {
background-color: #FFFFFF;
padding: 0 30rpx 50rpx;
font-size: 28rpx;
line-height: 36rpx;
color: #4A4A53;
}
.fj {
margin-top: 16rpx;
padding: 24rpx 32rpx 20rpx;
background-color: #fff;
.fj_item {
display: flex;
align-items: center;
margin-bottom: 20rpx;
}
.img {
width: 24rpx;
height: 24rpx;
}
.look {
width: 90%;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
white-space: normal;
word-break: break-all;
word-wrap: break-word;
font-size: 28rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #0CB17A;
padding-left: 15rpx;
}
}
.reply {
background-color: #fff;
padding: 50rpx 30rpx 150rpx;
margin: 16rpx 0 0 0;
.title {
font-size: 34rpx;
line-height: 48rpx;
color: #202131;
}
.list {
padding: 32rpx;
border-bottom: 2rpx solid #E2E2E8;
.userInfo {
color: rgba(0, 0, 0, 0.4500);
font-size: 28rpx;
line-height: 40rpx;
}
.replyTime {
color: rgba(0, 0, 0, 0.4500);
font-size: 26rpx;
line-height: 36rpx;
}
}
.reply_bg {
background: rgba(0, 0, 0, 0.03);
border-radius: 8rpx;
padding: 20rpx 32rpx;
margin-top: 16rpx;
}
}
}
}
.footer {
// width: 100%;
height: 10%;
background: #fff;
padding: 20rpx;
// position: fixed;
// bottom: 0;
// left: 0;
// z-index: 99;
.uni-input {
min-height: 96rpx;
background: rgba(0, 0, 0, 0.04);
border-radius: 8rpx;
// margin: 10rpx 32rpx 32rpx 32rpx;
padding: 0 20rpx;
}
}
</style>