| | |
| | | import type { Ref } from 'vue'; |
| | | import type { VbenFormSchema } from '#/adapter/form'; |
| | | import type { VxeTableGridOptions } from '#/adapter/vxe-table'; |
| | | |
| | | import { getSupplierSimpleList } from '#/api/srm/supplier'; |
| | | |
| | | import { z } from '#/adapter/form'; |
| | | |
| | | import { markRaw } from 'vue'; |
| | | |
| | |
| | | export type FormType = 'create' | 'detail' | 'edit'; |
| | | |
| | | /** 新增/修改的表单 */ |
| | | export function useFormSchema(): VbenFormSchema[] { |
| | | export function useFormSchema( |
| | | orderTotalTaxPrice?: Ref<number | undefined>, |
| | | ): VbenFormSchema[] { |
| | | return [ |
| | | { |
| | | fieldName: 'id', |
| | |
| | | }, |
| | | componentProps: (_values, form) => ({ |
| | | placeholder: '请选择采购订单', |
| | | onChange: (order: { supplierName?: string } | undefined) => { |
| | | onChange: ( |
| | | order: |
| | | | { supplierName?: string; totalTaxPrice?: number } |
| | | | undefined, |
| | | ) => { |
| | | form.setFieldValue('supplierName', order?.supplierName); |
| | | if (orderTotalTaxPrice) { |
| | | orderTotalTaxPrice.value = order?.totalTaxPrice; |
| | | } |
| | | }, |
| | | }), |
| | | }, |
| | |
| | | label: '来票金额(元)', |
| | | component: 'InputNumber', |
| | | rules: 'required', |
| | | description: () => |
| | | orderTotalTaxPrice?.value != null |
| | | ? `采购订单未开票金额:${Number(orderTotalTaxPrice.value).toFixed(2)} 元` |
| | | : '', |
| | | componentProps: { |
| | | class: '!w-full', |
| | | placeholder: '请输入来票金额', |
| | | min: 0, |
| | | precision: 2, |
| | | }, |
| | | dependencies: { |
| | | triggerFields: ['purchaseOrderId'], |
| | | componentProps: () => ({ |
| | | class: '!w-full', |
| | | placeholder: '请输入来票金额', |
| | | min: 0, |
| | | max: orderTotalTaxPrice?.value ?? undefined, |
| | | precision: 2, |
| | | }), |
| | | rules: () => { |
| | | const max = orderTotalTaxPrice?.value; |
| | | if (max != null) { |
| | | return z |
| | | .number({ message: '请输入来票金额' }) |
| | | .min(0, '来票金额不能小于 0') |
| | | .max(max, `来票金额不能大于未开票金额 ${Number(max).toFixed(2)}`); |
| | | } |
| | | return z |
| | | .number({ message: '请输入来票金额' }) |
| | | .min(0, '来票金额不能小于 0'); |
| | | }, |
| | | }, |
| | | }, |
| | | { |
| | |
| | | { |
| | | title: '来票金额(元)', |
| | | field: 'price', |
| | | minWidth: 150, |
| | | formatter: 'formatAmount2', |
| | | }, |
| | | { |
| | | title: '剩余可付金额', |
| | | field: 'remainingInvoicePrice', |
| | | minWidth: 150, |
| | | formatter: 'formatAmount2', |
| | | }, |