| | |
| | | import type { VbenFormSchema } from '#/adapter/form'; |
| | | import type { VxeTableGridOptions } from '#/adapter/vxe-table'; |
| | | |
| | | import { DICT_TYPE } from '../../../../packages/constants/src'; |
| | | import { getDictOptions } from '../../../../packages/effects/hooks/src'; |
| | | import { erpPriceInputFormatter } from '../../../../packages/utils/src'; |
| | | import { DICT_TYPE } from '@vben/constants'; |
| | | import { getDictOptions } from '@vben/hooks'; |
| | | import { erpPriceInputFormatter } from '@vben/utils'; |
| | | |
| | | import { getAccountSimpleList } from '#/api/erp/finance/account'; |
| | | import { getSupplierSimpleList } from '#/api/erp/purchase/supplier'; |
| | | import { getPurchaseInvoiceSimpleList } from '#/api/erp/purchase/invoice'; |
| | | import { getSupplierSimpleList } from '#/api/srm/supplier'; |
| | | import { getSimpleUserList } from '#/api/system/user'; |
| | | import { getRangePickerDefaultProps } from '#/utils'; |
| | | |
| | |
| | | placeholder: '选择付款时间', |
| | | showTime: true, |
| | | format: 'YYYY-MM-DD HH:mm:ss', |
| | | valueFormat: 'x', |
| | | valueFormat: 'YYYY-MM-DD HH:mm:ss', |
| | | }, |
| | | rules: 'required', |
| | | }, |
| | |
| | | fieldName: 'supplierId', |
| | | label: '供应商', |
| | | component: 'ApiSelect', |
| | | componentProps: { |
| | | componentProps: (_values, form) => ({ |
| | | disabled: formType === 'detail', |
| | | placeholder: '请选择供应商', |
| | | allowClear: true, |
| | |
| | | api: getSupplierSimpleList, |
| | | labelField: 'name', |
| | | valueField: 'id', |
| | | }, |
| | | onChange: () => { |
| | | // 供应商变化后,清空已选的关联来票 |
| | | form.setFieldValue('invoiceId', undefined); |
| | | }, |
| | | }), |
| | | rules: 'required', |
| | | }, |
| | | { |
| | | fieldName: 'invoiceId', |
| | | label: '关联来票', |
| | | component: formType === 'detail' ? 'Input' : 'Select', |
| | | componentProps: |
| | | formType === 'detail' |
| | | ? { |
| | | disabled: true, |
| | | placeholder: '--', |
| | | } |
| | | : undefined, |
| | | rules: 'required', |
| | | dependencies: { |
| | | // 依赖 invoiceId 自身,确保编辑回显时重新加载选项以匹配已选来票 |
| | | triggerFields: ['supplierId', 'invoiceId'], |
| | | disabled: (values) => formType === 'detail' || !values.supplierId, |
| | | async componentProps(values) { |
| | | if (formType === 'detail') { |
| | | return {}; |
| | | } |
| | | if (!values.supplierId) { |
| | | return { |
| | | options: [], |
| | | placeholder: '请先选择供应商', |
| | | }; |
| | | } |
| | | const invoices = await getPurchaseInvoiceSimpleList( |
| | | values.supplierId, |
| | | ); |
| | | return { |
| | | options: invoices.map((item) => { |
| | | const remain = item.remainingInvoicePrice ?? item.price ?? 0; |
| | | return { |
| | | label: `${item.no} / ${item.invoiceNo ?? '-'} / ¥${item.price ?? 0} / 剩余可付 ¥${remain.toFixed(2)}`, |
| | | value: item.id, |
| | | }; |
| | | }), |
| | | placeholder: '请选择关联来票', |
| | | } as any; |
| | | }, |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'financeUserId', |
| | |
| | | formItemClass: 'col-span-2', |
| | | }, |
| | | { |
| | | fieldName: 'fileUrl', |
| | | fieldName: 'blobIds', |
| | | label: '附件', |
| | | component: 'FileUpload', |
| | | componentProps: { |
| | | maxNumber: 1, |
| | | maxSize: 10, |
| | | accept: [ |
| | | 'pdf', |
| | | 'doc', |
| | | 'docx', |
| | | 'xls', |
| | | 'xlsx', |
| | | 'txt', |
| | | 'jpg', |
| | | 'jpeg', |
| | | 'png', |
| | | ], |
| | | valueKey: 'id', |
| | | maxNumber: 10, |
| | | multiple: true, |
| | | showDescription: formType !== 'detail', |
| | | disabled: formType === 'detail', |
| | | }, |
| | |
| | | minWidth: 120, |
| | | }, |
| | | { |
| | | field: 'invoice', |
| | | title: '关联来票', |
| | | minWidth: 200, |
| | | slots: { default: 'invoice' }, |
| | | }, |
| | | { |
| | | field: 'paymentTime', |
| | | title: '付款时间', |
| | | width: 160, |