From d195776f9d23f7c79a049ccececdf674853eadb7 Mon Sep 17 00:00:00 2001
From: fei <791364011@qq.com>
Date: 星期五, 10 十月 2025 23:20:03 +0800
Subject: [PATCH] 修改了对应代码

---
 src/views/archiveManager/archiveMaterial/index.vue |   26 ++++++++
 src/views/archiveManager/index.vue                 |   90 ++++++++++++++++++++++++++++--
 src/api/system/records.js                          |   11 +++
 3 files changed, 119 insertions(+), 8 deletions(-)

diff --git a/src/api/system/records.js b/src/api/system/records.js
index df20777..76c791b 100644
--- a/src/api/system/records.js
+++ b/src/api/system/records.js
@@ -58,7 +58,18 @@
     data: data
   })
 }
+//瀵煎叆
+export function enload(data) {
 
+  return request({
+    url: '/system/records/importData',
+    method: 'post',
+      headers: {
+      'Content-Type': 'multipart/form-data'
+    },
+    data: data
+  })
+}
 // 鍒犻櫎妗f璁板綍
 export function delRecords(id) {
   return request({
diff --git a/src/views/archiveManager/archiveMaterial/index.vue b/src/views/archiveManager/archiveMaterial/index.vue
index 4ed97fc..5130c0f 100644
--- a/src/views/archiveManager/archiveMaterial/index.vue
+++ b/src/views/archiveManager/archiveMaterial/index.vue
@@ -239,12 +239,14 @@
       :on-preview="handlePreview"
       :on-remove="handleRemove"
       :file-list="fileList"
+        :on-change="handleFileChange"
       :auto-upload="false"
       multiple
       accept=".jpg,.png"
     >
       <el-button slot="trigger" size="small" type="primary">閫夋嫨鏂囦欢</el-button>
       <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">涓婁紶鍒版湇鍔″櫒</el-button>
+      <el-button style="margin-left: 10px;" size="small" type="danger" @click="clearFileList">娓呯┖鍒楄〃</el-button>
       <div slot="tip" class="el-upload__tip">鍙笂浼燡PG绛夋牸寮忔枃浠讹紝鍗曚釜鏂囦欢涓嶈秴杩�50MB</div>
     </el-upload>
   </el-dialog>
@@ -883,9 +885,29 @@
     handlePreview(file) {
       console.log(file)
     },
+     handleFileChange(file, fileList) {
+    console.log('褰撳墠鏂囦欢鍒楄〃:', fileList);
+    this.fileList = fileList;
+  },
     // 鎻愪氦涓婁紶
     submitUpload() {
+      // 鑾峰彇褰撳墠閫夋嫨鐨勬枃浠舵暟閲�
+      const fileCount = this.fileList.length
+      if (fileCount === 0) {
+        this.$modal.msgWarning('璇峰厛閫夋嫨鏂囦欢鍐嶄笂浼�')
+        return
+      }
+      if(fileCount!==this.total)
+      {
+        this.$modal.msgWarning('璇烽�夋嫨涓庤褰曟暟涓�鑷寸殑鏂囦欢')
+        return
+      }
+      // 鎵ц涓婁紶
       this.$refs.upload.submit()
+    },
+    clearFileList() {
+      this.fileList = [];
+      this.$modal.msgSuccess('宸叉竻绌轰笂浼犲垪琛�');
     },
           handleKeyDown(e) {
       // 鍦╧eydown浜嬩欢涓洿鏃╁湴闃绘榛樿琛屼负
@@ -1086,8 +1108,8 @@
   // }
   const formData = new FormData();
   formData.append('file', file);
-  formData.append('recordId', this.recordId)
-  alert(this.recordId)
+ // formData.append('recordId', this.recordId)
+  // alert(this.recordId)
   console.log(file)
 
   // 鏄剧ず鍔犺浇涓姸鎬�
diff --git a/src/views/archiveManager/index.vue b/src/views/archiveManager/index.vue
index 51f93be..ee1f128 100644
--- a/src/views/archiveManager/index.vue
+++ b/src/views/archiveManager/index.vue
@@ -242,7 +242,7 @@
         >鎵归噺鎻愪氦</el-button>
       </el-col>
 
-        <el-col :span="1.5">
+        <el-col v-if="userId==1" :span="1.5">
         <el-button
           type="warning"
           plain
@@ -252,8 +252,17 @@
           v-hasPermi="['system:materials:edit']"
         >瀵煎叆妯℃澘涓嬭浇</el-button>
       </el-col>
-
-        <el-col :span="1.5">
+  <el-col v-if="userId!=1" :span="1.5">
+        <el-button
+          type="warning"
+          plain
+          icon="el-icon-download"
+          size="mini"
+          @click="handleExportTemplateOther"
+          v-hasPermi="['system:materials:edit']"
+        >瀵煎叆妯℃澘涓嬭浇</el-button>
+      </el-col>
+        <el-col  :span="1.5">
 
         <el-upload
           action=""
@@ -406,7 +415,8 @@
               v-model="form.recordZone"
               placeholder="閫夋嫨鍦板尯"
               @change="handleRecordTypeChange"
-              :disabled="userId!=1"              >
+              disabled
+                           >
               <el-option
                 v-for="item in zoneTypeOptions"
                 :key="item.value"
@@ -686,7 +696,7 @@
 </template>
 
 <script>
-import { batchSubmitRecords,updateStatusById,listRecords,getMaxId, getRecords, delRecords, addRecords, updateRecords } from "@/api/system/records"
+import { enload, batchSubmitRecords,updateStatusById,listRecords,getMaxId, getRecords, delRecords, addRecords, updateRecords } from "@/api/system/records"
 import { listAllCategory } from "@/api/system/category"
 import { listAllProjectName } from "@/api/system/projectName"
 import { listPlaceName, listAllPlaceName } from "@/api/system/placeName"
@@ -1018,10 +1028,18 @@
   if(this.recordTypeOptions.length > 0) {
       const recordParts = response.data.recordId.split('-')
       this.$set(this.form, 'recordType', recordParts[0])
-            this.$set(this.form, 'recordZone', recordParts[1])
+      if(this.recordTypeOptions.length==4)
+      {
+        this.$set(this.form, 'recordZone', recordParts[1])
 
       this.$set(this.form, 'recordYear', recordParts[2])
       this.$set(this.form, 'recordSeq', recordParts[3])
+      }
+      else
+      {
+            this.$set(this.form, 'recordYear', recordParts[1])
+      this.$set(this.form, 'recordSeq', recordParts[2])
+      }
     }
         this.open = true
         this.title = "淇敼妗f璁板綍"
@@ -1067,10 +1085,18 @@
   if(this.recordTypeOptions.length > 0) {
       const recordParts = response.data.recordId.split('-')
       this.$set(this.form, 'recordType', recordParts[0])
+      if(this.recordTypeOptions.length==4)
+      {
             this.$set(this.form, 'recordZone', recordParts[1])
 
       this.$set(this.form, 'recordYear', recordParts[2])
       this.$set(this.form, 'recordSeq', recordParts[3])
+      }
+      else
+      {
+            this.$set(this.form, 'recordYear', recordParts[1])
+      this.$set(this.form, 'recordSeq', recordParts[2])
+      }
     }
   this.open_check = true
   this.title = "鏌ョ湅妗f璁板綍"
@@ -1079,6 +1105,7 @@
 
     /** 鎻愪氦鎸夐挳 */
     submitForm() {
+      console.log(this.form)
       this.$refs["form"].validate(valid => {
         if (valid) {
           if (this.form.id != null) {
@@ -1142,7 +1169,58 @@
       this.download('system/records/export', {
         ...this.queryParams
       }, `records_${new Date().getTime()}.xlsx`)
+    },
+         /** 瀵煎叆妯℃澘涓嬭浇鎿嶄綔*/
+    handleExportTemplate()
+    {
+      this.download('/system/records/model', {
+
+      }, `records_${new Date().getTime()}.xlsx`)
+    },
+    handleExportTemplateOther()
+    {
+          this.download('/system/records/modelOther', {
+
+      }, `records_${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('excelImport', 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