From 7afa7c7ad7d7f1250a086a406453a7cbc8b5cbd5 Mon Sep 17 00:00:00 2001
From: tian <3072314689@qq.com>
Date: 星期二, 23 九月 2025 19:35:55 +0800
Subject: [PATCH] 合并‘

---
 src/views/archiveCategory/index.vue |   81 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 78 insertions(+), 3 deletions(-)

diff --git a/src/views/archiveCategory/index.vue b/src/views/archiveCategory/index.vue
index cdcc401..08e91ef 100644
--- a/src/views/archiveCategory/index.vue
+++ b/src/views/archiveCategory/index.vue
@@ -65,6 +65,35 @@
           @click="handleExport"
           v-hasPermi="['system:category:export']"
         >瀵煎嚭</el-button>
+        </el-col>
+
+    <el-col :span="1.5">
+        <el-button
+          type="warning"
+          plain
+          icon="el-icon-download"
+          size="mini"
+          @click="handleExportTemplate"
+          v-hasPermi="['system:category:export']"
+        >瀵煎叆妯℃澘涓嬭浇</el-button>
+      </el-col>
+
+        <el-col :span="1.5">
+
+        <el-upload
+          action=""
+
+          class="upload-demo"
+          :show-file-list="false"
+          :http-request="handleImport"
+              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>
@@ -105,10 +134,10 @@
     <!-- 娣诲姞鎴栦慨鏀广�愯濉啓鍔熻兘鍚嶇О銆戝璇濇 -->
     <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
-        <el-form-item label="缂栧彿" prop="numb">
+        <el-form-item label="缂栧彿" prop="numb" required>
           <el-input v-model="form.numb" placeholder="璇疯緭鍏ョ紪鍙�" />
         </el-form-item>
-        <el-form-item label="鍚嶇О" prop="nname">
+        <el-form-item label="鍚嶇О" prop="nname" required>
           <el-input v-model="form.nname" placeholder="璇疯緭鍏ュ悕绉�" />
         </el-form-item>
       </el-form>
@@ -121,7 +150,7 @@
 </template>
 
 <script>
-import { listCategory, getCategory, delCategory, addCategory, updateCategory } from "@/api/system/category"
+import { listCategory, getCategory, delCategory, addCategory, updateCategory, enload } from "@/api/system/category"
 
 export default {
   name: "Category",
@@ -156,6 +185,12 @@
       form: {},
       // 琛ㄥ崟鏍¢獙
       rules: {
+        numb: [
+          { required: true, message: '璇疯緭鍏ョ紪鍙�', trigger: 'blur' }
+        ],
+        nname: [
+          { required: true, message: '璇疯緭鍏ュ悕绉�', trigger: 'blur' }
+        ]
       }
     }
   },
@@ -253,6 +288,46 @@
       this.download('system/category/export', {
         ...this.queryParams
       }, `category_${new Date().getTime()}.xlsx`)
+    },
+            /** 瀵煎叆妯℃澘涓嬭浇鎿嶄綔*/
+    handleExportTemplate()
+    {
+     this.download('/system/category/model', {
+
+      }, `category_${new Date().getTime()}.xlsx`)
+    },
+     /** 瀵煎叆鎿嶄綔*/
+    async handleImport({file}){
+   // 妫�鏌ユ枃浠剁被鍨嬫槸鍚︿负xlsx
+  // if (!params.file.name.endsWith('.xlsx')) {
+  //   this.$message.error('璇蜂笂浼�.xlsx鏍煎紡鐨勬枃浠�');
+  //   return;
+  // }
+  const formData = new FormData();
+  formData.append('file', file);
+  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 || '鏈煡閿欒'));
+  });
+
     }
   }
 }

--
Gitblit v1.9.1