fei
9 小时以前 6429b95aa66bfbb214bcadb248b8b7ca5e754368
src/views/archiveManager/archiveMaterial/index.vue
@@ -1,6 +1,8 @@
<template>
    <div class="app-container">
         <h2 class="title-border">添加案卷详细记录</h2>
      <div v-if="sho">
         <h2 class="title-border">添加案卷详细记录   {当前录入了{{total}}条}  {当前档号为: {{recordStrId}} } {当前文号为: {{inquiryNumber}} }  </h2>
 <el-form ref="form" :model="form" :rules="rules" label-width="100px">
   <el-row>
@@ -14,7 +16,31 @@
    <el-row>
    <el-col :span="16">
          <el-form-item label="责任者" prop="creator">
            <el-input v-model="form.creator" placeholder="请输入责任者" />
            <div class="title-search-wrapper">
              <el-input
                type="textarea"
                rows="2"
                    v-auto-height="{ minRows: 2, maxRows: 10 }"
                v-model="form.creator"
                placeholder="请输入责任者"
                  @focus="(e) => e.target.select()"
              />
              <!-- 下拉建议框 -->
              <div
                v-if="showCreatorSuggestions && creatorSuggestions.length > 0 && false"
                class="title-suggestions"
              >
                <div
                  v-for="(item, index) in creatorSuggestions"
                  :key="index"
                  class="suggestion-item"
                  @mousedown.prevent="selectCreatorSuggestion(item)"
                >
                  {{ item }}
                </div>
              </div>
            </div>
          </el-form-item>
          </el-col>
  </el-row>
@@ -22,7 +48,29 @@
  <el-col :span="16">
          <el-form-item label="文件题名" prop="title">
            <el-input v-model="form.title" placeholder="请输入文件题名" />
            <div class="title-search-wrapper">
              <el-input
                type="textarea"
                rows="2"
                v-model="form.title"
                placeholder="请输入文件题名"
                @focus="(e) => e.target.select()"
              />
              <!-- 下拉建议框 -->
              <div
                v-if="showTitleSuggestions && titleSuggestions.length > 0  && false"
                class="title-suggestions"
              >
                <div
                  v-for="(item, index) in titleSuggestions"
                  :key="index"
                  class="suggestion-item"
                  @mousedown="selectTitleSuggestion(item)"
                >
                  {{ item }}
                </div>
              </div>
            </div>
          </el-form-item>
    </el-col>
    </el-row>
@@ -43,6 +91,7 @@
          <el-select
            v-model="form.fileStyle"
            placeholder="请选择材料类型"
            @change="handleFileStyleChange"
          >
            <el-option
              v-for="item in fileStyleOptions"
@@ -189,7 +238,7 @@
        </div>
</div>
<div class="title-border"></div>
@@ -197,7 +246,7 @@
      <el-row :gutter="12" class="mb8">
      <el-row :gutter="12" class="mb8 fixed-row">
        <el-col :span="1.5">
          <el-button
            type="primary"
@@ -210,6 +259,7 @@
        </el-col>
        <el-col :span="1.5">
          <el-button
          v-if="sho"
            type="success"
            plain
            icon="el-icon-edit"
@@ -219,6 +269,17 @@
            v-hasPermi="['system:materials:edit']"
          >修改</el-button>
        </el-col>
           <el-col :span="1.5">
          <el-button
            type="warning"
            plain
            icon="el-icon-download"
            size="mini"
            @click="handleExportDir"
            v-hasPermi="['system:materials:list']"
          >导出卷内目录</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="warning"
@@ -226,11 +287,13 @@
            icon="el-icon-download"
            size="mini"
            @click="handleExport"
            v-hasPermi="['system:materials:list']"
          >导出</el-button>
          >导出电子文件目录</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
          v-if="sho"
            type="danger"
            plain
            icon="el-icon-delete"
@@ -241,42 +304,7 @@
          >删除</el-button>
        </el-col>
          <el-col :span="1.5">
          <el-button
            type="success"
            plain
            icon="el-icon-edit"
            size="mini"
            @click="handleImport"
            v-hasPermi="['system:materials:edit']"
          >全部附件导入</el-button>
            <!-- 在按钮下方添加导入对话框 -->
  <el-dialog title="批量导入附件" :visible.sync="importDialogVisible" width="50%">
    <el-upload
      class="upload-demo"
      ref="upload"
      :action="uploadUrl"
      :headers="headers"
      :data="uploadParams"
      :on-success="handleSuccess"
      :on-error="handleError"
      :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>
        </el-col>
        <el-col :span="1.5">
        <el-button
          type="warning"
@@ -288,7 +316,7 @@
        >导入模板下载</el-button>
      </el-col>
        <el-col :span="1.5">
        <el-col      v-if="sho" :span="1.5">
        <el-upload
          action=""
@@ -305,12 +333,50 @@
        </el-upload>
      </el-col>
      <el-col :span="1.5">
              <el-button
              v-if="sho"
                type="success"
                plain
                icon="el-icon-edit"
                size="mini"
                @click="handleImport"
                v-hasPermi="['system:materials:edit']"
              >全部附件导入</el-button>
              已经上传了 {{this.fileCut}} 张附件,还要上传 {{this.totalPageCount-this.fileCut}} 张附件
                <!-- 在按钮下方添加导入对话框 -->
      <el-dialog title="批量导入附件" :visible.sync="importDialogVisible" width="50%">
        <el-upload
          class="upload-demo"
          ref="upload"
          :action="uploadUrl"
          :headers="headers"
          :data="uploadParams"
          :on-success="handleSuccess"
          :on-error="handleError"
          :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>
            </el-col>
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
      </el-row>
      <el-table v-loading="loading" :data="materialsList" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="操作" align="center" width="160" class-name="small-padding ">
        <el-table-column v-if="sho" label="操作" align="center" width="160" class-name="small-padding ">
              <template slot-scope="scope">
                <el-button
                  size="mini"
@@ -336,19 +402,19 @@
              </template>
            </el-table-column>
                <el-table-column label="文件材料序号" align="center" prop="fileNumber" />
        <el-table-column label="文件编号" align="center" prop="documentNumber" />
        <el-table-column label="文件编号" align="center" prop="documentNumber" width="180"/>
        <el-table-column label="责任者" align="center" prop="creator" />
        <el-table-column label="文件题名" align="center" prop="title" />
        <el-table-column label="责任者" align="center" prop="creator" width="180"/>
        <el-table-column label="文件题名" align="center" prop="title" width="220"/>
        <el-table-column label="日期" align="center" prop="date" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.date, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="页号" sortable align="center" prop="pageNumber"  />
        <el-table-column label="备注" align="center" prop="remarks" />
                <el-table-column label="页次" sortable align="center" prop="pageOrder"  />
        <el-table-column label="备注" align="center" prop="remarks" width="180"/>
            <!--          <el-table-column label="页次" sortable align="center" prop="pageOrder"  />
--->
        <el-table-column label="所处阶段" sortable align="center" width="180" prop="stage" />
        <el-table-column label="公开属性" sortable align="center" width="180" prop="publicity" />
        <el-table-column label="是否为附图及附件" align="center" prop="isAttachment" />
@@ -359,13 +425,13 @@
        <el-table-column label="是否涉密及敏感信息" align="center" prop="isSensitive" />
        <el-table-column label="是否注销" align="center" prop="isCanceled" />
        <el-table-column label="格式" align="center" prop="format" />
     <!--   <el-table-column label="格式" align="center" prop="format" />
        <el-table-column label="幅面" align="center" prop="sizeType" />
        <el-table-column label="水平分辨率" align="center" prop="horizontalResolution" />
        <el-table-column label="垂直分辨率" align="center" prop="verticalResolution" />
        <el-table-column label="宽度" align="center" prop="width" />
        <el-table-column label="高度" align="center" prop="height" />
        <el-table-column label="大小" align="center" prop="fileSize" />
        <el-table-column label="大小" align="center" prop="fileSize" /> -->
        <el-table-column label="附件及历史发文号" align="center" prop="attachmentHistoryNumbers" />
@@ -393,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;" />
@@ -416,9 +482,9 @@
    <el-form-item label="材料类型" prop="fileStyle">
          <el-select
            v-model="forms.fileStyle"
            placeholder="请选择材料类型"
            clearable
            @change="handleFileStyleChange2"
          >
            <el-option
              v-for="item in fileStyleOptions"
@@ -428,7 +494,7 @@
            />
          </el-select>
        </el-form-item>
     <el-form-item label="页号" prop="pageNumber">
     <el-form-item label="页号" prop="pageNumber" v-if="forms.fileStyle !== '其他材料'">
        <el-col :span="8">
          <el-input
            v-model.number="forms.pageNumber"
@@ -571,9 +637,11 @@
      <el-form-item label="文件题名" prop="title">
        <el-input
          v-model="queryParams.title"
          placeholder="请输入文件题目"
          placeholder="请输入文件题名"
          clearable
          @keyup.enter.native="handleQuery"
          :validate-event="false"
          @blur="validateQueryTitle"
        />
      </el-form-item>
      <el-form-item label="日期" prop="date">
@@ -586,7 +654,7 @@
          placeholder="请选择日期">
        </el-date-picker> -->
      </el-form-item>
      <el-form-item label="页号" prop="pageNumber">
    <!--  <el-form-item label="页号" prop="pageNumber">
        <el-col :span="8">
          <el-input
            v-model.number="queryParams.pageNumber"
@@ -606,7 +674,7 @@
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      </el-form-item> -->
     <el-form-item label="文字材料" prop="fileStyle">
          <el-select
            v-model="queryParams.fileStyle"
@@ -740,25 +808,42 @@
  </template>
  <script>
  import { islegal, listMaterials, enload, getMaterials, delMaterials, addMaterials, updateMaterials } from "@/api/system/materials"
  import {insertFile, getFileCount,islegal, listMaterials, enload, getMaterials, delMaterials, addMaterials, updateMaterials } from "@/api/system/materials"
import { getToken } from '@/utils/auth'
import store from '@/store'
import { updateStatusById } from "@/api/system/records"
import {delArchiverecordstouserByReIdAndUid} from "@/api/system/archiverecordstouser"
  export default {
    name: "Materials",
    data() {
      return {
        //附件数量
        fileCut: 0,
        //是否显示相关内容
        sho: true,
        totalPageCount: 0,
        // 记录元素初始位置和状态
  originalOffsetLeft: 0,
        originalWidth: 0,
            placeholderEl: null,
       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: '文字材料' },
@@ -803,6 +888,8 @@
          { value: '06-业务数据', label: '06-业务数据' },
        ],
        recordId: null,
        inquiryNumber: '',
        recordStrId: '',
        // 遮罩层
        loading: true,
        // 选中数组
@@ -819,6 +906,13 @@
        materialsList: [],
        // 弹出层标题
        title: "",
        // 文件题名搜索相关
        titleSuggestions: [], // 匹配的文件题名建议列表
        showTitleSuggestions: false, // 是否显示建议框
        titleSearchTimer: null, // 防抖定时器
        creatorSuggestions: [], // 匹配的责任人建议列表
        showCreatorSuggestions: false, // 是否显示责任人建议框
        creatorSearchTimer: null, // 责任人查询防抖定时器
        // 是否显示弹出层
        open: false,
        titles: "",
@@ -863,39 +957,95 @@
        // 表单校验
        rules: {
          creator: [
           // { required: true, message: "创建者不能为空", trigger: "blur" }
           // { required: true, message: "创建者不能为空", trigger: "blur" },
            { max: 85, message: "最大长度为85个字符", trigger: "blur" }
          ],
          title: [
            { required: true, message: "案卷题名不能为空", trigger: "blur" }
            { required: true, message: "案卷题名不能为空", trigger: "blur" },
             { pattern: /^[^\\/:*?"<>丨]+$/, message: "文件名不能包含 \\\:*?<>丨 等特殊字符", trigger: "blur" },
            { max: 85, message: "最大长度为85个字符", trigger: "blur" }
          ],
          date: [
          //  { required: true, message: "日期不能为空", trigger: "blur" },
            { pattern: /^\d{4}-\d{2}-\d{2}$/, message: "日期格式必须为yyyy-mm-dd", trigger: "blur" }
            { pattern: /^\d{4}-\d{2}-\d{2}$/, message: "日期格式必须为yyyy-mm-dd", trigger: "blur" },
            { max: 85, message: "最大长度为85个字符", trigger: "blur" }
          ],
          pageNumber: [
            { required: true, message: "页号不能为空", trigger: "blur" },
            { type: 'number', message: '页号必须为数字类型', trigger: ['blur', 'change'] },
            { pattern: /^\d+$/, message: '请输入正整数', trigger: 'blur' }
            { 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: [
            { required: true, message: "所处阶段不能为空", trigger: "change" }
            { required: true, message: "所处阶段不能为空", trigger: "change" },
            { max: 85, message: "最大长度为85个字符", trigger: "blur" }
          ],
          fileStyle: [
            { required: true, message: "材料类型不能为空", trigger: "change" },
            { max: 85, message: "最大长度为85个字符", trigger: "blur" }
          ],
          isAttachment: [
            { required: true, message: "是否为附件不能为空", trigger: "change" },
            { max: 85, message: "最大长度为85个字符", trigger: "blur" }
          ],
          retentionPeriod: [
            { required: true, message: "保管期限不能为空", trigger: "change" },
            { max: 85, message: "最大长度为85个字符", trigger: "blur" }
          ],
          isSensitive: [
            { required: true, message: "是否敏感不能为空", trigger: "change" },
            { max: 85, message: "最大长度为85个字符", trigger: "blur" }
          ],
          isCanceled: [
            { required: true, message: "是否注销不能为空", trigger: "change" },
            { max: 85, message: "最大长度为85个字符", trigger: "blur" }
          ]
        }
      }
    },
   mounted() {
     // 添加滚动事件监听
     window.addEventListener('scroll', this.handleScroll);
    // 改为监听keydown事件
    document.addEventListener('keydown', this.handleKeyDown)
  },
  beforeDestroy() {
    // 移除滚动事件监听
    document.removeEventListener('keydown', this.handleKeyDown)
    // 移除滚动事件监听
    window.removeEventListener('scroll', this.handleScroll);
    // 清理占位符
    if (this.placeholderEl && this.placeholderEl.parentNode) {
      this.placeholderEl.parentNode.removeChild(this.placeholderEl);
    }
  },
    created() {
      //const roleId = this.$route.params && this.$route.params.roleId
      const recordId = this.$route.params && this.$route.params.recordId
      this.recordStrId = this.$route.params && this.$route.params.recordStrId
      this.inquiryNumber = this.$route.params && this.$route.params.inquiryNumber
      this.totalPageCount = this.$route.params && this.$route.params.pageCount
      this.sho = this.$route.params && this.$route.params.sho
      // 将字符串转换为布尔值
      this.sho = this.sho === true || this.sho === "true"
      //alert(this.totalPageCount)
      //alert(recordId)
      this.recordId = recordId;
      this.uploadUrl = process.env.VUE_APP_BASE_API +'/system/materials/upload/'+this.recordId
      this.uploadUrl = process.env.VUE_APP_BASE_API +'/system/materials/uploads/'+this.recordId
// alert('Bearer ' + getToken())
      this.reset()
      this.form.securityLevel = '普通' // 设置对话框表单默认值
@@ -908,35 +1058,108 @@
        this.queryParams.recordId = recordId
        this.getList()
        getFileCount(recordId).then(response=>{
          this.fileCut = response.length
         // alert(this.fileCut)
        })
      }
    },
    methods: {
    handleTabKey (event) {
     // 默认行为
     event.preventDefault()
     // 手动全选
     const textarea = event.target
     textarea.select()
     // 如果需要切换到下一个元素,可以手动触发
     // const focusableElements = getFocusableElements()
     // moveFocusToNextElement()
   },
      // 输入事件(示例:可根据输入内容过滤建议列表)
          handleCreatorInput(val) {
            // 重置选中索引
            this.selectedIndex = -1;
            // 这里替换成你的实际建议列表获取逻辑
            // this.creatorSuggestions = ['张三', '李四', '王五', '赵六'].filter(item =>
            //   item.includes(val)
            // );
          },
          // 上方向键逻辑
          handleKeyUp() {
            if (!this.showCreatorSuggestions || this.creatorSuggestions.length === 0) return;
            // 向上切换,到顶则回到最后一项
            this.selectedIndex = this.selectedIndex <= 0
              ? this.creatorSuggestions.length - 1
              : this.selectedIndex - 1;
          },
          // 下方向键逻辑
          handleKeyDown() {
            if (!this.showCreatorSuggestions || this.creatorSuggestions.length === 0) return;
            // 向下切换,到底则回到第一项
            this.selectedIndex = this.selectedIndex >= this.creatorSuggestions.length - 1
              ? 0
              : this.selectedIndex + 1;
          },
          // 回车选中当前高亮项
          handleKeyEnter() {
            if (this.selectedIndex >= 0 && this.selectedIndex < this.creatorSuggestions.length) {
              this.selectCreatorSuggestion(this.creatorSuggestions[this.selectedIndex]);
            }
          },
        // 上传失败回调
    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;
      //  alert(123)
        // 刷新列表数据
        getFileCount(this.recordId).then(response=>{
          this.fileCut = response.length
    //      alert(98)
         // alert(this.fileCut)
         this.getList();
        })
      }
    },
       // 打开导入对话框
     // 打开导入对话框
    handleImport() {
      //生成新的记录
      // insertFile(this.recordId, this.totalPageCount).then(response => {
      //   console.log(response)
      // //  alert(3245)
      //   })
      this.importDialogVisible = true
    },
    // 文件移除
@@ -959,26 +1182,63 @@
        this.$modal.msgWarning('请先选择文件再上传')
        return
      }
      if(fileCount!==this.total)
      {
        this.$modal.msgWarning('请选择与记录数一致的文件')
        return
      }
     // alert(this.recordId)
      //判断页号与上传上传的文件的页号是不是一一对应的
     islegal(this.recordId).then(response => {
       console.log(response.data)
       var res = response.data
       if(res)
     // islegal(this.recordId).then(response => {
     //   console.log(response.data)
     //   var res = response.data.res
     //  console.log(res)
       //alert(response.data.total)
       // if(fileCount!=this.totalPageCount)
       // {
       //   this.$modal.msgWarning('请选择与记录数一致的文件')
       //   return
       // }
     //  else
       {
         // 定义允许的最大值
         const maxValue = this.totalPageCount;
         // 过滤fileList数组,保留数字部分不超过maxValue的元素
         this.fileList = this.fileList.filter(item => {
          // 步骤1:检测是否包含中文([\u4e00-\u9fa5]是中文的Unicode范围)
             const hasChinese = /[\u4e00-\u9fa5]/.test(item.name);
             // 有中文直接返回false,删除该元素
             if (hasChinese) return false;
           // 步骤1:提取name中的纯数字部分
           // 正则表达式解释:\d+ 匹配一个或多个数字
           const numStr = item.name.match(/\d+/);
           // 处理没有数字的情况(返回false,会被过滤掉)
           if (!numStr) return false;
           // 步骤2:将数字字符串转为数字
           const num = parseInt(numStr[0], 10);
           // 步骤3:判断是否小于等于最大值
           return num <= maxValue;
         });
         // 初始化上传状态计数
         this.uploadSuccessCount = 0;
         this.uploadFailCount = 0;
         this.totalUploadFiles = fileCount;
         // 执行上传
         console.log(this.fileList)
           this.$refs.upload.submit()
           this.getList()
      //     this.getList()
       }
       else
       {
         this.$modal.msgError("页号不连续,请修改为连续正确的页号!")
       }
     })
       // else
       // {
       //   this.$modal.msgError("页号不连续,请修改为连续正确的页号!")
       // }
     //})
    },
    clearFileList() {
@@ -1012,7 +1272,8 @@
        this.loading = true
        listMaterials(this.queryParams).then(response => {
          console.log(response)
          this.materialsList = response.data.data
          // 过滤掉visible为0的记录
          this.materialsList = response.data.data.filter(item => item.visible !== 0)
          this.total = response.data.total
          this.loading = false
        })
@@ -1053,6 +1314,139 @@
        }
        this.resetForm("forms")
      },
      // 处理文件题名输入事件
      handleTitleInput() {
        // 清除之前的定时器(防抖)
        if (this.titleSearchTimer) {
          clearTimeout(this.titleSearchTimer);
        }
        // 当输入框为空时,清空建议列表
        if (!this.form.title.trim()) {
          this.titleSuggestions = [];
          return;
        }
        // 设置新的定时器,延迟执行查询
        this.titleSearchTimer = setTimeout(() => {
          this.searchTitleSuggestions();
        }, 300);
      },
      // 搜索文件题名建议
      searchTitleSuggestions() {
        // 使用现有的listMaterials API,传入title作为查询参数
        listMaterials(
       {
          title: this.form.title,
          pageSize: 10 // 限制返回数量
        }).then(response => {
          console.log(response.data.data)
        //  alert(23)
          // 提取并去重title字段
          const titles = response.data.data.map(item => item.title);
          // 去重处理
          this.titleSuggestions = [...new Set(titles)];
          // 显示建议框
          this.showTitleSuggestions = true;
        }).catch(() => {
          // 错误处理
          this.titleSuggestions = [];
        });
      },
      // 处理失焦事件
      handleTitleBlur() {
        // 延迟隐藏,以便可以点击选择建议项
        setTimeout(() => {
          this.showTitleSuggestions = false;
        }, 200);
      },
      // 选择建议项
      selectTitleSuggestion(title) {
        this.form.title = title;
        this.showTitleSuggestions = false;
      },
      // 处理责任人输入事件
      handleCreatorInput() {
        // 清除之前的定时器(防抖)
        if (this.creatorSearchTimer) {
          clearTimeout(this.creatorSearchTimer);
        }
        // 当输入框为空时,清空建议列表
        if (!this.form.creator.trim()) {
          this.creatorSuggestions = [];
          return;
        }
        // 设置新的定时器,延迟执行查询
        this.creatorSearchTimer = setTimeout(() => {
          this.searchCreatorSuggestions();
        }, 300);
      },
      // 搜索责任人建议
      searchCreatorSuggestions() {
        // 使用现有的listMaterials API,传入creator作为查询参数
        listMaterials(
        {
          creator: this.form.creator,
          pageSize: 10 // 限制返回数量
        }).then(response => {
          // 提取并去重creator字段
          const creators = response.data.data.map(item => item.creator).filter(Boolean);
          // 去重处理
          this.creatorSuggestions = [...new Set(creators)];
          // 显示建议框
          this.showCreatorSuggestions = true;
        }).catch(() => {
          // 错误处理
          this.creatorSuggestions = [];
        });
      },
      // 处理责任人输入框失焦事件
      handleCreatorBlur() {
        // 延迟隐藏,以便可以点击选择建议项
        setTimeout(() => {
          this.showCreatorSuggestions = false;
        }, 200);
      },
      // 选择责任人建议项
      selectCreatorSuggestion(creator) {
        this.form.creator = creator;
        this.showCreatorSuggestions = false;
        // 手动触发 input 事件,确保表单验证等逻辑正常
            this.$nextTick(() => {
              const inputElement = this.$el.querySelector('textarea');
              if (inputElement) {
                inputElement.focus();
                // 将光标定位到文本末尾
                const length = inputElement.value.length;
                inputElement.setSelectionRange(length, length);
              }
            });
      },
      // 处理材料类型变化
      handleFileStyleChange(value) {
        // 当选择'其他材料'时,清空页码字段
        if (value === '其他材料') {
          this.form.pageNumber = null;
        }
      },
      // 处理材料类型变化(修改表单)
      handleFileStyleChange2(value) {
        // 当选择'其他材料'时,将页号设置为0
        if (value === '其他材料') {
          this.forms.pageNumber = null;
        }
      },
      // 表单重置
      reset() {
        this.form = {
@@ -1085,8 +1479,24 @@
        }
        this.resetForm("form")
      },
      // 验证查询表单中的文件题名
      validateQueryTitle() {
        const illegalCharsPattern = /[\\/:*?<>丨]/;
        if (this.queryParams.title && illegalCharsPattern.test(this.queryParams.title)) {
          this.$message.error("文件名不能包含 \\:/:*?<>丨 等特殊字符");
          this.queryParams.title = this.queryParams.title.replace(illegalCharsPattern, '');
        }
      },
      /** 搜索按钮操作 */
      handleQuery() {
        // 搜索前校验文件题名
        const illegalCharsPattern = /[\\/:*?<>丨]/;
        if (this.queryParams.title && illegalCharsPattern.test(this.queryParams.title)) {
          this.$message.error("文件名不能包含 \\:/:*?<>丨 等特殊字符");
          this.queryParams.title = this.queryParams.title.replace(illegalCharsPattern, '');
          return; // 阻止搜索,直到用户修正输入
        }
        this.queryParams.pageNum = 1
        this.getList()
      },
@@ -1113,6 +1523,10 @@
        const materialId = row.materialId || this.ids
        getMaterials(materialId).then(response => {
          this.forms = response.data
          // 如果材料类型是"其他材料",将页号设置为0
          if (this.forms.fileStyle === '其他材料') {
            this.forms.pageNumber = null;
          }
          this.open = true
          this.title = "修改案卷详细信息"
        })
@@ -1189,14 +1603,14 @@
          // 保存成功后,光标跳回文件编号输入框
          this.$nextTick(() => {
            this.$refs.documentNumberInput.focus();
            this.$refs.documentNumberInput.select();
          });
          this.getList()
        })
        }
        else
        {
          this.$message.error('请填写所有必填字段');
          })
          }
          else
          {
            this.$message.error('请填写所有必填字段');
        }
        })
@@ -1208,10 +1622,7 @@
            if (this.forms.materialId != null) {
              updateMaterials(this.forms).then(response => {
                this.$modal.msgSuccess("修改成功")
                // 修改成功后,光标跳回文件编号输入框
                this.$nextTick(() => {
                  this.$refs.documentNumberInput.focus();
                });
                this.open = false
                this.getList()
              })
@@ -1231,11 +1642,45 @@
          this.$modal.msgSuccess("删除成功")
        }).catch(() => {})
      },
      /** 导出按钮操作 */
           /** 导出按钮操作 - 支持导出选中行或全部数据 */
      handleExportDir() {
        // 判断是否有选中的行
        if (this.ids && this.ids.length > 0) {
          // 显示导出选中行的提示
          this.$message.info(`正在导出${this.ids.length}条选中的数据...`);
          // 导出选中的行数据
          this.download('system/materials/exportDir', {
            ids: this.ids.join(','),
         //   exportType: 'selected'
          }, `materiaDir_selected_${new Date().getTime()}.xls`)
        } else {
          // 显示导出全部数据的提示
          this.$message.info('正在导出符合当前查询条件的所有数据...');
          // 没有选中行时,导出当前查询条件的数据
          this.download('system/materials/exportDir', {
            ...this.queryParams
          }, `materiaDir_${new Date().getTime()}.xls`)
        }
      },
      /** 导出按钮操作 - 支持导出选中行或全部数据 */
      handleExport() {
        this.download('system/materials/export', {
          ...this.queryParams
        }, `materials_${new Date().getTime()}.xlsx`)
        // 判断是否有选中的行
        if (this.ids && this.ids.length > 0) {
          // 显示导出选中行的提示
          this.$message.info(`正在导出${this.ids.length}条选中的数据...`);
          // 导出选中的行数据
          this.download('system/materials/export', {
            ids: this.ids.join(','),
         //   exportType: 'selected'
          }, `materials_selected_${new Date().getTime()}.xls`)
        } else {
          // 显示导出全部数据的提示
          this.$message.info('正在导出符合当前查询条件的所有数据...');
          // 没有选中行时,导出当前查询条件的数据
          this.download('system/materials/export', {
            ...this.queryParams
          }, `materials_${new Date().getTime()}.xls`)
        }
      },
       /** 导入模板下载操作*/
@@ -1243,7 +1688,7 @@
    {
      this.download('/system/materials/model', {
      }, `materials_${new Date().getTime()}.xlsx`)
      }, `materials_${new Date().getTime()}.xls`)
    },
       /** 导入操作*/
    async handleImportData({file}){
@@ -1254,7 +1699,7 @@
  // }
  const formData = new FormData();
  formData.append('file', file);
 // formData.append('recordId', this.recordId)
  formData.append('recordId', this.recordId)
  // alert(this.recordId)
  console.log(file)
@@ -1296,7 +1741,7 @@
      //修改案卷的状态
  //  var id = row.id
      var status = '未上传附件'
      updateStatusById(status, recordId).then(response=>{
      updateStatusById(status, recordId, '退回管理员').then(response=>{
      //  this.$modal.msgSuccess("提交成功")
      //  this.getList()
      _this.$store.dispatch('tagsView/delView', this.$route);
@@ -1306,13 +1751,121 @@
      }).catch(() => {})
    },
    }
    // 滚动事件处理
    handleScroll() {
      const fixedRow = document.querySelector('.fixed-row');
      if (!fixedRow) return;
      // 获取元素当前位置信息
      const rect = fixedRow.getBoundingClientRect();
      const parentRect = fixedRow.parentNode.getBoundingClientRect();
      // 记录元素的原始位置(相对于文档顶部的位置)
      if (!this.originalTop) {
        this.originalTop = rect.top + window.pageYOffset;
      }
      // 检查元素是否应该进入悬浮状态(当滚动位置超过元素原始位置时)
      if (window.pageYOffset >= this.originalTop) {
        // 只在不在floating状态时添加,避免重复操作
        if (!fixedRow.classList.contains('floating')) {
          // 记录元素原始的左偏移量(相对于父容器)
          this.originalOffsetLeft = rect.left - parentRect.left;
          // 记录元素的原始宽度
          this.originalWidth = rect.width;
          // 添加floating类,使元素固定在顶部
          fixedRow.classList.add('floating');
          // 设置固定位置时的样式,保持与原始布局一致
          fixedRow.style.left = this.originalOffsetLeft + 'px';
          fixedRow.style.width = this.originalWidth + 'px';
          // 添加临时占位符,防止页面布局跳动
          if (!this.placeholderEl) {
            this.placeholderEl = document.createElement('div');
            this.placeholderEl.style.height = rect.height + 'px';
            this.placeholderEl.style.marginBottom = '10px';
            this.placeholderEl.style.boxSizing = 'border-box';
            fixedRow.parentNode.insertBefore(this.placeholderEl, fixedRow.nextSibling);
          }
        }
      } else {
        // 当滚动位置回到元素原始位置以上时,移除悬浮状态,恢复到文档流中
        if (fixedRow.classList.contains('floating')) {
          // 移除floating类
          fixedRow.classList.remove('floating');
          // 重置样式,让浏览器使用原始样式
          fixedRow.style.left = '';
          fixedRow.style.width = '';
          // 移除占位符,让元素回到原始位置
          if (this.placeholderEl && this.placeholderEl.parentNode) {
            this.placeholderEl.parentNode.removeChild(this.placeholderEl);
            this.placeholderEl = null;
          }
        }
      }
    },
}
  }
  </script>
</script>
<style scoped>
.title-search-wrapper {
        position: relative;
        width: 100%;
      }
      .title-suggestions {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        z-index: 1000;
        background-color: #fff;
        border: 1px solid #dcdfe6;
        border-radius: 4px;
        box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
        max-height: 200px;
        overflow-y: auto;
        margin-top: 4px;
      }
      .suggestion-item {
        padding: 10px 15px;
        cursor: pointer;
        transition: background-color 0.2s;
      }
      .suggestion-item:hover {
        background-color: #f5f7fa;
      }
.title-border {
  border-bottom: 1px solid #dcdfe6;
  padding-bottom: 10px;
  margin-bottom: 20px;
}
.fixed-row {
  position: static;
  z-index: 1000;
  background-color: #fff;
  padding: 10px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 10px;
  box-sizing: border-box;
}
.fixed-row.floating {
  position: fixed;
  top: 0;
  z-index: 2000;
  padding: 10px;
  margin-bottom: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  background-color: #fff;
}
</style>