报关价可以修改货币 港口要可以筛选,还有账户
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { ref, reactive, watch, onMounted, nextTick } from 'vue'
|
||||
import { componentSizeMap, ElMessage } from 'element-plus'
|
||||
import { ref, reactive, watch, nextTick } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { CrmService } from '@/api/crmApi'
|
||||
import { commonService } from '@/api/commonApi'
|
||||
import { vehicleService } from '@/api/vehicleApi'
|
||||
@@ -380,13 +380,14 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
try {
|
||||
const found = (currencyOptions?.value || []).find((c: any) => c.currency_code === code)
|
||||
return found?.rate || found?.exchange_rate || ''
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
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 up = Number(found?.float_percent_up)
|
||||
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 targetCurrency = baseForm.settlement_currency || 'USD'
|
||||
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(
|
||||
it.fob_transport_fee ?? (it as any).fob_fee,
|
||||
(it as any).fob_fee_currency,
|
||||
@@ -518,7 +523,7 @@ export function useStockingForm(isFinal = false, stockingId?: string | 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 commission = convertCurrency(
|
||||
it.commission ?? (it as any).commission,
|
||||
@@ -623,11 +628,16 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
customerDialog.loading = true
|
||||
try {
|
||||
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)
|
||||
customerDialog.tableData = data || []
|
||||
Object.assign(customerDialog.pagination, { currentPage: current, pageSize: size, total })
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// 忽略错误
|
||||
} finally {
|
||||
customerDialog.loading = false
|
||||
}
|
||||
@@ -736,7 +746,9 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
baseForm.remark = res.remark || ''
|
||||
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.contract_exchange_rate =
|
||||
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 || '',
|
||||
unit_price: it.unit_price?.amount ? Number(it.unit_price.amount) : undefined,
|
||||
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 ?? '',
|
||||
remark: it.remark || '',
|
||||
ocean_freight: it.ocean_freight?.amount ?? '',
|
||||
@@ -797,15 +811,22 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
discount: undefined,
|
||||
discount_currency: it.discount_price?.currency || 'CNY',
|
||||
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_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_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)
|
||||
? 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_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,
|
||||
'二手减价'
|
||||
),
|
||||
clearance_price: wrapMoney(it.clearance_price, baseForm.settlement_currency, '报关价')
|
||||
clearance_price: wrapMoney(it.clearance_price, (it as any).clearance_price_currency, '报关价')
|
||||
}))
|
||||
|
||||
// 从提交参数中移除 settlement_currency
|
||||
@@ -932,7 +955,7 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
window.location.href = '/crmpc/stocking/stocking_list'
|
||||
}
|
||||
}, 1000)
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// ElMessage.error('保存失败')
|
||||
}
|
||||
}
|
||||
@@ -948,14 +971,22 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
validateContractRate()
|
||||
}
|
||||
// 结算币种变化时,按新币种重算所有行利润
|
||||
(items.value || []).forEach((it: any, index: number) => {
|
||||
;(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))
|
||||
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].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].tax_refund = isNaN(refund) ? 0 : (Number(refund.toFixed(2)) as any)
|
||||
;(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
|
||||
val.forEach((it: any, index: number) => {
|
||||
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)
|
||||
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)
|
||||
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'
|
||||
}
|
||||
})
|
||||
// 合计到岸价 = 所有单价相加
|
||||
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)
|
||||
}, 0)
|
||||
baseForm.total_cif = Number(sum.toFixed(2))
|
||||
|
||||
|
||||
// 同步合计币种为第一行单价币种(若有)
|
||||
if (items.value.length > 0) {
|
||||
const c = items.value[0]?.unit_price_currency
|
||||
@@ -1018,10 +1060,10 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
loadPortOptions(),
|
||||
loadDictOptions()
|
||||
])
|
||||
|
||||
|
||||
// 设置默认汇率
|
||||
baseForm.contract_exchange_rate = getCurrencyRate('CNY')
|
||||
|
||||
|
||||
// 设置预计发送日默认为当天
|
||||
const today = new Date()
|
||||
const year = today.getFullYear()
|
||||
@@ -1038,7 +1080,7 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
contractFile,
|
||||
customerDialog,
|
||||
vehicleDialog,
|
||||
|
||||
|
||||
// 选项数据
|
||||
channelOptions,
|
||||
countryOptions,
|
||||
@@ -1052,11 +1094,11 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
ncolorOptions,
|
||||
transportOptions,
|
||||
trade_termsOptions,
|
||||
|
||||
|
||||
// 上传相关
|
||||
actionImageUplode,
|
||||
uploadHeaders,
|
||||
|
||||
|
||||
// 方法
|
||||
initializeForm,
|
||||
populateFromDetail,
|
||||
@@ -1067,31 +1109,31 @@ export function useStockingForm(isFinal = false, stockingId?: string | number) {
|
||||
calcProfit,
|
||||
calcClearanceFee,
|
||||
calcTaxRefund,
|
||||
|
||||
|
||||
// 合同文件方法
|
||||
isImageFile,
|
||||
beforeContractUpload,
|
||||
handleContractUpload,
|
||||
removeContractFile,
|
||||
|
||||
|
||||
// 订单项方法
|
||||
copyRow,
|
||||
addRowAfter,
|
||||
removeRow,
|
||||
newItem,
|
||||
|
||||
|
||||
// 收款项方法
|
||||
addPaymentItem,
|
||||
removePaymentItem,
|
||||
newPaymentItem,
|
||||
|
||||
|
||||
// 客户选择方法
|
||||
openCustomerDialog,
|
||||
getCustomerList,
|
||||
handleCustomerSizeChange,
|
||||
handleCustomerCurrentChange,
|
||||
chooseCustomer,
|
||||
|
||||
|
||||
// 车辆选择方法
|
||||
openVehicleDialog,
|
||||
getVehicleList,
|
||||
|
||||
Reference in New Issue
Block a user