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/index.vue |  213 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 193 insertions(+), 20 deletions(-)

diff --git a/src/views/archiveManager/index.vue b/src/views/archiveManager/index.vue
index a3f7aa2..ee1f128 100644
--- a/src/views/archiveManager/index.vue
+++ b/src/views/archiveManager/index.vue
@@ -230,6 +230,58 @@
           v-hasPermi="['system:records:export']"
         >瀵煎嚭</el-button>
       </el-col>
+
+          <el-col :span="1.5">
+        <el-button
+          type="warning"
+          plain
+          icon="el-icon-download"
+          size="mini"
+          @click="handleBatchSubmit"
+          v-hasPermi="['system:records:export']"
+        >鎵归噺鎻愪氦</el-button>
+      </el-col>
+
+        <el-col v-if="userId==1" :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 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=""
+
+          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>
 
@@ -290,7 +342,7 @@
             @click="handleCheck(scope.row)"
           >鏌ョ湅</el-button>
     <el-button
-          v-if="userId!==1"
+          v-if="userId!==1&&scope.row.ownData"
 
             size="mini"
             type="text"
@@ -355,7 +407,25 @@
       />
     </el-select>
   </el-col>
-  <el-col :span="6">
+
+
+     <el-col :span="6">
+            <el-select
+
+              v-model="form.recordZone"
+              placeholder="閫夋嫨鍦板尯"
+              @change="handleRecordTypeChange"
+              disabled
+                           >
+              <el-option
+                v-for="item in zoneTypeOptions"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value"
+              />
+            </el-select>
+          </el-col>
+  <el-col :span="4">
     <el-input
       v-model="form.recordYear"
       placeholder="杈撳叆骞翠唤"
@@ -365,7 +435,7 @@
       @input="generateRecordId"
     />
   </el-col>
-  <el-col :span="6">
+  <el-col :span="4">
     <el-input
       v-model="form.recordSeq"
       placeholder="鑷姩鐢熸垚"
@@ -482,16 +552,19 @@
           <el-col :span="4">
             <el-input
               v-model="form.recordYear"
+                            @input="generateRecordId"
+
               placeholder="杈撳叆骞翠唤"
-              @input="generateRecordId"
 :disabled="userId!=1"
             />
           </el-col>
           <el-col :span="4">
             <el-input
               v-model="form.recordSeq"
-              placeholder="鑷姩鐢熸垚"
-              disabled
+              :disabled="userId!=1"
+              @input="generateRecordId"
+
+              placeholder="杈撳叆妗f搴忓彿"
             />
           </el-col>
         </el-row>
@@ -623,10 +696,10 @@
 </template>
 
 <script>
-import { 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 { listName } from "@/api/system/projectName"
-import { listPlaceName } from "@/api/system/placeName"
+import { listAllProjectName } from "@/api/system/projectName"
+import { listPlaceName, listAllPlaceName } from "@/api/system/placeName"
 export default {
   name: "Records",
   data() {
@@ -733,7 +806,7 @@
     this.userId = this.$store.state.user.id;
 
 // 鑾峰彇鐢ㄦ埛瑙掕壊
-    this.getId()
+  //  this.getId()
     this.getRecordTypes()
     this.getZoneOptions()
     this.fetchProjectOptions()
@@ -794,9 +867,8 @@
     async getZoneOptions()
     {
       try {
-        const response = await listPlaceName()
-        console.log(response)
-     //   alert(134)
+        const response = await listAllPlaceName()
+        console.log("1111111333333",response.data)
         this.zoneTypeOptions = response.data.data.map(item => ({
           value: item.nnumber,
           label: item.name
@@ -807,8 +879,8 @@
     },
     async fetchProjectOptions() {
       try {
-        const response = await listName()
-        console.log(response)
+        const response = await listAllProjectName()
+        console.log("1111111",response)
         this.projectOptions = response.data.data.map(item => ({
           value: item.name,
           label: item.name
@@ -838,7 +910,7 @@
     /** 鐢熸垚妗f鍙� */
     generateRecordId() {
 
-      if (this.form.recordType && this.form.recordZone && this.form.recordYear) {
+      if (this.form.recordType && this.form.recordZone && this.form.recordYear && this.form.recordSeq) {
 
         // getNextRecordId({
         //   type: this.form.recordType,
@@ -914,7 +986,7 @@
     /** 鏂板鎸夐挳鎿嶄綔 */
     handleAdd() {
       this.reset()
-      this.form.recordSeq = this.maxId
+    // this.form.recordSeq = this.maxId
       this.open = true
       this.vis = false;
       this.title = "娣诲姞妗f璁板綍"
@@ -934,7 +1006,7 @@
     //
     handleSubmit(row)
     {
-      alert(row.id)
+   //   alert(row.id)
       var id = row.id
       updateStatusById(id).then(response=>{
         this.$modal.msgSuccess("鎻愪氦鎴愬姛")
@@ -956,13 +1028,49 @@
   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璁板綍"
+      })
+    },
+    /** 鎵归噺鎻愪氦 */
+    handleBatchSubmit() {
+     // alert(this.ids)
+      if (this.ids.length === 0) {
+        this.$modal.msgWarning('璇烽�夋嫨瑕佹彁浜ょ殑妗f璁板綍')
+        return
+      }
+      const myValidIds = this.recordsList
+  .filter(item => item.ownData === true)
+  .map(item => item.id);
+          // 妫�鏌ラ�変腑鐨処D鏄惁鍏ㄩ儴灞炰簬鑷繁
+    const invalidIds = this.ids.filter(id => !myValidIds.includes(id));
+    
+    if (invalidIds.length > 0) {
+      this.$message.error(`鍖呭惈鏃犳潈鎿嶄綔鐨処D: ${invalidIds.join(',')}`);
+      return false;
+    }
+    //濡傛灉id鍏ㄩ儴鏈夋晥鎵嶇户缁彁浜�
+      batchSubmitRecords( this.ids ).then(response => {
+        if (response.code === 0) {
+          this.$modal.msgSuccess('鎵归噺鎻愪氦鎴愬姛')
+          this.getList()
+          this.ids = []
+        } else {
+          this.$modal.msgError(response.msg || '鎵归噺鎻愪氦澶辫触')
+        }
       })
     },
     /** 淇敼鎸夐挳鎿嶄綔 */
@@ -977,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璁板綍"
@@ -989,6 +1105,7 @@
 
     /** 鎻愪氦鎸夐挳 */
     submitForm() {
+      console.log(this.form)
       this.$refs["form"].validate(valid => {
         if (valid) {
           if (this.form.id != null) {
@@ -999,11 +1116,16 @@
             })
           } else {
             console.log(this.form)
+
             addRecords(this.form).then(response => {
+              console.log(response)
+              if(response.code==0)
+                this.$modal.msgError(response.msg)
+              else{
               this.$modal.msgSuccess("鏂板鎴愬姛")
               this.open = false
               this.getId()
-              this.getList()
+              this.getList()}
 
 
             })
@@ -1047,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