报关价可以修改货币 港口要可以筛选,还有账户

This commit is contained in:
浅念
2025-10-16 09:54:39 +08:00
parent 16abb6364c
commit 222d07d483
5 changed files with 124 additions and 63 deletions
+77 -35
View File
@@ -1,5 +1,5 @@
import { ref, reactive, watch, onMounted, nextTick } from 'vue' import { ref, reactive, watch, nextTick } from 'vue'
import { componentSizeMap, ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { CrmService } from '@/api/crmApi' import { CrmService } from '@/api/crmApi'
import { commonService } from '@/api/commonApi' import { commonService } from '@/api/commonApi'
import { vehicleService } from '@/api/vehicleApi' import { vehicleService } from '@/api/vehicleApi'
@@ -380,13 +380,14 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
try { try {
const found = (currencyOptions?.value || []).find((c: any) => c.currency_code === code) const found = (currencyOptions?.value || []).find((c: any) => c.currency_code === code)
return found?.rate || found?.exchange_rate || '' return found?.rate || found?.exchange_rate || ''
} catch (e) { } catch {
return '' return ''
} }
} }
const getCurrencyBounds = (code: string): { min: number; max: number; base: number } => { const getCurrencyBounds = (code: string): { min: number; max: number; base: number } => {
const found: any = (currencyOptions?.value || []).find((c: any) => c.currency_code === code) || {} const found: any =
(currencyOptions?.value || []).find((c: any) => c.currency_code === code) || {}
const base = Number(found?.rate || found?.exchange_rate || 0) || 0 const base = Number(found?.rate || found?.exchange_rate || 0) || 0
const up = Number(found?.float_percent_up) const up = Number(found?.float_percent_up)
const down = Number(found?.float_percent_down) const down = Number(found?.float_percent_down)
@@ -441,7 +442,11 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
const calcProfit = (it: any): number => { const calcProfit = (it: any): number => {
const targetCurrency = baseForm.settlement_currency || 'USD' const targetCurrency = baseForm.settlement_currency || 'USD'
const unit = convertCurrency(it.unit_price, it.unit_price_currency, targetCurrency) const unit = convertCurrency(it.unit_price, it.unit_price_currency, targetCurrency)
const retrofit = convertCurrency(it.retrofit_fee, (it as any).modify_fee_currency, targetCurrency) const retrofit = convertCurrency(
it.retrofit_fee,
(it as any).modify_fee_currency,
targetCurrency
)
const fob = convertCurrency( const fob = convertCurrency(
it.fob_transport_fee ?? (it as any).fob_fee, it.fob_transport_fee ?? (it as any).fob_fee,
(it as any).fob_fee_currency, (it as any).fob_fee_currency,
@@ -518,7 +523,7 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
} }
const calcClearanceFee = (it: any): number => { const calcClearanceFee = (it: any): number => {
const targetCurrency = baseForm.settlement_currency || 'USD' const targetCurrency = it.clearance_price_currency || baseForm.settlement_currency || 'USD'
const unit = convertCurrency(it.unit_price, it.unit_price_currency, targetCurrency) const unit = convertCurrency(it.unit_price, it.unit_price_currency, targetCurrency)
const commission = convertCurrency( const commission = convertCurrency(
it.commission ?? (it as any).commission, it.commission ?? (it as any).commission,
@@ -623,11 +628,16 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
customerDialog.loading = true customerDialog.loading = true
try { try {
const { currentPage, pageSize } = customerDialog.pagination const { currentPage, pageSize } = customerDialog.pagination
const params = { current: currentPage, size: pageSize, keyword: customerDialog.search.keyword } const params = {
current: currentPage,
size: pageSize,
keyword: customerDialog.search.keyword
}
const { data, current, size, total } = await CrmService.getcustomerList(params as any) const { data, current, size, total } = await CrmService.getcustomerList(params as any)
customerDialog.tableData = data || [] customerDialog.tableData = data || []
Object.assign(customerDialog.pagination, { currentPage: current, pageSize: size, total }) Object.assign(customerDialog.pagination, { currentPage: current, pageSize: size, total })
} catch (e) { } catch {
// 忽略错误
} finally { } finally {
customerDialog.loading = false customerDialog.loading = false
} }
@@ -736,7 +746,9 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
baseForm.remark = res.remark || '' baseForm.remark = res.remark || ''
baseForm.settlement_currency = res.settlement_currency || 'CNY' baseForm.settlement_currency = res.settlement_currency || 'CNY'
// 合计与汇率 // 合计与汇率
baseForm.total_cif = res.cif_total_amount.amount ? Number(res.cif_total_amount.amount) : undefined 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.total_cif_currency = res.settlement_currency || baseForm.total_cif_currency
baseForm.contract_exchange_rate = baseForm.contract_exchange_rate =
res.contract_exchange_rate || getCurrencyRate(baseForm.total_cif_currency) res.contract_exchange_rate || getCurrencyRate(baseForm.total_cif_currency)
@@ -760,7 +772,9 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
color_exterior_snapshot: it.color_exterior_snapshot || '', color_exterior_snapshot: it.color_exterior_snapshot || '',
unit_price: it.unit_price?.amount ? Number(it.unit_price.amount) : undefined, unit_price: it.unit_price?.amount ? Number(it.unit_price.amount) : undefined,
handling_fee: it.handling_fee?.amount ?? '', handling_fee: it.handling_fee?.amount ?? '',
fob_transport_fee: it.fob_transport_fee?.amount ? Number(it.fob_transport_fee.amount) : undefined, fob_transport_fee: it.fob_transport_fee?.amount
? Number(it.fob_transport_fee.amount)
: undefined,
port_misc_fee: it.port_misc_fee?.amount ?? '', port_misc_fee: it.port_misc_fee?.amount ?? '',
remark: it.remark || '', remark: it.remark || '',
ocean_freight: it.ocean_freight?.amount ?? '', ocean_freight: it.ocean_freight?.amount ?? '',
@@ -797,15 +811,22 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
discount: undefined, discount: undefined,
discount_currency: it.discount_price?.currency || 'CNY', discount_currency: it.discount_price?.currency || 'CNY',
discount_currency_snapshot: '', discount_currency_snapshot: '',
contract_rate: baseForm.contract_exchange_rate ? Number(baseForm.contract_exchange_rate) : undefined, contract_rate: baseForm.contract_exchange_rate
? Number(baseForm.contract_exchange_rate)
: undefined,
profit: it.profit?.amount ? Number(it.profit.amount) : undefined, profit: it.profit?.amount ? Number(it.profit.amount) : undefined,
profit_type_snapshot: '', profit_type_snapshot: '',
clearance_price: it.clearance_price?.amount ? Number(it.clearance_price.amount) : undefined, 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 || 'CNY',
clearance_price_currency_snapshot: '', clearance_price_currency_snapshot: '',
modify_ids: Array.isArray(it.modify_list) ? it.modify_list.map((m: any) => Number(m.option_id)) : [], modify_ids: Array.isArray(it.modify_list)
? it.modify_list.map((m: any) => Number(m.option_id))
: [],
modify_list: Array.isArray(it.modify_list) modify_list: Array.isArray(it.modify_list)
? it.modify_list.map((m: any) => ({ option_id: String(m.option_id), option_name_snapshot: m.option_name_snapshot })) ? it.modify_list.map((m: any) => ({
option_id: String(m.option_id),
option_name_snapshot: m.option_name_snapshot
}))
: [], : [],
modify_fee_currency: it.retrofit_fee?.currency || 'CNY', modify_fee_currency: it.retrofit_fee?.currency || 'CNY',
modify_fee_currency_snapshot: '', modify_fee_currency_snapshot: '',
@@ -835,7 +856,9 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
} }
} }
// 等待本轮变更完成后,再恢复自动计算 // 等待本轮变更完成后,再恢复自动计算
nextTick(() => { isPopulating.value = false }) nextTick(() => {
isPopulating.value = false
})
} }
// 提交方法 // 提交方法
@@ -897,7 +920,7 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
(it as any).reduction_price_currency, (it as any).reduction_price_currency,
'二手减价' '二手减价'
), ),
clearance_price: wrapMoney(it.clearance_price, baseForm.settlement_currency, '报关价') clearance_price: wrapMoney(it.clearance_price, (it as any).clearance_price_currency, '报关价')
})) }))
// 从提交参数中移除 settlement_currency // 从提交参数中移除 settlement_currency
@@ -932,7 +955,7 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
window.location.href = '/crmpc/stocking/stocking_list' window.location.href = '/crmpc/stocking/stocking_list'
} }
}, 1000) }, 1000)
} catch (e) { } catch {
// ElMessage.error('保存失败') // ElMessage.error('保存失败')
} }
} }
@@ -948,14 +971,22 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
validateContractRate() validateContractRate()
} }
// 结算币种变化时,按新币种重算所有行利润 // 结算币种变化时,按新币种重算所有行利润
(items.value || []).forEach((it: any, index: number) => { ;(items.value || []).forEach((it: any, index: number) => {
const profit = calcProfit(it) const profit = calcProfit(it)
if (items.value[index]) items.value[index].profit = isNaN(profit) ? 0 : Number(profit.toFixed(2)) if (items.value[index])
items.value[index].profit = isNaN(profit) ? 0 : Number(profit.toFixed(2))
const clearance = calcClearanceFee(it) 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].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) const refund = calcTaxRefund(it)
if (items.value[index]) { if (items.value[index]) {
items.value[index].tax_refund = isNaN(refund) ? 0 : Number(refund.toFixed(2)) as any 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] as any).tax_refund_currency = baseForm.settlement_currency || 'USD'
} }
}) })
@@ -980,22 +1011,33 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
if (isPopulating.value) return if (isPopulating.value) return
val.forEach((it: any, index: number) => { val.forEach((it: any, index: number) => {
const profit = calcProfit(it) const profit = calcProfit(it)
if (items.value[index]) items.value[index].profit = isNaN(profit) ? 0 : Number(profit.toFixed(2)) if (items.value[index])
items.value[index].profit = isNaN(profit) ? 0 : Number(profit.toFixed(2))
const clearance = calcClearanceFee(it) 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].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) const refund = calcTaxRefund(it)
if (items.value[index]) { if (items.value[index]) {
items.value[index].tax_refund = isNaN(refund) ? 0 : Number(refund.toFixed(2)) as any 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] as any).tax_refund_currency = baseForm.settlement_currency || 'USD'
} }
}) })
// 合计到岸价 = 所有单价相加 // 合计到岸价 = 所有单价相加
const sum = (val || []).reduce((acc: number, cur: any) => { const sum = (val || []).reduce((acc: number, cur: any) => {
const n = cur?.unit_price === undefined || cur?.unit_price === null || cur?.unit_price === '' ? 0 : Number(cur.unit_price) const n =
cur?.unit_price === undefined || cur?.unit_price === null || cur?.unit_price === ''
? 0
: Number(cur.unit_price)
return acc + (isNaN(n) ? 0 : n) return acc + (isNaN(n) ? 0 : n)
}, 0) }, 0)
baseForm.total_cif = Number(sum.toFixed(2)) baseForm.total_cif = Number(sum.toFixed(2))
// 同步合计币种为第一行单价币种(若有) // 同步合计币种为第一行单价币种(若有)
if (items.value.length > 0) { if (items.value.length > 0) {
const c = items.value[0]?.unit_price_currency const c = items.value[0]?.unit_price_currency
@@ -1018,10 +1060,10 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
loadPortOptions(), loadPortOptions(),
loadDictOptions() loadDictOptions()
]) ])
// 设置默认汇率 // 设置默认汇率
baseForm.contract_exchange_rate = getCurrencyRate('CNY') baseForm.contract_exchange_rate = getCurrencyRate('CNY')
// 设置预计发送日默认为当天 // 设置预计发送日默认为当天
const today = new Date() const today = new Date()
const year = today.getFullYear() const year = today.getFullYear()
@@ -1038,7 +1080,7 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
contractFile, contractFile,
customerDialog, customerDialog,
vehicleDialog, vehicleDialog,
// 选项数据 // 选项数据
channelOptions, channelOptions,
countryOptions, countryOptions,
@@ -1052,11 +1094,11 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
ncolorOptions, ncolorOptions,
transportOptions, transportOptions,
trade_termsOptions, trade_termsOptions,
// 上传相关 // 上传相关
actionImageUplode, actionImageUplode,
uploadHeaders, uploadHeaders,
// 方法 // 方法
initializeForm, initializeForm,
populateFromDetail, populateFromDetail,
@@ -1067,31 +1109,31 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
calcProfit, calcProfit,
calcClearanceFee, calcClearanceFee,
calcTaxRefund, calcTaxRefund,
// 合同文件方法 // 合同文件方法
isImageFile, isImageFile,
beforeContractUpload, beforeContractUpload,
handleContractUpload, handleContractUpload,
removeContractFile, removeContractFile,
// 订单项方法 // 订单项方法
copyRow, copyRow,
addRowAfter, addRowAfter,
removeRow, removeRow,
newItem, newItem,
// 收款项方法 // 收款项方法
addPaymentItem, addPaymentItem,
removePaymentItem, removePaymentItem,
newPaymentItem, newPaymentItem,
// 客户选择方法 // 客户选择方法
openCustomerDialog, openCustomerDialog,
getCustomerList, getCustomerList,
handleCustomerSizeChange, handleCustomerSizeChange,
handleCustomerCurrentChange, handleCustomerCurrentChange,
chooseCustomer, chooseCustomer,
// 车辆选择方法 // 车辆选择方法
openVehicleDialog, openVehicleDialog,
getVehicleList, getVehicleList,
+12 -6
View File
@@ -473,14 +473,17 @@
:class="Number(item.clearance_price) < 0 ? 'customs-fee-negative' : ''" :class="Number(item.clearance_price) < 0 ? 'customs-fee-negative' : ''"
> >
<template #suffix> <template #suffix>
<span style="font-size: 11px"> <ElSelect v-model="item.clearance_price_currency" style="width: 74px">
{{ <ElOption
((currencyOptions || []).find((c: any) => c.currency_code === baseForm.settlement_currency)?.currency_name) || v-for="c in currencyOptions"
baseForm.settlement_currency :key="c.currency_code"
}} :label="c.currency_name"
</span> :value="c.currency_code"
/>
</ElSelect>
</template> </template>
</ElInput> </ElInput>
<ElInput v-model="item.clearance_price_currency_snapshot" type="hidden" />
</ElFormItem> </ElFormItem>
</ElCol> </ElCol>
</ElRow> </ElRow>
@@ -583,6 +586,7 @@
<ElSelect <ElSelect
v-model="baseForm.domestic_port_id" v-model="baseForm.domestic_port_id"
placeholder="请选择国内收货商" placeholder="请选择国内收货商"
filterable
@change=" @change="
(val) => (val) =>
(baseForm.domestic_port_snapshot = (baseForm.domestic_port_snapshot =
@@ -646,6 +650,7 @@
<ElFormItem label="清关目的港" label-width="98px" prop="clearance_port_id" required> <ElFormItem label="清关目的港" label-width="98px" prop="clearance_port_id" required>
<ElSelect <ElSelect
v-model="baseForm.clearance_port_id" v-model="baseForm.clearance_port_id"
filterable
placeholder="请选择" placeholder="请选择"
@change=" @change="
(val) => (val) =>
@@ -731,6 +736,7 @@
<ElFormItem label="账户" label-width="65px" prop="account_id" required> <ElFormItem label="账户" label-width="65px" prop="account_id" required>
<ElSelect <ElSelect
v-model="payment.account_id" v-model="payment.account_id"
filterable
placeholder="请选择账户" placeholder="请选择账户"
@change=" @change="
(val) => (val) =>
+10 -7
View File
@@ -493,17 +493,20 @@
<ElInput <ElInput
v-model="item.clearance_price" v-model="item.clearance_price"
placeholder="正在计算报关价" placeholder="正在计算报关价"
:class="Number(item.clearance_price) < 0 ? 'profit-negative' : ''" :class="Number(item.clearance_price) < 0 ? 'customs-fee-negative' : ''"
> >
<template #suffix> <template #suffix>
<span style="font-size: 11px"> <ElSelect v-model="item.clearance_price_currency" style="width: 74px">
{{ <ElOption
((currencyOptions || []).find((c: any) => c.currency_code === baseForm.settlement_currency)?.currency_name) || v-for="c in currencyOptions"
baseForm.settlement_currency :key="c.currency_code"
}} :label="c.currency_name"
</span> :value="c.currency_code"
/>
</ElSelect>
</template> </template>
</ElInput> </ElInput>
<ElInput v-model="item.clearance_price_currency_snapshot" type="hidden" />
</ElFormItem> </ElFormItem>
</ElCol> </ElCol>
<ElCol :sm="12" :md="12" :lg="6" :xl="4"> <ElCol :sm="12" :md="12" :lg="6" :xl="4">
+15 -7
View File
@@ -579,18 +579,26 @@
<ElFormItem label="报关价" label-width="95px"> <ElFormItem label="报关价" label-width="95px">
<ElInput <ElInput
v-model="item.clearance_price" v-model="item.clearance_price"
:disabled="item._echo_vin === true"
placeholder="正在计算报关价" placeholder="正在计算报关价"
:class="Number(item.clearance_price) < 0 ? 'profit-negative' : ''" :class="Number(item.clearance_price) < 0 ? 'customs-fee-negative' : ''"
> >
<template #suffix> <template #suffix>
<span style="font-size: 11px"> <ElSelect
{{ v-model="item.clearance_price_currency"
((currencyOptions || []).find((c: any) => c.currency_code === baseForm.settlement_currency)?.currency_name) || :disabled="item._echo_vin === true"
baseForm.settlement_currency style="width: 74px"
}} >
</span> <ElOption
v-for="c in currencyOptions"
:key="c.currency_code"
:label="c.currency_name"
:value="c.currency_code"
/>
</ElSelect>
</template> </template>
</ElInput> </ElInput>
<ElInput v-model="item.clearance_price_currency_snapshot" type="hidden" />
</ElFormItem> </ElFormItem>
</ElCol> </ElCol>
<ElCol :sm="12" :md="12" :lg="6" :xl="4"> <ElCol :sm="12" :md="12" :lg="6" :xl="4">
+10 -8
View File
@@ -493,18 +493,20 @@
<ElInput <ElInput
v-model="item.clearance_price" v-model="item.clearance_price"
placeholder="正在计算报关价" placeholder="正在计算报关价"
:class="Number(item.clearance_price) < 0 ? 'profit-negative' : ''" :class="Number(item.clearance_price) < 0 ? 'customs-fee-negative' : ''"
> >
<template #suffix> <template #suffix>
<span style="font-size: 11px"> <ElSelect v-model="item.clearance_price_currency" style="width: 74px">
{{ <ElOption
((currencyOptions || []).find((c: any) => c.currency_code === baseForm.settlement_currency) v-for="c in currencyOptions"
?.currency_name) || :key="c.currency_code"
baseForm.settlement_currency :label="c.currency_name"
}} :value="c.currency_code"
</span> />
</ElSelect>
</template> </template>
</ElInput> </ElInput>
<ElInput v-model="item.clearance_price_currency_snapshot" type="hidden" />
</ElFormItem> </ElFormItem>
</ElCol> </ElCol>
</ElRow> </ElRow>