|
@@ -20,9 +20,7 @@ Component({
|
|
|
* 组件的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
- originFiles: [
|
|
|
-
|
|
|
- ],
|
|
|
+ originFiles: [],
|
|
|
attachmentids: [],
|
|
|
gridConfig: {
|
|
|
column: 5,
|
|
@@ -41,23 +39,21 @@ Component({
|
|
|
*/
|
|
|
methods: {
|
|
|
handleAdd(file) {
|
|
|
- let files = file.detail.files.map(e => {
|
|
|
+ let files = this.data.originFiles.concat(file.detail.files.map(e => {
|
|
|
e.status = 'loading'
|
|
|
return e
|
|
|
- })
|
|
|
+ }));
|
|
|
this.setData({
|
|
|
uploadCount: files.length,
|
|
|
- originFiles: files,
|
|
|
- attachmentids: []
|
|
|
+ originFiles: files
|
|
|
})
|
|
|
this.toSetFileData()
|
|
|
},
|
|
|
handleRemove(data) {
|
|
|
- let file = data.detail.file
|
|
|
+ let file = data.detail.file;
|
|
|
this.setData({
|
|
|
- originFiles: this.data.originFiles.filter(e => {
|
|
|
- return e.name !== file.name
|
|
|
- })
|
|
|
+ originFiles: this.data.originFiles.filter(e => e.name !== file.name),
|
|
|
+ attachmentids: this.data.attachmentids.filter(e => e !== file.attachmentids)
|
|
|
})
|
|
|
},
|
|
|
toSetFileData() {
|
|
@@ -125,20 +121,17 @@ Component({
|
|
|
}
|
|
|
}).then(rs => {
|
|
|
console.log("上传附件反馈", rs)
|
|
|
+ that.data.attachmentids.push(rs.data.attachmentids[0])
|
|
|
that.setData({
|
|
|
+ uploadCount: that.data.uploadCount - 1,
|
|
|
originFiles: that.data.originFiles.map(e => {
|
|
|
if (e.name === res.filename) {
|
|
|
- e.status = ''
|
|
|
+ e.status = '';
|
|
|
+ e.attachmentids = rs.data.attachmentids[0]
|
|
|
}
|
|
|
return e
|
|
|
})
|
|
|
})
|
|
|
-
|
|
|
- that.data.attachmentids.push(rs.data.attachmentids[0])
|
|
|
-
|
|
|
- that.setData({
|
|
|
- uploadCount: that.data.uploadCount - 1
|
|
|
- })
|
|
|
}).catch(err => {
|
|
|
console.log(err)
|
|
|
})
|