From ba9e41aeb286f381d862e83fbe72a0c696608b22 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期四, 12 三月 2026 16:32:31 +0800
Subject: [PATCH] 产品维护接口对接

---
 src/views/basicData/product/ImportExcel/index.vue |  197 ++++++++++++++++++++++++++-----------------------
 1 files changed, 105 insertions(+), 92 deletions(-)

diff --git a/src/views/basicData/product/ImportExcel/index.vue b/src/views/basicData/product/ImportExcel/index.vue
index 2afbb64..3611960 100644
--- a/src/views/basicData/product/ImportExcel/index.vue
+++ b/src/views/basicData/product/ImportExcel/index.vue
@@ -1,14 +1,25 @@
 <template>
-  <el-button type="info" plain icon="Upload" @click="handleImport">
+  <el-button type="info"
+             plain
+             icon="Upload"
+             @click="handleImport">
     瀵煎叆
   </el-button>
-  <el-dialog v-model="upload.open" :title="upload.title" @close="handleDialogClose">
-    <FileUpload ref="fileUploadRef" accept=".xlsx, .xls" :headers="upload.headers" :action="uploadUrl"
-      :disabled="upload.isUploading" :showTip="true" @success="handleFileSuccess"
-      :downloadTemplate="handleDownloadTemplate" />
+  <el-dialog v-model="upload.open"
+             :title="upload.title"
+             @close="handleDialogClose">
+    <FileUpload ref="fileUploadRef"
+                accept=".xlsx, .xls"
+                :headers="upload.headers"
+                :action="uploadUrl"
+                :disabled="upload.isUploading"
+                :showTip="true"
+                @success="handleFileSuccess"
+                :downloadTemplate="handleDownloadTemplate" />
     <template #footer>
       <div class="dialog-footer">
-        <el-button type="primary" @click="submitFileForm">纭� 瀹�</el-button>
+        <el-button type="primary"
+                   @click="submitFileForm">纭� 瀹�</el-button>
         <el-button @click="upload.open = false">鍙� 娑�</el-button>
       </div>
     </template>
@@ -16,100 +27,102 @@
 </template>
 
 <script setup>
-import { reactive, computed } from "vue";
-import { getToken } from "@/utils/auth.js";
-import { FileUpload } from "@/components/Upload";
-import { ElMessage } from "element-plus";
-import { downloadProductModelImportTemplate } from "@/api/basicData/product.js";
+  import { reactive, computed } from "vue";
+  import { getToken } from "@/utils/auth.js";
+  import { FileUpload } from "@/components/Upload";
+  import { ElMessage } from "element-plus";
+  import { downloadProductModelImportTemplate } from "@/api/basicData/newProduct.js";
 
-defineOptions({
-  name: "浜у搧缁存姢瀵煎叆",
-});
+  defineOptions({
+    name: "浜у搧缁存姢瀵煎叆",
+  });
 
-const props = defineProps({
-  productId: { type: [String, Number], default: "" },
-});
-const emits = defineEmits(["uploadSuccess"]);
-const fileUploadRef = ref();
-const upload = reactive({
-  // 鏄惁鏄剧ず寮瑰嚭灞傦紙渚涘簲鍟嗗鍏ワ級
-  open: false,
-  // 寮瑰嚭灞傛爣棰橈紙渚涘簲鍟嗗鍏ワ級
-  title: "",
-  // 鏄惁绂佺敤涓婁紶
-  isUploading: false,
-  // 璁剧疆涓婁紶鐨勮姹傚ご閮�
-  headers: { Authorization: "Bearer " + getToken() },
-});
-// 涓婁紶鐨勫湴鍧�锛堟惡甯� productId 鍙傛暟锛屼紶缁欏悗绔殑 importProduct 鎺ュ彛锛�
-const uploadUrl = computed(
-  () =>
-    import.meta.env.VITE_APP_BASE_API +
-    "/basic/product/import" +
-    (props.productId ? `?productId=${props.productId}` : "")
-);
-// 鐐瑰嚮瀵煎叆
-const handleImport = () => {
-  if (!props.productId) {
-    ElMessage({ message: "璇峰厛閫夋嫨浜у搧", type: "warning" });
-    return;
-  }
-  upload.open = true;
-  upload.title = "浜у搧瀵煎叆";
-};
+  const props = defineProps({
+    productId: { type: [String, Number], default: "" },
+  });
+  const emits = defineEmits(["uploadSuccess"]);
+  const fileUploadRef = ref();
+  const upload = reactive({
+    // 鏄惁鏄剧ず寮瑰嚭灞傦紙渚涘簲鍟嗗鍏ワ級
+    open: false,
+    // 寮瑰嚭灞傛爣棰橈紙渚涘簲鍟嗗鍏ワ級
+    title: "",
+    // 鏄惁绂佺敤涓婁紶
+    isUploading: false,
+    // 璁剧疆涓婁紶鐨勮姹傚ご閮�
+    headers: { Authorization: "Bearer " + getToken() },
+  });
+  // 涓婁紶鐨勫湴鍧�锛堟惡甯� productId 鍙傛暟锛屼紶缁欏悗绔殑 importProduct 鎺ュ彛锛�
+  const uploadUrl = computed(
+    () =>
+      import.meta.env.VITE_APP_BASE_API +
+      "/productMaterialSku/import" +
+      (props.productId ? `?materialId=${props.productId}` : "")
+  );
+  // 鐐瑰嚮瀵煎叆
+  const handleImport = () => {
+    if (!props.productId) {
+      ElMessage({ message: "璇峰厛閫夋嫨浜у搧", type: "warning" });
+      return;
+    }
+    upload.open = true;
+    upload.title = "浜у搧瑙勬牸瀵煎叆";
+  };
 
-const submitFileForm = () => {
-  fileUploadRef.value.uploadApi();
-};
+  const submitFileForm = () => {
+    fileUploadRef.value.uploadApi();
+  };
 
-// 鍏抽棴寮圭獥鏃舵竻闄ゅ凡閫夋枃浠�
-const handleDialogClose = () => {
-  fileUploadRef.value?.clearFiles?.();
-};
+  // 鍏抽棴寮圭獥鏃舵竻闄ゅ凡閫夋枃浠�
+  const handleDialogClose = () => {
+    fileUploadRef.value?.clearFiles?.();
+  };
 
-const handleFileSuccess = (response) => {
-  const { code, msg } = response;
-  if (code == 200) {
-    ElMessage({ message: msg || "瀵煎叆鎴愬姛", type: "success" });
-    upload.open = false;
-    emits("uploadSuccess");
-  } else {
-    ElMessage({ message: msg, type: "error" });
-  }
-};
+  const handleFileSuccess = response => {
+    const { code, msg } = response;
+    if (code == 200) {
+      ElMessage({ message: msg || "瀵煎叆鎴愬姛", type: "success" });
+      upload.open = false;
+      emits("uploadSuccess");
+    } else {
+      ElMessage({ message: msg, type: "error" });
+    }
+  };
 
-// 涓嬭浇 Excel 瀵煎叆妯℃澘
-const handleDownloadTemplate = () => {
-  downloadProductModelImportTemplate()
-    .then((blobData) => {
-      const blob =
-        blobData instanceof Blob
-          ? blobData
-          : new Blob([blobData], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
-      const url = window.URL.createObjectURL(blob);
-      const link = document.createElement("a");
-      link.href = url;
-      link.download = "浜у搧瀵煎叆妯℃澘.xlsx";
-      document.body.appendChild(link);
-      link.click();
-      document.body.removeChild(link);
-      window.URL.revokeObjectURL(url);
-      ElMessage({ message: "妯℃澘涓嬭浇鎴愬姛", type: "success" });
-    })
-    .catch(() => {
-      ElMessage({ message: "妯℃澘涓嬭浇澶辫触", type: "error" });
-    });
-};
+  // 涓嬭浇 Excel 瀵煎叆妯℃澘
+  const handleDownloadTemplate = () => {
+    downloadProductModelImportTemplate()
+      .then(blobData => {
+        const blob =
+          blobData instanceof Blob
+            ? blobData
+            : new Blob([blobData], {
+                type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+              });
+        const url = window.URL.createObjectURL(blob);
+        const link = document.createElement("a");
+        link.href = url;
+        link.download = "浜у搧瑙勬牸瀵煎叆妯℃澘.xlsx";
+        document.body.appendChild(link);
+        link.click();
+        document.body.removeChild(link);
+        window.URL.revokeObjectURL(url);
+        ElMessage({ message: "妯℃澘涓嬭浇鎴愬姛", type: "success" });
+      })
+      .catch(() => {
+        ElMessage({ message: "妯℃澘涓嬭浇澶辫触", type: "error" });
+      });
+  };
 </script>
 
 <style scoped>
-.import-tip {
-  margin-top: 12px;
-  font-size: 12px;
-  color: var(--el-text-color-secondary);
-}
+  .import-tip {
+    margin-top: 12px;
+    font-size: 12px;
+    color: var(--el-text-color-secondary);
+  }
 
-.import-tip .el-button {
-  margin-left: 8px;
-}
+  .import-tip .el-button {
+    margin-left: 8px;
+  }
 </style>

--
Gitblit v1.9.3