spring
2026-07-03 2540d86f0dbd77f654f558c3bf9d5ddbe7422f16
src/views/mes/pd/project/modules/document-form.vue
@@ -1,7 +1,7 @@
<script lang="ts" setup>
import type { MesPdDocumentApi } from '#/api/mes/pd/document';
import { ref } from 'vue';
import { markRaw, ref } from 'vue';
import { useVbenModal } from '#/packages/effects/common-ui/src';
import { MesPdDocumentTypeEnum } from '#/packages/constants/src';
@@ -14,6 +14,7 @@
  getPdDocument,
  updatePdDocument,
} from '#/api/mes/pd/document';
import { FileUpload } from '#/components/upload';
import { $t } from '#/locales';
import { getPdDocumentTypeOptions } from '../data';
@@ -25,9 +26,11 @@
const [Form, formApi] = useVbenForm({
  commonConfig: {
    componentProps: { class: 'w-full' },
    formItemClass: 'col-span-1',
    labelWidth: 100,
  },
  layout: 'horizontal',
  wrapperClass: 'grid-cols-1',
  schema: [
    {
      fieldName: 'id',
@@ -50,14 +53,14 @@
      rules: 'selectRequired',
    },
    {
      fieldName: 'name',
      fieldName: 'documentName',
      label: '资料名称',
      component: 'Input',
      componentProps: { placeholder: '请输入资料名称' },
      rules: 'required',
    },
    {
      fieldName: 'version',
      fieldName: 'documentVersion',
      label: '版本号',
      component: 'Input',
      componentProps: { placeholder: '如 V1.0' },
@@ -65,21 +68,23 @@
    },
    {
      fieldName: 'fileUrl',
      label: '文件地址',
      component: 'Input',
      componentProps: { placeholder: '请输入文件 URL 或上传后填入' },
      label: '文件',
      component: markRaw(FileUpload),
      componentProps: {
        directory: 'mes/pd',
        maxNumber: 1,
        onChange: async (url: string) => {
          if (url) {
            await formApi?.setFieldValue('fileUrl', url);
          }
        },
      },
    },
    {
      fieldName: 'fileName',
      label: '文件名',
      component: 'Input',
      componentProps: { placeholder: '如 bom-list.xlsx' },
    },
    {
      fieldName: 'remark',
      label: '备注',
      component: 'Textarea',
      componentProps: { placeholder: '请输入备注', rows: 3 },
      componentProps: { placeholder: '上传后自动填入,也可手动输入' },
    },
  ],
  showDefaultActions: false,
@@ -113,10 +118,10 @@
    const data = modalApi.getData<{
      id?: number;
      projectId: number;
      documentType?: number;
      documentType?: string;
    }>();
    isUpdate.value = !!data.id;
    modalApi.setState({ title: isUpdate.value ? '编辑附件' : '上传附件' });
    modalApi.setState({ title: isUpdate.value ? '编辑资料' : '上传资料' });
    if (data.id) {
      modalApi.lock();
      try {
@@ -136,7 +141,7 @@
</script>
<template>
  <Modal class="w-[560px]">
  <Modal class="w-[720px]">
    <Form class="mx-4" />
  </Modal>
</template>