fei
6 天以前 0c6b2eb953f5ed4df00a77a5f7b14b9ff6c563fe
src/views/archiveManager/archiveMaterial/index.vue
@@ -2,7 +2,7 @@
    <div class="app-container">
      <div v-if="sho">
         <h2 class="title-border">添加案卷详细记录</h2>
         <h2 class="title-border">添加案卷详细记录   {当前录入了{{total}}条}</h2>
 <el-form ref="form" :model="form" :rules="rules" label-width="100px">
   <el-row>
@@ -18,6 +18,8 @@
          <el-form-item label="责任者" prop="creator">
            <div class="title-search-wrapper">
              <el-input
                type="textarea"
                rows="1"
                v-model="form.creator"
                placeholder="请输入责任者"
                @input="handleCreatorInput"
@@ -48,6 +50,8 @@
          <el-form-item label="文件题名" prop="title">
            <div class="title-search-wrapper">
              <el-input
                type="textarea"
                rows="1"
                v-model="form.title"
                placeholder="请输入文件题名"
                @input="handleTitleInput"
@@ -350,7 +354,7 @@
        >导入模板下载</el-button>
      </el-col>
        <el-col :span="1.5">
        <el-col      v-if="sho" :span="1.5">
        <el-upload
          action=""
@@ -361,7 +365,7 @@
              accept=".xlsx,.xls"
        >
          <el-button size="mini"  v-if="sho" type="primary"
          <el-button size="mini"   type="primary"
                     plain
                     icon="el-icon-top">导入</el-button>
@@ -455,13 +459,13 @@
           <el-row>
           <el-col :span="16">
               <el-form-item label="责任者" prop="creator">
                   <el-input v-model="forms.creator" placeholder="请输入责任者" />
                   <el-input type="textarea" rows="1" v-model="forms.creator" placeholder="请输入责任者" />
                 </el-form-item>
           </el-col>
           </el-row>
           <el-form-item label="文件题名" prop="title">
             <el-input v-model="forms.title" placeholder="请输入文件题名" />
             <el-input type="textarea" rows="1" v-model="forms.title" placeholder="请输入文件题名" />
           </el-form-item>
                 <el-form-item label="日期" prop="date">
                  <el-input v-model="forms.date" placeholder="请输入日期 (格式:yyyy-mm-dd)" style="width: 200px;" />
@@ -824,13 +828,17 @@
       importDialogVisible: false,
      fileList: [],
      uploadUrl:  process.env.VUE_APP_BASE_API +'/system/materials/upload/'+this.recordId, // 替换为实际的上传接口
      uploadUrl:  process.env.VUE_APP_BASE_API +'/system/materials/uploads/'+this.recordId, // 替换为实际的上传接口
           headers: {
        Authorization: 'Bearer ' + getToken()
      },
      uploadParams: {
        type: 'material' // 自定义上传类型
      },
      // 上传状态跟踪
      uploadSuccessCount: 0,
      uploadFailCount: 0,
      totalUploadFiles: 0,
      // 添加材料类型选项
      fileStyleOptions: [
          { value: '文字材料', label: '文字材料' },
@@ -959,6 +967,14 @@
            { required: true, message: "页号不能为空", trigger: "blur" },
            { type: 'number', message: '页号必须为数字类型', trigger: ['blur', 'change'] },
            { pattern: /^[1-9]\d*$/, message: '请输入大于0的正整数', trigger: 'blur' },
            { validator: (rule, value, callback) => {
                if (this.totalPageCount > 0 && value > this.totalPageCount) {
                  callback(new Error(`页号不能超过总页数${this.totalPageCount}`));
                } else {
                  callback();
                }
              }, trigger: ['blur', 'change']
            },
            // { max: 85, message: "最大长度为85个字符", trigger: "blur" }
          ],
          stage: [
@@ -1039,29 +1055,43 @@
    methods: {
        // 上传失败回调
    handleError(err, file, fileList) {
      this.$modal.msgError("上传失败: " + err.message)
       // 清除上传列表
  this.$refs.upload.clearFiles();
      // 失败计数+1
      this.uploadFailCount++;
      // 检查是否所有文件都上传完成
      this.checkUploadComplete();
    },
          // 上传成功回调
    handleSuccess(response, file, fileList) {
      if (response.code === 200) {
        this.$modal.msgSuccess("上传成功")
 // 清除上传列表
  this.$refs.upload.clearFiles();
  // 关闭上传对话框
  this.importDialogVisible = false;
        // 刷新列表数据
        this.getList();        // 这里可以调用接口关联上传的文件和当前记录
        //更新档案的状态
        // 成功计数+1
        this.uploadSuccessCount++;
      } else {
        // alert(234)
        console.log(response)
        this.$modal.msgError(response.msg)
        // 失败计数+1
        this.uploadFailCount++;
      }
      // 检查是否所有文件都上传完成
      this.checkUploadComplete();
    },
    // 检查所有文件是否上传完成
    checkUploadComplete() {
      // 当所有文件都上传完成时
      if (this.uploadSuccessCount + this.uploadFailCount === this.totalUploadFiles) {
        if (this.uploadFailCount === 0) {
          // 所有文件上传成功
          this.$modal.msgSuccess("所有文件上传成功");
        } else {
          // 部分文件上传失败
          this.$modal.msgError(`上传完成,但有 ${this.uploadFailCount} 个文件上传失败`);
        }
        // 清除上传列表
        this.$refs.upload.clearFiles();
        // 关闭上传对话框
        this.importDialogVisible = false;
        // 刷新列表数据
        this.getList();
      }
    },
       // 打开导入对话框
     // 打开导入对话框
    handleImport() {
      //生成新的记录
      insertFile(this.recordId, this.totalPageCount).then(response => {
@@ -1106,6 +1136,10 @@
       }
       else
       {
         // 初始化上传状态计数
         this.uploadSuccessCount = 0;
         this.uploadFailCount = 0;
         this.totalUploadFiles = fileCount;
         // 执行上传
           this.$refs.upload.submit()
           this.getList()
@@ -1146,22 +1180,7 @@
      /** 查询【请填写功能名称】列表 */
      getList() {
        this.loading = true
        // 处理档案号搜索逻辑,包括范围搜索
        const queryParams = { ...this.queryParams }
        // 检查是否包含范围搜索符号
        if (queryParams.fileNumber && queryParams.fileNumber.includes('~')) {
          const rangeParts = queryParams.fileNumber.split('~')
          if (rangeParts.length === 2) {
            // 解析范围搜索参数
            // 保留原始fileNumber用于其他处理
            queryParams.fileNumberStart = rangeParts[0].trim()
            queryParams.fileNumberEnd = rangeParts[1].trim()
          }
        }
        listMaterials(queryParams).then(response => {
        listMaterials(this.queryParams).then(response => {
          console.log(response)
          // 过滤掉visible为0的记录
          this.materialsList = response.data.data.filter(item => item.visible !== 0)
@@ -1313,12 +1332,10 @@
        this.showCreatorSuggestions = false;
      },
      // 处理材料类型变化(新增表单)
      // 处理材料类型变化
      handleFileStyleChange(value) {
        // 当选择'其他材料'时,将页号设置为0
     //   alert(value)
        // 当选择'其他材料'时,清空页码字段
        if (value === '其他材料') {
        //  alert(34)
          this.form.pageNumber = null;
        }
      },
@@ -1486,30 +1503,26 @@
          // 保存成功后,光标跳回文件编号输入框
          this.$nextTick(() => {
            this.$refs.documentNumberInput.focus();
            this.$refs.documentNumberInput.select();
          });
          this.getList()
        })
        }
        else
        {
          this.$message.error('请填写所有必填字段');
          })
          }
          else
          {
            this.$message.error('请填写所有必填字段');
        }
        })
      },
      /** 提交按钮 */
      submitForms() {
        console.log(this.forms)
        this.$refs["forms"].validate(valid => {
          if (valid) {
            if (this.forms.materialId != null) {
              updateMaterials(this.forms).then(response => {
                this.$modal.msgSuccess("修改成功")
                // 修改成功后,光标跳回文件编号输入框
                this.$nextTick(() => {
                  this.$refs.documentNumberInput.focus();
                });
                this.open = false
                this.getList()
              })
@@ -1752,3 +1765,7 @@
  background-color: #fff;
}
</style>