给商品库存报表增加合计

This commit is contained in:
季圣华
2021-10-15 02:10:42 +08:00
parent 62e27459c2
commit c41b176dae
2 changed files with 63 additions and 6 deletions

View File

@@ -376,6 +376,34 @@ export const JeecgListMixin = {
}
this.scroll.y = document.documentElement.clientHeight-searchWrapperDomLen-operatorDomLen-basicLength
}
},
/** 表格增加合计行 */
tableAddTotalRow(columns, dataSource) {
if(this.ipagination.pageSize!==10) {
let numKey = 'rowIndex'
let totalRow = { [numKey]: '合计' }
//移除不需要合计的列
let removeCols = 'action,mBarCode,purchaseDecimal'
columns.forEach(column => {
let { key, dataIndex } = column
if (![key, dataIndex].includes(numKey)) {
let total = 0
dataSource.forEach(data => {
total += Number.parseFloat(data[dataIndex])
})
if (Number.isNaN(total)) {
total = '-'
} else {
total = total.toFixed(2)
}
if(removeCols.indexOf(dataIndex)>-1) {
total = '-'
}
totalRow[dataIndex] = total
}
})
dataSource.push(totalRow)
}
}
}

View File

@@ -61,14 +61,31 @@
rowKey="id"
:columns="columns"
:dataSource="dataSource"
:pagination="ipagination"
:pagination="false"
:scroll="scroll"
:loading="loading"
@change="handleTableChange">
<span slot="action" slot-scope="text, record">
<a @click="showMaterialInOutList(record)">流水</a>
<a @click="showMaterialInOutList(record)">{{record.id?'流水':''}}</a>
</span>
</a-table>
<a-row :gutter="24" style="margin-top: 8px;text-align:right;">
<a-col :md="12" :sm="24"></a-col>
<a-col :md="12" :sm="24">
<a-pagination @change="onChange" @showSizeChange="onShowSizeChange"
size="small"
show-size-changer
:showQuickJumper="true"
:page-size="ipagination.pageSize"
:page-size-options="ipagination.pageSizeOptions"
:total="ipagination.total"
:show-total="(total, range) => ` ${total} `">
<template slot="buildOptionText" slot-scope="props">
<span>{{ props.value-1 }}条/页</span>
</template>
</a-pagination>
</a-col>
</a-row>
</section>
<!-- table区域-end -->
<material-in-out-list ref="materialInOutList" @ok="modalFormOk"></material-in-out-list>
@@ -109,7 +126,8 @@
mpList: getMpListShort(Vue.ls.get('materialPropertyList')) //扩展属性
},
ipagination:{
pageSizeOptions: ['10', '20', '30', '100', '200']
pageSize: 11,
pageSizeOptions: ['11', '21', '31', '101', '201']
},
depotList: [],
categoryTree:[],
@@ -118,9 +136,9 @@
// 表头
columns: [
{
title: '#', dataIndex: '', key:'rowIndex', width:40, align:"center",
title: '#', dataIndex: 'rowIndex', width:40, align:"center",
customRender:function (t,r,index) {
return parseInt(index)+1;
return (t !== '合计') ? (parseInt(index) + 1) : t
}
},
{title: '条码', dataIndex: 'mBarCode', width: 80},
@@ -153,7 +171,7 @@
let param = Object.assign({}, this.queryParam, this.isorter);
param.field = this.getQueryField();
param.currentPage = this.ipagination.current;
param.pageSize = this.ipagination.pageSize;
param.pageSize = this.ipagination.pageSize-1;
return param;
},
getDepotData() {
@@ -199,6 +217,7 @@
this.ipagination.total = res.data.total;
this.currentStock = res.data.currentStock;
this.currentStockPrice = res.data.currentStockPrice;
this.tableAddTotalRow(this.columns, this.dataSource)
}
if(res.code===510){
this.$message.warning(res.data)
@@ -220,6 +239,16 @@
aoa.push(item)
}
openDownloadDialog(sheet2blob(aoa), '商品库存')
},
onChange(page, pageSize) {
this.ipagination.current = page
this.ipagination.pageSize = pageSize
this.loadData(this.ipagination.current);
},
onShowSizeChange(current, size) {
this.ipagination.current = current
this.ipagination.pageSize = size
this.loadData(this.ipagination.current);
}
}
}