This commit is contained in:
2026-05-08 16:27:31 +08:00
parent 14735af0b3
commit 8719cdd6d6
6 changed files with 174 additions and 33 deletions
+1 -1
View File
@@ -481,7 +481,7 @@ export function prescriptionOrderLogs(params: { id: number }) {
}
/** 修改订单金额 */
export function prescriptionOrderUpdateAmount(params: { id: number; amount_update: number }) {
export function prescriptionOrderUpdateAmount(params: { id: number; amount: number }) {
return request.post({ url: '/tcm.prescriptionOrder/updateAmount', params })
}
@@ -1216,9 +1216,9 @@
<el-form-item label="当前金额">
<div class="text-sm text-gray-700 font-medium">¥{{ formatMoney(detailData?.amount) }}</div>
</el-form-item>
<el-form-item label="新金额" prop="amount_update">
<el-form-item label="新金额" prop="amount">
<el-input-number
v-model="updateAmountForm.amount_update"
v-model="updateAmountForm.amount"
:min="0.01"
:step="0.01"
:precision="2"
@@ -3356,10 +3356,10 @@ const updateAmountSaving = ref(false)
const updateAmountFormRef = ref<FormInstance>()
const updateAmountForm = reactive({
id: 0,
amount_update: undefined as number | undefined
amount: undefined as number | undefined
})
const updateAmountRules: FormRules = {
amount_update: [
amount: [
{ required: true, message: '请输入订单金额', trigger: 'blur' },
{
validator: (_rule, value, callback) => {
@@ -3496,7 +3496,7 @@ function resetPatchRxPatientForm() {
function resetUpdateAmountDialog() {
updateAmountForm.id = 0
updateAmountForm.amount_update = undefined
updateAmountForm.amount = undefined
updateAmountFormRef.value?.clearValidate()
}
@@ -3507,7 +3507,7 @@ function openUpdateAmount() {
return
}
updateAmountForm.id = Number(row?.id) || 0
updateAmountForm.amount_update = Number(row?.amount) || undefined
updateAmountForm.amount = Number(row?.amount) || undefined
updateAmountVisible.value = true
nextTick(() => updateAmountFormRef.value?.clearValidate())
}
@@ -3568,7 +3568,7 @@ async function submitUpdateAmount() {
try {
await prescriptionOrderUpdateAmount({
id: orderId,
amount_update: Number(updateAmountForm.amount_update)
amount: Number(updateAmountForm.amount)
})
feedback.msgSuccess('修改成功')
updateAmountVisible.value = false
@@ -677,7 +677,19 @@
<el-row :gutter="16" class="mb-5">
<el-col :xs="12" :sm="6">
<el-card shadow="never" class="stat-card border border-gray-100 bg-gray-50/50">
<div class="stat-title text-gray-500 text-xs mb-1">总金额</div>
<div class="flex items-center justify-between mb-1">
<div class="stat-title text-gray-500 text-xs">总金额</div>
<el-button
v-if="canUpdateAmount(detailData)"
v-perms="['tcm.prescriptionOrder/updateAmount']"
type="primary"
size="small"
link
@click="openUpdateAmount"
>
修改
</el-button>
</div>
<div class="stat-value text-red-500 font-bold text-xl">¥{{ detailData.amount }}</div>
</el-card>
</el-col>
@@ -1221,6 +1233,47 @@
</div>
</el-drawer>
<el-dialog
v-model="updateAmountVisible"
title="修改订单金额"
width="92%"
destroy-on-close
:close-on-click-modal="false"
@closed="resetUpdateAmountDialog"
>
<el-form
ref="updateAmountFormRef"
:model="updateAmountForm"
:rules="updateAmountRules"
label-width="84px"
@submit.prevent="submitUpdateAmount"
>
<el-form-item label="当前金额">
<div class="text-sm text-gray-700 font-medium">¥{{ formatMoney(detailData?.amount) }}</div>
</el-form-item>
<el-form-item label="新金额" prop="amount">
<el-input-number
v-model="updateAmountForm.amount"
:min="0.01"
:step="0.01"
:precision="2"
controls-position="right"
class="w-full"
placeholder="请输入新金额"
/>
</el-form-item>
<div class="text-xs text-gray-400 pl-[84px] -mt-1 leading-relaxed">
已完成或已取消订单不可修改提交成功后会刷新详情与操作日志
</div>
</el-form>
<template #footer>
<el-button @click="updateAmountVisible = false">取消</el-button>
<el-button type="primary" :loading="updateAmountSaving" @click="submitUpdateAmount">
确认修改
</el-button>
</template>
</el-dialog>
<!-- 编辑分步向导与创建业务订单弹窗统一 -->
<el-dialog
v-model="editVisible"
@@ -2342,6 +2395,7 @@ import {
prescriptionOrderLogisticsTrace,
prescriptionOrderShip,
prescriptionOrderLogs,
prescriptionOrderUpdateAmount,
prescriptionOrderAddPayOrder,
prescriptionOrderComplete,
prescriptionOrderRevokeRxAudit,
@@ -3133,6 +3187,12 @@ function handleCardMoreCommand(cmd: string, row: Record<string, any>) {
else if (cmd === 'withdraw') confirmWithdraw(row as any)
}
function canUpdateAmount(row: { id?: number; fulfillment_status?: number } | null | undefined) {
if (!row?.id) return false
const fs = Number(row.fulfillment_status)
return fs !== 3 && fs !== 4
}
const detailVisible = ref(false)
const detailLoading = ref(false)
const detailData = ref<Record<string, any> | null>(null)
@@ -3344,6 +3404,29 @@ const logisticsTracePayload = ref<Record<string, any> | null>(null)
const logisticsTracePhoneTail = ref('')
const detailLogs = ref<any[]>([])
const updateAmountVisible = ref(false)
const updateAmountSaving = ref(false)
const updateAmountFormRef = ref<FormInstance>()
const updateAmountForm = reactive({
id: 0,
amount: undefined as number | undefined
})
const updateAmountRules: FormRules = {
amount: [
{ required: true, message: '请输入订单金额', trigger: 'blur' },
{
validator: (_rule, value, callback) => {
const num = Number(value)
if (!Number.isFinite(num) || num <= 0) {
callback(new Error('订单金额必须大于0'))
return
}
callback()
},
trigger: 'blur'
}
]
}
function canViewPrescriptionOrderLogs() {
const p = userStore.perms || []
@@ -3379,6 +3462,7 @@ function logActionText(act: string) {
revoke_pay_audit: '撤回支付审核',
gancao_submit: '甘草下单',
patch_rx_patient: '处方患者信息',
update_amount: '修改订单金额',
complete: '完成订单'
}
return m[act] || act
@@ -3463,6 +3547,24 @@ function resetPatchRxPatientForm() {
patchRxPatientForm.phone = ''
}
function resetUpdateAmountDialog() {
updateAmountForm.id = 0
updateAmountForm.amount = undefined
updateAmountFormRef.value?.clearValidate()
}
function openUpdateAmount() {
const row = detailData.value
if (!canUpdateAmount(row)) {
feedback.msgWarning('当前订单状态不允许修改金额')
return
}
updateAmountForm.id = Number(row?.id) || 0
updateAmountForm.amount = Number(row?.amount) || undefined
updateAmountVisible.value = true
nextTick(() => updateAmountFormRef.value?.clearValidate())
}
async function refreshCurrentPrescriptionOrderDetail() {
const id = detailData.value?.id
if (!id) return
@@ -3502,6 +3604,37 @@ async function submitPatchRxPatient() {
}
}
async function submitUpdateAmount() {
const form = updateAmountFormRef.value
if (!form) return
try {
await form.validate()
} catch {
return
}
if (!canUpdateAmount(detailData.value)) {
feedback.msgWarning('当前订单状态不允许修改金额')
return
}
const orderId = updateAmountForm.id
updateAmountSaving.value = true
try {
await prescriptionOrderUpdateAmount({
id: orderId,
amount: Number(updateAmountForm.amount)
})
feedback.msgSuccess('修改成功')
updateAmountVisible.value = false
await refreshCurrentPrescriptionOrderDetail()
await fetchLogs(orderId)
getLists()
} catch {
/* 拦截器已提示 */
} finally {
updateAmountSaving.value = false
}
}
async function openDetail(id: number) {
// Bug
detailData.value = null