소스 검색

新增下一个按钮

duy 6 일 전
부모
커밋
850a5e489f
1개의 변경된 파일127개의 추가작업 그리고 13개의 파일을 삭제
  1. 127 13
      src/views/certificate/lists/addList.vue

+ 127 - 13
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,17 +370,27 @@ 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()//获取项目和合同段
 
     },
     //#region
-    cancel () {//取消按钮
-      this.$router.push('/certificate/list')
-    },
+   cancel() {
+    const { value, certificateTypeValue, searchinput, pageindex, pagesize } = this.$route.query;
+    this.$router.push({
+      path: '/certificate/list',
+      query: {
+        value,
+        certificateTypeValue,
+        searchinput,
+        pageindex,
+        pagesize
+      }
+    });
+  },
     savess () {//保存按钮
       this.$refs.form.validate(async valid => {
         if (valid) {
@@ -510,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
@@ -544,12 +572,16 @@ export default {
           message: '新增电签成功!'
         })
         // this.$router.push('/certificate/list')
-        this.$router.push({
+       this.$router.push({
           path: '/certificate/list',
           query: {
-            value:this.$route.query.value
+            value: this.$route.query.value,
+            certificateTypeValue: this.$route.query.certificateTypeValue,
+            searchinput: this.$route.query.searchinput,
+            pageindex: this.$route.query.pageindex,
+            pagesize: this.$route.query.pagesize
           }
-        })
+        });
       }
     },
     async findUserByName () { //关联用户
@@ -606,12 +638,16 @@ export default {
           message: '修改电签成功!'
         })
         // this.$router.push('/certificate/list')
-        this.$router.push({
+         this.$router.push({
           path: '/certificate/list',
           query: {
-            value:this.$route.query.value
+            value: this.$route.query.value,
+            certificateTypeValue: this.$route.query.certificateTypeValue,
+            searchinput: this.$route.query.searchinput,
+            pageindex: this.$route.query.pageindex,
+            pagesize: this.$route.query.pagesize
           }
-        })
+        });
       }
     },
     //#endregion
@@ -690,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()
@@ -697,6 +810,7 @@ export default {
     this.queryRole()//获取角色方
     this.findUserByName()//关联用户
     this.findPfxType();//查询企业签章类型
+      this.getTableData(); // 添加这行,获取列表数据用于计算下一条
   },
   mounted () {
     this.updateDependentFieldValidation();