Commit 7df53dfa by yuzhenWang

Merge branch 'wyz' into 'test'

测试出账检核--分期出账

See merge request !118
parents 124358e9 f51c60b8
......@@ -11,6 +11,7 @@ const useUserStore = defineStore('user', {
state: () => ({
token: getToken(),
id: '',
realName:'',
name: '',
nickName: '',
avatar: '',
......@@ -74,6 +75,7 @@ const useUserStore = defineStore('user', {
this.id = user.userId
this.name = user.userName
this.realName = user.realName
this.nickName = user.nickName
this.avatar = avatar
this.isSuperAdmin = user.isSuperAdmin
......
......@@ -15,7 +15,7 @@
<template #searchForm>
<SearchForm ref="searchFormRef" :config="searchConfig" />
</template>
1111
<!-- 列表区域 -->
<template #table>
<!-- 统计信息卡片 v-if="statisticsData.totalInAmount > 0"-->
......@@ -249,7 +249,7 @@
<!-- 分期出账弹窗 -->
<CommonDialog
dialogTitle="分期出账"
dialogWidth="80%"
dialogWidth="90%"
confirmText="提交"
:openDialog="installmentsBillFlag"
:showAction="true"
......@@ -454,52 +454,137 @@ const splitTableColumns = ref([
inputType: 'decimal', // integer / decimalNumber / decimal
decimalDigits: 2, // 小数位数,默认2
required: true,
placeholder: '请输入金额'
placeholder: '请输入出账比例',
width: 150
},
{
editType: 'select',
prop: 'ruleCurrency',
label: '保单币种',
dictType: 'bx_currency_type',
required: true,
width: 150
},
{
editType: 'select',
prop: 'originalCurrency',
label: '原币种',
dictType: 'bx_currency_type',
required: true,
width: 150
},
{
editType: 'select',
prop: 'payoutCurrency',
label: '发放币种',
dictType: 'bx_currency_type',
required: true,
width: 150
},
{
prop: 'amount',
editType: 'input',
prop: 'originalAmount',
label: '原币种金额',
inputType: 'decimal',
required: true,
width: 150
},
{
editType: 'input',
inputType: 'decimalNumber', // integer / decimalNumber / decimal
decimalDigits: 2, // 小数位数,默认2
required: true
prop: 'originalToHkdRate',
label: '汇率3(原币种->港币)',
inputType: 'decimal',
required: true,
width: 150
},
{
prop: 'originalAmount',
label: '本次出账原币种金额',
editType: 'input',
inputType: 'decimalNumber', // integer / decimalNumber / decimal
decimalDigits: 2, // 小数位数,默认2
required: true
prop: 'hkdAmount',
label: '港币金额',
inputType: 'decimal',
required: true,
width: 150
},
{
prop: 'exchangeRate',
label: '结算汇率',
editType: 'input',
inputType: 'decimal', // integer / decimalNumber / decimal
decimalDigits: 2, // 小数位数,默认2
required: true
prop: 'hkdToPayoutRate',
label: '汇率1(港币->发放币种)',
inputType: 'decimal',
required: true,
width: 150
},
{
prop: 'hkdAmount',
label: '港币出账金额',
editType: 'input',
inputType: 'decimalNumber', // integer / decimalNumber / decimal
decimalDigits: 2, // 小数位数,默认2
required: true
prop: 'payoutAmount',
label: '实际发放金额',
inputType: 'decimal',
required: true,
width: 150
},
{
editType: 'input',
prop: 'exchangeRate',
label: '汇率2(保单币种->港币)入账检核汇率',
inputType: 'decimal',
required: true,
width: 150
// defaultValue: 1
},
{
editType: 'input',
prop: 'ruleAmount',
label: '保单币种金额',
inputType: 'decimal',
required: true,
width: 150
},
// {
// prop: 'amount',
// label: '原币种金额',
// editType: 'input',
// inputType: 'decimalNumber', // integer / decimalNumber / decimal
// decimalDigits: 2, // 小数位数,默认2
// required: true
// },
// {
// prop: 'originalAmount',
// label: '本次出账原币种金额',
// editType: 'input',
// inputType: 'decimalNumber', // integer / decimalNumber / decimal
// decimalDigits: 2, // 小数位数,默认2
// required: true
// },
// {
// prop: 'exchangeRate',
// label: '结算汇率',
// editType: 'input',
// inputType: 'decimal', // integer / decimalNumber / decimal
// decimalDigits: 2, // 小数位数,默认2
// required: true
// },
// {
// prop: 'hkdAmount',
// label: '港币出账金额',
// editType: 'input',
// inputType: 'decimalNumber', // integer / decimalNumber / decimal
// decimalDigits: 2, // 小数位数,默认2
// required: true
// },
{
prop: 'payoutYearMonth',
label: '出账年月(估)',
editType: 'month',
required: true
required: true,
width: 150
},
{
prop: 'remark',
label: '备注',
editType: 'input',
inputType: 'textarea',
required: false
required: false,
width: 150
}
// {
// prop: 'userId',
......@@ -671,14 +756,14 @@ const handleInputChange = async (formType, prop, value, item) => {
// 计算保单币种金额
const exchangeRate = rateExchangeForm.value.exchangeRate
const hkdAmount = value
const ruleAmount = multiply(hkdAmount, exchangeRate, 2)
const ruleAmount = multiply(hkdAmount, exchangeRate, 2, 'Divided')
await nextTick()
rateExchangeForm.value.ruleAmount = ruleAmount
} else if (prop == 'exchangeRate' && value && rateExchangeForm.value.hkdAmount) {
// 计算保单币种金额
const exchangeRate = value
const hkdAmount = rateExchangeForm.value.hkdAmount
const ruleAmount = multiply(hkdAmount, exchangeRate, 2)
const ruleAmount = multiply(hkdAmount, exchangeRate, 2, 'Divided')
await nextTick()
rateExchangeForm.value.ruleAmount = ruleAmount
}
......@@ -701,49 +786,85 @@ const handleInputChange = async (formType, prop, value, item) => {
}
}
// 精确乘法并保留小数位数
const multiply = (a, b, digits = 2) => {
const multiply = (a, b, digits = 2, calculatedType) => {
if (a == null || b == null) return null
const numA = parseFloat(a)
const numB = parseFloat(b)
if (isNaN(numA) || isNaN(numB)) return null
if (calculatedType && calculatedType == 'Divided') {
return round(numA / numB, digits)
}
return round(numA * numB, digits)
}
const handleSplitCellChange = ({ row, col, newValue, oldValue, rowIndex, prop }) => {
// 避免同一字段重复触发(如修改 chuAmount 会触发 hkdAmount 计算,该计算会再次触发 cell-change)
// 通过比较新旧值跳过无实际变化的更新
// if (newValue === oldValue) return
const currentRow = splitTableData.value[rowIndex]
if (!currentRow) return
let needUpdate = false
const updatedRow = { ...currentRow }
// 联动规则1:出账比例 或 原币种金额 变化 → 重算 本次出账原币种金额
if (prop === 'splitRatio' || prop === 'amount') {
// 联动规则1:计算原币种金额 应出账比例*应出账金额(HKD)
if (prop === 'splitRatio' && selectedRow.value.hkdAmount) {
let ratio = prop === 'splitRatio' ? newValue : currentRow.splitRatio
const amount = prop === 'amount' ? newValue : currentRow.amount
if (ratio) {
ratio = ratio / 100
}
const newChuAmount = multiply(amount, ratio, 2)
updatedRow.originalAmount = newChuAmount
const originalAmount = multiply(selectedRow.value.hkdAmount, ratio, 2)
updatedRow.originalAmount = originalAmount
// 原币种金额发生变化更新港币金额
if (updatedRow.originalToHkdRate) {
updatedRow.hkdAmount = multiply(updatedRow.originalAmount, updatedRow.originalToHkdRate, 2)
}
//港币金额发生变化 更新实际发放金额
if (updatedRow.hkdToPayoutRate && updatedRow.hkdAmount) {
updatedRow.payoutAmount = multiply(updatedRow.hkdAmount, updatedRow.hkdToPayoutRate, 2)
}
//港币金额发生变化 更新保单币种金额
if (updatedRow.exchangeRate && updatedRow.hkdAmount) {
updatedRow.ruleAmount = multiply(updatedRow.hkdAmount, updatedRow.exchangeRate, 2, 'Divided')
}
needUpdate = true
}
// 联动规则2:汇率 或 本次出账原币种金额 变化 → 重算 港币金额
if (prop === 'exchangeRate' || prop === 'originalAmount') {
const rate = prop === 'exchangeRate' ? newValue : currentRow.exchangeRate
const chuAmt = prop === 'originalAmount' ? newValue : currentRow.originalAmount
const newHkdAmount = multiply(chuAmt, rate, 2)
updatedRow.hkdAmount = newHkdAmount
// 联动规则2:原币种->港币 或 原币种金额 变化 → 重算 港币金额 = 原币种金额*原币种->港币
if (prop === 'originalToHkdRate' || prop === 'originalAmount') {
const originalToHkdRate = prop === 'originalToHkdRate' ? newValue : currentRow.originalToHkdRate
const originalAmount = prop === 'originalAmount' ? newValue : currentRow.originalAmount
const hkdAmount = multiply(originalAmount, originalToHkdRate, 2)
updatedRow.hkdAmount = hkdAmount
//港币金额发生变化 更新实际发放金额
if (updatedRow.hkdToPayoutRate && updatedRow.hkdAmount) {
updatedRow.payoutAmount = multiply(updatedRow.hkdAmount, updatedRow.hkdToPayoutRate, 2)
}
//港币金额发生变化 更新保单币种金额
if (updatedRow.exchangeRate && updatedRow.hkdAmount) {
updatedRow.ruleAmount = multiply(updatedRow.hkdAmount, updatedRow.exchangeRate, 2, 'Divided')
}
needUpdate = true
console.log('updatedRow.hkdAmount', updatedRow.hkdAmount)
}
// 联动规则3:港币->发放币种 或 港币金额 变化 → 重算 实际发放金额 = 港币金额*港币->发放币种汇率
if (prop === 'hkdToPayoutRate' || prop === 'hkdAmount') {
const hkdToPayoutRate = prop === 'hkdToPayoutRate' ? newValue : currentRow.hkdToPayoutRate
const hkdAmount = prop === 'hkdAmount' ? newValue : currentRow.hkdAmount
const payoutAmount = multiply(hkdAmount, hkdToPayoutRate, 2)
updatedRow.payoutAmount = payoutAmount
needUpdate = true
}
// 联动规则4:保单币种->港币 或 港币金额 变化 → 重算 保单币种金额 = 港币金额/保单币种->港币汇率
if (prop === 'exchangeRate' || prop === 'hkdAmount') {
const exchangeRate = prop === 'exchangeRate' ? newValue : currentRow.exchangeRate
const hkdAmount = prop === 'hkdAmount' ? newValue : currentRow.hkdAmount
const ruleAmount = multiply(hkdAmount, exchangeRate, 2, 'Divided')
updatedRow.ruleAmount = ruleAmount
needUpdate = true
}
//出账比例发生变化,一系列得金额都会变化
// if (prop === 'splitRatio' && updatedRow.splitRatio) {
// needUpdate = true
// }
// 如果用户手动修改了 hkdAmount,不做反向联动(符合需求)
if (needUpdate) {
// 更新表格数据(整体替换,触发视图更新)
const newData = [...splitTableData.value]
......@@ -783,16 +904,25 @@ let nextId = 1
const generateId = () => Date.now() + nextId++
// 添加出账
const addSpiltRecord = () => {
if (splitTableData.value.length > 0) {
let ratio = 0
splitTableData.value.forEach(item => {
ratio += Number(item.splitRatio)
})
console.log('比例', ratio)
if (ratio > 100 || ratio == 100) {
ElMessage.error('应出账比例不能大于100%')
return
}
}
const newRow = {
id: generateId(), // 必须有 rowIdKey 对应的字段(默认 'id')
splitRatio: '', // 出账比例
amount: selectedRow.value.amount, // 原币种金额
exchangeRate: '', // 结算汇率
hkdAmount: '', // 港币出账金额
payoutYearMonth: '', // 出账年月(估)
originalAmount: '', //本次出账原币种金额
remark: '' // 备注
payoutCurrency: 'HKD',
ruleCurrency: selectedRow.value.ruleCurrency,
originalCurrency: selectedRow.value.originalCurrency
}
// 插入到表格数据最前面
splitTableData.value.push(newRow)
}
......@@ -1288,12 +1418,9 @@ watch(
if (newVal) {
//3.计算保单币种金额 港币金额*保单币种->港币汇率
if (newVal.hkdAmount != null && newVal.exchangeRate != null) {
const calculated1 = multiply(newVal.hkdAmount, newVal.exchangeRate, 2)
const calculated1 = multiply(newVal.hkdAmount, newVal.exchangeRate, 2, 'Divided')
if (addCheckRecordFormModel.value.ruleAmount !== calculated1) {
addCheckRecordFormModel.value.ruleAmount = Number(calculated1).toFixed(2)
console.log('====================================')
console.log('calculated1', addCheckRecordFormModel.value.ruleAmount)
console.log('====================================')
}
}
// 计算港币金额 原币种金额*原币种->港币
......@@ -1314,6 +1441,33 @@ watch(
},
{ deep: true, immediate: true } // immediate: true 可以让初始值也计算一次
)
// 检测splitTableData
// watch(
// () => splitTableData.value, // 推荐使用 getter 形式,避免直接监听 ref 对象
// newVal => {
// if (newVal) {
// let data = JSON.parse(JSON.stringify(newVal))
// splitTableData.value = data.map(item => {
// // 计算原币种金额 出账比例*selectedRow.value.hkdAmount
// if (item.splitRatio !== null && selectedRow.value.hkdAmount !== null) {
// let ratio = Number(item.splitRatio) / 100
// if (ratio > 0) {
// const calculated1 = multiply(selectedRow.value.hkdAmount, ratio, 2)
// if (item.originalAmount && item.originalAmount !== calculated1) {
// item.originalAmount = Number(calculated1).toFixed(2)
// }
// }
// }
// //计算保单币种金额 港币金额*保单币种->港币汇率 未实现
// //计算港币金额 原币种金额*原币种->港币 未实现
// //计算实际发放金额 港币金额*港币->发放币种汇率 未实现
// return item
// })
// }
// },
// { deep: true, immediate: true } // immediate: true 可以让初始值也计算一次
// )
</script>
<style scoped>
......
......@@ -980,19 +980,12 @@ const receivableReportTableColumns = ref([
{ prop: 'commissionDate', label: '入账年月(估)', sortable: true, width: '130' },
{
prop: 'commissionRatio',
label: '产品对应来佣率',
label: '保单来佣率',
sortable: true,
width: '120',
formatter: row => (row.commissionRatio || 0) + '%' || '-'
},
{
prop: 'hkdAmount',
label: '预估入账金额HKD',
sortable: true,
width: '120',
formatter: row => formatCurrency(row.hkdAmount || 0)
},
{
prop: 'paidRatio',
label: '已入账比例',
sortable: true,
......@@ -1000,25 +993,25 @@ const receivableReportTableColumns = ref([
formatter: row => (row.paidRatio || 0) + '%' || '-'
},
{
prop: 'paidAmount',
label: '已入账金额HKD',
prop: 'unpaidRatio',
label: '待入账比例',
sortable: true,
width: '120',
formatter: row => formatCurrency(row.paidAmount || 0)
formatter: row => (row.unpaidRatio || 0) + '%' || '-'
},
{
prop: 'unpaidRatio',
label: '待入账比例',
prop: 'paidAmount',
label: '已入账金额HKD',
sortable: true,
width: '120',
formatter: row => (row.unpaidRatio || 0) + '%' || '-'
formatter: row => formatCurrency(row.paidAmount || 0)
},
{
prop: 'unpaidAmount',
label: '待入账金额HKD',
prop: 'hkdAmount',
label: '待入账金额HKD(估)',
sortable: true,
width: '120',
formatter: row => formatCurrency(row.unpaidAmount || 0)
formatter: row => formatCurrency(row.hkdAmount || 0)
},
{ prop: 'exchangeRate', label: '结算汇率(估)', sortable: true, width: '120' },
{
......@@ -1029,6 +1022,20 @@ const receivableReportTableColumns = ref([
formatter: row => row.insuranceCompany || '-'
},
{
prop: 'productName',
label: '产品计划',
sortable: true,
width: '120',
formatter: row => row.productName || '-'
},
{
prop: 'premium',
label: '期交保费',
sortable: true,
width: '120',
formatter: row => formatCurrency(row.premium || 0)
},
{
prop: 'policyHolder',
label: '投保人',
sortable: true,
......@@ -1043,24 +1050,18 @@ const receivableReportTableColumns = ref([
formatter: row => row.policyHolderEn || '-'
},
{
prop: 'remark',
label: '备注',
width: '150',
formatter: row => row.remark || '-'
},
{
prop: 'productName',
label: '产品计划',
prop: 'insured',
label: '受保人',
sortable: true,
width: '120',
formatter: row => row.productName || '-'
formatter: row => row.insured || '-'
},
{
prop: 'premium',
label: '期交保费',
prop: 'insuredEn',
label: '受保人(英文)',
sortable: true,
width: '120',
formatter: row => formatCurrency(row.premium || 0)
formatter: row => row.insuredEn || '-'
},
{
prop: 'policyCurrency',
......@@ -1068,6 +1069,19 @@ const receivableReportTableColumns = ref([
sortable: true,
width: '120',
formatter: row => row.policyCurrency || '-'
},
// {
// prop: 'unpaidAmount',
// label: '待入账金额HKD',
// sortable: true,
// width: '120',
// formatter: row => formatCurrency(row.unpaidAmount || 0)
// },
{
prop: 'remark',
label: '备注',
width: '150',
formatter: row => row.remark || '-'
}
])
// 应收明细
......
......@@ -157,11 +157,13 @@ const route = useRoute()
const router = useRouter()
const activeName = ref()
const loading = ref(false)
console.log('userStore', userStore)
const processInfo = ref({
fnaNo: '--',
status: '未保存',
createTime: proxy.parseTime(new Date()),
creatorName: userStore.name
creatorName: userStore.realName
}) // 流程详情信息
const updateStatus = ref(false)
const dictTypeLists = ref([])
......@@ -399,9 +401,9 @@ function getProcessInfo(fnaBizId, changeTab, currentTab) {
getProcessDetail(fnaBizId).then(async res => {
if (res.code == 200) {
processInfo.value = res.data
if (!processInfo.value.creatorName) {
processInfo.value.creatorName = userStore.name
}
// if (!processInfo.value.creatorName) {
// processInfo.value.creatorName = userStore.realName
// }
tabsList.value.forEach(item => {
if (res.data[item.key] && item.status) {
item.status = '1'
......
......@@ -550,7 +550,7 @@ const affirmConfig = [
type: 'select',
prop: 'status',
label: '保单状态',
dictType: 'csf_policy_status_new',
dictType: 'csf_policy_follow_status_new',
visible: formData =>
(formData.remainingUnpaidAmount && Number(formData.remainingUnpaidAmount) < 0) ||
Number(formData.remainingUnpaidAmount) == 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment