JohnnyChan преди 1 ден
родител
ревизия
8c9ac5cd23
променени са 3 файла, в които са добавени 48 реда и са изтрити 3 реда
  1. 9 0
      JLHWEB/src/api/interface/index.ts
  2. 1 1
      JLHWEB/src/api/modules/basicinfo.ts
  3. 38 2
      JLHWEB/src/views/baseinfo/mtrldef/components/ImportPrice.vue

+ 9 - 0
JLHWEB/src/api/interface/index.ts

@@ -1192,6 +1192,11 @@ export namespace Basicinfo {
   export interface ReqFormulaCheck {
     formula: string;
   }
+  export interface ResimportMtrl {
+    messageList: any[];
+    successqty: number;
+    allqty: number;
+  }
 }
 
 export namespace SalePrice {
@@ -1302,6 +1307,10 @@ export namespace Mattress {
     isEdit?: number;
     configcodetype?: number;
   }
+  export interface ReqMattressSubspecs {
+    mattressid: number;
+    onlymattress?: number;
+  }
   export interface ResRefreshMattressInterface {
     mxList: any[];
   }

+ 1 - 1
JLHWEB/src/api/modules/basicinfo.ts

@@ -530,5 +530,5 @@ export const FormulaCheck = (params: Basicinfo.ReqFormulaCheck) => {
  * @name 导入数据(物料价格表)
  */
 export const ImportMtrlPrice = (params: any) => {
-  return http.post(PORT1 + `/ImportMtrlPriceByExcel`, params);
+  return http.post<Basicinfo.ResimportMtrl>(PORT1 + `/ImportMtrlPriceByExcel`, params);
 };

+ 38 - 2
JLHWEB/src/views/baseinfo/mtrldef/components/ImportPrice.vue

@@ -19,7 +19,7 @@
       </template>
     </el-upload>
     <div style="text-align: right">
-      <el-button class="ml-3" type="success" @click="confirm"> 导入 </el-button>
+      <el-button class="ml-3" type="success" :loading="uploading" @click="confirm"> 导入 </el-button>
     </div>
   </LJDialog>
 </template>
@@ -30,6 +30,9 @@ import { ElMessage } from "element-plus";
 import { ImportMtrlPrice } from "@/api/modules/basicinfo";
 import LJDialog from "@/components/LjDialog/index.vue";
 import { base64 } from "js-md5";
+import { ElNotification } from "element-plus";
+import { TYPE, useToast, POSITION } from "vue-toastification";
+import ToastErrCopy from "@/components/ToastWidget/ToastErrCopy/index.vue";
 //import type { FileParams } from "../index.vue";
 
 interface UploadWidgetProps {
@@ -59,11 +62,40 @@ const uploadRef = ref();
 const afterReader = async (data: any) => {
   console.log("afterReader :>> ", data);
 
-  await ImportMtrlPrice({
+  let res = await ImportMtrlPrice({
     filename: data[0].fileName,
     base64: data[0].base64
   });
+  console.log("afterReader res :>> ", res);
 
+  let errmsg = "";
+  if (res?.messageList.length > 0) {
+    errmsg = `,以下类别或物料不存在 <br />` + res.messageList.join(" <br />");
+  }
+  // ElNotification({
+  //   title: "温馨提示",
+  //   message: `读取${res.allqty}条数据,成功录入${res.successqty}个价格,失败${res?.messageList.length}个物料` + errmsg,
+  //   type: "warning"
+  // });
+
+  const toast = useToast();
+  toast(
+    {
+      component: ToastErrCopy,
+      props: {
+        type: "info",
+        title: "温馨提示",
+        message: `读取${res.allqty}条数据,成功录入${res.successqty}个价格,失败${res?.messageList.length}个物料` + errmsg
+      }
+    },
+    {
+      position: POSITION.TOP_RIGHT,
+      icon: false,
+      timeout: 0,
+      closeButton: true,
+      toastClassName: "longjoe-toast"
+    }
+  );
   // setTimeout(() => {
   ElMessage.success("导入成功");
   successStatus.value = true;
@@ -72,6 +104,8 @@ const afterReader = async (data: any) => {
 
     emit("closed");
   }, 500);
+
+  uploading.value = false;
   //   closeTimer.value = setInterval(() => {
   //     toCloseTime.value--;
   //     if (toCloseTime.value <= 0) {
@@ -116,6 +150,8 @@ const confirm = async () => {
       console.log("reader.result :>> ", index, successKey, reader.result);
       if (successKey == fileList.value.length) {
         afterReader(base64List);
+      } else {
+        uploading.value = false;
       }
     };
   });