Kaynağa Gözat

编辑增加下一个按钮

duy 5 gün önce
ebeveyn
işleme
0a5ca7310d

+ 35 - 18
src/views/certificate/list.vue

@@ -128,6 +128,8 @@ export default {
       pageindex: 1,
       pagesize: 20,
       certificateTypeValue: null, //证书类型
+      nextId: null,
+
     };
   },
   watch: {
@@ -177,24 +179,39 @@ export default {
 
     //#region 头接口
    // 修改pushRouter方法,传递完整的查询状态
-    pushRouter(id) {
-      this.$router.push({
-        path: "/certificate/list/addList",
-        query: {
-          id,
-          // 传递项目ID
-          value: this.value,
-          // 传递证书类型
-          certificateTypeValue: this.certificateTypeValue,
-          // 传递搜索关键词
-          searchinput: this.searchinput,
-          // 传递当前页码
-          pageindex: this.pageindex,
-          // 传递每页条数
-          pagesize: this.pagesize
-        }
-      });
-    },
+  // 在列表页的pushRouter方法中修改下一条ID的计算方式
+pushRouter(id) {
+  // 找到当前行在表格数据中的索引
+  const currentIndex = this.tableData.findIndex(row => row.id === id);
+  // 获取下一行数据的id(如果存在)
+  let nextId = null;
+  
+  // 如果是最后一条记录,查询下一页的第一条
+  if (currentIndex === this.tableData.length - 1) {
+    // 检查是否有下一页
+    if (this.pageindex * this.pagesize < this.total) {
+      // 这里只是标记需要加载下一页,实际数据在编辑页处理
+      nextId = 'nextPage';
+    }
+  } else {
+    // 正常获取下一条
+    const nextRow = this.tableData[currentIndex + 1];
+    nextId = nextRow ? nextRow.id : null;
+  }
+  
+  this.$router.push({
+    path: "/certificate/list/addList",
+    query: {
+      id,
+      value: this.value,
+      certificateTypeValue: this.certificateTypeValue,
+      searchinput: this.searchinput,
+      pageindex: this.pageindex,
+      pagesize: this.pagesize,
+      nextId: nextId
+    }
+  });
+},
     //#endregion
 
     //#region 列表接口

+ 100 - 4
src/views/certificate/lists/addList.vue

@@ -255,6 +255,13 @@
         v-throttle='2000'
         @click="savess()"
       >保存</el-button>
+      <el-button
+        class="marleft30"
+        type="warning"
+        v-if="fromId!=0"
+      
+        @click="nextClick()"
+      >下一个</el-button>
     </div>
   </basic-container>
 </template>
@@ -262,6 +269,11 @@
 <script>
 import { save, getById, findUserByName, queryRole, queryProjectAndContract, addFileInfo, update, findPfxType, picPresave, prePicture, compressAndUpload } from "@/api/certificate/list";
 import {getDictionary as getDictbiz} from "@/api/system/dictbiz";
+import {
+
+  listpage,
+
+} from "@/api/certificate/list";
 export default {
   data () {
     return {
@@ -305,6 +317,12 @@ export default {
       pfxType: [],//
       options:[],
       signatureId: '',
+      fromId: '',
+      tableData:[],
+      pageindex: 1,
+      total: 0,
+      currentPage:1
+
     }
   },
   methods: {
@@ -352,9 +370,9 @@ export default {
       this.updateDependentFieldValidation()
     },
     async init () {
-
+      this.fromId = this.$route.query.id;
       if (this.$route.query.id != 0) {
-        await this.getById()
+        await this.getById(this.fromId)
       }
       this.queryProjectAndContract()//获取项目和合同段
 
@@ -520,8 +538,8 @@ export default {
     //#endregion
 
     //#region //接口
-    async getById () {//获取详细信息
-      const { data: res } = await getById({ id: this.$route.query.id })
+    async getById (id) {//获取详细信息
+      const { data: res } = await getById({ id: id })
       console.log(res);
       if (res.code == 200) {
         this.form = res.data
@@ -708,6 +726,83 @@ export default {
       return data.preUrl
     },
     stopClick() {},
+   async nextClick() {
+        let nextId = this.$route.query.nextId;
+        
+        // 处理需要加载下一页的情况
+        if (nextId === 'nextPage') {
+          nextId = await this.getNextPageData();
+        }
+        
+        if (nextId) {
+          // 获取下一条记录的详细信息
+          await this.getById(nextId);
+          
+          // 更新当前ID和下一条ID参数
+          const currentIndex = this.tableData.findIndex(row => row.id === nextId);
+          let newNextId = null;
+          
+          if (currentIndex === this.tableData.length - 1) {
+            newNextId = 'nextPage';
+          } else {
+            const nextRow = this.tableData[currentIndex + 1];
+            newNextId = nextRow ? nextRow.id : null;
+          }
+          
+          // 更新URL中的参数,保持浏览器历史正确
+        
+      this.$router.replace({
+        query: {
+          ...this.$route.query,
+          id: nextId,
+          nextId: newNextId,
+          pageindex: nextId === 'nextPage'?this.currentPage+1:this.currentPage, // 更新当前页码
+        }
+      });
+        } else {
+          this.$message({
+            type: 'info',
+            message: '已经是最后一条记录'
+          });
+        }
+    },
+    // 在编辑页添加获取列表数据的方法,用于计算下一条
+  async getTableData() {
+      const { data: res } = await listpage({
+        current: this.$route.query.pageindex || 1,
+        size: this.$route.query.pagesize || 20,
+        projectId: this.$route.query.value,
+        certificateUserName: this.$route.query.searchinput,
+        certificateType: this.$route.query.certificateTypeValue,
+      });
+      
+      if (res.code === 200) {
+        this.tableData = res.data.records;
+        this.total = res.data.total;
+        this.currentPage = res.data.current;
+      }
+  },
+    async getNextPageData() {
+    // 从路由参数中获取当前分页信息
+    const currentPage = Number(this.$route.query.pageindex) || 1;
+    const pageSize = Number(this.$route.query.pagesize) || 20;
+    console.log(currentPage,'currentPage');
+    
+    // 调用列表接口查询下一页数据
+    const { data: res } = await listpage({
+      current: currentPage + 1, // 下一页
+      size: pageSize,
+      projectId: this.$route.query.value,
+      certificateUserName: this.$route.query.searchinput,
+      certificateType: this.$route.query.certificateTypeValue,
+    });
+    
+    if (res.code === 200 && res.data.records.length > 0) {
+      // 返回下一页第一条记录的ID
+      return res.data.records[0].id;
+    }
+    return null; // 没有下一页数据
+  },
   },
   created () {
     this.getOptions()
@@ -715,6 +810,7 @@ export default {
     this.queryRole()//获取角色方
     this.findUserByName()//关联用户
     this.findPfxType();//查询企业签章类型
+      this.getTableData(); // 添加这行,获取列表数据用于计算下一条
   },
   mounted () {
     this.updateDependentFieldValidation();