修改 备货单页面

This commit is contained in:
浅念
2025-09-10 18:11:39 +08:00
parent 9052bd1027
commit 853e9591b3
13 changed files with 1724 additions and 486 deletions
+43 -10
View File
@@ -28,6 +28,8 @@ export interface BaseForm {
clearance_port_id: string
clearance_port_snapshot: string
latest_arrival_date: string
pick_up_date: string
collect_all_date: string
contract_exchange_rate: string
contract_exchange_rate_currency: string
remark: string
@@ -59,6 +61,9 @@ export interface ItemRow {
handling_fee: string
fob_transport_fee: number | undefined
port_misc_fee: string
ocean_freight: string
ocean_freight_currency: string
ocean_freight_currency_snapshot: string
retrofit_fee: string
total_price: number | undefined
official_price: number | undefined
@@ -164,7 +169,9 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
is_final: isFinal ? '1' : '0',
object_id: stockingId || '0',
contract: '',
contract_url: ''
contract_url: '',
pick_up_date:'',
collect_all_date: ''
})
// 创建新的订单项
@@ -186,6 +193,9 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
handling_fee: '',
fob_transport_fee: undefined,
port_misc_fee: '',
ocean_freight: '',
ocean_freight_currency: 'USD',
ocean_freight_currency_snapshot: '',
retrofit_fee: '',
total_price: undefined,
official_price: undefined,
@@ -392,19 +402,19 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
const fob = toUSD(it.fob_transport_fee ?? (it as any).fob_fee, (it as any).fob_fee_currency)
const handling = toUSD(it.handling_fee ?? (it as any).helper_fee, (it as any).helper_fee_currency)
const port = toUSD(it.port_misc_fee ?? (it as any).port_fee, (it as any).port_fee_currency)
const ocean =toUSD(it.ocean_freight ?? (it as any).ocean_freight, (it as any).ocean_freight_currency)
const mileageVal = Number(it.mileage ?? 0)
if (mileageVal > 0) {
// 二手车:用挂牌价与二手减价替代官方指导价与优惠
const listing = toUSD(it.listing_price ?? (it as any).listing_price, (it as any).listing_price_currency)
const reduction = toUSD(it.reduction_price ?? (it as any).reduction_price, (it as any).reduction_price_currency)
return unit - (retrofit + fob + listing + reduction + handling + port)
return unit - (retrofit + fob + listing + reduction + handling + port + ocean)
}
// 新车/里程<=0:保持原有计算(官方指导价与优惠)
const guide = toUSD(it.official_price ?? (it as any).guide_price, (it as any).guide_price_currency)
const discount = toUSD(it.discount_price ?? (it as any).discount, (it as any).discount_currency)
return unit - (retrofit + fob + guide + discount + handling + port)
return unit - (retrofit + fob + guide + discount + handling + port + ocean)
}
// 合同文件相关方法
@@ -506,6 +516,8 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
const chooseCustomer = (row: any) => {
baseForm.customer_id = row.id || ''
baseForm.customer_snapshot = row.contacts || row.name || ''
baseForm.customer_country_id = row.country_id || ''
baseForm.customer_country_snapshot = row.country_name || ''
customerDialog.visible = false
}
@@ -563,8 +575,9 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
// 数据回显方法
const populateFromDetail = (res: any) => {
if (!res) return
// 基础信息
baseForm.pick_up_date = res.pick_up_date || ''
baseForm.collect_all_date = res.collect_all_date || ''
baseForm.pi_no = res.pi_no || ''
baseForm.contract = res.contract || ''
baseForm.biz_date = res.biz_date || ''
@@ -615,6 +628,9 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
handling_fee: it.handling_fee?.amount ?? '',
fob_transport_fee: it.fob_transport_fee?.amount ? Number(it.fob_transport_fee.amount) : undefined,
port_misc_fee: it.port_misc_fee?.amount ?? '',
ocean_freight: it.ocean_freight?.amount ?? '',
ocean_freight_currency: it.ocean_freight?.currency || 'USD',
ocean_freight_currency_snapshot: '',
retrofit_fee: it.retrofit_fee?.amount ?? '',
total_price: it.total_price?.amount ? Number(it.total_price.amount) : undefined,
official_price: it.official_price?.amount ? Number(it.official_price.amount) : undefined,
@@ -674,7 +690,7 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
}
// 提交方法
const handleSubmit = async () => {
const handleSubmit = async (type: number, edit?: string) => {
const mappedItems = items.value.map((it) => ({
sku_id: it.sku_id,
vin: it.vin || '',
@@ -696,6 +712,7 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
(it as any).port_fee_currency,
'港杂费'
),
ocean_freight: wrapMoney(it.ocean_freight, (it as any).ocean_freight_currency, '海运费'),
retrofit_fee: wrapMoney((it as any).retrofit_fee, (it as any).modify_fee_currency, '改装费'),
modify_list: it.modify_list,
total_price: wrapMoney(it.total_price, (it as any).total_price_currency, '总价'),
@@ -713,15 +730,31 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
reduction_price: wrapMoney(it.reduction_price, (it as any).reduction_price_currency, '二手减价')
}))
// 从提交参数中移除 contract_exchange_rate_currency
const baseFormWithoutCur = { ...(baseForm as any) }
delete (baseFormWithoutCur as any).contract_exchange_rate_currency
delete (baseFormWithoutCur as any).total_cif
delete (baseFormWithoutCur as any).total_cif_currency
delete (baseFormWithoutCur as any).total_cif_currency_snapshot
delete (baseFormWithoutCur as any).contract_url
const payload = {
...baseForm,
...baseFormWithoutCur,
veh_list: mappedItems,
account_list: paymentItems.value
account_list: paymentItems.value,
approval_status: type
}
try {
const { message } = await CrmService.addStock(payload as any)
ElMessage.success(message || '保存成功')
if (edit) {
const { message } = await CrmService.editStock({
...payload,
id: edit
} as any)
ElMessage.success(message || '保存成功')
} else {
const { message } = await CrmService.addStock(payload as any)
ElMessage.success(message || '保存成功')
}
setTimeout(() => {
window.location.href = '/crmpc/stocking/stocking_list'
}, 1000)