Browse Source

同一用户在不同数据集下上传同一个文件时做提示

tags/v0.1.8
yuyuanshifu 5 years ago
parent
commit
1de27fdce0
2 changed files with 20 additions and 0 deletions
  1. +9
    -0
      routers/repo/attachment.go
  2. +11
    -0
      web_src/js/components/MinioUploader.vue

+ 9
- 0
routers/repo/attachment.go View File

@@ -368,12 +368,21 @@ func GetSuccessChunks(ctx *context.Context) {
attachID = attach.ID
}

dataset, err := models.GetDatasetByID(attach.DatasetID)
if err != nil {
ctx.ServerError("GetDatasetByID", err)
return
}

ctx.JSON(200, map[string]string{
"uuid": fileChunk.UUID,
"uploaded": strconv.Itoa(fileChunk.IsUploaded),
"uploadID": fileChunk.UploadID,
"chunks": string(chunks),
"attachID": strconv.Itoa(int(attachID)),
"datasetID": strconv.Itoa(int(attach.DatasetID)),
"fileName": attach.Name,
"datasetName": dataset.Title,
})

}


+ 11
- 0
web_src/js/components/MinioUploader.vue View File

@@ -216,6 +216,14 @@ export default {
// 删除数据集记录,未删除文件
await addAttachment(file);
}
//不同数据集上传同一个文件
if (file.datasetID != '') {
if (Number(file.datasetID) != file.datasetId) {
var info = "该文件已上传,对应数据集(" + file.datasetName + ")-文件(" + file.realName + ")";
window.alert(info);
window.location.reload();
}
}
console.log('文件已上传完成');
this.progress = 100;
this.status = this.dropzoneParams.data('upload-complete');
@@ -257,6 +265,9 @@ export default {
file.uploaded = response.data.uploaded;
file.chunks = response.data.chunks;
file.attachID = response.data.attachID;
file.datasetID = response.data.datasetID;
file.datasetName = response.data.datasetName;
file.realName = response.data.fileName;
return file;
} catch (error) {
this.emitDropzoneFailed(file);


Loading…
Cancel
Save