| | |
| | | import { getSimpleUserList } from '#/api/system/user'; |
| | | import CrmCustomerSelect from '#/components/crm-customer-select.vue'; |
| | | |
| | | import { markRaw } from 'vue'; |
| | | import { markRaw, ref } from 'vue'; |
| | | |
| | | /** |
| | | * 当前所选合同的可开票金额(合同金额 - 已开票金额) |
| | | * |
| | | * 仅用于输入框提示,不限制实际开票金额 |
| | | */ |
| | | const invoiceableAmount = ref<null | number>(null); |
| | | |
| | | /** 新增/修改的表单 */ |
| | | export function useFormSchema(): VbenFormSchema[] { |
| | |
| | | onChange: () => { |
| | | form.setFieldValue('contractId', undefined); |
| | | form.setFieldValue('price', undefined); |
| | | invoiceableAmount.value = null; |
| | | }, |
| | | }), |
| | | dependencies: { |
| | |
| | | const approvedContracts = contracts.filter( |
| | | (item) => item.auditStatus === 20, |
| | | ); |
| | | const findRemain = (contractId?: number) => { |
| | | const contract = approvedContracts.find( |
| | | (item) => item.id === contractId, |
| | | ); |
| | | return contract |
| | | ? (contract.totalPrice ?? 0) - (contract.totalInvoicePrice ?? 0) |
| | | : null; |
| | | }; |
| | | // 回填当前已选合同的可开票金额(编辑场景) |
| | | invoiceableAmount.value = findRemain(values.contractId); |
| | | return { |
| | | options: approvedContracts.map((item) => { |
| | | const remain = |
| | |
| | | }; |
| | | }), |
| | | placeholder: '请选择合同', |
| | | onChange: () => { |
| | | onChange: (value: number) => { |
| | | form.setFieldValue('price', undefined); |
| | | invoiceableAmount.value = findRemain(value); |
| | | }, |
| | | } as any; |
| | | }, |
| | |
| | | label: '开票金额(元)', |
| | | component: 'InputNumber', |
| | | rules: 'required', |
| | | componentProps: { |
| | | // 仅做提示,不限制实际开票金额 |
| | | help: () => |
| | | invoiceableAmount.value === null |
| | | ? '可开票金额 = 合同金额 - 已开票金额,仅供参考,不限制开票金额' |
| | | : `该合同可开票金额:¥${invoiceableAmount.value.toFixed(2)}(仅供参考,不限制开票金额)`, |
| | | componentProps: () => ({ |
| | | class: '!w-full', |
| | | placeholder: '请输入开票金额', |
| | | placeholder: |
| | | invoiceableAmount.value === null |
| | | ? '请输入开票金额' |
| | | : `可开票 ¥${invoiceableAmount.value.toFixed(2)}(不限)`, |
| | | min: 0, |
| | | precision: 2, |
| | | }, |
| | | }), |
| | | }, |
| | | { |
| | | fieldName: 'invoiceTime', |