| | |
| | | <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'; |
| | |
| | | getPdDocument, |
| | | updatePdDocument, |
| | | } from '#/api/mes/pd/document'; |
| | | import { FileUpload } from '#/components/upload'; |
| | | import { $t } from '#/locales'; |
| | | |
| | | import { getPdDocumentTypeOptions } from '../data'; |
| | |
| | | const [Form, formApi] = useVbenForm({ |
| | | commonConfig: { |
| | | componentProps: { class: 'w-full' }, |
| | | formItemClass: 'col-span-1', |
| | | labelWidth: 100, |
| | | }, |
| | | layout: 'horizontal', |
| | | wrapperClass: 'grid-cols-1', |
| | | schema: [ |
| | | { |
| | | fieldName: 'id', |
| | |
| | | rules: 'selectRequired', |
| | | }, |
| | | { |
| | | fieldName: 'name', |
| | | fieldName: 'documentName', |
| | | label: '资料名称', |
| | | component: 'Input', |
| | | componentProps: { placeholder: '请输入资料名称' }, |
| | | rules: 'required', |
| | | }, |
| | | { |
| | | fieldName: 'version', |
| | | fieldName: 'documentVersion', |
| | | label: '版本号', |
| | | component: 'Input', |
| | | componentProps: { placeholder: '如 V1.0' }, |
| | |
| | | }, |
| | | { |
| | | 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, |
| | |
| | | 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 { |
| | |
| | | </script> |
| | | |
| | | <template> |
| | | <Modal class="w-[560px]"> |
| | | <Modal class="w-[720px]"> |
| | | <Form class="mx-4" /> |
| | | </Modal> |
| | | </template> |