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
import create from 'dd-store'
import { saveFileInfo, addSchedule, uploadPermissions, previewPermissions, updateMeetingTask } from '../../api/request.js'
import { throttle, debounce } from './../../utils/utils.js'
import pageStore from '../meetingDetail/store';
create.Page({
store: pageStore,
data: {
fileInfos: null, //store
description: '',//store
id: ''
},
onLoad(query) {
dd.setNavigationBar({
title: '添加会议文件'
});
// 编辑的时候传了文件ID
if (query && query.id) {
this.setData({
id: query.id
});
dd.setNavigationBar({
title: '编辑会议文件'
});
}
},
onShow() {
},
inputChange: debounce(function (e) {
const value = e.detail.value;
if (value) {
this.store.data.description = value;
this.update();
}
}, 100),
//添加会议文件
add() {
const data = {
ddUserId: getApp().globalData.userid,
type: 'add',
projectName: 'MING_MEETING'
}
uploadPermissions(data).then(res => {
if (res.data.code === 0) {
const _that = this
dd.uploadAttachmentToDingTalk({
image: { multiple: true, compress: true, max: 9, spaceId: res.data.data },
space: { spaceId: res.data.data, compress: true, isCopy: 1, max: 9 },
types: ["photo", "camera", "space"],
success: (res) => {
_that.store.data.fileInfos.push(...res.data)
_that.update();
},
fail: (err) => {
}
})
}
})
},
// 保存
saveUpload: throttle(function () {
const { fileInfos, oldFileInfos, description, oldDescription } = this.store.data;
if (!fileInfos || (fileInfos && fileInfos.length == 0)) {
dd.showToast({
content: '请上传文件'
})
return;
}
//如果实际没有修改,不生成记录
if (this.data.id) {
if (oldFileInfos == JSON.stringify(fileInfos) && description == oldDescription) {
return dd.navigateBack()
}
}
const data = {
resourceType: 'accessory',
creatorId: getApp().globalData.userid,
category: '2',
scheduleId: this.store.data.scheduleId,
groupId: this.store.data.groupId,
uploader: getApp().globalData.userid,
creatorInfo: getApp().globalData.userInfo,
thirdStoreTenant: 'dingTalk',
fileInfos: JSON.stringify(fileInfos),
description: description,
logType: 'schedule_accessory_add'
}
//编辑文件
if (this.data.id) {
data.logType = 'schedule_accessory_modify';
data.id = this.data.id
updateMeetingTask(data).then(res => {
this.store.data.isNeedReloadList = true;
this.update();
dd.navigateBack()
})
}
//新增文件
else {
saveFileInfo(data).then(res => {
this.store.data.isNeedReloadList = true;
this.update();
dd.navigateBack()
})
}
}, 1000)
});