fei
2025-10-10 d195776f9d23f7c79a049ccececdf674853eadb7
修改了对应代码
3个文件已修改
127 ■■■■■ 已修改文件
src/api/system/records.js 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/archiveManager/archiveMaterial/index.vue 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/archiveManager/index.vue 90 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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
  })
}
// 删除档案记录
export function delRecords(id) {
  return request({
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">可上传JPG等格式文件,单个文件不超过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) {
      // 在keydown事件中更早地阻止默认行为
@@ -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)
  // 显示加载中状态
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 = "修改档案记录"
@@ -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 = "查看档案记录"
@@ -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>