From f10cf167372f2d8c4c0e14f42f361d7ab96d8347 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期五, 03 七月 2026 13:59:00 +0800
Subject: [PATCH] Merge branch 'dev_pro2.0' of http://114.132.189.42:9002/r/mom-pro2-before into dev_pro2.0
---
src/views/mes/pd/project/modules/document-list.vue | 165 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 165 insertions(+), 0 deletions(-)
diff --git a/src/views/mes/pd/project/modules/document-list.vue b/src/views/mes/pd/project/modules/document-list.vue
new file mode 100644
index 0000000..cfb129f
--- /dev/null
+++ b/src/views/mes/pd/project/modules/document-list.vue
@@ -0,0 +1,165 @@
+<script lang="ts" setup>
+import type { FormType } from '../data';
+
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+import type { MesPdDocumentApi } from '#/api/mes/pd/document';
+
+import { computed, watch } from 'vue';
+
+import { useVbenModal } from '#/packages/effects/common-ui/src';
+import { MesPdDocumentTypeEnum } from '#/packages/constants/src';
+
+import { message } from 'ant-design-vue';
+
+import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
+import {
+ deletePdDocument,
+ getPdDocumentPage,
+} from '#/api/mes/pd/document';
+import { $t } from '#/locales';
+
+import {
+ useMaterialListGridColumns,
+ useMaterialListGridFormSchema,
+} from '../data';
+import DocumentForm from './document-form.vue';
+
+const props = withDefaults(
+ defineProps<{
+ formType: FormType;
+ gridHeight?: number | string;
+ projectId: number;
+ tableTitle?: string;
+ version?: string;
+ }>(),
+ {
+ gridHeight: 360,
+ tableTitle: '璁捐璧勬枡',
+ },
+);
+
+const isEditable = computed(() =>
+ ['create', 'update'].includes(props.formType),
+);
+
+const [DocumentFormModal, documentFormModalApi] = useVbenModal({
+ connectedComponent: DocumentForm,
+ destroyOnClose: true,
+});
+
+function handleRefresh() {
+ gridApi.query();
+}
+
+function handleCreate() {
+ documentFormModalApi
+ .setData({
+ projectId: props.projectId,
+ documentType: MesPdDocumentTypeEnum.SCHEME,
+ })
+ .open();
+}
+
+function handleEdit(row: MesPdDocumentApi.Document) {
+ documentFormModalApi.setData({ id: row.id, projectId: props.projectId }).open();
+}
+
+async function handleDelete(row: MesPdDocumentApi.Document) {
+ const hideLoading = message.loading({
+ content: $t('ui.actionMessage.deleting', [row.name]),
+ duration: 0,
+ });
+ try {
+ await deletePdDocument(row.id!);
+ message.success($t('ui.actionMessage.deleteSuccess', [row.name]));
+ handleRefresh();
+ } finally {
+ hideLoading();
+ }
+}
+
+function handlePreview(row: MesPdDocumentApi.Document) {
+ if (row.fileUrl) {
+ window.open(row.fileUrl, '_blank');
+ }
+}
+
+const [Grid, gridApi] = useVbenVxeGrid({
+ formOptions: { schema: useMaterialListGridFormSchema() },
+ gridOptions: {
+ columns: useMaterialListGridColumns(),
+ height: props.gridHeight,
+ keepSource: true,
+ proxyConfig: {
+ ajax: {
+ query: async ({ page }, formValues) => {
+ return await getPdDocumentPage({
+ pageNo: page.currentPage,
+ pageSize: page.pageSize,
+ projectId: props.projectId,
+ version: props.version,
+ ...formValues,
+ });
+ },
+ },
+ },
+ rowConfig: { keyField: 'id', isHover: true },
+ toolbarConfig: { refresh: true, search: true },
+ } as VxeTableGridOptions<MesPdDocumentApi.Document>,
+});
+
+watch(
+ () => props.version,
+ () => {
+ gridApi.query();
+ },
+);
+</script>
+
+<template>
+ <DocumentFormModal @success="handleRefresh" />
+ <Grid :table-title="tableTitle">
+ <template v-if="isEditable" #toolbar-tools>
+ <TableAction
+ :actions="[
+ {
+ label: '涓婁紶闄勪欢',
+ type: 'primary',
+ icon: ACTION_ICON.ADD,
+ onClick: handleCreate,
+ },
+ ]"
+ />
+ </template>
+ <template #actions="{ row }">
+ <TableAction
+ :actions="[
+ {
+ label: '棰勮',
+ type: 'link',
+ ifShow: !!row.fileUrl,
+ onClick: handlePreview.bind(null, row),
+ },
+ {
+ label: $t('common.edit'),
+ type: 'link',
+ icon: ACTION_ICON.EDIT,
+ ifShow: isEditable,
+ onClick: handleEdit.bind(null, row),
+ },
+ {
+ label: $t('common.delete'),
+ type: 'link',
+ danger: true,
+ icon: ACTION_ICON.DELETE,
+ ifShow: isEditable,
+ popConfirm: {
+ title: $t('ui.actionMessage.deleteConfirm', [row.name]),
+ confirm: handleDelete.bind(null, row),
+ },
+ },
+ ]"
+ />
+ </template>
+ </Grid>
+</template>
--
Gitblit v1.9.3