|
|
@@ -104,7 +104,7 @@
|
|
|
|
|
|
<div
|
|
|
class="action-item"
|
|
|
- :class="{ disabled: !accountData.account_book_id || accountData.balance <= 0 }"
|
|
|
+ :class="{ disabled: !accountData.account_book_id || (accountData.balance ?? 0) <= 0 }"
|
|
|
>
|
|
|
<div class="action-icon">
|
|
|
<el-icon :size="32"><Money /></el-icon>
|
|
|
@@ -112,13 +112,13 @@
|
|
|
<div class="action-title">发起转账</div>
|
|
|
<div class="action-desc">
|
|
|
<template v-if="!accountData.account_book_id">需先开通专户</template>
|
|
|
- <template v-else-if="accountData.balance <= 0">余额不足</template>
|
|
|
+ <template v-else-if="(accountData.balance ?? 0) <= 0">余额不足</template>
|
|
|
<template v-else>立即转账</template>
|
|
|
</div>
|
|
|
<el-button
|
|
|
v-hasPerm="['module_payment:account:transfer']"
|
|
|
type="primary"
|
|
|
- :disabled="!accountData.account_book_id || accountData.balance <= 0"
|
|
|
+ :disabled="!accountData.account_book_id || (accountData.balance ?? 0) <= 0"
|
|
|
@click="$emit('goTab', 'transfer')"
|
|
|
>
|
|
|
去转账
|
|
|
@@ -157,8 +157,8 @@
|
|
|
<div class="stat-item">
|
|
|
<div class="stat-label">账户状态</div>
|
|
|
<div class="stat-value">
|
|
|
- <el-tag :type="getAccountStatusType(accountData.status)">
|
|
|
- {{ accountData.status || "未开通" }}
|
|
|
+ <el-tag :type="getAccountStatusType(accountData.status ?? '')">
|
|
|
+ {{ accountStatusText }}
|
|
|
</el-tag>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -278,7 +278,7 @@
|
|
|
import { useEnterpriseStore } from "@/store/modules/enterprise.store";
|
|
|
import AccountAPI from "@/api/module_payment/account";
|
|
|
import { Refresh, Document, Coin, Wallet, Money } from "@element-plus/icons-vue";
|
|
|
-import { ref, computed, onMounted } from "vue";
|
|
|
+import { ref, computed, watch } from "vue";
|
|
|
import en from "@/lang/package/en";
|
|
|
|
|
|
const props = defineProps<{
|
|
|
@@ -377,9 +377,10 @@ function getAuthorizeStatusType(status: string) {
|
|
|
|
|
|
function getAccountStatusType(status: string) {
|
|
|
const map: Record<string, any> = {
|
|
|
+ ACTIVE: "success",
|
|
|
+ FROZEN: "warning",
|
|
|
+ CLOSED: "danger",
|
|
|
ON: "success",
|
|
|
- // FROZEN: "warning",
|
|
|
- // CLOSED: "danger",
|
|
|
};
|
|
|
return map[status] || "info";
|
|
|
}
|
|
|
@@ -413,8 +414,8 @@ async function fetchAccountInfo() {
|
|
|
const account = res.data.data[0];
|
|
|
accountData.value = {
|
|
|
account_book_id: account.account_book_id,
|
|
|
- balance: Number(account.available_amount),
|
|
|
- status: account.enable_status,
|
|
|
+ balance: Number(account.balance ?? account.available_amount ?? 0),
|
|
|
+ status: account.status ?? account.enable_status,
|
|
|
scene: account.scene,
|
|
|
};
|
|
|
}
|
|
|
@@ -463,9 +464,13 @@ async function refresh() {
|
|
|
|
|
|
defineExpose({ refresh });
|
|
|
|
|
|
-// onMounted(() => {
|
|
|
-// fetchAccountInfo();
|
|
|
-// });
|
|
|
+// 监听 enterpriseId 变化自动拉取账户数据(immediate 确保初始化时也拉取)
|
|
|
+watch(currentEnterpriseId, (id) => {
|
|
|
+ if (id) {
|
|
|
+ fetchAccountInfo();
|
|
|
+ fetchTransferAmount();
|
|
|
+ }
|
|
|
+}, { immediate: true });
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|