10.17沟通调整
计划收款信息增加复制操作 上传合同调整为:上传合同、上传PI、上传水单(均为必传,且支持多文件操作与下载)
This commit is contained in:
+395
-127
@@ -33,13 +33,17 @@ export interface BaseForm {
|
||||
contract_exchange_rate: string
|
||||
settlement_currency: string
|
||||
remark: string
|
||||
total_cif: number | undefined
|
||||
total_cif_currency: string
|
||||
total_cif_currency_snapshot: string
|
||||
cif_total: number | undefined
|
||||
cif_total_currency: string
|
||||
cif_total_currency_snapshot: string
|
||||
is_final: string
|
||||
object_id: string | number
|
||||
contract: string
|
||||
contract_url?: string
|
||||
contract: string[]
|
||||
contract_url?: string[]
|
||||
pi_doc: string[]
|
||||
pi_doc_url?: string[]
|
||||
transaction_slip: string[]
|
||||
transaction_slip_url?: string[]
|
||||
}
|
||||
|
||||
export interface ItemRow {
|
||||
@@ -105,11 +109,22 @@ export interface ItemRow {
|
||||
discount_currency_snapshot: string
|
||||
contract_rate?: number | undefined
|
||||
profit: number | undefined
|
||||
profit_currency: string
|
||||
profit_currency_snapshot: string
|
||||
profit_type_snapshot?: string
|
||||
modify_ids: string[]
|
||||
modify_list: Array<{ option_id: string; option_name_snapshot: string }>
|
||||
modify_fee_currency: string
|
||||
modify_fee_currency_snapshot: string
|
||||
accessory_price: number | undefined
|
||||
accessory_price_currency: string
|
||||
accessory_price_currency_snapshot: string
|
||||
retention_price: number | undefined
|
||||
retention_price_currency: string
|
||||
retention_price_currency_snapshot: string
|
||||
car_price: number | undefined
|
||||
car_price_currency: string
|
||||
car_price_currency_snapshot: string
|
||||
}
|
||||
|
||||
export interface PaymentItem {
|
||||
@@ -138,6 +153,7 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
const actionImageUplode = `${import.meta.env.VITE_API_URL}/ticket/upload?scene=stock_orders`
|
||||
// 回显填充抑制标记:为 true 时不触发自动计算覆盖接口值
|
||||
const isPopulating = ref(false)
|
||||
const userEditing = ref<Set<number>>(new Set()) // 跟踪用户正在编辑的行
|
||||
|
||||
// 选项数据
|
||||
const channelOptions = ref<any>()
|
||||
@@ -177,15 +193,19 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
clearance_port_snapshot: '',
|
||||
latest_arrival_date: '',
|
||||
contract_exchange_rate: '',
|
||||
settlement_currency: 'CNY',
|
||||
settlement_currency: 'USD',
|
||||
remark: '',
|
||||
total_cif: undefined,
|
||||
total_cif_currency: 'CNY',
|
||||
total_cif_currency_snapshot: '',
|
||||
cif_total: undefined,
|
||||
cif_total_currency: 'USD',
|
||||
cif_total_currency_snapshot: '',
|
||||
is_final: isFinal ? '1' : '0',
|
||||
object_id: stockingId || '0',
|
||||
contract: '',
|
||||
contract_url: '',
|
||||
contract: [],
|
||||
contract_url: [],
|
||||
pi_doc: [],
|
||||
pi_doc_url: [],
|
||||
transaction_slip: [],
|
||||
transaction_slip_url: [],
|
||||
pick_up_date: '',
|
||||
collect_all_date: ''
|
||||
})
|
||||
@@ -197,11 +217,11 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
_echo_vin: false,
|
||||
mileage: 0,
|
||||
listing_price: undefined,
|
||||
listing_price_currency: 'CNY',
|
||||
listing_price_currency_snapshot: '人民币',
|
||||
listing_price_currency: 'USD',
|
||||
listing_price_currency_snapshot: '美元',
|
||||
reduction_price: undefined,
|
||||
reduction_price_currency: 'CNY',
|
||||
reduction_price_currency_snapshot: '人民币',
|
||||
reduction_price_currency: 'USD',
|
||||
reduction_price_currency_snapshot: '美元',
|
||||
color_interior_code: '',
|
||||
color_interior_snapshot: '',
|
||||
color_exterior_code: '',
|
||||
@@ -212,51 +232,62 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
port_misc_fee: '',
|
||||
remark: '',
|
||||
ocean_freight: '',
|
||||
ocean_freight_currency: 'CNY',
|
||||
ocean_freight_currency_snapshot: '人民币',
|
||||
ocean_freight_currency: 'USD',
|
||||
ocean_freight_currency_snapshot: '美元',
|
||||
commission: '',
|
||||
commission_currency: 'CNY',
|
||||
commission_currency_snapshot: '人民币',
|
||||
commission_currency: 'USD',
|
||||
commission_currency_snapshot: '美元',
|
||||
purchase_tax: '',
|
||||
purchase_tax_currency: 'CNY',
|
||||
purchase_tax_currency_snapshot: '人民币',
|
||||
purchase_tax_currency: 'USD',
|
||||
purchase_tax_currency_snapshot: '美元',
|
||||
tax_refund: '',
|
||||
tax_refund_currency: 'CNY',
|
||||
tax_refund_currency_snapshot: '人民币',
|
||||
clearance_price: undefined,
|
||||
clearance_price_currency: 'CNY',
|
||||
clearance_price_currency_snapshot: '人民币',
|
||||
clearance_price_currency: 'USD',
|
||||
clearance_price_currency_snapshot: '美元',
|
||||
retrofit_fee: '',
|
||||
total_price: undefined,
|
||||
official_price: undefined,
|
||||
discount_price: undefined,
|
||||
fob_fee: undefined,
|
||||
fob_fee_currency: 'CNY',
|
||||
fob_fee_currency_snapshot: '人民币',
|
||||
fob_fee_currency: 'USD',
|
||||
fob_fee_currency_snapshot: '美元',
|
||||
helper_fee: undefined,
|
||||
helper_fee_currency: 'CNY',
|
||||
helper_fee_currency_snapshot: '人民币',
|
||||
helper_fee_currency: 'USD',
|
||||
helper_fee_currency_snapshot: '美元',
|
||||
domestic_freight: undefined,
|
||||
domestic_freight_currency: 'CNY',
|
||||
domestic_freight_currency_snapshot: '人民币',
|
||||
domestic_freight_currency: 'USD',
|
||||
domestic_freight_currency_snapshot: '美元',
|
||||
port_fee: undefined,
|
||||
port_fee_currency: 'CNY',
|
||||
port_fee_currency_snapshot: '人民币',
|
||||
unit_price_currency: 'CNY',
|
||||
unit_price_currency_snapshot: '人民币',
|
||||
total_price_currency: 'CNY',
|
||||
total_price_currency_snapshot: '人民币',
|
||||
guide_price_currency: 'CNY',
|
||||
guide_price_currency_snapshot: '人民币',
|
||||
port_fee_currency: 'USD',
|
||||
port_fee_currency_snapshot: '美元',
|
||||
unit_price_currency: 'USD',
|
||||
unit_price_currency_snapshot: '美元',
|
||||
total_price_currency: 'USD',
|
||||
total_price_currency_snapshot: '美元',
|
||||
guide_price_currency: 'USD',
|
||||
guide_price_currency_snapshot: '美元',
|
||||
discount: undefined,
|
||||
discount_currency: 'CNY',
|
||||
discount_currency_snapshot: '人民币',
|
||||
discount_currency: 'USD',
|
||||
discount_currency_snapshot: '美元',
|
||||
contract_rate: 7.16,
|
||||
profit: undefined,
|
||||
profit_currency: 'CNY',
|
||||
profit_currency_snapshot: '人民币',
|
||||
modify_ids: [],
|
||||
modify_list: [],
|
||||
modify_fee_currency: 'CNY',
|
||||
modify_fee_currency_snapshot: '人民币'
|
||||
modify_fee_currency: 'USD',
|
||||
modify_fee_currency_snapshot: '美元',
|
||||
accessory_price: undefined,
|
||||
accessory_price_currency: 'USD',
|
||||
accessory_price_currency_snapshot: '美元',
|
||||
retention_price: undefined,
|
||||
retention_price_currency: 'USD',
|
||||
retention_price_currency_snapshot: '美元',
|
||||
car_price: undefined,
|
||||
car_price_currency: 'USD',
|
||||
car_price_currency_snapshot: '美元'
|
||||
})
|
||||
|
||||
// 创建新的收款项
|
||||
@@ -264,8 +295,8 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
remit_country_id: '',
|
||||
remit_country_name_snapshot: '',
|
||||
remit_date: '',
|
||||
currency_code: 'CNY',
|
||||
currency_name_snapshot: '人民币',
|
||||
currency_code: 'USD',
|
||||
currency_name_snapshot: '美元',
|
||||
account_id: '',
|
||||
account_name_snapshot: '',
|
||||
remitter_name: '',
|
||||
@@ -274,7 +305,9 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
|
||||
const items = ref<ItemRow[]>([newItem()])
|
||||
const paymentItems = ref<PaymentItem[]>([newPaymentItem()])
|
||||
const contractFile = ref<{ name: string; url: string; file_name: string } | null>(null)
|
||||
const contractFiles = ref<{ name: string; url: string; file_name: string }[]>([])
|
||||
const piFiles = ref<{ name: string; url: string; file_name: string }[]>([])
|
||||
const waterBillFiles = ref<{ name: string; url: string; file_name: string }[]>([])
|
||||
|
||||
// 弹框状态
|
||||
const customerDialog = reactive<DialogState>({
|
||||
@@ -439,8 +472,9 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
return (val * rateFrom) / rateTo
|
||||
}
|
||||
|
||||
// 利润=收款价-官方指导价/二手挂牌价+优惠-手续费-改装费-配件费-fob运费-港杂-海运-佣金-挂账-购置税+预估退税
|
||||
const calcProfit = (it: any): number => {
|
||||
const targetCurrency = baseForm.settlement_currency || 'USD'
|
||||
const targetCurrency = 'CNY' // 固定使用人民币
|
||||
const unit = convertCurrency(it.unit_price, it.unit_price_currency, targetCurrency)
|
||||
const retrofit = convertCurrency(
|
||||
it.retrofit_fee,
|
||||
@@ -482,6 +516,18 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
(it as any).tax_refund_currency,
|
||||
targetCurrency
|
||||
)
|
||||
//挂账
|
||||
const retention = convertCurrency(
|
||||
it.retention_price ?? (it as any).retention_price,
|
||||
(it as any).retention_price_currency,
|
||||
targetCurrency
|
||||
)
|
||||
//配件
|
||||
const accessory = convertCurrency(
|
||||
it.accessory_price ?? (it as any).accessory_price,
|
||||
(it as any).accessory_price_currency,
|
||||
targetCurrency
|
||||
)
|
||||
const mileageVal = Number(it.mileage ?? 0)
|
||||
if (mileageVal > 0) {
|
||||
// 二手车:用挂牌价与二手减价替代官方指导价与优惠
|
||||
@@ -497,7 +543,7 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
)
|
||||
return (
|
||||
unit -
|
||||
(retrofit + fob + listing + handling + port + ocean + commission + purchaseTax) +
|
||||
(retrofit + fob + listing + handling + port + ocean + commission + purchaseTax + retention + accessory) +
|
||||
taxRefund +
|
||||
reduction
|
||||
)
|
||||
@@ -516,27 +562,29 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
)
|
||||
return (
|
||||
unit -
|
||||
(retrofit + fob + guide + handling + port + ocean + commission + purchaseTax) +
|
||||
(retrofit + fob + guide + handling + port + ocean + commission + purchaseTax + retention + accessory) +
|
||||
taxRefund +
|
||||
discount
|
||||
)
|
||||
}
|
||||
|
||||
// 计算报关价 = 收款价 - 挂账
|
||||
const calcClearanceFee = (it: any): number => {
|
||||
const targetCurrency = it.clearance_price_currency || baseForm.settlement_currency || 'USD'
|
||||
const unit = convertCurrency(it.unit_price, it.unit_price_currency, targetCurrency)
|
||||
const commission = convertCurrency(
|
||||
it.commission ?? (it as any).commission,
|
||||
(it as any).commission_currency,
|
||||
const retention = convertCurrency(
|
||||
it.retention_price ?? (it as any).retention_price,
|
||||
(it as any).retention_price_currency,
|
||||
targetCurrency
|
||||
)
|
||||
return unit - commission
|
||||
return unit - retention
|
||||
}
|
||||
|
||||
// 计算预估退税额 = (官方价 - 折扣价) * 11.5% (固定人民币)
|
||||
const calcTaxRefund = (it: any): number => {
|
||||
const mileageVal = Number(it.mileage ?? 0)
|
||||
if (mileageVal > 0) return 0
|
||||
const targetCurrency = baseForm.settlement_currency || 'USD'
|
||||
const targetCurrency = 'CNY' // 固定使用人民币
|
||||
const official = convertCurrency(
|
||||
it.official_price ?? (it as any).guide_price,
|
||||
(it as any).guide_price_currency,
|
||||
@@ -552,6 +600,32 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
return refund < 0 ? 0 : refund
|
||||
}
|
||||
|
||||
// 计算车价:车价 = 报关价 - FOB运费 - 港杂费 - 海运费
|
||||
const calcCarPrice = (it: any): number => {
|
||||
const targetCurrency = it.car_price_currency || baseForm.settlement_currency || 'USD'
|
||||
const clearance = convertCurrency(
|
||||
it.clearance_price ?? (it as any).clearance_price,
|
||||
(it as any).clearance_price_currency,
|
||||
targetCurrency
|
||||
)
|
||||
const fob = convertCurrency(
|
||||
it.fob_transport_fee ?? (it as any).fob_fee,
|
||||
(it as any).fob_fee_currency,
|
||||
targetCurrency
|
||||
)
|
||||
const port = convertCurrency(
|
||||
it.port_misc_fee ?? (it as any).port_fee,
|
||||
(it as any).port_fee_currency,
|
||||
targetCurrency
|
||||
)
|
||||
const ocean = convertCurrency(
|
||||
it.ocean_freight ?? (it as any).ocean_freight,
|
||||
(it as any).ocean_freight_currency,
|
||||
targetCurrency
|
||||
)
|
||||
return clearance - fob - port - ocean
|
||||
}
|
||||
|
||||
// 合同文件相关方法
|
||||
const isImageFile = (file: { name: string; url: string; file_name: string }) => {
|
||||
return /\.(jpg|jpeg|png|gif)$/i.test(file.name) || file.file_name.startsWith('image/')
|
||||
@@ -578,20 +652,69 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
url: response.data.file_url,
|
||||
file_name: response.data.file_name
|
||||
}
|
||||
contractFile.value = fileInfo
|
||||
baseForm.contract = response.data.file_name
|
||||
contractFiles.value.push(fileInfo)
|
||||
// 更新合同字段为文件名数组
|
||||
baseForm.contract = contractFiles.value.map((file) => file.file_name)
|
||||
ElMessage.success('合同上传成功!')
|
||||
} else {
|
||||
ElMessage.error(response.message || '合同上传失败!')
|
||||
}
|
||||
}
|
||||
|
||||
const removeContractFile = () => {
|
||||
contractFile.value = null
|
||||
baseForm.contract = ''
|
||||
const removeContractFile = (index: number) => {
|
||||
contractFiles.value.splice(index, 1)
|
||||
// 更新合同字段为文件名数组
|
||||
baseForm.contract = contractFiles.value.map((file) => file.file_name)
|
||||
ElMessage.success('合同文件已删除')
|
||||
}
|
||||
|
||||
const downloadContractFile = (file: { name: string; url: string; file_name: string }) => {
|
||||
// 创建下载链接
|
||||
const link = document.createElement('a')
|
||||
link.href = file.url
|
||||
link.download = file.name
|
||||
link.target = '_blank'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
}
|
||||
|
||||
// PI文件处理方法
|
||||
const removePiFile = (index: number) => {
|
||||
piFiles.value.splice(index, 1)
|
||||
// 更新PI字段为文件名数组
|
||||
baseForm.pi_doc = piFiles.value.map((file) => file.file_name)
|
||||
ElMessage.success('PI文件已删除')
|
||||
}
|
||||
|
||||
const downloadPiFile = (file: { name: string; url: string; file_name: string }) => {
|
||||
const link = document.createElement('a')
|
||||
link.href = file.url
|
||||
link.download = file.name
|
||||
link.target = '_blank'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
}
|
||||
|
||||
// 水单文件处理方法
|
||||
const removeWaterBillFile = (index: number) => {
|
||||
waterBillFiles.value.splice(index, 1)
|
||||
// 更新水单字段为文件名数组
|
||||
baseForm.transaction_slip = waterBillFiles.value.map((file) => file.file_name)
|
||||
ElMessage.success('水单文件已删除')
|
||||
}
|
||||
|
||||
const downloadWaterBillFile = (file: { name: string; url: string; file_name: string }) => {
|
||||
const link = document.createElement('a')
|
||||
link.href = file.url
|
||||
link.download = file.name
|
||||
link.target = '_blank'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
}
|
||||
|
||||
// 订单项操作方法
|
||||
const copyRow = (idx: number) => {
|
||||
const copied = JSON.parse(JSON.stringify(items.value[idx])) as ItemRow
|
||||
@@ -617,6 +740,15 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
}
|
||||
}
|
||||
|
||||
const copyPaymentItem = (idx: number) => {
|
||||
const originalItem = paymentItems.value[idx]
|
||||
if (originalItem) {
|
||||
const copiedItem = { ...originalItem }
|
||||
// 完全复制所有字段,包括汇款人和汇款日期
|
||||
paymentItems.value.splice(idx + 1, 0, copiedItem)
|
||||
}
|
||||
}
|
||||
|
||||
// 客户选择相关方法
|
||||
const openCustomerDialog = () => {
|
||||
customerDialog.visible = true
|
||||
@@ -701,7 +833,7 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
if (idx !== undefined && idx >= 0 && idx < items.value.length) {
|
||||
const target = items.value[idx]
|
||||
target.sku_id = row.id || ''
|
||||
target.model_snapshot = row.model_name || row.name || ''
|
||||
target.model_snapshot = row.brand_name + ' ' + row.series_name + ' ' + row.model_name
|
||||
target.color_exterior_code = row.color_exterior_code || ''
|
||||
target.color_exterior_snapshot = row.color_exterior_text || ''
|
||||
target.color_interior_code = row.color_interior_code || ''
|
||||
@@ -722,7 +854,10 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
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.contract = Array.isArray(res.contract)
|
||||
? res.contract
|
||||
: (res.contract ? String(res.contract).split(',') : [])
|
||||
baseForm.biz_date = res.biz_date || ''
|
||||
baseForm.clearance_country_id = res.clearance_country_id || ''
|
||||
baseForm.clearance_country_snapshot = res.clearance_country_snapshot || ''
|
||||
@@ -744,14 +879,11 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
baseForm.clearance_port_snapshot = res.clearance_port_snapshot || ''
|
||||
baseForm.latest_arrival_date = res.latest_arrival_date || ''
|
||||
baseForm.remark = res.remark || ''
|
||||
baseForm.settlement_currency = res.settlement_currency || 'CNY'
|
||||
baseForm.settlement_currency = res.settlement_currency || 'USD'
|
||||
// 合计与汇率
|
||||
baseForm.total_cif = res.cif_total_amount.amount
|
||||
? Number(res.cif_total_amount.amount)
|
||||
: undefined
|
||||
baseForm.total_cif_currency = res.settlement_currency || baseForm.total_cif_currency
|
||||
baseForm.contract_exchange_rate =
|
||||
res.contract_exchange_rate || getCurrencyRate(baseForm.total_cif_currency)
|
||||
baseForm.cif_total = res.cif_total.amount ? Number(res.cif_total.amount) : undefined
|
||||
baseForm.cif_total_currency = res.cif_total.currency || 'USD'
|
||||
baseForm.contract_exchange_rate = res.contract_exchange_rate
|
||||
// 明细
|
||||
const list = Array.isArray(res.veh_list) ? res.veh_list : []
|
||||
items.value = list.map((it: any) => ({
|
||||
@@ -761,10 +893,10 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
mileage: it.mileage ?? 0,
|
||||
model_snapshot: it.model_snapshot || '',
|
||||
listing_price: it.listing_price?.amount ? Number(it.listing_price.amount) : undefined,
|
||||
listing_price_currency: it.listing_price?.currency || 'CNY',
|
||||
listing_price_currency: it.listing_price?.currency || 'USD',
|
||||
listing_price_currency_snapshot: '',
|
||||
reduction_price: it.reduction_price?.amount ? Number(it.reduction_price.amount) : undefined,
|
||||
reduction_price_currency: it.reduction_price?.currency || 'CNY',
|
||||
reduction_price_currency: it.reduction_price?.currency || 'USD',
|
||||
reduction_price_currency_snapshot: '',
|
||||
color_interior_code: it.color_interior_code || '',
|
||||
color_interior_snapshot: it.color_interior_snapshot || '',
|
||||
@@ -778,38 +910,38 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
port_misc_fee: it.port_misc_fee?.amount ?? '',
|
||||
remark: it.remark || '',
|
||||
ocean_freight: it.ocean_freight?.amount ?? '',
|
||||
ocean_freight_currency: it.ocean_freight?.currency || 'CNY',
|
||||
ocean_freight_currency: it.ocean_freight?.currency || 'USD',
|
||||
ocean_freight_currency_snapshot: '',
|
||||
commission: it.commission?.amount ?? '',
|
||||
commission_currency: it.commission?.currency || 'CNY',
|
||||
commission_currency: it.commission?.currency || 'USD',
|
||||
commission_currency_snapshot: '',
|
||||
purchase_tax: it.purchase_tax?.amount ?? '',
|
||||
purchase_tax_currency: it.purchase_tax?.currency || 'CNY',
|
||||
purchase_tax_currency: it.purchase_tax?.currency || 'USD',
|
||||
purchase_tax_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,
|
||||
discount_price: it.discount_price?.amount ? Number(it.discount_price.amount) : undefined,
|
||||
fob_fee: undefined,
|
||||
fob_fee_currency: it.fob_transport_fee?.currency || 'CNY',
|
||||
fob_fee_currency: it.fob_transport_fee?.currency || 'USD',
|
||||
fob_fee_currency_snapshot: '',
|
||||
helper_fee: undefined,
|
||||
helper_fee_currency: it.handling_fee?.currency || 'CNY',
|
||||
helper_fee_currency: it.handling_fee?.currency || 'USD',
|
||||
helper_fee_currency_snapshot: '',
|
||||
domestic_freight: undefined,
|
||||
domestic_freight_currency: it.domestic_freight?.currency || 'CNY',
|
||||
domestic_freight_currency: it.domestic_freight?.currency || 'USD',
|
||||
domestic_freight_currency_snapshot: '',
|
||||
port_fee: undefined,
|
||||
port_fee_currency: it.port_misc_fee?.currency || 'CNY',
|
||||
port_fee_currency: it.port_misc_fee?.currency || 'USD',
|
||||
port_fee_currency_snapshot: '',
|
||||
unit_price_currency: it.unit_price?.currency || 'CNY',
|
||||
unit_price_currency: it.unit_price?.currency || 'USD',
|
||||
unit_price_currency_snapshot: '',
|
||||
total_price_currency: it.total_price?.currency || 'CNY',
|
||||
total_price_currency: it.total_price?.currency || 'USD',
|
||||
total_price_currency_snapshot: '',
|
||||
guide_price_currency: it.official_price?.currency || 'CNY',
|
||||
guide_price_currency: it.official_price?.currency || 'USD',
|
||||
guide_price_currency_snapshot: '',
|
||||
discount: undefined,
|
||||
discount_currency: it.discount_price?.currency || 'CNY',
|
||||
discount_currency: it.discount_price?.currency || 'USD',
|
||||
discount_currency_snapshot: '',
|
||||
contract_rate: baseForm.contract_exchange_rate
|
||||
? Number(baseForm.contract_exchange_rate)
|
||||
@@ -817,7 +949,7 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
profit: it.profit?.amount ? Number(it.profit.amount) : undefined,
|
||||
profit_type_snapshot: '',
|
||||
clearance_price: it.clearance_price?.amount ? Number(it.clearance_price.amount) : undefined,
|
||||
clearance_price_currency: it.clearance_price?.currency || 'CNY',
|
||||
clearance_price_currency: it.clearance_price?.currency || 'USD',
|
||||
clearance_price_currency_snapshot: '',
|
||||
modify_ids: Array.isArray(it.modify_list)
|
||||
? it.modify_list.map((m: any) => Number(m.option_id))
|
||||
@@ -828,11 +960,20 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
option_name_snapshot: m.option_name_snapshot
|
||||
}))
|
||||
: [],
|
||||
modify_fee_currency: it.retrofit_fee?.currency || 'CNY',
|
||||
modify_fee_currency: it.retrofit_fee?.currency || 'USD',
|
||||
modify_fee_currency_snapshot: '',
|
||||
tax_refund: it.tax_refund?.amount ?? '',
|
||||
tax_refund_currency: it.tax_refund?.currency || 'CNY',
|
||||
tax_refund_currency_snapshot: ''
|
||||
tax_refund_currency: it.tax_refund?.currency || 'USD',
|
||||
tax_refund_currency_snapshot: '',
|
||||
accessory_price: it.accessory_price?.amount ? Number(it.accessory_price.amount) : undefined,
|
||||
accessory_price_currency: it.accessory_price?.currency || 'USD',
|
||||
accessory_price_currency_snapshot: '',
|
||||
retention_price: it.retention_price?.amount ? Number(it.retention_price.amount) : undefined,
|
||||
retention_price_currency: it.retention_price?.currency || 'USD',
|
||||
retention_price_currency_snapshot: '',
|
||||
car_price: it.car_price?.amount ? Number(it.car_price.amount) : undefined,
|
||||
car_price_currency: it.car_price?.currency || 'USD',
|
||||
car_price_currency_snapshot: ''
|
||||
}))
|
||||
// 计划收款
|
||||
const pays = Array.isArray(res.account_list) ? res.account_list : []
|
||||
@@ -847,13 +988,55 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
remitter_name: p.remitter_name || '',
|
||||
amount: p.amount ? Number(p.amount) : undefined
|
||||
}))
|
||||
// 合同文件回显
|
||||
// 合同文件回显(兼容数组与逗号字符串)
|
||||
if (res.contract) {
|
||||
contractFile.value = {
|
||||
name: '合同文件',
|
||||
url: res.contract_url || res.contract,
|
||||
file_name: res.contract
|
||||
}
|
||||
const contractNamesArr: string[] = Array.isArray(res.contract)
|
||||
? res.contract
|
||||
: String(res.contract).split(',')
|
||||
const contractUrlsArr: string[] = Array.isArray(res.contract_url)
|
||||
? (res.contract_url as string[])
|
||||
: (res.contract_url ? String(res.contract_url).split(',') : [])
|
||||
baseForm.contract = contractNamesArr
|
||||
baseForm.contract_url = contractUrlsArr
|
||||
contractFiles.value = contractNamesArr.map((fileName: string, index: number) => ({
|
||||
name: fileName,
|
||||
url: contractUrlsArr[index] || fileName,
|
||||
file_name: fileName
|
||||
}))
|
||||
}
|
||||
|
||||
// PI文件回显(兼容数组与逗号字符串)
|
||||
if (res.pi_doc) {
|
||||
const piNamesArr: string[] = Array.isArray(res.pi_doc)
|
||||
? res.pi_doc
|
||||
: String(res.pi_doc).split(',')
|
||||
const piUrlsArr: string[] = Array.isArray(res.pi_doc_url)
|
||||
? (res.pi_doc_url as string[])
|
||||
: (res.pi_doc_url ? String(res.pi_doc_url).split(',') : [])
|
||||
baseForm.pi_doc = piNamesArr
|
||||
baseForm.pi_doc_url = piUrlsArr
|
||||
piFiles.value = piNamesArr.map((fileName: string, index: number) => ({
|
||||
name: fileName,
|
||||
url: piUrlsArr[index] || fileName,
|
||||
file_name: fileName
|
||||
}))
|
||||
}
|
||||
|
||||
// 水单文件回显(兼容数组与逗号字符串)
|
||||
if (res.transaction_slip) {
|
||||
const slipNamesArr: string[] = Array.isArray(res.transaction_slip)
|
||||
? res.transaction_slip
|
||||
: String(res.transaction_slip).split(',')
|
||||
const slipUrlsArr: string[] = Array.isArray(res.transaction_slip_url)
|
||||
? (res.transaction_slip_url as string[])
|
||||
: (res.transaction_slip_url ? String(res.transaction_slip_url).split(',') : [])
|
||||
baseForm.transaction_slip = slipNamesArr
|
||||
baseForm.transaction_slip_url = slipUrlsArr
|
||||
waterBillFiles.value = slipNamesArr.map((fileName: string, index: number) => ({
|
||||
name: fileName,
|
||||
url: slipUrlsArr[index] || fileName,
|
||||
file_name: fileName
|
||||
}))
|
||||
}
|
||||
// 等待本轮变更完成后,再恢复自动计算
|
||||
nextTick(() => {
|
||||
@@ -865,6 +1048,18 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
const handleSubmit = async (type: number, edit?: string, isfinal?: string) => {
|
||||
// 提交校验:最终提交且为提交动作时(type=1),必须填写 VIN
|
||||
const isFinalFlag = isfinal === '1' || (isfinal as any) === true
|
||||
if(type === 1&&baseForm.contract.length == 0){
|
||||
ElMessage.error('请上传合同文件')
|
||||
return
|
||||
}
|
||||
if(type === 1&&baseForm.pi_doc.length == 0){
|
||||
ElMessage.error('请上传pi文件')
|
||||
return
|
||||
}
|
||||
if(type === 1&& baseForm.transaction_slip.length == 0){
|
||||
ElMessage.error('请上传水单文件')
|
||||
return
|
||||
}
|
||||
if (isFinalFlag && type === 1) {
|
||||
// const hasEmptyVin = (items.value || []).some((it) => !it.vin || String(it.vin).trim() === '')
|
||||
// if (hasEmptyVin) {
|
||||
@@ -898,7 +1093,7 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
commission: wrapMoney(it.commission, (it as any).commission_currency, '佣金'),
|
||||
purchase_tax: wrapMoney(it.purchase_tax, (it as any).purchase_tax_currency, '购置税'),
|
||||
// tax_refund: wrapMoney(it.tax_refund, (it as any).tax_refund_currency, '退税'),
|
||||
tax_refund: wrapMoney(it.tax_refund, baseForm.settlement_currency, '退税'),
|
||||
tax_refund: wrapMoney(it.tax_refund, 'CNY', '退税'),
|
||||
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, '总价'),
|
||||
@@ -913,22 +1108,37 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
(it as any).discount_currency,
|
||||
'优惠额'
|
||||
),
|
||||
profit: wrapMoney(it.profit, baseForm.settlement_currency, '利润'),
|
||||
profit: wrapMoney(it.profit, 'CNY', '利润'),
|
||||
listing_price: wrapMoney(it.listing_price, (it as any).listing_price_currency, '挂牌价'),
|
||||
reduction_price: wrapMoney(
|
||||
it.reduction_price,
|
||||
(it as any).reduction_price_currency,
|
||||
'二手减价'
|
||||
),
|
||||
clearance_price: wrapMoney(it.clearance_price, (it as any).clearance_price_currency, '报关价')
|
||||
clearance_price: wrapMoney(
|
||||
it.clearance_price,
|
||||
(it as any).clearance_price_currency,
|
||||
'报关价'
|
||||
),
|
||||
accessory_price: wrapMoney(
|
||||
it.accessory_price,
|
||||
(it as any).accessory_price_currency,
|
||||
'配件价'
|
||||
),
|
||||
retention_price: wrapMoney(it.retention_price, (it as any).retention_price_currency, '挂账'),
|
||||
car_price: wrapMoney(it.car_price, (it as any).car_price_currency, '车价')
|
||||
}))
|
||||
|
||||
// 从提交参数中移除 settlement_currency
|
||||
const baseFormWithoutCur = { ...(baseForm as any) }
|
||||
delete (baseFormWithoutCur as any).total_cif
|
||||
delete (baseFormWithoutCur as any).total_cif_currency
|
||||
delete (baseFormWithoutCur as any).total_cif_currency_snapshot
|
||||
baseFormWithoutCur.cif_total = wrapMoney(baseFormWithoutCur.cif_total, baseFormWithoutCur.cif_total_currency, '合计')
|
||||
|
||||
// delete (baseFormWithoutCur as any).cif_total
|
||||
delete (baseFormWithoutCur as any).cif_total_currency
|
||||
delete (baseFormWithoutCur as any).cif_total_currency_snapshot
|
||||
delete (baseFormWithoutCur as any).contract_url
|
||||
delete (baseFormWithoutCur as any).pi_doc_url
|
||||
delete (baseFormWithoutCur as any).transaction_slip_url
|
||||
const payload = {
|
||||
...baseFormWithoutCur,
|
||||
veh_list: mappedItems,
|
||||
@@ -970,26 +1180,26 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
if (typeof validateContractRate === 'function') {
|
||||
validateContractRate()
|
||||
}
|
||||
// 结算币种变化时,按新币种重算所有行利润
|
||||
;(items.value || []).forEach((it: any, index: number) => {
|
||||
const profit = calcProfit(it)
|
||||
if (items.value[index])
|
||||
items.value[index].profit = isNaN(profit) ? 0 : Number(profit.toFixed(2))
|
||||
const clearance = calcClearanceFee(it)
|
||||
if (items.value[index]) {
|
||||
items.value[index].clearance_price = isNaN(clearance) ? 0 : Number(clearance.toFixed(2))
|
||||
// 确保报关价货币单位与计算结果一致
|
||||
if (items.value[index]) {
|
||||
;(items.value[index] as any).clearance_price_currency =
|
||||
it.clearance_price_currency || baseForm.settlement_currency || 'USD'
|
||||
}
|
||||
}
|
||||
const refund = calcTaxRefund(it)
|
||||
if (items.value[index]) {
|
||||
items.value[index].tax_refund = isNaN(refund) ? 0 : (Number(refund.toFixed(2)) as any)
|
||||
;(items.value[index] as any).tax_refund_currency = baseForm.settlement_currency || 'USD'
|
||||
}
|
||||
})
|
||||
// // 结算币种变化时,按新币种重算所有行利润
|
||||
// ;(items.value || []).forEach((it: any, index: number) => {
|
||||
// const profit = calcProfit(it)
|
||||
// if (items.value[index])
|
||||
// items.value[index].profit = isNaN(profit) ? 0 : Number(profit.toFixed(2))
|
||||
// const clearance = calcClearanceFee(it)
|
||||
// if (items.value[index]) {
|
||||
// items.value[index].clearance_price = isNaN(clearance) ? 0 : Number(clearance.toFixed(2))
|
||||
// // 确保报关价货币单位与计算结果一致
|
||||
// if (items.value[index]) {
|
||||
// ;(items.value[index] as any).clearance_price_currency =
|
||||
// it.clearance_price_currency || baseForm.settlement_currency || 'USD'
|
||||
// }
|
||||
// }
|
||||
// const refund = calcTaxRefund(it)
|
||||
// if (items.value[index]) {
|
||||
// items.value[index].tax_refund = isNaN(refund) ? 0 : (Number(refund.toFixed(2)) as any)
|
||||
// ;(items.value[index] as any).tax_refund_currency = baseForm.settlement_currency || 'USD'
|
||||
// }
|
||||
// })
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -1010,9 +1220,15 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
(val) => {
|
||||
if (isPopulating.value) return
|
||||
val.forEach((it: any, index: number) => {
|
||||
// 跳过用户正在编辑的行
|
||||
if (userEditing.value.has(index)) return
|
||||
const profit = calcProfit(it)
|
||||
if (items.value[index])
|
||||
if (items.value[index]) {
|
||||
items.value[index].profit = isNaN(profit) ? 0 : Number(profit.toFixed(2))
|
||||
;(items.value[index] as any).profit_currency = 'CNY'
|
||||
}
|
||||
|
||||
// 自动计算报关价
|
||||
const clearance = calcClearanceFee(it)
|
||||
if (items.value[index]) {
|
||||
items.value[index].clearance_price = isNaN(clearance) ? 0 : Number(clearance.toFixed(2))
|
||||
@@ -1022,31 +1238,74 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
it.clearance_price_currency || baseForm.settlement_currency || 'USD'
|
||||
}
|
||||
}
|
||||
|
||||
// 自动计算预估退税额
|
||||
const refund = calcTaxRefund(it)
|
||||
if (items.value[index]) {
|
||||
items.value[index].tax_refund = isNaN(refund) ? 0 : (Number(refund.toFixed(2)) as any)
|
||||
;(items.value[index] as any).tax_refund_currency = baseForm.settlement_currency || 'USD'
|
||||
items.value[index].tax_refund = isNaN(refund) ? '0' : String(Number(refund.toFixed(2)))
|
||||
;(items.value[index] as any).tax_refund_currency = 'CNY'
|
||||
}
|
||||
|
||||
// 自动计算车价
|
||||
const carPrice = calcCarPrice(it)
|
||||
if (items.value[index]) {
|
||||
items.value[index].car_price = isNaN(carPrice) ? 0 : Number(carPrice.toFixed(2))
|
||||
;(items.value[index] as any).car_price_currency =
|
||||
it.car_price_currency || baseForm.settlement_currency || 'USD'
|
||||
}
|
||||
})
|
||||
// 合计到岸价 = 所有单价相加
|
||||
// 合计到岸价 = 所有报关价相加
|
||||
const sum = (val || []).reduce((acc: number, cur: any) => {
|
||||
const n =
|
||||
cur?.unit_price === undefined || cur?.unit_price === null || cur?.unit_price === ''
|
||||
cur?.clearance_price === undefined ||
|
||||
cur?.clearance_price === null ||
|
||||
cur?.clearance_price === ''
|
||||
? 0
|
||||
: Number(cur.unit_price)
|
||||
: Number(cur.clearance_price)
|
||||
return acc + (isNaN(n) ? 0 : n)
|
||||
}, 0)
|
||||
baseForm.total_cif = Number(sum.toFixed(2))
|
||||
baseForm.cif_total = Number(sum.toFixed(2))
|
||||
|
||||
// 同步合计币种为第一行单价币种(若有)
|
||||
// 同步合计币种为第一行报关价币种(若有)
|
||||
if (items.value.length > 0) {
|
||||
const c = items.value[0]?.unit_price_currency
|
||||
if (c) baseForm.total_cif_currency = c
|
||||
const c = items.value[0]?.clearance_price_currency
|
||||
if (c) baseForm.cif_total_currency = c
|
||||
}
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
// 监听车价货币单位变化,重新计算车价并更新货币名称快照
|
||||
watch(
|
||||
() => items.value.map((item: any) => item.car_price_currency),
|
||||
(newCurrencies, oldCurrencies) => {
|
||||
if (isPopulating.value) return
|
||||
newCurrencies.forEach((currency: string, index: number) => {
|
||||
if (currency && currency !== oldCurrencies?.[index]) {
|
||||
const found = (currencyOptions.value || []).find((x: any) => x.currency_code === currency)
|
||||
if (found && items.value[index]) {
|
||||
;(items.value[index] as any).car_price_currency_snapshot = found.currency_name
|
||||
// 重新计算车价
|
||||
const carPrice = calcCarPrice(items.value[index])
|
||||
items.value[index].car_price = isNaN(carPrice) ? 0 : Number(carPrice.toFixed(2))
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
// 处理用户编辑状态的方法
|
||||
const handleUserEdit = (index: number) => {
|
||||
// 标记用户正在编辑这一行
|
||||
userEditing.value.add(index)
|
||||
|
||||
// 延迟清除编辑状态,给用户时间完成输入
|
||||
setTimeout(() => {
|
||||
userEditing.value.delete(index)
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
// 初始化方法
|
||||
const initializeForm = async () => {
|
||||
await Promise.all([
|
||||
@@ -1062,7 +1321,7 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
])
|
||||
|
||||
// 设置默认汇率
|
||||
baseForm.contract_exchange_rate = getCurrencyRate('CNY')
|
||||
baseForm.contract_exchange_rate = getCurrencyRate('USD')
|
||||
|
||||
// 设置预计发送日默认为当天
|
||||
const today = new Date()
|
||||
@@ -1077,7 +1336,9 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
baseForm,
|
||||
items,
|
||||
paymentItems,
|
||||
contractFile,
|
||||
contractFiles,
|
||||
piFiles,
|
||||
waterBillFiles,
|
||||
customerDialog,
|
||||
vehicleDialog,
|
||||
|
||||
@@ -1109,12 +1370,18 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
calcProfit,
|
||||
calcClearanceFee,
|
||||
calcTaxRefund,
|
||||
handleUserEdit,
|
||||
|
||||
// 合同文件方法
|
||||
isImageFile,
|
||||
beforeContractUpload,
|
||||
handleContractUpload,
|
||||
removeContractFile,
|
||||
downloadContractFile,
|
||||
removePiFile,
|
||||
downloadPiFile,
|
||||
removeWaterBillFile,
|
||||
downloadWaterBillFile,
|
||||
|
||||
// 订单项方法
|
||||
copyRow,
|
||||
@@ -1125,6 +1392,7 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
// 收款项方法
|
||||
addPaymentItem,
|
||||
removePaymentItem,
|
||||
copyPaymentItem,
|
||||
newPaymentItem,
|
||||
|
||||
// 客户选择方法
|
||||
|
||||
Reference in New Issue
Block a user