Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-csf-front
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yuzhenWang
yd-csf-front
Commits
dbb8c004
Commit
dbb8c004
authored
Apr 08, 2026
by
yuzhenWang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改金额实时变化
parent
a06d41d7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
10 deletions
+68
-10
package.json
+1
-0
src/views/financialCenter/financialSalary.vue
+67
-10
No files found.
package.json
View file @
dbb8c004
...
...
@@ -33,6 +33,7 @@
"
js-cookie
"
:
"3.0.5"
,
"
jsencrypt
"
:
"3.3.2"
,
"
jszip
"
:
"^3.10.1"
,
"
lodash
"
:
"^4.18.1"
,
"
nprogress
"
:
"0.2.0"
,
"
p-limit
"
:
"^7.3.0"
,
"
pinia
"
:
"3.0.2"
,
...
...
src/views/financialCenter/financialSalary.vue
View file @
dbb8c004
...
...
@@ -179,13 +179,15 @@
</el-table-column>
<el-table-column
label=
"原币种金额"
prop=
"fromAmount"
width=
"150"
>
<
template
#
default=
"scope"
>
<!-- @input="val => (scope.row.fromAmount = amountInput.filterInput(val, 4))"
@blur="billInputBlur('fromAmount', scope.row)" -->
<el-input
v-model=
"scope.row.fromAmount"
placeholder=
"请输入"
clearable
@
clear=
"clearInput('fromAmount', scope.row)"
@
input=
"val =>
(scope.row.fromAmount = amountInput.filterInput(val, 4)
)"
@
blur=
"
billInputBlur('fromAmount',
scope.row)"
@
input=
"val =>
handleFromAmountInput(val, scope.row
)"
@
blur=
"
handleFromAmountBlur(
scope.row)"
:formatter=
"value => inputThousands(value)"
:parser=
"value => value.replace(/\$\s?|(,*)/g, '')"
/>
...
...
@@ -210,6 +212,8 @@
</el-select>
</
template
>
</el-table-column>
<!-- @blur="billInputBlur('exchangeRate', scope.row)"
@input="val => (scope.row.exchangeRate = amountInput.filterInput(val, 4))" -->
<el-table-column
label=
"汇率(%)"
prop=
"exchangeRate"
width=
"150"
>
<
template
#
default=
"scope"
>
<el-input
...
...
@@ -217,8 +221,8 @@
placeholder=
"请输入"
clearable
@
clear=
"clearInput('exchangeRate', scope.row)"
@
blur=
"billInputBlur('exchangeRate'
, scope.row)"
@
input=
"val => (scope.row.exchangeRate = amountInput.filterInput(val, 4)
)"
@
input=
"val => handleExchangeRateInput(val
, scope.row)"
@
blur=
"handleExchangeRateBlur(scope.row
)"
/>
</
template
>
</el-table-column>
...
...
@@ -228,6 +232,7 @@
v-model=
"scope.row.toAmount"
placeholder=
"请输入"
clearable
:disabled=
"true"
@
input=
"val => (scope.row.toAmount = amountInput.filterInput(val, 4))"
:formatter=
"value => inputThousands(value)"
:parser=
"value => value.replace(/\$\s?|(,*)/g, '')"
...
...
@@ -312,6 +317,7 @@ import { generateId } from '@/utils/common'
import
{
ElMessageBox
,
ElMessage
}
from
'element-plus'
import
SearchForm
from
'@/components/SearchForm/SearchForm.vue'
import
{
usePositiveDecimal
}
from
'@/utils/usePositiveDecimal'
import
{
debounce
}
from
'lodash-es'
const
amountInput
=
usePositiveDecimal
(
4
)
// 默认2位小数
const
{
proxy
}
=
getCurrentInstance
()
...
...
@@ -386,7 +392,10 @@ let billStatistic = ref({ beSplitAmount: 0, beSplitCurrency: 0 })
let
saleInfo
=
ref
({})
let
addBillLoading
=
ref
(
false
)
let
submitBillLoading
=
ref
(
false
)
// 存储每行的防抖函数(原币种金额)
const
debounceChangeRateMap
=
new
WeakMap
()
// 存储每行的防抖函数(汇率)
const
debounceChangeToAmountMap
=
new
WeakMap
()
// 表格操作菜单
const
dropdownItems
=
[
{
label
:
'拆分出账'
,
value
:
'splitBilling'
}
...
...
@@ -402,6 +411,51 @@ const clearInput = (key, row) => {
row
.
toAmount
=
'0.00'
}
}
const
getDebouncedChangeRate
=
row
=>
{
if
(
!
debounceChangeRateMap
.
has
(
row
))
{
const
debounced
=
debounce
(
r
=>
{
changeRate
(
r
)
},
500
)
debounceChangeRateMap
.
set
(
row
,
debounced
)
}
return
debounceChangeRateMap
.
get
(
row
)
}
const
getDebouncedChangeToAmount
=
row
=>
{
if
(
!
debounceChangeToAmountMap
.
has
(
row
))
{
const
debounced
=
debounce
(
r
=>
{
changeToAmount
(
r
)
},
500
)
debounceChangeToAmountMap
.
set
(
row
,
debounced
)
}
return
debounceChangeToAmountMap
.
get
(
row
)
}
// 原币种金额输入处理
const
handleFromAmountInput
=
(
val
,
row
)
=>
{
row
.
fromAmount
=
amountInput
.
filterInput
(
val
,
4
)
getDebouncedChangeRate
(
row
)(
row
)
}
// 原币种金额失焦处理
const
handleFromAmountBlur
=
row
=>
{
const
debounced
=
debounceChangeRateMap
.
get
(
row
)
if
(
debounced
)
debounced
.
cancel
()
changeRate
(
row
)
}
// 汇率输入处理
const
handleExchangeRateInput
=
(
val
,
row
)
=>
{
row
.
exchangeRate
=
amountInput
.
filterInput
(
val
,
4
)
getDebouncedChangeToAmount
(
row
)(
row
)
}
// 汇率失焦处理
const
handleExchangeRateBlur
=
row
=>
{
const
debounced
=
debounceChangeToAmountMap
.
get
(
row
)
if
(
debounced
)
debounced
.
cancel
()
changeToAmount
(
row
)
}
const
billInputBlur
=
(
type
,
row
)
=>
{
if
(
type
==
'fromAmount'
)
{
if
(
row
.
fromAmount
)
{
...
...
@@ -414,7 +468,7 @@ const billInputBlur = (type, row) => {
}
}
// 改变汇率
const
changeRate
=
async
row
=>
{
const
changeRate
=
async
(
row
,
type
)
=>
{
try
{
if
(
row
.
toCurrency
&&
row
.
fromAmount
)
{
const
params
=
{
...
...
@@ -426,9 +480,12 @@ const changeRate = async row => {
const
response
=
await
billSplitRate
(
params
)
if
(
response
.
data
)
{
row
.
exchangeRate
=
response
.
data
.
exchangeRate
?
(
response
.
data
.
exchangeRate
*
100
).
toFixed
(
4
)
:
''
if
(
type
==
'toCurrency'
)
{
row
.
exchangeRate
=
response
.
data
.
exchangeRate
?
(
response
.
data
.
exchangeRate
*
100
).
toFixed
(
4
)
:
''
}
row
.
toAmount
=
Number
(
response
.
data
.
convertedAmount
).
toFixed
(
4
)
}
}
else
{
...
...
@@ -480,7 +537,7 @@ const handleBillConfirm = async () => {
}
const
changeToCurrency
=
row
=>
{
if
(
row
.
toCurrency
)
{
changeRate
(
row
)
changeRate
(
row
,
'toCurrency'
)
}
else
{
row
.
exchangeRate
=
''
row
.
toAmount
=
''
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment