From 27c8277d717b34b55f3ea967027b53b067f77df3 Mon Sep 17 00:00:00 2001
From: xiaoyi <908147524@qq.com>
Date: 星期四, 20 八月 2026 16:58:49 +0800
Subject: [PATCH] feat 功能变更
---
src/views/mes/pd/product/index.vue | 214 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 214 insertions(+), 0 deletions(-)
diff --git a/src/views/mes/pd/product/index.vue b/src/views/mes/pd/product/index.vue
new file mode 100644
index 0000000..bc25d7c
--- /dev/null
+++ b/src/views/mes/pd/product/index.vue
@@ -0,0 +1,214 @@
+<script lang="ts" setup>
+ import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+ import type { MesPdProductApi } from '#/api/mes/pd/product';
+
+ import { useVbenModal } from '@vben/common-ui';
+ import { $t } from '@vben/locales';
+ import { downloadFileFromBlobPart } from '@vben/utils';
+
+ import { message } from 'ant-design-vue';
+
+ import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
+ import {
+ deleteProduct,
+ exportProduct,
+ getProductPage,
+ submitProduct,
+ } from '#/api/mes/pd/product';
+
+ import { AuditStatus, useGridColumns, useGridFormSchema } from './data';
+ import Audit from './modules/audit.vue';
+ import Form from './modules/form.vue';
+
+ const [FormModal, formModalApi] = useVbenModal({
+ connectedComponent: Form,
+ destroyOnClose: true,
+ });
+ const [AuditModal, auditModalApi] = useVbenModal({
+ connectedComponent: Audit,
+ destroyOnClose: true,
+ });
+
+ /** 鍒锋柊琛ㄦ牸 */
+ function handleRefresh() {
+ gridApi.query();
+ }
+
+ /** 鏂板 */
+ function handleCreate() {
+ formModalApi.setData({ formType: 'create' }).open();
+ }
+
+ /** 鏌ョ湅 */
+ function handleDetail(row: MesPdProductApi.Product) {
+ formModalApi.setData({ id: row.id, formType: 'detail' }).open();
+ }
+
+ /** 缂栬緫 */
+ function handleEdit(row: MesPdProductApi.Product) {
+ formModalApi.setData({ id: row.id, formType: 'update' }).open();
+ }
+
+ /** 鍒犻櫎 */
+ async function handleDelete(row: MesPdProductApi.Product) {
+ const hideLoading = message.loading({
+ content: $t('ui.actionMessage.deleting', [row.code ?? '']),
+ duration: 0,
+ });
+ try {
+ await deleteProduct(row.id!);
+ message.success($t('ui.actionMessage.deleteSuccess', [row.code ?? '']));
+ handleRefresh();
+ } finally {
+ hideLoading();
+ }
+ }
+
+ /** 鎻愪氦瀹℃壒锛堟湭鎻愪氦/椹冲洖 鈫� 瀹℃壒涓級 */
+ async function handleSubmit(row: MesPdProductApi.Product) {
+ const hideLoading = message.loading({ content: '鎻愪氦瀹℃壒涓�...', duration: 0 });
+ try {
+ await submitProduct(row.id!);
+ message.success('鎻愪氦鎴愬姛');
+ handleRefresh();
+ } finally {
+ hideLoading();
+ }
+ }
+
+ /** 鎵撳紑瀹℃壒寮圭獥锛堥�氳繃/椹冲洖锛� */
+ function handleAudit(row: MesPdProductApi.Product, pass: boolean) {
+ auditModalApi.setData({ row, pass }).open();
+ }
+
+ /** 瀵煎嚭 */
+ async function handleExport() {
+ const data = await exportProduct(await gridApi.formApi.getValues());
+ downloadFileFromBlobPart({ fileName: '浜у搧妗f.xls', source: data });
+ }
+
+ const [Grid, gridApi] = useVbenVxeGrid({
+ formOptions: {
+ schema: useGridFormSchema(),
+ },
+ gridOptions: {
+ columns: useGridColumns(),
+ height: 'auto',
+ keepSource: true,
+ proxyConfig: {
+ ajax: {
+ query: async ({ page }, formValues) =>
+ await getProductPage({
+ pageNo: page.currentPage,
+ pageSize: page.pageSize,
+ ...formValues,
+ }),
+ },
+ },
+ rowConfig: {
+ keyField: 'id',
+ isHover: true,
+ },
+ toolbarConfig: {
+ refresh: true,
+ search: true,
+ },
+ } as VxeTableGridOptions<MesPdProductApi.Product>,
+ });
+</script>
+
+<template>
+ <Page auto-content-height>
+ <FormModal @success="handleRefresh" />
+ <AuditModal @success="handleRefresh" />
+ <Grid table-title="浜у搧妗f鍒楄〃">
+ <template #toolbar-tools>
+ <TableAction
+ :actions="[
+ {
+ label: $t('ui.actionTitle.create', ['浜у搧妗f']),
+ type: 'primary',
+ icon: ACTION_ICON.ADD,
+ auth: ['mes:pd-product:create'],
+ onClick: handleCreate,
+ },
+ {
+ label: $t('ui.actionTitle.export'),
+ type: 'primary',
+ icon: ACTION_ICON.DOWNLOAD,
+ auth: ['mes:pd-product:export'],
+ onClick: handleExport,
+ },
+ ]"
+ />
+ </template>
+ <template #actions="{ row }">
+ <TableAction
+ :actions="[
+ {
+ label: '鎻愪氦瀹℃壒',
+ type: 'link',
+ icon: ACTION_ICON.AUDIT,
+ auth: ['mes:pd-product:submit'],
+ ifShow:
+ row.auditStatus === AuditStatus.DRAFT ||
+ row.auditStatus === AuditStatus.REJECT,
+ popConfirm: {
+ title: '纭鎻愪氦瀹℃壒锛�',
+ confirm: handleSubmit.bind(null, row),
+ },
+ },
+ {
+ label: '瀹℃牳閫氳繃',
+ type: 'link',
+ icon: ACTION_ICON.AUDIT,
+ auth: ['mes:pd-product:audit'],
+ ifShow: row.auditStatus === AuditStatus.PROCESS,
+ onClick: handleAudit.bind(null, row, true),
+ },
+ {
+ label: '瀹℃牳椹冲洖',
+ type: 'link',
+ danger: true,
+ icon: ACTION_ICON.AUDIT,
+ auth: ['mes:pd-product:audit'],
+ ifShow: row.auditStatus === AuditStatus.PROCESS,
+ onClick: handleAudit.bind(null, row, false),
+ },
+ {
+ label: $t('common.edit'),
+ type: 'link',
+ icon: ACTION_ICON.EDIT,
+ auth: ['mes:pd-product:update'],
+ ifShow:
+ row.auditStatus === AuditStatus.DRAFT ||
+ row.auditStatus === AuditStatus.REJECT,
+ onClick: handleEdit.bind(null, row),
+ },
+ {
+ label: $t('common.delete'),
+ type: 'link',
+ danger: true,
+ icon: ACTION_ICON.DELETE,
+ auth: ['mes:pd-product:delete'],
+ ifShow:
+ row.auditStatus === AuditStatus.DRAFT ||
+ row.auditStatus === AuditStatus.REJECT,
+ popConfirm: {
+ title: $t('ui.actionMessage.deleteConfirm', [row.code ?? '']),
+ confirm: handleDelete.bind(null, row),
+ },
+ },
+ {
+ label: $t('common.detail'),
+ type: 'link',
+ icon: ACTION_ICON.VIEW,
+ auth: ['mes:pd-product:query'],
+ onClick: handleDetail.bind(null, row),
+ },
+ ]"
+ />
+ </template>
+ </Grid>
+ </Page>
+</template>
--
Gitblit v1.9.3