增加可修改计费重功能

This commit is contained in:
wuweihua
2026-10-14 15:25:26 +08:00
parent 2d7bd678f3
commit 6a50b0f122
16 changed files with 1306 additions and 10 deletions
@@ -67,6 +67,7 @@
<el-descriptions class="detail-desc" :column="2" border size="small">
<el-descriptions-item label="产品">{{ productLabel(detail) }}</el-descriptions-item>
<el-descriptions-item label="计费重量(kg)">{{ formatWeight(detail.chargeWeight ?? detail.weight) }}</el-descriptions-item>
<el-descriptions-item label="原计费重(kg)">{{ formatWeight(detail.weight) }}</el-descriptions-item>
<el-descriptions-item label="重量段">{{ detail.weightLabel || '-' }}</el-descriptions-item>
<el-descriptions-item label="计费时间">{{ detail.bizDate || '-' }}</el-descriptions-item>
<el-descriptions-item label="计价来源">
@@ -94,6 +95,7 @@
<el-tab-pane label="应收" name="income">
<div class="fee-toolbar">
<el-button type="primary" plain size="small" icon="Plus" v-hasPermi="['price:billing:feeAdd']" @click="openAddFee">增加费用</el-button>
<el-button type="primary" plain size="small" icon="Edit" v-hasPermi="['price:billing:chargeWeightEdit']" :disabled="detail.refundStatus === 'REFUNDED'" @click="openEditCw">修改计费重</el-button>
</div>
<el-table v-if="incomeFees.length" :data="incomeFees" border size="small" class="fee-table">
<el-table-column label="费用名称" min-width="140" show-overflow-tooltip>
@@ -171,11 +173,20 @@
:edit-row="editFeeRow"
@success="onFeeAdded"
/>
<edit-charge-weight-dialog
v-model="editCwOpen"
:bill-id="detail?.billId || ''"
:order-no="detail?.orderNo || ''"
:origin-weight="detail?.weight"
:current-charge-weight="detail?.chargeWeight"
@success="onChargeWeightUpdated"
/>
</el-drawer>
</template>
<script setup>
import AddIncomeFeeDialog from './AddIncomeFeeDialog.vue'
import EditChargeWeightDialog from './EditChargeWeightDialog.vue'
import { deleteIncomeBillFee } from '@/api/price/billing'
const { proxy } = getCurrentInstance()
@@ -192,6 +203,7 @@ const emit = defineEmits(['update:modelValue', 'updated'])
const feeTab = ref('income')
const addFeeOpen = ref(false)
const editFeeRow = ref(null)
const editCwOpen = ref(false)
const { bms_fee_type, bms_currency } = useDict('bms_fee_type', 'bms_currency')
const incomeFees = computed(() => {
@@ -240,6 +252,16 @@ function onFeeAdded(data) {
if (data) emit('updated', data)
}
function openEditCw() {
if (!props.detail?.billId) return
if (props.detail.refundStatus === 'REFUNDED') return
editCwOpen.value = true
}
function onChargeWeightUpdated(data) {
if (data) emit('updated', data)
}
function customerActiveLabel(status) {
const map = { ACTIVE: '正常', MISSING: '不存在', DISABLED: '停用' }
@@ -0,0 +1,114 @@
<template>
<el-dialog
:title="dlgTitle"
v-model="visible"
width="420px"
append-to-body
destroy-on-close
@closed="onClosed"
>
<el-form ref="formRef" :model="form" :rules="rules" label-width="120px">
<el-form-item label="订单号">
<span>{{ orderNo || '-' }}</span>
</el-form-item>
<el-form-item label="原计费重(kg)">
<span>{{ formatWeight(originWeight) }}</span>
</el-form-item>
<el-form-item label="当前计费重(kg)">
<span>{{ formatWeight(currentChargeWeight) }}</span>
</el-form-item>
<el-form-item label="人工修改计费重" prop="chargeWeight">
<el-input-number
v-model="form.chargeWeight"
:min="0.001"
:precision="3"
:step="0.1"
controls-position="right"
style="width: 100%;"
/>
</el-form-item>
</el-form>
<template #footer>
<el-button type="primary" :loading="submitting" @click="submit">确 定</el-button>
<el-button :disabled="submitting" @click="visible = false">取 消</el-button>
</template>
</el-dialog>
</template>
<script setup>
import { updateChargeWeight } from '@/api/price/billing'
import { ElMessage } from 'element-plus'
const dlgTitle = '修改计费重'
const props = defineProps({
modelValue: { type: Boolean, default: false },
billId: { type: String, default: '' },
orderNo: { type: String, default: '' },
originWeight: { type: [Number, String], default: null },
currentChargeWeight: { type: [Number, String], default: null }
})
const emit = defineEmits(['update:modelValue', 'success'])
const visible = computed({
get: () => props.modelValue,
set: (v) => emit('update:modelValue', v)
})
const formRef = ref()
const submitting = ref(false)
const form = reactive({ chargeWeight: undefined })
const rules = {
chargeWeight: [
{ required: true, message: '请输入人工修改计费重', trigger: 'blur' },
{
validator: (_r, v, cb) => {
if (v == null || Number(v) <= 0) cb(new Error('计费重必须大于 0'))
else cb()
},
trigger: 'blur'
}
]
}
watch(
() => props.modelValue,
(open) => {
if (!open) return
const cur = props.currentChargeWeight
form.chargeWeight = cur == null || cur === '' ? undefined : Number(cur)
}
)
function formatWeight(val) {
if (val === null || val === undefined || val === '') return '-'
const num = Number(val)
if (Number.isNaN(num)) return val
return num.toFixed(3)
}
function onClosed() {
form.chargeWeight = undefined
formRef.value?.resetFields?.()
submitting.value = false
}
function submit() {
formRef.value?.validate?.((ok) => {
if (!ok) return
if (!props.billId) return
submitting.value = true
updateChargeWeight({ billId: props.billId, chargeWeight: form.chargeWeight })
.then((res) => {
ElMessage.success('修改成功,已重新计费')
emit('success', res.data || null)
visible.value = false
})
.finally(() => {
submitting.value = false
})
})
}
</script>