| | |
| | | import { erpPriceInputFormatter } from '@vben/utils'; |
| | | |
| | | import { getAccountSimpleList } from '#/api/erp/finance/account'; |
| | | import { getPurchaseInvoiceSimpleList } from '#/api/erp/purchase/invoice'; |
| | | import { getSupplierSimpleList } from '#/api/srm/supplier'; |
| | | import { getSimpleUserList } from '#/api/system/user'; |
| | | import { getRangePickerDefaultProps } from '#/utils'; |
| | |
| | | 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', |
| | |
| | | minWidth: 120, |
| | | }, |
| | | { |
| | | field: 'invoice', |
| | | title: '关联来票', |
| | | minWidth: 200, |
| | | slots: { default: 'invoice' }, |
| | | }, |
| | | { |
| | | field: 'paymentTime', |
| | | title: '付款时间', |
| | | width: 160, |