diff --git a/backend/my_work/routers/api_Files.go b/backend/my_work/routers/api_Files.go index 9813ba3..62d47ba 100644 --- a/backend/my_work/routers/api_Files.go +++ b/backend/my_work/routers/api_Files.go @@ -14,8 +14,9 @@ import ( type TabFileInfo_ struct { ID uint `gorm:"primaryKey;autoIncrement"` Name string `gorm:"not null;size:256;index"` // 前端报告的文件名 - Path string `gorm:"not null;size:300"` // - Sha256 string `gorm:"not null;size:64;index"` // + Size int64 `gorm:"not null"` + Path string `gorm:"not null;size:300"` // + Sha256 string `gorm:"not null;size:64;index"` // Mime string `gorm:"size:64;index"` Type string `gorm:"size:64;index"` Const uint `gorm:"default:1;index"` @@ -128,6 +129,7 @@ func ApiFiles(r *gin.RouterGroup) { //先检查数据库有没有数据 fund_file_info := TabFileInfo_{ Name: filename, + Size: file.Size, Sha256: hash_str, Mime: mimeType, Type: "image", diff --git a/frontend/ops_vue_js/src/components/useDropzone.vue b/frontend/ops_vue_js/src/components/useDropzone.vue index 14146b1..aee2aca 100644 --- a/frontend/ops_vue_js/src/components/useDropzone.vue +++ b/frontend/ops_vue_js/src/components/useDropzone.vue @@ -209,33 +209,36 @@ function return_files() { // 加载初始已有文件(编辑场景) function loadInitialFiles() { if (!dropzoneInstance || !prop.initialFiles?.length) return; + + prop.initialFiles.forEach((f) => { // 构造 Dropzone 期望的 mock file 对象 - const mockFile = { - name: f.Name || f.name || f.hash, - size: f.Size || f.size || 0, - type: f.Mime || f.mime || "image/jpeg", - status: Dropzone.SUCCESS, - accepted: true, - upload: { uuid: f.Hash || f.hash || f.Sha256 }, - previewElement: null, - _removeLink: null, - }; - // 通知 Dropzone "这是一个已存在的文件,不要上传" - dropzoneInstance.emit("addedfile", mockFile); - dropzoneInstance.emit("complete", mockFile); - dropzoneInstance.files.push(mockFile); - // 填充上传结果字段 - const url = `/api/files/get/${f.Hash || f.hash || f.Sha256}`; - files.push({ - uuid: f.Hash || f.hash || f.Sha256, - hash: f.Hash || f.hash || f.Sha256, - get_url: url, - download_url: `/api/files/download/${f.Hash || f.hash || f.Sha256}`, - file_name: f.Name || f.name || "", - file_size: f.Size || f.size || 0, - is_upload: true, - }); + console.log(f) + // const mockFile = { + // name: f.Name, + // size: f.Size, + // type: f.Mime, + // status: Dropzone.SUCCESS, + // accepted: true, + // upload: { uuid: f.Sha256 }, + // previewElement: null, + // _removeLink: null, + // }; + // // 通知 Dropzone "这是一个已存在的文件,不要上传" + // dropzoneInstance.emit("addedfile", mockFile); + // dropzoneInstance.emit("complete", mockFile); + // dropzoneInstance.files.push(mockFile); + // // 填充上传结果字段 + // const url = `/api/files/get/${f.Sha256}`; + // files.push({ + // uuid: f.Sha256, + // hash: f.Sha256, + // get_url: url, + // download_url: `/api/files/download/${f.Sha256}`, + // file_name: f.Name, + // file_size: f.Size, + // is_upload: true, + // }); }); } diff --git a/frontend/ops_vue_js/src/i18n/en.json b/frontend/ops_vue_js/src/i18n/en.json index 8be64d7..6e42966 100644 --- a/frontend/ops_vue_js/src/i18n/en.json +++ b/frontend/ops_vue_js/src/i18n/en.json @@ -100,7 +100,8 @@ "commit_placeholder": "Add comment (optional)", "upload_photos": "Upload Photos", "commit_create": "Order created", - "edit_order": "Edit Order" + "edit_order": "Edit Order", + "submit_changes":"Submit changes" }, "purchase_addorder": { "add_order": "Add Order", diff --git a/frontend/ops_vue_js/src/i18n/zh-CN.json b/frontend/ops_vue_js/src/i18n/zh-CN.json index 855a735..c188d0b 100644 --- a/frontend/ops_vue_js/src/i18n/zh-CN.json +++ b/frontend/ops_vue_js/src/i18n/zh-CN.json @@ -100,7 +100,8 @@ "commit_placeholder": "添加备注(可选)", "upload_photos": "上传图片", "commit_create": "订单创建", - "edit_order": "编辑订单" + "edit_order": "编辑订单", + "submit_changes":"提交修改" }, "purchase_addorder": { "add_order": "添加订单", diff --git a/frontend/ops_vue_js/src/views/purchase/editorder.vue b/frontend/ops_vue_js/src/views/purchase/editorder.vue index e67b520..0f5ea2b 100644 --- a/frontend/ops_vue_js/src/views/purchase/editorder.vue +++ b/frontend/ops_vue_js/src/views/purchase/editorder.vue @@ -141,7 +141,9 @@ onMounted(async () => { // 回填图片 await nextTick(); if (photos && photos.length > 0) { - dropzoneRef.value?.loadInitialFiles(photos); + //dropzoneRef.value?.loadInitialFiles(photos); + //console.log(photos) + form.photos=photos } } catch { pageError.value = t("purchase.order_not_found"); @@ -196,16 +198,33 @@ async function handleSubmit() {