From e7bfb25d3d4f1e8554ab0df063693972c5c5fd3b Mon Sep 17 00:00:00 2001 From: lb Date: Tue, 7 Feb 2023 16:31:47 +0800 Subject: [PATCH] init uploadBtn --- public/index.html | 4 +- src/components/DialogJustForm.vue | 15 ++- .../uploadBtn/components/FileList.vue | 89 +++++++++++++ src/components/uploadBtn/index.vue | 122 ++++++++++++++++++ src/views/modules/pms/equipmentType/config.js | 5 +- .../modules/pms/materialStorage/config.js | 2 +- 6 files changed, 231 insertions(+), 6 deletions(-) create mode 100644 src/components/uploadBtn/components/FileList.vue create mode 100644 src/components/uploadBtn/index.vue diff --git a/public/index.html b/public/index.html index 2a3aa34..d204e3c 100644 --- a/public/index.html +++ b/public/index.html @@ -38,8 +38,8 @@ <% if (process.env.VUE_APP_NODE_ENV === 'dev') { %> <% } %> diff --git a/src/components/DialogJustForm.vue b/src/components/DialogJustForm.vue index f0b1351..3d9d437 100644 --- a/src/components/DialogJustForm.vue +++ b/src/components/DialogJustForm.vue @@ -55,8 +55,10 @@ :on-change="handleUploadChange" v-bind="col.elparams" :headers="uploadHeaders" + name="files" + :on-success="handleUploadSuccess" > - 选择文件 + 选择文件
只能上传jpg/png文件,且不超过500kb
@@ -189,6 +191,17 @@ export default { }, }, methods: { + handleUploadSuccess(response, file, fileList) { + /** 上传成功修改本地展示的文件名 */ + if (response.code === 0) { + // const { fileName } = response.data[0]; + const fileName = response.data[0].fileUrl.split("/").pop(); + file.name = fileName; + } else { + console.log("response, file, fileList", response, file, fileList); + } + }, + /** utitilities */ showButton(operate) { const notDetailMode = !this.detailMode; diff --git a/src/components/uploadBtn/components/FileList.vue b/src/components/uploadBtn/components/FileList.vue new file mode 100644 index 0000000..eaf5e65 --- /dev/null +++ b/src/components/uploadBtn/components/FileList.vue @@ -0,0 +1,89 @@ + + + + + diff --git a/src/components/uploadBtn/index.vue b/src/components/uploadBtn/index.vue new file mode 100644 index 0000000..d6f9a53 --- /dev/null +++ b/src/components/uploadBtn/index.vue @@ -0,0 +1,122 @@ + + + + + diff --git a/src/views/modules/pms/equipmentType/config.js b/src/views/modules/pms/equipmentType/config.js index 06f5ce0..df5ab95 100644 --- a/src/views/modules/pms/equipmentType/config.js +++ b/src/views/modules/pms/equipmentType/config.js @@ -1,5 +1,5 @@ import TableOperaionComponent from "@/components/noTemplateComponents/operationComponent"; -import StatusComponent from "@/components/noTemplateComponents/statusComponent"; +import detailComponent from "@/components/noTemplateComponents/detailComponent"; import request from "@/utils/request"; import { dictFind, timeFilter } from '@/utils/filters' @@ -10,6 +10,7 @@ export default function () { { prop: "code", label: "类型编码" }, // { prop: "description", label: "描述" }, { prop: "remark", label: "备注" }, + { prop: 'detail', label: "详情", subcomponent: detailComponent }, { prop: "operations", name: "操作", @@ -94,7 +95,7 @@ export default function () { ], // [{ textarea: true, label: "描述信息", prop: "description", elparams: { placeholder: "描述信息" } }], [{ input: true, label: "备注", prop: "remark", elparams: { placeholder: "备注" } }], - [{ upload: true, actionUrl: window.SITE_CONFIG['apiURL'] + '/pms/equipmentTypeFile', label: "上传资料", fileList:[], prop: "upload", elparams: null }], + [{ upload: true, actionUrl: window.SITE_CONFIG['apiURL'] + '/pms/attachment/uploadFileFormData?typeCode=equipmentType', label: "上传资料", fileList: [], prop: "upload", elparams: null }], ], operations: [ { name: "add", label: "保存", type: "primary", permission: "pms:equipmentType:save", showOnEdit: false }, diff --git a/src/views/modules/pms/materialStorage/config.js b/src/views/modules/pms/materialStorage/config.js index f2961b1..7292055 100644 --- a/src/views/modules/pms/materialStorage/config.js +++ b/src/views/modules/pms/materialStorage/config.js @@ -8,7 +8,7 @@ export default function () { { prop: "name", label: "料仓名称" }, { prop: "code", label: "料仓编码" }, { prop: "typeDictValue", label: "料仓类型", filter: dictFilter('liaocang') }, - { prop: "status", label: "状态", subcomponent: switchBtn }, // subcomponent + { prop: "enabled", label: "状态", subcomponent: switchBtn }, // subcomponent { prop: "description", label: "描述" }, { prop: "remark", label: "备注" }, {