Просмотр исходного кода

fix: 手工发放弹窗嵌入制度详情页+自动发放不显示按钮

- QuotaList: 仅manual模式显示手工发放按钮,弹窗直接嵌入
- InstitutionDetail: 传递grantMode给QuotaList
- 移除router.push导航(避免路由未配置导致404)
alphah 2 недель назад
Родитель
Сommit
98c7294910

BIN
frontend/dist.zip


+ 6 - 1
frontend/src/views/module_payment/institution/components/InstitutionDetail.vue

@@ -63,7 +63,12 @@
       </el-tab-pane>
 
       <el-tab-pane label="额度管理" name="quota">
-        <QuotaList :institution-id="props.institutionId" readonly />
+        <QuotaList
+          :institution-id="props.institutionId"
+          :grant-mode="detailData.grant_mode || 'period'"
+          :enterprise-id="detailData.enterprise_id"
+          readonly
+        />
       </el-tab-pane>
     </el-tabs>
   </div>

+ 46 - 48
frontend/src/views/module_payment/institution/components/QuotaList.vue

@@ -1,18 +1,7 @@
 <template>
   <div class="quota-list">
-    <div class="quota-list__toolbar" style="display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px;">
-      <el-button
-        type="primary"
-        size="small"
-        @click="goToQuotaPage('quota')"
-      >
-        额度管理
-      </el-button>
-      <el-button
-        type="success"
-        size="small"
-        @click="goToQuotaPage('batch')"
-      >
+    <div v-if="grantMode === 'manual'" class="quota-list__toolbar" style="display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px;">
+      <el-button type="success" size="small" @click="showBatchDialog = true">
         手工发放
       </el-button>
     </div>
@@ -32,19 +21,19 @@
           {{ scope.row.employee_id || "-" }}
         </template>
       </el-table-column>
-      <el-table-column prop="total_amount" label="额度类型" width="90">
+      <el-table-column prop="quota_type" label="额度类型" width="90">
         <template #default="scope">
-          {{ scope.row.total_amount ? '余额' : '额度' }}
+          {{ formatQuotaType(scope.row.quota_type) }}
         </template>
       </el-table-column>
       <el-table-column prop="total_amount" label="总金额" width="100" align="right">
         <template #default="scope">
-          {{ scope.row.total_amount ? `¥${scope.row.total_amount}` : "-" }}
+          {{ scope.row.total_amount ? `¥${Number(scope.row.total_amount).toFixed(2)}` : "-" }}
         </template>
       </el-table-column>
       <el-table-column prop="available_amount" label="可用金额" width="100" align="right">
         <template #default="scope">
-          {{ scope.row.available_amount ? `¥${scope.row.available_amount}` : "-" }}
+          {{ scope.row.available_amount ? `¥${Number(scope.row.available_amount).toFixed(2)}` : "-" }}
         </template>
       </el-table-column>
       <el-table-column prop="status" label="状态" width="90">
@@ -57,19 +46,12 @@
       <el-table-column prop="created_time" label="创建时间" width="160" />
       <el-table-column v-if="!readonly" label="操作" width="120" align="center" fixed="right">
         <template #default="scope">
-          <el-button
-            v-hasPerm="['module_payment:quota:detail']"
-            type="text"
-            size="small"
-            @click="handleDetail(scope.row)"
-          >
-            详情
-          </el-button>
+          <el-button type="text" size="small" @click="handleDetail(scope.row)">详情</el-button>
         </template>
       </el-table-column>
     </el-table>
 
-    <div class="quota-list__pagination">
+    <div class="quota-list__pagination" style="margin-top: 16px; text-align: right;">
       <el-pagination
         v-model:current-page="pageNo"
         v-model:page-size="pageSize"
@@ -82,10 +64,16 @@
       />
     </div>
 
-    <QuotaDetailDialog
-      v-model:visible="detailVisible"
-      :quota-id="currentQuotaId"
-    />
+    <QuotaDetailDialog v-model:visible="detailVisible" :quota-id="currentQuotaId" />
+
+    <!-- 手工发放弹窗 -->
+    <el-dialog v-model="showBatchDialog" title="手工发放额度" width="800px" destroy-on-close>
+      <IssueBatchForm ref="batchFormRef" :enterprise-id="enterpriseId" :institution-id="institutionId" />
+      <template #footer>
+        <el-button type="primary" @click="handleBatchSubmit">确认发放</el-button>
+        <el-button @click="showBatchDialog = false">取消</el-button>
+      </template>
+    </el-dialog>
   </div>
 </template>
 
@@ -96,16 +84,19 @@ import QuotaAPI, {
   QUOTA_TYPE_OPTIONS,
 } from "@/api/module_payment/quota";
 import QuotaDetailDialog from "./QuotaDetailDialog.vue";
+import IssueBatchForm from "@/views/module_payment/quota/components/IssueBatchForm.vue";
 import { ElMessage } from "element-plus";
 import { onMounted, ref } from "vue";
-import { useRouter } from "vue-router";
+import { useEnterpriseStore } from "@/store/modules/enterprise.store";
 
 interface Props {
   institutionId: string;
   readonly?: boolean;
+  grantMode?: string;
+  enterpriseId?: string;
 }
 
-const props = withDefaults(defineProps<Props>(), { readonly: false });
+const props = withDefaults(defineProps<Props>(), { readonly: false, grantMode: "period" });
 
 const list = ref<any[]>([]);
 const total = ref(0);
@@ -115,17 +106,9 @@ const loading = ref(false);
 
 const detailVisible = ref(false);
 const currentQuotaId = ref("");
-const router = useRouter();
 
-function goToQuotaPage(tab: string) {
-  router.push({
-    path: "/module_payment/quota",
-    query: {
-      institution_id: props.institutionId,
-      tab: tab,
-    },
-  });
-}
+const showBatchDialog = ref(false);
+const batchFormRef = ref();
 
 async function fetchList() {
   if (!props.institutionId) return;
@@ -149,15 +132,32 @@ function formatQuotaType(type?: string) {
   return option ? option.label : type;
 }
 
-function handleCreate() {
-  ElMessage.info("请在独立的「额度管理」页面发放额度");
-}
-
 function handleDetail(row: any) {
   currentQuotaId.value = row.quota_id;
   detailVisible.value = true;
 }
 
+async function handleBatchSubmit() {
+  const formValid = await batchFormRef.value?.submitForm();
+  if (!formValid) return;
+
+  const formData = batchFormRef.value?.getFormData();
+  if (!formData) return;
+
+  try {
+    const res = await QuotaAPI.issueBatchCreate(formData);
+    const data = res?.data?.data || res;
+    ElMessage.success("发放成功");
+    showBatchDialog.value = false;
+    if (data?.issue_quota_check_failed_list?.length > 0) {
+      ElMessage.warning(`有 ${data.issue_quota_check_failed_list.length} 条校验失败`);
+    }
+    fetchList();
+  } catch (e: any) {
+    console.error("发放失败", e);
+  }
+}
+
 onMounted(() => {
   fetchList();
 });
@@ -169,7 +169,5 @@ onMounted(() => {
 }
 .quota-list__pagination {
   margin-top: 16px;
-  display: flex;
-  justify-content: flex-end;
 }
 </style>