fix: MOM
1.采购来票登记时选好采购订单后提示可来票金额
| | |
| | | totalCount?: number; // 合计数量 |
| | | totalPrice?: number; // 合计金额,单位:元 |
| | | totalProductPrice?: number; // 产品金额,单位:元 |
| | | totalTaxPrice?: number; // 合计税额,单位:元 |
| | | discountPercent?: number; // 优惠率,百分比 |
| | | discountPrice?: number; // 优惠金额,单位:元 |
| | | depositPrice?: number; // 定金金额,单位:元 |
| | |
| | | formItemClass: 'col-span-3', |
| | | }, |
| | | { |
| | | fieldName: 'accountId', |
| | | fieldName: 'accountName', |
| | | label: '付款账户', |
| | | component: 'ApiSelect', |
| | | component: 'Input', |
| | | rules: 'required', |
| | | componentProps: { |
| | | placeholder: '请选择付款账户', |
| | | placeholder: '请输入付款账户', |
| | | allowClear: true, |
| | | showSearch: true, |
| | | api: getAccountSimpleList, |
| | | labelField: 'name', |
| | | valueField: 'id', |
| | | }, |
| | | help: '付款账户数据来自【财务管理 → 结算账户】菜单维护的开启状态账户,无选项时请先在结算账户页面新增。', |
| | | }, |
| | | { |
| | | fieldName: 'totalPrice', |
| | |
| | | id: undefined, |
| | | no: '', |
| | | supplierId: undefined, |
| | | accountId: undefined, |
| | | accountName: undefined, |
| | | financeUserId: undefined, |
| | | paymentTime: undefined, |
| | | remark: '', |
| | |
| | | formApi.setDisabled(formType.value === 'detail'); |
| | | formApi.updateSchema(useFormSchema(formType.value)); |
| | | if (!data || !data.id) { |
| | | // 新增时,默认选中账户 |
| | | // 新增时,默认填入默认结算账户名称 |
| | | const accountList = await getAccountSimpleList(); |
| | | const defaultAccount = accountList.find((item) => item.defaultStatus); |
| | | if (defaultAccount) { |
| | | await formApi.setValues({ accountId: defaultAccount.id }); |
| | | await formApi.setValues({ accountName: defaultAccount.name }); |
| | | } |
| | | return; |
| | | } |
| | |
| | | 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', |
| | | }, |
| | |
| | | const emit = defineEmits(['success']); |
| | | const formData = ref<ErpPurchaseInvoiceApi.PurchaseInvoice>(); |
| | | const formType = ref<FormType>('create'); |
| | | const orderTotalTaxPrice = ref<number>(); // 所选采购订单合计税额(未开票金额,用于提示与校验) |
| | | |
| | | const getTitle = computed(() => { |
| | | if (formType.value === 'create') { |
| | |
| | | }, |
| | | wrapperClass: 'grid-cols-2', |
| | | layout: 'horizontal', |
| | | schema: useFormSchema(), |
| | | schema: useFormSchema(orderTotalTaxPrice), |
| | | showDefaultActions: false, |
| | | }); |
| | | |
| | |
| | | async onOpenChange(isOpen: boolean) { |
| | | if (!isOpen) { |
| | | formData.value = undefined; |
| | | orderTotalTaxPrice.value = undefined; |
| | | return; |
| | | } |
| | | const data = modalApi.getData<{ formType: FormType; id?: number }>(); |
| | | formType.value = data.formType; |
| | | formApi.setDisabled(formType.value === 'detail'); |
| | | formApi.updateSchema(useFormSchema()); |
| | | formApi.updateSchema(useFormSchema(orderTotalTaxPrice)); |
| | | await formApi.resetForm(); |
| | | if (!data || !data.id) { |
| | | return; |
| | |
| | | minWidth: 120, |
| | | }, |
| | | { |
| | | field: 'totalTaxPrice', |
| | | title: '未开票金额', |
| | | formatter: 'formatAmount2', |
| | | minWidth: 120, |
| | | }, |
| | | { |
| | | field: 'status', |
| | | title: '状态', |
| | | minWidth: 100, |