From beca018db6c27baf5e0f7a1d0509963097a76028 Mon Sep 17 00:00:00 2001 From: lb Date: Wed, 15 Feb 2023 17:07:59 +0800 Subject: [PATCH] update 2023/2/15 --- src/components/DialogWithMenu.vue | 78 ++++++++++++++++++++++--------- 1 file changed, 57 insertions(+), 21 deletions(-) diff --git a/src/components/DialogWithMenu.vue b/src/components/DialogWithMenu.vue index a3141aa..b7fdd88 100644 --- a/src/components/DialogWithMenu.vue +++ b/src/components/DialogWithMenu.vue @@ -33,9 +33,7 @@ :headers="uploadHeaders" :on-success="handleUploadSuccess" > - - 上传 - + 上传 @@ -150,19 +148,18 @@
- 文件列表
  • {{ file.name }} - + - + - + @@ -387,7 +384,12 @@ export default { () => { Object.keys(this.dataForm).forEach((key) => { if (excludeId && key === "id") return; - this.dataForm[key] = null; + if ("files" in this.dataForm) this.dataForm.files = []; + if ("fileIds" in this.dataForm) this.dataForm.fileIds = []; + else this.dataForm[key] = null; + if (Array.isArray(this.fileList)) { + this.fileList = []; + } }); this.activeMenu = this.configs.menu[0].name; this.$refs.dataForm[0].clearValidate(); @@ -441,19 +443,38 @@ export default { }, /** handlers */ - handleFileClick(type) { + handleFileClick(type, file) { switch (type) { case "view": break; case "download": { + /** 通知 */ + this.$notify({ + title: "成功", + message: "开始下载", + type: "success", + }); + break; } case "delete": { + console.log("deleting", file); + const { id } = file; + this.fileList = this.fileList.filter((f) => f.id !== id); + this.updateRemoteFiles().then((res) => { + /** 通知 */ + this.$notify({ + title: "成功", + message: "已删除", + type: "success", + }); + }); + break; } } }, handleUploadSuccess(response, file, fileList) { - console.log("[DialogWithMenu] uploadedFileList", response, file, fileList, this.uploadedFileList); + console.log("[DialogWithMenu] uploadedFileList", response, file, fileList); if (response.code === 0) { const uploadedFile = response.data[0]; @@ -464,6 +485,7 @@ export default { typeCode: file.typeCode, }; + this.fileList.push(fileItem); /** 通知 */ this.$notify({ title: "成功", @@ -471,15 +493,23 @@ export default { type: "success", }); - this.fileList.push(fileItem); - // this.uploadedFileList.push(fileItem); - // this.$emit("update-file-list", this.uploadedFileList); - this.updateFileList(this.fileList) + this.updateRemoteFiles(); } }, - updateFileList(list) { - // this.$http.put() + + updateRemoteFiles() { + return this.$http + .put("/pms/product", { + id: "id" in this.dataForm ? this.dataForm.id : "DEFAULT_ID", + // code: "code" in this.dataForm ? this.dataForm.code : "DEFAULT_CODE", + // ...this.dataForm, + fileIds: this.fileList.map((f) => f.id), + }) + .then(({ data: res }) => { + console.log("updateFileList", this.fileList, res); + }); }, + handleComponentModelUpdate(propName, { subject, payload: { data } }) { this.dataForm[propName] = JSON.stringify(data); console.log("[DialogJustForm] handleComponentModelUpdate", this.dataForm[propName]); @@ -692,8 +722,8 @@ export default { z-index: 10000; } -ul, -li { +ul.file-list, +ul.file-list > li { padding: 0; margin: 0; list-style: none; @@ -703,18 +733,24 @@ li { max-height: 20vh; overflow-y: auto; margin-top: 12px; - width: 240px; + /* width: 240px; */ display: flex; flex-direction: column; - background-color: #ccc; } -.file-list > li { +ul.file-list > li { + border-radius: 4px; + background-color: #edededd2; padding: 8px; + margin-bottom: 2px; display: flex; justify-content: space-between; } +ul.file-list > li:hover { + background-color: #ededed; +} + .file-operations { display: flex; }