diff --git a/jshERP-web/src/mixins/JeecgListMixin.js b/jshERP-web/src/mixins/JeecgListMixin.js index 256305d0..4f853849 100644 --- a/jshERP-web/src/mixins/JeecgListMixin.js +++ b/jshERP-web/src/mixins/JeecgListMixin.js @@ -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) + } } } diff --git a/jshERP-web/src/views/report/MaterialStock.vue b/jshERP-web/src/views/report/MaterialStock.vue index af261418..f780e70c 100644 --- a/jshERP-web/src/views/report/MaterialStock.vue +++ b/jshERP-web/src/views/report/MaterialStock.vue @@ -61,14 +61,31 @@ rowKey="id" :columns="columns" :dataSource="dataSource" - :pagination="ipagination" + :pagination="false" :scroll="scroll" :loading="loading" @change="handleTableChange"> - 流水 + {{record.id?'流水':''}} + + + + + + + + @@ -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); } } }