Browse Source

解决ant表格加上筛选行有bug的问题

yuhan 1 year ago
parent
commit
8c27c89e8d

+ 30 - 12
src/views/module_kzks/projectCostList/ProjectCostList.vue

@@ -305,17 +305,29 @@ import { number } from 'echarts';
     data () {
       return {
         /* 分页参数 */
-        // ipagination:{
-        //   current: 1,
-        //   pageSize: 11,
-        //   pageSizeOptions: ['10', '20', '30'],
-        //   showTotal: (total, range) => {
-        //     return range[0] + "-" + range[1] + " 共" + total + "条"
-        //   },
-        //   showQuickJumper: true,
-        //   showSizeChanger: true,
-        //   total: 0
-        // },
+        ipagination:{
+          current: 1,
+          pageSize: 11, // 设置a-table调用时加上筛选行
+          pageSizeOptions: ['11', '21', '31'],
+          showTotal: (total, range) => {
+            // console.log(total, range, this.ipagination.current)
+            var current = this.ipagination.current
+            if(this.showListTotal){
+              return (range[0] - current + 1) + "-" + (range[1] - current) + " 共" + this.showListTotal + "条"
+            } else {
+              return range[0] + "-" + range[1] + " 共" + total + "条"
+            }
+          },
+          showQuickJumper: true,
+          showSizeChanger: true,
+          total: 0,
+          // 显示时减去筛选行
+          buildOptionText: (size) => {
+            return new Number(size.value) - 1 + '条/页'
+          }
+        },
+        // 用来前端显示出去筛选行的total
+        showListTotal: 0,
         description: '项目成本管理页面',
         // 一键折叠/展开
         expandedRowKeys: [],
@@ -649,9 +661,11 @@ import { number } from 'echarts';
         }
         var params = this.getQueryParams();//查询条件
         console.log(params)
+        // 查询时减去筛选行
         params.pageSize = (Number(params.pageSize) - 1).toString()
         this.loading = true;
         getAction(this.url.list, params).then((res) => {
+          console.log(res)
           if (res.success) {
             //update-begin---author:zhangyafei    Date:20201118  for:适配不分页的数据列表------------
             this.dataSource = res.result.pageList.records||res.result.pageList;
@@ -661,7 +675,11 @@ import { number } from 'echarts';
             this.dataSource.unshift(amount)
             if(res.result.pageList.total)
             {
-              this.ipagination.total = res.result.pageList.total;
+              // 解决页数显示不对的问题:因为a-table当前默认是加上筛选行的,合计时几页就加上几
+              // 例如:当前total后端返回32,一页10个应该是4页,但是a-table调用的是一页11个,所以32/11 会显示3页
+              this.ipagination.total = res.result.pageList.total + res.result.pageList.pages;
+              // 设置显示的total数
+              this.showListTotal = res.result.pageList.total
             }else{
               this.ipagination.total = 0;
             }

+ 5 - 0
src/views/module_kzks/projectCostList/modulesDetail/MaterialDetailList.vue

@@ -129,6 +129,11 @@
             dataIndex: 'ckdh'
           },
           {
+            title:'物料编码',
+            align:"center",
+            dataIndex: 'wlbm'
+          },
+          {
             title:'采购单价',
             align:"center",
             dataIndex: 'cgdj'