修改报表格式2
This commit is contained in:
@@ -168,6 +168,8 @@
|
||||
fit
|
||||
:default-sort="{ prop: 'chargeTime', order: 'descending' }"
|
||||
@header-click="handleHeaderClick"
|
||||
show-summary
|
||||
:summary-method="getSummaries"
|
||||
>
|
||||
<!-- :span-method="arraySpanMethod" -->
|
||||
<!-- :summary-method="getSummaries"
|
||||
@@ -283,7 +285,11 @@
|
||||
min-width="100px"
|
||||
:show-overflow-tooltip="true"
|
||||
resizable
|
||||
/>
|
||||
>
|
||||
<template #default="scope">
|
||||
<span>{{ scope.row.price || scope.row.salePrice || '0.00' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="金额"
|
||||
align="center"
|
||||
@@ -312,7 +318,7 @@
|
||||
resizable
|
||||
>
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.chargeTime) }}</span>
|
||||
<span>{{ parseTime(scope.row.chargeTime || scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -351,6 +357,7 @@ import {
|
||||
} from "./statisticalManagent";
|
||||
import useUserStore from "@/store/modules/user";
|
||||
import { watch } from "vue";
|
||||
import { parseTime } from '@/utils/his'; // 导入日期时间处理工具函数
|
||||
const userStore = useUserStore();
|
||||
|
||||
const router = useRouter();
|
||||
@@ -436,10 +443,10 @@ function getTotals(row,i){
|
||||
// totalReturnPriceSums += Number(purchaseinventoryList.value[i-j].refundPrice)
|
||||
}
|
||||
}
|
||||
xiaojiTotal.value.push({inde:i+1,busNo:row.busNo,genderEnum_enumText:row.genderEnum_enumText,totalPrice:totalPriceSums.toFixed(4)||0.0000})
|
||||
xiaojiTotal.value.push({inde:i+1,busNo:row.busNo,genderEnum_enumText:row.genderEnum_enumText,totalPrice:totalPriceSums.toFixed(2)||0.00})
|
||||
// var totalPrice2 = 0
|
||||
// var refundPrice2 = 0
|
||||
purchaseinventoryList.value.splice(i+1, 0, {busNo:row.busNo,genderEnum_enumText:row.genderEnum_enumText,departmentName:'小计',totalPrice:totalPriceSums.toFixed(4)||0.0000})
|
||||
purchaseinventoryList.value.splice(i+1, 0, {busNo:row.busNo,genderEnum_enumText:row.genderEnum_enumText,departmentName:'小计',totalPrice:totalPriceSums.toFixed(2)||0.00})
|
||||
// purchaseinventoryList.value.map(k=>{
|
||||
// if(k.departmentName!='小计'){
|
||||
// totalPrice2 += Number(k.totalPrice)
|
||||
@@ -450,66 +457,43 @@ function getTotals(row,i){
|
||||
// refundPrice2 = refundPrice2?refundPrice2.toFixed(4):refundPrice2
|
||||
// purchaseinventoryList.value.push({departmentName:'合计',totalPrice:totalPrice2,refundPrice:refundPrice2})
|
||||
}
|
||||
const arraySpanMethod = ({
|
||||
row,
|
||||
column,
|
||||
rowIndex,
|
||||
columnIndex,
|
||||
}) => {
|
||||
// 合并一样的列住院号 outpatientNumber属性&&(queryParams.value.statisticsType==1||queryParams.value.statisticsType==4||queryParams.value.statisticsType==6)
|
||||
if (columnIndex === 1&&purchaseinventoryList.value.length>0) {
|
||||
if (rowIndex === 0 || (rowIndex > 0 && row.busNo !== purchaseinventoryList.value[rowIndex - 1]?.busNo)) {
|
||||
let rowspan = 1;
|
||||
let totalPriceSum = 0
|
||||
// let totalReturnPriceSum = 0
|
||||
for (let i = rowIndex + 1; i < purchaseinventoryList.value.length+1; i++) {
|
||||
if(purchaseinventoryList.value[i-1].departmentName!='合计'){
|
||||
if (purchaseinventoryList.value[i]&&purchaseinventoryList.value[i].busNo === row.busNo) {
|
||||
rowspan++;
|
||||
totalPriceSum += Number(purchaseinventoryList.value[i].totalPrice)
|
||||
// totalReturnPriceSum += Number(purchaseinventoryList.value[i].refundPrice)
|
||||
if(i==purchaseinventoryList.value.length-1){
|
||||
let findIndexTotal = xiaojiTotal.value.findIndex(k=>k.busNo==row.busNo)
|
||||
if(findIndexTotal<0){
|
||||
getTotals(row,i)
|
||||
}
|
||||
}else{
|
||||
}
|
||||
} else {
|
||||
totalPriceSum += Number(row.totalPrice)
|
||||
// totalReturnPriceSum += Number(row.refundPrice)
|
||||
let findIndexTotal = xiaojiTotal.value.findIndex(k=>k.busNo==row.busNo)
|
||||
if(findIndexTotal<0){
|
||||
xiaojiTotal.value.push({inde:i,genderEnum_enumText:row.genderEnum_enumText,busNo:row.busNo,totalPrice:totalPriceSum})
|
||||
purchaseinventoryList.value.splice(i, 0, {busNo:row.busNo,genderEnum_enumText:row.genderEnum_enumText,departmentName:'小计',totalPrice:totalPriceSum.toFixed(4)||0.0000})
|
||||
// console.log(purchaseinventoryList.value,"12121")
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 行合并方法 - 简化实现,避免在合并过程中修改数组
|
||||
const arraySpanMethod = ({row, column, rowIndex, columnIndex}) => {
|
||||
// 跳过小计行和合计行的合并处理
|
||||
if (row.departmentName === '小计' || row.departmentName === '合计') {
|
||||
return { rowspan: 1, colspan: 1 };
|
||||
}
|
||||
|
||||
// 只合并门诊号列(索引1)
|
||||
if (columnIndex === 1) {
|
||||
// 查找当前门诊号的起始位置
|
||||
let startIndex = rowIndex;
|
||||
while (startIndex > 0) {
|
||||
const prevRow = purchaseinventoryList.value[startIndex - 1];
|
||||
// 如果前一行是小计行或者门诊号不同,当前行就是起始行
|
||||
if (prevRow.departmentName === '小计' || prevRow.busNo !== row.busNo) {
|
||||
break;
|
||||
}
|
||||
startIndex--;
|
||||
}
|
||||
|
||||
// 如果当前行是门诊号的起始行
|
||||
if (startIndex === rowIndex) {
|
||||
let rowspan = 1;
|
||||
// 计算门诊号相同的连续行数
|
||||
for (let i = rowIndex + 1; i < purchaseinventoryList.value.length; i++) {
|
||||
const nextRow = purchaseinventoryList.value[i];
|
||||
// 如果下一行是小计行或者门诊号不同,停止计数
|
||||
if (nextRow.departmentName === '小计' || nextRow.busNo !== row.busNo) {
|
||||
break;
|
||||
}
|
||||
rowspan++;
|
||||
}
|
||||
// console.log(purchaseinventoryList.value,"12122")
|
||||
return { rowspan, colspan: 1 };
|
||||
} else {
|
||||
// console.log(purchaseinventoryList.value,"12123")
|
||||
// 非起始行不显示
|
||||
return { rowspan: 0, colspan: 0 };
|
||||
}
|
||||
// }else{ // 姓名列patientName
|
||||
// if (columnIndex ===2&&purchaseinventoryList.value.length>0) {
|
||||
// if (rowIndex === 0 || (rowIndex > 0 && row.name !== purchaseinventoryList.value[rowIndex - 1]?.name)) {
|
||||
// let rowspan = 1;
|
||||
// for (let i = rowIndex + 1; i < purchaseinventoryList.value.length; i++) {
|
||||
// if (purchaseinventoryList.value[i].name === row.name) {
|
||||
// rowspan++;
|
||||
// } else {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// return { rowspan:rowspan, colspan: 1 };
|
||||
// } else {
|
||||
// return { rowspan: 0, colspan: 0 };
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
const getSummaries = (param) => {
|
||||
@@ -527,11 +511,11 @@ const getSummaries = (param) => {
|
||||
sums[index] = `${values.reduce((prev, curr) => {
|
||||
const value = Number(curr)
|
||||
if (!Number.isNaN(value)) {
|
||||
return (Number(prev) + Number(curr)).toFixed(4) || 0.0000
|
||||
return (Number(prev) + Number(curr)).toFixed(2) || 0.00
|
||||
} else {
|
||||
return Number(prev)
|
||||
}
|
||||
}, 0.0000)}`
|
||||
}, 0.00)}`
|
||||
} else {
|
||||
sums[index] = ' '
|
||||
}
|
||||
@@ -583,6 +567,7 @@ function getList(type) {
|
||||
// var purchaseinventoryLists = []
|
||||
// var purchaseinventoryListsArray = []
|
||||
getReportChargePage(queryParams.value).then((res) => {
|
||||
console.log('API返回数据:', res.data.records && res.data.records.length > 0 ? res.data.records[0] : {}); // 调试日志
|
||||
// purchaseinventoryLists = res.data.records||[] //转换数据结构
|
||||
// if(purchaseinventoryLists.length>0){
|
||||
// purchaseinventoryLists.map(p=>{
|
||||
@@ -594,10 +579,15 @@ function getList(type) {
|
||||
purchaseinventoryList.value = res.data.records||[]
|
||||
total.value = res.data.total
|
||||
purchaseinventoryList.value.map(k=>{
|
||||
k.totalPrice = k.totalPrice?k.totalPrice.toFixed(4):'0.0000'
|
||||
k.price = k.price?k.price.toFixed(4):'0.0000'
|
||||
k.totalPrice = k.totalPrice?k.totalPrice.toFixed(2):'0.00'
|
||||
// 优先使用price,其次使用salePrice
|
||||
k.price = k.price ? k.price.toFixed(2) : (k.salePrice ? k.salePrice.toFixed(2) : '0.00')
|
||||
// 如果没有chargeTime,尝试使用createTime作为替代
|
||||
if (!k.chargeTime && k.createTime) {
|
||||
k.chargeTime = k.createTime;
|
||||
}
|
||||
// k.refundPrice = k.refundPrice || '0.00'
|
||||
k.number = k.number?(k.number+(k.quantityUnit_dictText?k.quantityUnit_dictText:"")):('0.0000'+ k.quantityUnit_dictText?k.quantityUnit_dictText:"")
|
||||
k.number = k.number ? (k.number + (k.quantityUnit_dictText || '')) : ('0.00' + (k.quantityUnit_dictText || ''))
|
||||
// k.refundQuantity = k.refundQuantity?(k.refundQuantity+k.refundUnitCode_dictText):('0.00'+ k.quantityUnit_dictText)
|
||||
if(total.value&&total.value<=queryParams.value.pageSize){
|
||||
totalPrice2 += Number(k.totalPrice)
|
||||
@@ -607,15 +597,7 @@ function getList(type) {
|
||||
if(total.value<=res.data.size){
|
||||
loading.value = false;
|
||||
}
|
||||
// 1页数据
|
||||
if(total.value&&total.value<=queryParams.value.pageSize){
|
||||
totalPrice2 = totalPrice2?totalPrice2.toFixed(4):totalPrice2
|
||||
// refundPrice2 = refundPrice2?refundPrice2.toFixed(4):refundPrice2
|
||||
let pageNoAll = total.value / queryParams.value.pageSize
|
||||
if(Math.ceil(pageNoAll)==queryParams.value.pageNo){
|
||||
purchaseinventoryList.value.push({departmentName:'合计',totalPrice:totalPrice2})
|
||||
}
|
||||
}
|
||||
// 1页数据时,不再手动添加合计行,使用表格的show-summary功能
|
||||
|
||||
// 带分页数据
|
||||
if(total.value&&total.value>queryParams.value.pageSize){
|
||||
@@ -636,10 +618,15 @@ function getList(type) {
|
||||
purchaseinventoryListAll.value = res.data.records||[]
|
||||
if(purchaseinventoryListAll.value.length>0){
|
||||
purchaseinventoryListAll.value.map((k,index)=>{
|
||||
k.totalPrice = k.totalPrice?k.totalPrice.toFixed(4):'0.0000'
|
||||
k.price = k.price?k.price.toFixed(4):'0.0000'
|
||||
k.totalPrice = k.totalPrice?k.totalPrice.toFixed(2):'0.00'
|
||||
// 优先使用price,其次使用salePrice
|
||||
k.price = k.price ? k.price.toFixed(2) : (k.salePrice ? k.salePrice.toFixed(2) : '0.00')
|
||||
// 如果没有chargeTime,尝试使用createTime作为替代
|
||||
if (!k.chargeTime && k.createTime) {
|
||||
k.chargeTime = k.createTime;
|
||||
}
|
||||
// k.refundPrice = k.refundPrice || '0.00'
|
||||
k.number = k.number?(k.number+k.quantityUnit_dictText?k.quantityUnit_dictText:""):('0.0000'+ k.quantityUnit_dictText?k.quantityUnit_dictText:"")
|
||||
k.number = k.number ? (k.number + (k.quantityUnit_dictText || '')) : ('0.00' + (k.quantityUnit_dictText || ''))
|
||||
// k.refundQuantity = k.refundQuantity?(k.refundQuantity+k.refundUnitCode_dictText):('0.00'+ k.quantityUnit_dictText)
|
||||
totalPrice2 += Number(k.totalPrice)
|
||||
// refundPrice2 += Number(k.refundPrice)
|
||||
@@ -655,7 +642,7 @@ function getList(type) {
|
||||
|
||||
if(dispenseNoIndex1>0){
|
||||
purchaseinventoryList.value[dispenseNoIndex1].totalPrice = Number(purchaseinventoryList.value[dispenseNoIndex1].totalPrice)+Number(purchaseinventoryListAll.value[index-m].totalPrice)
|
||||
purchaseinventoryList.value[dispenseNoIndex1].totalPrice = purchaseinventoryList.value[dispenseNoIndex1].totalPrice?purchaseinventoryList.value[dispenseNoIndex1].totalPrice.toFixed(4):'0.0000'
|
||||
purchaseinventoryList.value[dispenseNoIndex1].totalPrice = purchaseinventoryList.value[dispenseNoIndex1].totalPrice?purchaseinventoryList.value[dispenseNoIndex1].totalPrice.toFixed(2):'0.00'
|
||||
}
|
||||
}
|
||||
if ((index+m) == (queryParams.value.pageSize*queryParams.value.pageNo)&& k.busNo == purchaseinventoryListAll.value[index + m]?.busNo) {
|
||||
@@ -674,10 +661,7 @@ function getList(type) {
|
||||
totalPrice2 = totalPrice2?totalPrice2.toFixed(4):totalPrice2
|
||||
// refundPrice2 = refundPrice2?refundPrice2.toFixed(4):refundPrice2
|
||||
loading.value = false;
|
||||
let pageNoAll = total.value / queryParams.value.pageSize
|
||||
if(Math.ceil(pageNoAll)==queryParams.value.pageNo){
|
||||
purchaseinventoryList.value.push({departmentName:'合计',totalPrice:totalPrice2})
|
||||
}
|
||||
// 不再手动添加合计行,使用表格的show-summary功能
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user