| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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'; |
| | | |
| | | import PurchaseOrderSelect from './modules/purchase-order-select.vue'; |
| | | |
| | | /** 表åç±»å */ |
| | | export type FormType = 'create' | 'detail' | 'edit'; |
| | | |
| | | /** æ°å¢/ä¿®æ¹ç表å */ |
| | | export function useFormSchema( |
| | | orderRemainInvoicePrice?: Ref<number | undefined>, |
| | | ): VbenFormSchema[] { |
| | | return [ |
| | | { |
| | | fieldName: 'id', |
| | | component: 'Input', |
| | | dependencies: { |
| | | triggerFields: [''], |
| | | show: () => false, |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'no', |
| | | label: 'æ¥ç¥¨ç¼å·', |
| | | component: 'Input', |
| | | componentProps: { |
| | | placeholder: 'ä¿åæ¶èªå¨çæ', |
| | | disabled: true, |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'purchaseOrderId', |
| | | label: 'éè´è®¢å', |
| | | component: markRaw(PurchaseOrderSelect), |
| | | rules: 'required', |
| | | dependencies: { |
| | | triggerFields: ['id'], |
| | | disabled: (values) => !!values.id, |
| | | }, |
| | | componentProps: (_values, form) => ({ |
| | | placeholder: 'è¯·éæ©éè´è®¢å', |
| | | onChange: ( |
| | | order: |
| | | | { supplierName?: string; remainInvoicePrice?: number } |
| | | | undefined, |
| | | ) => { |
| | | form.setFieldValue('supplierName', order?.supplierName); |
| | | if (orderRemainInvoicePrice) { |
| | | orderRemainInvoicePrice.value = order?.remainInvoicePrice; |
| | | } |
| | | }, |
| | | }), |
| | | }, |
| | | { |
| | | fieldName: 'supplierName', |
| | | label: 'ä¾åºå', |
| | | component: 'Input', |
| | | componentProps: { |
| | | placeholder: 'éæ©éè´è®¢ååèªå¨å¸¦åº', |
| | | disabled: true, |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'invoiceNo', |
| | | label: 'å票å·ç ', |
| | | component: 'Input', |
| | | componentProps: { |
| | | placeholder: '请è¾å
¥å票å·ç ', |
| | | allowClear: true, |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'invoiceTitle', |
| | | label: 'å票æ¬å¤´', |
| | | component: 'Input', |
| | | componentProps: { |
| | | placeholder: '请è¾å
¥å票æ¬å¤´', |
| | | allowClear: true, |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'price', |
| | | label: 'æ¥ç¥¨éé¢ï¼å
ï¼', |
| | | component: 'InputNumber', |
| | | rules: 'required', |
| | | description: () => |
| | | orderRemainInvoicePrice?.value != null |
| | | ? `éè´è®¢åæªå¼ç¥¨éé¢ï¼${Number(orderRemainInvoicePrice.value).toFixed(2)} å
` |
| | | : '', |
| | | componentProps: { |
| | | class: '!w-full', |
| | | placeholder: '请è¾å
¥æ¥ç¥¨éé¢', |
| | | min: 0, |
| | | precision: 2, |
| | | }, |
| | | dependencies: { |
| | | triggerFields: ['purchaseOrderId'], |
| | | componentProps: () => ({ |
| | | class: '!w-full', |
| | | placeholder: '请è¾å
¥æ¥ç¥¨éé¢', |
| | | min: 0, |
| | | max: orderRemainInvoicePrice?.value ?? undefined, |
| | | precision: 2, |
| | | }), |
| | | rules: () => { |
| | | const max = orderRemainInvoicePrice?.value; |
| | | if (max != null) { |
| | | return z |
| | | .number({ message: '请è¾å
¥æ¥ç¥¨éé¢' }) |
| | | .min(0, 'æ¥ç¥¨éé¢ä¸è½å°äº 0') |
| | | .max(max, `æ¥ç¥¨éé¢ä¸è½å¤§äºæªå¼ç¥¨éé¢ ${Number(max).toFixed(2)}`); |
| | | } |
| | | return z |
| | | .number({ message: '请è¾å
¥æ¥ç¥¨éé¢' }) |
| | | .min(0, 'æ¥ç¥¨éé¢ä¸è½å°äº 0'); |
| | | }, |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'invoiceTime', |
| | | label: 'æ¥ç¥¨æ¥æ', |
| | | component: 'DatePicker', |
| | | rules: 'required', |
| | | componentProps: { |
| | | placeholder: 'è¯·éæ©æ¥ç¥¨æ¥æ', |
| | | showTime: false, |
| | | valueFormat: 'YYYY-MM-DD', |
| | | format: 'YYYY-MM-DD', |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'blobIds', |
| | | label: 'å票éä»¶', |
| | | component: 'FileUpload', |
| | | componentProps: { |
| | | valueKey: 'id', |
| | | maxNumber: 10, |
| | | multiple: true, |
| | | accept: ['jpg', 'jpeg', 'png', 'pdf'], |
| | | helpText: 'æ¯æjpgãjpegãpngãpdfæ ¼å¼ï¼å个æä»¶ä¸è¶
è¿50MB', |
| | | }, |
| | | formItemClass: 'md:col-span-2', |
| | | }, |
| | | { |
| | | fieldName: 'remark', |
| | | label: '夿³¨', |
| | | component: 'Textarea', |
| | | componentProps: { |
| | | placeholder: '请è¾å
¥å¤æ³¨', |
| | | rows: 4, |
| | | }, |
| | | formItemClass: 'md:col-span-2', |
| | | }, |
| | | ]; |
| | | } |
| | | |
| | | /** å表çæç´¢è¡¨å */ |
| | | export function useGridFormSchema(): VbenFormSchema[] { |
| | | return [ |
| | | { |
| | | fieldName: 'no', |
| | | label: 'æ¥ç¥¨ç¼å·', |
| | | component: 'Input', |
| | | componentProps: { |
| | | placeholder: '请è¾å
¥æ¥ç¥¨ç¼å·', |
| | | allowClear: true, |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'supplierId', |
| | | label: 'ä¾åºå', |
| | | component: 'ApiSelect', |
| | | componentProps: { |
| | | placeholder: 'è¯·éæ©ä¾åºå', |
| | | allowClear: true, |
| | | showSearch: true, |
| | | api: getSupplierSimpleList, |
| | | labelField: 'name', |
| | | valueField: 'id', |
| | | }, |
| | | }, |
| | | ]; |
| | | } |
| | | |
| | | /** å表çåæ®µ */ |
| | | export function useGridColumns(): VxeTableGridOptions['columns'] { |
| | | return [ |
| | | { |
| | | title: 'æ¥ç¥¨ç¼å·', |
| | | field: 'no', |
| | | minWidth: 160, |
| | | fixed: 'left', |
| | | slots: { default: 'no' }, |
| | | }, |
| | | { |
| | | title: 'ä¾åºå', |
| | | field: 'supplierName', |
| | | minWidth: 150, |
| | | }, |
| | | { |
| | | title: 'éè´è®¢åç¼å·', |
| | | field: 'order', |
| | | minWidth: 160, |
| | | slots: { default: 'orderNo' }, |
| | | }, |
| | | { |
| | | title: 'å票å·ç ', |
| | | field: 'invoiceNo', |
| | | minWidth: 150, |
| | | }, |
| | | { |
| | | title: 'æ¥ç¥¨éé¢ï¼å
ï¼', |
| | | field: 'price', |
| | | minWidth: 150, |
| | | formatter: 'formatAmount2', |
| | | }, |
| | | { |
| | | title: 'æ¥ç¥¨æ¥æ', |
| | | field: 'invoiceTime', |
| | | minWidth: 150, |
| | | formatter: 'formatDateTime', |
| | | }, |
| | | { |
| | | title: '夿³¨', |
| | | field: 'remark', |
| | | minWidth: 150, |
| | | }, |
| | | { |
| | | title: 'éä»¶', |
| | | field: 'attachmentList', |
| | | minWidth: 100, |
| | | fixed: 'right', |
| | | slots: { default: 'attachment' }, |
| | | }, |
| | | { |
| | | title: 'æä½', |
| | | field: 'actions', |
| | | minWidth: 200, |
| | | fixed: 'right', |
| | | slots: { default: 'actions' }, |
| | | }, |
| | | ]; |
| | | } |