liu
9 天以前 749cb2f4ad815c5a68c19fe961d5ca2149a84dd4
src/views/erp/finance/payment/index.vue
@@ -2,9 +2,10 @@
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { ErpFinancePaymentApi } from '#/api/erp/finance/payment';
import { ref } from 'vue';
import { onMounted, ref } from 'vue';
import { Page, useVbenModal } from '@vben/common-ui';
import { useUserStore } from '@vben/stores';
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
import { message } from 'ant-design-vue';
@@ -13,25 +14,56 @@
import {
  deleteFinancePayment,
  exportFinancePayment,
  getFinancePaymentApproverUserIds,
  getFinancePaymentPage,
  updateFinancePaymentStatus,
  submitFinancePayment,
} from '#/api/erp/finance/payment';
import { $t } from '#/locales';
import { useGridColumns, useGridFormSchema } from './data';
import AuditModal from './modules/audit-modal.vue';
import Form from './modules/form.vue';
/** ERP 付款单列表 */
defineOptions({ name: 'ErpFinancePayment' });
const userStore = useUserStore();
/** 当前业务类型的审批人编号集合,用于判断是否展示审核按钮 */
const approverIds = ref<number[]>([]);
/** 当前登录用户编号 */
const currentUserId = userStore.userInfo?.id;
const [FormModal, formModalApi] = useVbenModal({
  connectedComponent: Form,
  destroyOnClose: true,
});
/** 刷新表格 */
const [AuditModalComp, auditModalApi] = useVbenModal({
  connectedComponent: AuditModal,
  destroyOnClose: true,
});
/** 刷新表格、审批人集合 */
function handleRefresh() {
  gridApi.query();
  loadApproverIds();
}
/** 加载当前业务类型的审批人编号集合 */
async function loadApproverIds() {
  try {
    approverIds.value = (await getFinancePaymentApproverUserIds()) ?? [];
  } catch {
    approverIds.value = [];
  }
}
/** 当前用户是否为该业务类型的审批人,且单据处于审批中 */
function canAudit(row: ErpFinancePaymentApi.FinancePayment) {
  return (
    row.status === 15 && approverIds.value.includes(currentUserId as number)
  );
}
/** 导出表格 */
@@ -65,22 +97,43 @@
  }
}
/** 审批/反审批操作 */
async function handleUpdateStatus(
  row: ErpFinancePaymentApi.FinancePayment,
  status: number,
) {
/** 提交审核 - 后端按审批配置校验审批人,无需前端选择流程 */
async function handleSubmit(row: ErpFinancePaymentApi.FinancePayment) {
  const hideLoading = message.loading({
    content: `确定${status === 20 ? '审批' : '反审批'}该付款单吗?`,
    content: '正在提交审核...',
    duration: 0,
  });
  try {
    await updateFinancePaymentStatus(row.id!, status);
    message.success(`${status === 20 ? '审批' : '反审批'}成功`);
    await submitFinancePayment(row.id!);
    message.success('提交成功,等待审批人审核');
    handleRefresh();
  } finally {
    hideLoading();
  }
}
/** 审核 - 通过 / 不通过 */
function handleAudit(row: ErpFinancePaymentApi.FinancePayment, pass: boolean) {
  auditModalApi.setData({ pass, row }).open();
}
/** 查看审批记录 - 轻量级审批不再跳转 BPM 流程详情 */
function handleViewProcess(row: ErpFinancePaymentApi.FinancePayment) {
  const parts: string[] = [];
  if (row.reviewerName) {
    parts.push(`审核人:${row.reviewerName}`);
  }
  if (row.reviewTime) {
    parts.push(`审核时间:${row.reviewTime}`);
  }
  if (row.reviewRemark) {
    parts.push(`审核意见:${row.reviewRemark}`);
  }
  if (parts.length === 0) {
    message.info('该付款单暂无审核记录');
    return;
  }
  message.info(parts.join(' '));
}
const checkedIds = ref<number[]>([]);
@@ -130,10 +183,15 @@
    checkboxChange: handleRowCheckboxChange,
  },
});
onMounted(() => {
  loadApproverIds();
});
</script>
<template>
  <Page auto-content-height><FormModal @success="handleRefresh" />
    <AuditModalComp @success="handleRefresh" />
    <Grid table-title="付款单列表">
      <template #toolbar-tools>
        <TableAction
@@ -189,22 +247,43 @@
              type: 'link',
              icon: ACTION_ICON.EDIT,
              auth: ['erp:finance-payment:update'],
              ifShow: () => row.status !== 20,
              ifShow: () => row.status !== 20 && row.status !== 15,
              onClick: handleEdit.bind(null, row),
            },
            {
              label: row.status === 10 ? '审批' : '反审批',
              label: '提交审核',
              type: 'link',
              icon: ACTION_ICON.AUDIT,
              auth: ['erp:finance-payment:update-status'],
              popConfirm: {
                title: `确认${row.status === 10 ? '审批' : '反审批'}${row.no}吗?`,
                confirm: handleUpdateStatus.bind(
                  null,
                  row,
                  row.status === 10 ? 20 : 10,
                ),
              },
              auth: ['erp:finance-payment:update'],
              // 未审核(含审核不通过退回)均可提交,退回后需修改再重新提交
              ifShow: () => row.status === 10,
              onClick: handleSubmit.bind(null, row),
            },
            {
              label: '审核',
              type: 'link',
              icon: ACTION_ICON.AUDIT,
              auth: ['erp:finance-payment:audit'],
              // 仅「审批中 + 当前登录用户是审批人」才显示,其他人看不到该按钮
              ifShow: canAudit(row),
              onClick: handleAudit.bind(null, row, true),
            },
            {
              label: '审核不通过',
              type: 'link',
              danger: true,
              icon: ACTION_ICON.AUDIT,
              auth: ['erp:finance-payment:audit'],
              ifShow: canAudit(row),
              onClick: handleAudit.bind(null, row, false),
            },
            {
              label: '查看审批',
              type: 'link',
              icon: ACTION_ICON.VIEW,
              auth: ['erp:finance-payment:query'],
              ifShow: () => row.status === 20 || !!row.reviewRemark,
              onClick: handleViewProcess.bind(null, row),
            },
            {
              label: $t('common.delete'),
@@ -212,6 +291,7 @@
              danger: true,
              icon: ACTION_ICON.DELETE,
              auth: ['erp:finance-payment:delete'],
              ifShow: () => row.status !== 15,
              popConfirm: {
                title: $t('ui.actionMessage.deleteConfirm', [row.no]),
                confirm: handleDelete.bind(null, [row.id!]),