From 882c04207fdc667b0be8dc347e320d0414eedb94 Mon Sep 17 00:00:00 2001
From: fei <791364011@qq.com>
Date: 星期二, 16 九月 2025 22:27:11 +0800
Subject: [PATCH] 新增了代码

---
 src/views/archiveManager/archiveMaterial/index.vue |   84 +++++++++++++++++++++++++++++++++++++++---
 1 files changed, 78 insertions(+), 6 deletions(-)

diff --git a/src/views/archiveManager/archiveMaterial/index.vue b/src/views/archiveManager/archiveMaterial/index.vue
index b0b9a5c..e9f1ffb 100644
--- a/src/views/archiveManager/archiveMaterial/index.vue
+++ b/src/views/archiveManager/archiveMaterial/index.vue
@@ -178,7 +178,7 @@
 
 
 
-      <el-row :gutter="10" class="mb8">
+      <el-row :gutter="12" class="mb8">
         <el-col :span="1.5">
           <el-button
             type="primary"
@@ -220,6 +220,7 @@
             @click="handleExport"
             v-hasPermi="['system:materials:export']"
           >瀵煎嚭</el-button>
+        </el-col>
           <el-col :span="1.5">
           <el-button
             type="success"
@@ -229,6 +230,8 @@
             @click="handleImport"
             v-hasPermi="['system:materials:edit']"
           >鍏ㄩ儴闄勪欢瀵煎叆</el-button>
+
+
             <!-- 鍦ㄦ寜閽笅鏂规坊鍔犲鍏ュ璇濇 -->
   <el-dialog title="鎵归噺瀵煎叆闄勪欢" :visible.sync="importDialogVisible" width="50%">
     <el-upload
@@ -248,12 +251,38 @@
     >
       <el-button slot="trigger" size="small" type="primary">閫夋嫨鏂囦欢</el-button>
       <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">涓婁紶鍒版湇鍔″櫒</el-button>
-      <div slot="tip" class="el-upload__tip">鍙笂浼燩DF/DOC/XLS/JPG绛夋牸寮忔枃浠讹紝鍗曚釜鏂囦欢涓嶈秴杩�50MB</div>
+      <div slot="tip" class="el-upload__tip">鍙笂浼燡PG绛夋牸寮忔枃浠讹紝鍗曚釜鏂囦欢涓嶈秴杩�50MB</div>
     </el-upload>
   </el-dialog>
         </el-col>
-        
-        </el-col>
+        <el-col :span="1.5">
+        <el-button
+          type="warning"
+          plain
+          icon="el-icon-download"
+          size="mini"
+          @click="handleExportTemplate"
+          v-hasPermi="['system:materials:edit']"
+        >瀵煎叆妯℃澘涓嬭浇</el-button>
+      </el-col>
+
+        <el-col :span="1.5">
+
+        <el-upload
+          action=""
+
+          class="upload-demo"
+          :show-file-list="false"
+          :http-request="handleImportData"
+              accept=".xlsx,.xls"
+
+        >
+          <el-button size="mini"   type="primary"
+                     plain
+                     icon="el-icon-top">瀵煎叆</el-button>
+
+        </el-upload>
+      </el-col>
         <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
       </el-row>
 
@@ -657,7 +686,7 @@
   </template>
 
   <script>
-  import { listMaterials, getMaterials, delMaterials, addMaterials, updateMaterials } from "@/api/system/materials"
+  import { listMaterials, enload, getMaterials, delMaterials, addMaterials, updateMaterials } from "@/api/system/materials"
 import { getToken } from '@/utils/auth'
 
   export default {
@@ -1032,7 +1061,50 @@
         this.download('system/materials/export', {
           ...this.queryParams
         }, `materials_${new Date().getTime()}.xlsx`)
-      }
+      },
+
+       /** 瀵煎叆妯℃澘涓嬭浇鎿嶄綔*/
+    handleExportTemplate()
+    {
+      this.download('/system/materials/model', {
+
+      }, `materials_${new Date().getTime()}.xlsx`)
+    },
+       /** 瀵煎叆鎿嶄綔*/
+    async handleImportData({file}){
+   // 妫�鏌ユ枃浠剁被鍨嬫槸鍚︿负xlsx
+  // if (!params.file.name.endsWith('.xlsx')) {
+  //   this.$message.error('璇蜂笂浼�.xlsx鏍煎紡鐨勬枃浠�');
+  //   return;
+  // }
+  const formData = new FormData();
+  formData.append('file', file);
+  formData.append('recordId', this.recordId)
+  alert(this.recordId)
+  console.log(file)
+
+  // 鏄剧ず鍔犺浇涓姸鎬�
+  const loading = this.$loading({
+    lock: true,
+    text: '涓婁紶涓�...',
+    spinner: 'el-icon-loading',
+    background: 'rgba(0, 0, 0, 0.7)'
+  });
+
+  enload(formData, {
+    headers: {
+      'Content-Type': 'multipart/form-data'
+    }
+  }).then(response => {
+    loading.close();
+    this.$message.success('瀵煎叆鎴愬姛');
+    this.getList();
+  }).catch(error => {
+    loading.close();
+    this.$message.error('瀵煎叆澶辫触: ' + (error.message || '鏈煡閿欒'));
+  });
+
+    }
     }
   }
   </script>

--
Gitblit v1.9.1