294 检查项目设置-》套餐设置:基本信息服务费字段的值系统没有自动合计套餐明细服务费字段所有行的值

295 检查项目设置-》套餐设置:套餐明细数量字段后面需要增加单位字段
This commit is contained in:
Ranyunqiao
2026-03-30 09:03:49 +08:00
parent 6d23d36a9c
commit b5527cc07f
4 changed files with 44 additions and 7 deletions

View File

@@ -152,11 +152,11 @@
<el-form-item label="服务费">
<el-input-number
v-model="formData.serviceFee"
:precision="2"
:precision="2"
:min="0"
placeholder="请输入服务费"
placeholder="自动合计"
style="width: 100%"
:disabled="isReadOnly"
disabled
/>
</el-form-item>
</el-col>
@@ -281,6 +281,12 @@
<span v-else>{{ row.quantity }}</span>
</template>
</el-table-column>
<el-table-column prop="unit" label="单位" width="80" align="center">
<template #default="{ row }">
<span v-if="row.editing">{{ row.unit || '-' }}</span>
<span v-else>{{ row.unit || '-' }}</span>
</template>
</el-table-column>
<el-table-column prop="unitPrice" label="单价" width="150" align="center">
<template #default="{ row }">
<el-input
@@ -309,7 +315,7 @@
placeholder="服务费"
style="width: 100%"
:controls="false"
@change="calculateTotal(row)"
@input="(val) => handleServiceChargeInput(val, row)"
/>
<span v-else>{{ row.serviceCharge?.toFixed(2) || '0.00' }}</span>
</template>
@@ -539,6 +545,7 @@ function loadPackageData(data) {
days: item.days || '',
quantity: item.quantity || 1,
unitPrice: item.unitPrice || 0,
unit: item.unit || '',
amount: item.amount || 0,
serviceCharge: item.serviceCharge || 0,
total: item.total || 0,
@@ -553,6 +560,9 @@ function loadPackageData(data) {
console.log('formData 加载后:', formData)
console.log('detailData 加载后:', detailData.value)
// 加载数据后自动计算总服务费
calculateTotalServiceFee()
}
onMounted(async () => {
@@ -781,10 +791,12 @@ async function loadDiagnosisTreatmentItem(itemId, itemData) {
async function loadDiagnosisTreatmentList(forceRefresh = false) {
// 如果不是强制刷新且已有数据且未过期,直接返回
if (!forceRefresh && diagnosisTreatmentList.value.length > 0) {
return
// 由于缓存过期时间改为0始终视为过期需要重新加载
// 这里直接跳过,不返回,让它重新加载
}
// 从session缓存读取
let useCache = false
try {
const cachedData = cache.session.getJSON(DIAGNOSIS_TREATMENT_CACHE_KEY)
if (cachedData && cachedData.timestamp) {
@@ -812,7 +824,7 @@ async function loadDiagnosisTreatmentList(forceRefresh = false) {
if (allItems.length > 0) {
diagnosisTreatmentList.value = allItems
// 保存到缓存
cache.session.setJSON(DIAGNOSIS_TREATMENT_CACHE_KEY, {
data: allItems,
@@ -877,6 +889,7 @@ function handleAddRow() {
frequency: '',
days: '',
quantity: 1,
unit: '',
unitPrice: 0,
amount: 0,
serviceCharge: 0,
@@ -914,6 +927,7 @@ function handleDeleteRow(index) {
}).then(() => {
detailData.value.splice(index, 1)
calculatePackagePrice()
calculateTotalServiceFee()
ElMessage.success('删除成功')
}).catch(() => {})
}
@@ -1027,7 +1041,9 @@ function handleItemSelect(row) {
row.itemName = item.name || item.itemName || ''
row.code = item.busNo || item.code || item.itemCode || ''
row.unitPrice = parseFloat(item.retailPrice || item.unitPrice || item.price || 0)
console.log('设置单价:', row.unitPrice)
// permittedUnitCode_dictText是字典翻译后的值permittedUnitCode是后端返回的原始值
row.unit = item.permittedUnitCode_dictText || item.permittedUnitCode || ''
// 缓存选中的项目
loadDiagnosisTreatmentItem(row.itemId, item)
@@ -1044,10 +1060,23 @@ function calculateAmount(row) {
calculateTotal(row)
}
// 处理服务费输入
function handleServiceChargeInput(val, row) {
row.serviceCharge = val || 0
calculateTotal(row)
}
// 计算总金额
function calculateTotal(row) {
row.total = (row.amount || 0) + (row.serviceCharge || 0)
calculatePackagePrice()
calculateTotalServiceFee()
}
// 计算总服务费(合计所有明细行的服务费)
function calculateTotalServiceFee() {
const totalServiceFee = detailData.value.reduce((sum, item) => sum + (item.serviceCharge || 0), 0)
formData.serviceFee = totalServiceFee
}
// 计算套餐金额(应用折扣)
@@ -1203,6 +1232,7 @@ async function handleSave() {
frequency: item.frequency || '',
days: item.days || '',
quantity: parseInt(item.quantity) || 1,
unit: item.unit || '',
unitPrice: parseFloat(item.unitPrice) || 0,
amount: parseFloat(item.amount) || 0,
serviceCharge: parseFloat(item.serviceCharge) || 0,