优化积分修改时的备注写入适配多语言
This commit is contained in:
@@ -92,7 +92,7 @@ interface UserAssetInfo {
|
||||
}
|
||||
|
||||
const config = useConfig()
|
||||
const { t } = useI18n()
|
||||
const { t, locale } = useI18n()
|
||||
const injectedBaTable = inject<baTableClass>('baTable')
|
||||
if (!injectedBaTable) {
|
||||
throw new Error('baTable is not provided')
|
||||
@@ -132,17 +132,24 @@ const rules: Partial<Record<string, FormItemRule[]>> = reactive({
|
||||
],
|
||||
})
|
||||
|
||||
const syncMemoToForm = (scoreValue: number) => {
|
||||
let memoText = ''
|
||||
if (scoreValue > 0) {
|
||||
memoText = t('mall.pointsLog.admin_add_memo', { value: Math.abs(scoreValue) })
|
||||
} else if (scoreValue < 0) {
|
||||
memoText = t('mall.pointsLog.admin_deduct_memo', { value: Math.abs(scoreValue) })
|
||||
}
|
||||
state.memo = memoText
|
||||
if (baTable.form.items) {
|
||||
baTable.form.items.memo = memoText
|
||||
}
|
||||
}
|
||||
|
||||
const changeScore = (value: number | undefined) => {
|
||||
const scoreValue = value ?? 0
|
||||
const availablePoints = state.userAsset.available_points ?? 0
|
||||
state.after = availablePoints + scoreValue
|
||||
if (scoreValue > 0) {
|
||||
state.memo = t('mall.pointsLog.admin_add_memo', { value: Math.abs(scoreValue) })
|
||||
} else if (scoreValue < 0) {
|
||||
state.memo = t('mall.pointsLog.admin_deduct_memo', { value: Math.abs(scoreValue) })
|
||||
} else {
|
||||
state.memo = ''
|
||||
}
|
||||
syncMemoToForm(scoreValue)
|
||||
}
|
||||
|
||||
const getUserAssetInfo = () => {
|
||||
@@ -151,6 +158,9 @@ const getUserAssetInfo = () => {
|
||||
state.userAsset = {}
|
||||
state.after = 0
|
||||
state.memo = ''
|
||||
if (baTable.form.items) {
|
||||
baTable.form.items.memo = ''
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -168,6 +178,12 @@ watch(
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
watch(locale, () => {
|
||||
if (baTable.form.operate === 'Add') {
|
||||
changeScore(baTable.form.items?.score_value as number | undefined)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
|
||||
Reference in New Issue
Block a user