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-form.vue |  142 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 142 insertions(+), 0 deletions(-)

diff --git a/src/views/mes/pd/project/modules/document-form.vue b/src/views/mes/pd/project/modules/document-form.vue
new file mode 100644
index 0000000..9d015cf
--- /dev/null
+++ b/src/views/mes/pd/project/modules/document-form.vue
@@ -0,0 +1,142 @@
+<script lang="ts" setup>
+import type { MesPdDocumentApi } from '#/api/mes/pd/document';
+
+import { ref } from 'vue';
+
+import { useVbenModal } from '#/packages/effects/common-ui/src';
+import { MesPdDocumentTypeEnum } from '#/packages/constants/src';
+
+import { message } from 'ant-design-vue';
+
+import { useVbenForm } from '#/adapter/form';
+import {
+  createPdDocument,
+  getPdDocument,
+  updatePdDocument,
+} from '#/api/mes/pd/document';
+import { $t } from '#/locales';
+
+import { getPdDocumentTypeOptions } from '../data';
+
+const emit = defineEmits(['success']);
+
+const isUpdate = ref(false);
+
+const [Form, formApi] = useVbenForm({
+  commonConfig: {
+    componentProps: { class: 'w-full' },
+    labelWidth: 100,
+  },
+  layout: 'horizontal',
+  schema: [
+    {
+      fieldName: 'id',
+      component: 'Input',
+      dependencies: { triggerFields: [''], show: () => false },
+    },
+    {
+      fieldName: 'projectId',
+      component: 'Input',
+      dependencies: { triggerFields: [''], show: () => false },
+    },
+    {
+      fieldName: 'documentType',
+      label: '璧勬枡绫诲瀷',
+      component: 'Select',
+      componentProps: {
+        options: getPdDocumentTypeOptions(),
+        placeholder: '璇烽�夋嫨璧勬枡绫诲瀷',
+      },
+      rules: 'selectRequired',
+    },
+    {
+      fieldName: 'name',
+      label: '璧勬枡鍚嶇О',
+      component: 'Input',
+      componentProps: { placeholder: '璇疯緭鍏ヨ祫鏂欏悕绉�' },
+      rules: 'required',
+    },
+    {
+      fieldName: 'version',
+      label: '鐗堟湰鍙�',
+      component: 'Input',
+      componentProps: { placeholder: '濡� V1.0' },
+      rules: 'required',
+    },
+    {
+      fieldName: 'fileUrl',
+      label: '鏂囦欢鍦板潃',
+      component: 'Input',
+      componentProps: { placeholder: '璇疯緭鍏ユ枃浠� URL 鎴栦笂浼犲悗濉叆' },
+    },
+    {
+      fieldName: 'fileName',
+      label: '鏂囦欢鍚�',
+      component: 'Input',
+      componentProps: { placeholder: '濡� bom-list.xlsx' },
+    },
+    {
+      fieldName: 'remark',
+      label: '澶囨敞',
+      component: 'Textarea',
+      componentProps: { placeholder: '璇疯緭鍏ュ娉�', rows: 3 },
+    },
+  ],
+  showDefaultActions: false,
+});
+
+const [Modal, modalApi] = useVbenModal({
+  async onConfirm() {
+    const { valid } = await formApi.validate();
+    if (!valid) {
+      return;
+    }
+    modalApi.lock();
+    const data = (await formApi.getValues()) as MesPdDocumentApi.Document;
+    try {
+      if (isUpdate.value) {
+        await updatePdDocument(data);
+      } else {
+        await createPdDocument(data);
+      }
+      emit('success');
+      message.success($t('ui.actionMessage.operationSuccess'));
+      await modalApi.close();
+    } finally {
+      modalApi.unlock();
+    }
+  },
+  async onOpenChange(isOpen: boolean) {
+    if (!isOpen) {
+      return;
+    }
+    const data = modalApi.getData<{
+      id?: number;
+      projectId: number;
+      documentType?: number;
+    }>();
+    isUpdate.value = !!data.id;
+    modalApi.setState({ title: isUpdate.value ? '缂栬緫闄勪欢' : '涓婁紶闄勪欢' });
+    if (data.id) {
+      modalApi.lock();
+      try {
+        const detail = await getPdDocument(data.id);
+        await formApi.setValues(detail);
+      } finally {
+        modalApi.unlock();
+      }
+      return;
+    }
+    await formApi.setValues({
+      projectId: data.projectId,
+      documentType: data.documentType ?? MesPdDocumentTypeEnum.SCHEME,
+    });
+  },
+});
+</script>
+
+<template>
+  <Modal class="w-[560px]">
+    <Form class="mx-4" />
+  </Modal>
+</template>

--
Gitblit v1.9.3