From 9d787c0f551bbf0dd096ebcbb79b8b69caaaddd7 Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期五, 16 一月 2026 11:44:29 +0800
Subject: [PATCH] 原材料,过程,出厂检验新增编辑规格改成下拉框,值根据产品获取

---
 src/views/productionManagement/productionProcess/index.vue |   83 ++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 81 insertions(+), 2 deletions(-)

diff --git a/src/views/productionManagement/productionProcess/index.vue b/src/views/productionManagement/productionProcess/index.vue
index cbe55a6..7ab8c9a 100644
--- a/src/views/productionManagement/productionProcess/index.vue
+++ b/src/views/productionManagement/productionProcess/index.vue
@@ -30,6 +30,7 @@
            class="mb10">
         <el-button type="primary"
                    @click="showNewModal">鏂板宸ュ簭</el-button>
+        <el-button type="info" plain @click="handleImport">瀵煎叆</el-button>
         <el-button type="danger"
                    @click="handleDelete"
                    :disabled="selectedRows.length === 0"
@@ -52,14 +53,29 @@
                   v-model:visible="isShowEditModal"
                   :record="record"
                   @completed="getList" />
+    <ImportDialog
+      ref="importDialogRef"
+      v-model="importDialogVisible"
+      title="瀵煎叆宸ュ簭"
+      :action="importAction"
+      :headers="importHeaders"
+      :auto-upload="false"
+      :on-success="handleImportSuccess"
+      :on-error="handleImportError"
+      @confirm="handleImportConfirm"
+      @download-template="handleDownloadTemplate"
+      @close="handleImportClose"
+    />
   </div>
 </template>
 
 <script setup>
-  import { onMounted, ref } from "vue";
+  import { onMounted, ref, reactive, toRefs, getCurrentInstance } from "vue";
   import NewProcess from "@/views/productionManagement/productionProcess/New.vue";
   import EditProcess from "@/views/productionManagement/productionProcess/Edit.vue";
-  import { listPage, del } from "@/api/productionManagement/productionProcess.js";
+  import ImportDialog from "@/components/Dialog/ImportDialog.vue";
+  import { listPage, del, importData, downloadTemplate } from "@/api/productionManagement/productionProcess.js";
+  import { getToken } from "@/utils/auth";
 
   const data = reactive({
     searchForm: {
@@ -113,12 +129,18 @@
   const isShowNewModal = ref(false);
   const isShowEditModal = ref(false);
   const record = ref({});
+  const importDialogVisible = ref(false);
+  const importDialogRef = ref(null);
   const page = reactive({
     current: 1,
     size: 100,
     total: 0,
   });
   const { proxy } = getCurrentInstance();
+  
+  // 瀵煎叆鐩稿叧閰嶇疆
+  const importAction = import.meta.env.VITE_APP_BASE_API + "/productProcess/importData";
+  const importHeaders = { Authorization: "Bearer " + getToken() };
 
   // 鏌ヨ鍒楄〃
   /** 鎼滅储鎸夐挳鎿嶄綔 */
@@ -200,6 +222,63 @@
     }
   }
 
+  // 瀵煎叆
+  const handleImport = () => {
+    importDialogVisible.value = true;
+  };
+
+  // 纭瀵煎叆
+  const handleImportConfirm = () => {
+    if (importDialogRef.value) {
+      importDialogRef.value.submit();
+    }
+  };
+
+  // 瀵煎叆鎴愬姛
+  const handleImportSuccess = (response) => {
+    if (response.code === 200) {
+      proxy.$modal.msgSuccess("瀵煎叆鎴愬姛");
+      importDialogVisible.value = false;
+      if (importDialogRef.value) {
+        importDialogRef.value.clearFiles();
+      }
+      getList();
+    } else {
+      proxy.$modal.msgError(response.msg || "瀵煎叆澶辫触");
+    }
+  };
+
+  // 瀵煎叆澶辫触
+  const handleImportError = (error) => {
+    proxy.$modal.msgError("瀵煎叆澶辫触锛�" + (error.message || "鏈煡閿欒"));
+  };
+
+  // 鍏抽棴瀵煎叆寮圭獥
+  const handleImportClose = () => {
+    if (importDialogRef.value) {
+      importDialogRef.value.clearFiles();
+    }
+  };
+
+  // 涓嬭浇妯℃澘
+  const handleDownloadTemplate = async () => {
+    try {
+      const res = await downloadTemplate();
+      const blob = new Blob([res], {
+        type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+      });
+      const url = window.URL.createObjectURL(blob);
+      const link = document.createElement("a");
+      link.href = url;
+      link.download = "宸ュ簭瀵煎叆妯℃澘.xlsx";
+      link.click();
+      window.URL.revokeObjectURL(url);
+      proxy.$modal.msgSuccess("妯℃澘涓嬭浇鎴愬姛");
+    } catch (error) {
+      proxy.$modal.msgError("妯℃澘涓嬭浇澶辫触");
+    }
+  };
+
   // 瀵煎嚭
   // const handleOut = () => {
   // 	ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {

--
Gitblit v1.9.3