src/views/erp/purchase/order/index.vue
@@ -2,12 +2,13 @@
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { ErpPurchaseOrderApi } from '#/api/erp/purchase/order';
import { ref } from 'vue';
import { onMounted, ref } from 'vue';
import { useRoute } from 'vue-router';
import { Page, useVbenModal } from '@vben/common-ui';
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
import { message } from 'ant-design-vue';
import { message, Tag } from 'ant-design-vue';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import {
@@ -15,7 +16,6 @@
  deletePurchaseOrder,
  exportPurchaseOrder,
  getPurchaseOrderPage,
  updatePurchaseOrderStatus,
} from '#/api/erp/purchase/order';
import { $t } from '#/locales';
@@ -24,6 +24,8 @@
/** ERP 采购订单列表 */
defineOptions({ name: 'ErpPurchaseOrder' });
const route = useRoute();
const [FormModal, formModalApi] = useVbenModal({
  connectedComponent: Form,
@@ -60,24 +62,6 @@
  try {
    await deletePurchaseOrder(ids);
    message.success($t('ui.actionMessage.deleteSuccess'));
    handleRefresh();
  } finally {
    hideLoading();
  }
}
/** 审批/反审批操作 */
async function handleUpdateStatus(
  row: ErpPurchaseOrderApi.PurchaseOrder,
  status: number,
) {
  const hideLoading = message.loading({
    content: `确定${status === 20 ? '审批' : '反审批'}该订单吗?`,
    duration: 0,
  });
  try {
    await updatePurchaseOrderStatus(row.id!, status);
    message.success(`${status === 20 ? '审批' : '反审批'}成功`);
    handleRefresh();
  } finally {
    hideLoading();
@@ -146,10 +130,18 @@
    checkboxChange: handleRowCheckboxChange,
  },
});
onMounted(() => {
  const id = route.query.id;
  if (id) {
    formModalApi.setData({ formType: 'detail', id: Number(id) }).open();
  }
});
</script>
<template>
  <Page auto-content-height><FormModal @success="handleRefresh" />
  <Page auto-content-height>
    <FormModal @success="handleRefresh" />
    <Grid table-title="采购订单列表">
      <template #toolbar-tools>
        <TableAction
@@ -183,6 +175,11 @@
          ]"
        />
      </template>
      <template #inStatus="{ row }">
        <Tag v-if="row.inStatus === 0" color="default">未入库</Tag>
        <Tag v-else-if="row.inStatus === 1" color="warning">部分入库</Tag>
        <Tag v-else-if="row.inStatus === 2" color="success">全部入库</Tag>
      </template>
      <template #actions="{ row }">
        <TableAction
          :actions="[
@@ -200,20 +197,6 @@
              auth: ['erp:purchase-order:update'],
              ifShow: () => row.status !== 20,
              onClick: handleEdit.bind(null, row),
            },
            {
              label: row.status === 10 ? '审批' : '反审批',
              type: 'link',
              icon: ACTION_ICON.AUDIT,
              auth: ['erp:purchase-order:update-status'],
              popConfirm: {
                title: `确认${row.status === 10 ? '审批' : '反审批'}${row.no}吗?`,
                confirm: handleUpdateStatus.bind(
                  null,
                  row,
                  row.status === 10 ? 20 : 10,
                ),
              },
            },
            {
              label: '确认收货',