Bladeren bron

feat: 资金专户转账页新增发起提现按钮和弹窗

alphah 1 week geleden
bovenliggende
commit
c308abb68c

BIN
frontend/dist.zip


+ 13 - 0
frontend/src/api/module_payment/account.ts

@@ -153,6 +153,19 @@ export const AccountAPI = {
       method: "get",
     });
   },
+
+  withdraw(data: {
+    enterprise_id: string;
+    account_book_id: string;
+    amount: number;
+    remark?: string;
+  }) {
+    return request<ApiResponse>({
+      url: `${API_PATH}/withdraw`,
+      method: "post",
+      data,
+    });
+  },
 };
 
 export interface ReceiptQueryOutSchema {

+ 77 - 0
frontend/src/views/module_payment/account/index.vue

@@ -254,6 +254,14 @@
                   :disabled="!accountInfo.account_book_id || accountInfo.balance <= 0" @click="handleTransfer">
                   发起转账
                 </el-button>
+                <el-button
+                  v-hasPerm="['module_payment:account:withdraw']"
+                  type="warning"
+                  :disabled="!accountInfo.account_book_id || accountInfo.balance <= 0"
+                  @click="withdrawVisible = true"
+                >
+                  发起提现
+                </el-button>
                 <el-button @click="handleTransferReset">重置</el-button>
                 <el-button v-hasPerm="['module_payment:account:transfer']" type="primary" @click="openBatchTransferDialog">
                     批量转账
@@ -527,6 +535,33 @@
       </template>
     </el-dialog>
 
+    <!-- 提现弹窗 -->
+    <el-dialog v-model="withdrawVisible" title="发起提现" width="500px" destroy-on-close>
+      <el-form ref="withdrawFormRef" :model="withdrawForm" :rules="withdrawRules" label-width="100px">
+        <el-form-item label="当前余额">
+          <span style="font-weight: bold; color: #67c23a">¥{{ accountInfo.balance?.toFixed(2) ?? "0.00" }}</span>
+        </el-form-item>
+        <el-form-item label="提现金额" prop="amount">
+          <el-input-number
+            v-model="withdrawForm.amount"
+            :min="0.01"
+            :max="accountInfo.balance"
+            :precision="2"
+            :controls="false"
+            placeholder="请输入提现金额"
+            style="width: 100%"
+          />
+        </el-form-item>
+        <el-form-item label="提现原因" prop="remark">
+          <el-input v-model="withdrawForm.remark" placeholder="选填,默认'提现'" maxlength="50" show-word-limit />
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <el-button @click="withdrawVisible = false">取消</el-button>
+        <el-button type="primary" :loading="withdrawLoading" @click="handleWithdraw">确认提现</el-button>
+      </template>
+    </el-dialog>
+
     <!-- 下载报表弹窗 -->
     <el-dialog title="下载转账报表" v-model="showDownloadMenu" width="500px" :close-on-click-modal="false">
       <div class="download-options">
@@ -1243,6 +1278,48 @@ function handleTransferReset() {
   };
 }
 
+// ===== 提现 =====
+const withdrawVisible = ref(false);
+const withdrawLoading = ref(false);
+const withdrawFormRef = ref<FormInstance>();
+const withdrawForm = reactive({ amount: 0, remark: "" });
+
+const withdrawRules: FormRules = {
+  amount: [
+    { required: true, message: "请输入提现金额", trigger: "blur" },
+    {
+      validator: (_rule, value, callback) => {
+        if (value <= 0) callback(new Error("提现金额必须大于0"));
+        else if (value > accountInfo.value.balance) callback(new Error("提现金额不能超过账户余额"));
+        else callback();
+      },
+      trigger: "blur",
+    },
+  ],
+};
+
+async function handleWithdraw() {
+  const valid = await withdrawFormRef.value?.validate().catch(() => false);
+  if (!valid) return;
+  withdrawLoading.value = true;
+  try {
+    await AccountAPI.withdraw({
+      enterprise_id: enterpriseStore.getCurrentEnterprise?.enterprise_id || "",
+      account_book_id: accountInfo.value.account_book_id,
+      amount: withdrawForm.amount,
+      remark: withdrawForm.remark || "提现",
+    });
+    ElMessage.success("提现成功");
+    withdrawVisible.value = false;
+    withdrawForm.amount = 0;
+    withdrawForm.remark = "";
+    overviewRef.value?.refresh();
+    handleTransferSearch();
+  } finally {
+    withdrawLoading.value = false;
+  }
+}
+
 async function handleTransferSearch() {
   transferPage.page_no = 1;
   await fetchTransferList();