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
import create from 'dd-store';
import { renderSize } from "../../utils/utils"
import pageStore from '../../pages/meetingDetail/store';
import { uploadPermissions, previewOssFile } from '../../api/request.js'
import openLink from "dingtalk-jsapi/api/biz/util/openLink";
create.Component({
store: pageStore,
mixins: [],
data: {
logId: '', //store
fileList: []
},
props: {
isCanEdit: true,
isCanDelete: false,
isPreview: true, // 是否点击预览,
},
didMount() {
const fileList = []
for (let i = 0; i < this.props.fileInfos.length; i++) {
this.props.fileInfos[i].sizeShow = renderSize(this.props.fileInfos[i].size)
fileList.push(this.props.fileInfos[i])
}
this.setData({
fileList: fileList
})
},
didUpdate() {
const fileList = []
for (let i = 0; i < this.props.fileInfos.length; i++) {
this.props.fileInfos[i].sizeShow = renderSize(this.props.fileInfos[i].size)
fileList.push(this.props.fileInfos[i])
}
this.setData({
fileList: fileList
})
},
didUnmount() {
},
methods: {
//移除文件
removeFile(e) {
this.store.data.logId = '';
const fileInfos = this.store.data.fileInfos.filter(it => it.fileId !== e.target.dataset.id);
this.store.data.fileInfos = fileInfos;
this.update();
},
//预览文件
preview(e) {
// 如果出现编辑蒙层时阻止预览的点击事件
if (this.store.data.logId) {
return;
}
if (!this.props.isPreview) {
return
}
const file = e.target.dataset.file
console.log(file)
if (file.platform === 'oss') {
if (file.webUrl) {
dd.previewImage({
current: 0,
urls: [
file.webUrl
],
});
} else {
// 预览文件
previewOssFile({ objectName: file.fileId }).then(res => {
openLink({
url: res.data.data.webUrl
});
})
}
} else {
let data = {
ddUserId: getApp().globalData.userid,
type: 'download',
projectName: 'MING_MEETING',
fileIds: file.fileId
}
uploadPermissions(data).then(res => {
dd.previewFileInDingTalk({
corpId: dd.corpId,
spaceId: res.data.data,
fileId: file.fileId,
fileName: file.name,
fileSize: file.size,
fileType: file.mimeType,
})
})
}
},
//显示操作框
showOperate(e) {
if (this.props.isCanEdit) {
this.store.data.logId = e.target.dataset.logId;
this.update();
}
},
//删除动态下的文件和描述
deleteFile(e) {
dd.confirm({
title: '删除文件',
content: '确认删除文件吗?',
confirmButtonText: '确定',
cancelButtonText: '取消',
success: (res) => {
if (res.confirm) {
this.props.onDeleteMeetingFile(e.target.dataset.id)
}
}
})
},
//去编辑文件页面
updateFile(e) {
this.store.data.logId = '';
const { fileInfos, description, id } = e.target.dataset.fileView;
this.store.data.oldFileInfos = JSON.stringify(fileInfos);
this.store.data.oldDescription = description;
this.store.data.fileInfos = fileInfos;
this.store.data.description = e.target.dataset.fileView.description;
this.update();
setTimeout(() => {
dd.navigateTo({ url: `./../uploadFile/uploadFile?id=${id}` })
})
}
},
});