From 891a75556b1a6cb8d64c92afa30ed906ab5b4905 Mon Sep 17 00:00:00 2001 From: lb Date: Mon, 17 Apr 2023 17:01:40 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E8=AE=A2=E5=8D=95=EF=BC=8C=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E7=9A=84=E8=8E=B7=E5=8F=96=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/DialogUpload.vue | 20 ++- src/views/modules/pms/bom/config.js | 19 ++- .../pms/order/components/DialogJustForm.vue | 116 +++++++++++------- .../pms/order/components/DialogUpload.vue | 63 ++++++++-- .../order/components/ListSectionWithHead.vue | 3 +- src/views/modules/pms/order/config.js | 6 +- 6 files changed, 165 insertions(+), 62 deletions(-) diff --git a/src/components/DialogUpload.vue b/src/components/DialogUpload.vue index c7efb42..40d966a 100644 --- a/src/components/DialogUpload.vue +++ b/src/components/DialogUpload.vue @@ -14,7 +14,8 @@ :headers="uploadHeaders" :show-file-list="false" :on-error="handleError" - :on-success="handleSuccess"> + :on-success="handleSuccess" + :before-upload="handleBeforeUploadCheck">
将文件拖到此处,或 @@ -109,6 +110,23 @@ export default { // 上传前检查文件大小: Boolean }, + handleBeforeUploadCheck(file) { + if (typeof file !== "object") return false; + if (!("name" in file) || !("type" in file)) return false; + const isXlsx = + file.name.split(".").pop() === "xlsx" && + file.type === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; + const isXls = file.name.split(".").pop() === "xls" && file.type === "application/vnd.ms-excel"; + if (isXls || isXlsx) return true; + // false + this.$message({ + message: "仅支持上传 Excel(.xls, .xlsx) 文件", + type: "error", + duration: 1500, + }); + return false; + }, + handleSuccess(response, file, fileList) { // console.log("success response", response); diff --git a/src/views/modules/pms/bom/config.js b/src/views/modules/pms/bom/config.js index 516e466..a623b37 100644 --- a/src/views/modules/pms/bom/config.js +++ b/src/views/modules/pms/bom/config.js @@ -161,8 +161,20 @@ export default function () { props: [ { type: "index", label: "序号" }, { prop: "material", label: "物料", isEditField: true }, - { width: 130, prop: "qty", label: "配方物料重量", filter: (val) => (!!val ? val + " kg" : "-"), isEditField: true }, - { width: 130, prop: "sumqty", label: "配方总重量", filter: (val) => (!!val ? val + " kg" : "-"), isEditField: true }, + { + width: 130, + prop: "qty", + label: "配方物料重量", + filter: (val) => (!!val ? val + " kg" : "-"), + isEditField: true, + }, + { + width: 130, + prop: "sumqty", + label: "配方总重量", + filter: (val) => (!!val ? val + " kg" : "-"), + isEditField: true, + }, { prop: "percent", label: "配比 [%]", filter: (val) => (!!val ? val + " %" : "-"), isEditField: true }, { prop: "remark", label: "备注", isEditField: true }, { prop: "createTime", label: "添加时间", filter: timeFilter }, @@ -251,7 +263,8 @@ export default function () { copyUrl: "/pms/bom/copy", subase: "/pms/bomMaterial", subpage: "/pms/bomMaterial/page", - importOrderUrl: '/pms/order/importExcelBom', // 导入的api + importUrl: "/pms/order/importExcelBom", // 导入的api + templateUrl: "/importTemplates/bomImport.xlsx", }, }; } diff --git a/src/views/modules/pms/order/components/DialogJustForm.vue b/src/views/modules/pms/order/components/DialogJustForm.vue index 832a646..d6c1da6 100644 --- a/src/views/modules/pms/order/components/DialogJustForm.vue +++ b/src/views/modules/pms/order/components/DialogJustForm.vue @@ -1,43 +1,49 @@