| | |
| | | |
| | | import { ref } from 'vue'; |
| | | |
| | | import { Page, useVbenModal } from '../../../../packages/effects/common-ui/src'; |
| | | import { confirm, Page, useVbenModal } from '../../../../packages/effects/common-ui/src'; |
| | | import { downloadFileFromBlobPart, isEmpty } from '../../../../packages/utils/src'; |
| | | |
| | | import { message, Tag } from 'ant-design-vue'; |
| | | |
| | | import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; |
| | | import { |
| | | approvePurchaseRequest, |
| | | convertToPurchaseOrder, |
| | | deletePurchaseRequest, |
| | | exportPurchaseRequest, |
| | | getApproveProcessList, |
| | | getPurchaseRequestPage, |
| | | submitPurchaseRequest, |
| | | } from '#/api/erp/purchase/request'; |
| | | import { $t } from '#/locales'; |
| | | |
| | | import { useGridColumns, useGridFormSchema, PURCHASE_REQUEST_STATUS } from './data'; |
| | | import { useGridColumns, useGridFormSchema } from './data'; |
| | | import Form from './modules/form.vue'; |
| | | import OrderForm from './modules/order-form.vue'; |
| | | import ProcessSelectModal from './modules/process-select-modal.vue'; |
| | | |
| | | /** ERP 采购申请列表 */ |
| | | defineOptions({ name: 'ErpPurchaseRequest' }); |
| | | |
| | | const [FormModal, formModalApi] = useVbenModal({ |
| | | connectedComponent: Form, |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | | const [OrderFormModal, orderFormModalApi] = useVbenModal({ |
| | | connectedComponent: OrderForm, |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | | const [ProcessModal, processModalApi] = useVbenModal({ |
| | | connectedComponent: ProcessSelectModal, |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /** 审批采购申请 */ |
| | | async function handleApprove(row: ErpPurchaseRequestApi.PurchaseRequest, status: number) { |
| | | /** 提交审批 - 先获取流程列表 */ |
| | | async function handleSubmit(row: ErpPurchaseRequestApi.PurchaseRequest) { |
| | | const hideLoading = message.loading({ |
| | | content: `确定${status === 1 ? '审批通过' : '审批拒绝'}该申请吗?`, |
| | | content: '获取审批流程...', |
| | | duration: 0, |
| | | }); |
| | | try { |
| | | await approvePurchaseRequest({ id: row.id!, status, remark: '' }); |
| | | message.success(`${status === 1 ? '审批通过' : '审批拒绝'}成功`); |
| | | handleRefresh(); |
| | | } finally { |
| | | const processList = await getApproveProcessList(row.id!); |
| | | hideLoading(); |
| | | if (!processList || processList.length === 0) { |
| | | message.warning('暂无可用审批流程,请先配置 BPM 流程'); |
| | | return; |
| | | } |
| | | // 打开流程选择弹窗 |
| | | processModalApi.setData({ id: row.id, processList }).open(); |
| | | } catch { |
| | | hideLoading(); |
| | | } |
| | | } |
| | | |
| | | /** 转为采购订单 */ |
| | | async function handleConvert(row: ErpPurchaseRequestApi.PurchaseRequest) { |
| | | const hideLoading = message.loading({ |
| | | content: '正在转为采购订单...', |
| | | duration: 0, |
| | | }); |
| | | try { |
| | | await convertToPurchaseOrder(row.id!); |
| | | message.success('已成功转为采购订单'); |
| | | handleRefresh(); |
| | | } finally { |
| | | hideLoading(); |
| | | } |
| | | /** 生成采购订单 */ |
| | | function handleGenerateOrder(row: ErpPurchaseRequestApi.PurchaseRequest) { |
| | | orderFormModalApi.setData({ id: row.id, supplierId: row.supplierId }).open(); |
| | | } |
| | | |
| | | const checkedIds = ref<number[]>([]); |
| | |
| | | <template> |
| | | <Page auto-content-height> |
| | | <FormModal @success="handleRefresh" /> |
| | | <OrderFormModal @success="handleRefresh" /> |
| | | <ProcessModal @success="handleRefresh" /> |
| | | <Grid table-title="采购申请列表"> |
| | | <template #toolbar-tools> |
| | | <TableAction |
| | |
| | | /> |
| | | </template> |
| | | <template #status="{ row }"> |
| | | <Tag v-if="row.status === 0" color="warning">待审批</Tag> |
| | | <Tag v-else-if="row.status === 1" color="success">已审批</Tag> |
| | | <Tag v-else-if="row.status === 2" color="error">已拒绝</Tag> |
| | | <Tag v-else-if="row.status === 3" color="default">已转订单</Tag> |
| | | <Tag v-if="row.status === 0" color="default">未提交</Tag> |
| | | <Tag v-else-if="row.status === 10" color="processing">审批中</Tag> |
| | | <Tag v-else-if="row.status === 20" color="success">审核通过</Tag> |
| | | <Tag v-else-if="row.status === 30" color="error">审核不通过</Tag> |
| | | <Tag v-else-if="row.status === 40" color="warning">已取消</Tag> |
| | | </template> |
| | | <template #actions="{ row }"> |
| | | <TableAction |
| | |
| | | onClick: handleEdit.bind(null, row), |
| | | }, |
| | | { |
| | | label: '审批通过', |
| | | label: '提交', |
| | | type: 'link', |
| | | auth: ['erp:purchase-request:approve'], |
| | | ifShow: () => row.status === 0, |
| | | popConfirm: { |
| | | title: '确认审批通过该申请吗?', |
| | | confirm: handleApprove.bind(null, row, 1), |
| | | }, |
| | | ifShow: () => row.status === 0 || row.status === 30, |
| | | onClick: handleSubmit.bind(null, row), |
| | | }, |
| | | { |
| | | label: '审批拒绝', |
| | | label: '生成订单', |
| | | type: 'link', |
| | | danger: true, |
| | | auth: ['erp:purchase-request:approve'], |
| | | ifShow: () => row.status === 0, |
| | | popConfirm: { |
| | | title: '确认审批拒绝该申请吗?', |
| | | confirm: handleApprove.bind(null, row, 2), |
| | | }, |
| | | }, |
| | | { |
| | | label: '转订单', |
| | | type: 'link', |
| | | auth: ['erp:purchase-request:convert'], |
| | | ifShow: () => row.status === 1, |
| | | popConfirm: { |
| | | title: '确认转为采购订单吗?', |
| | | confirm: handleConvert.bind(null, row), |
| | | }, |
| | | auth: ['erp:purchase-request:generate-order'], |
| | | ifShow: () => row.status === 20 && !row.orderId, |
| | | onClick: handleGenerateOrder.bind(null, row), |
| | | }, |
| | | { |
| | | label: $t('common.delete'), |
| | |
| | | </template> |
| | | </Grid> |
| | | </Page> |
| | | </template> |
| | | </template> |