| | |
| | | import type { VbenFormApi, VbenFormSchema } from '#/adapter/form'; |
| | | import type { VxeTableGridOptions } from '#/adapter/vxe-table'; |
| | | import type { MdmItemApi } from '#/api/mdm/item'; |
| | | import type { MesWmMaterialStockApi } from '#/api/mes/wm/materialstock'; |
| | | import type { MesWmProductSalesApi } from '#/api/mes/wm/productsales'; |
| | | import type { MesWmProductSalesDetailApi } from '#/api/mes/wm/productsales/detail'; |
| | |
| | | DICT_TYPE, |
| | | MesAutoCodeRuleCode, |
| | | MesWmSalesNoticeStatusEnum, |
| | | } from '../../../packages/constants/src'; |
| | | import { getDictOptions } from '../../../packages/effects/hooks/src'; |
| | | } from '@vben/constants'; |
| | | import { getDictOptions } from '@vben/hooks'; |
| | | |
| | | import { Button } from 'ant-design-vue'; |
| | | |
| | | import { z } from '#/adapter/form'; |
| | | import CrmCustomerSelect from '#/components/crm-customer-select.vue'; |
| | | import { generateAutoCode } from '#/api/mes/md/autocode/record'; |
| | | import { ErpSaleOrderSelect } from '#/views/erp/sale/order/components'; |
| | | import { getRangePickerDefaultProps } from '#/utils'; |
| | | import { MdClientSelect } from '#/views/mes/md/client/components'; |
| | | import { MdItemSelect } from '#/views/mes/md/item/components'; |
| | | import { MdmItemSelect } from '#/views/basicData/mdm/components'; |
| | | import { WmMaterialStockSelect } from '#/views/wls/materialstock/components'; |
| | | import { |
| | | buildItemUnitSchema, |
| | | useLineUnitHandlers, |
| | | } from '#/views/wls/utils/item-unit-convert'; |
| | | import { |
| | | WmSalesNoticeLineSelect, |
| | | WmSalesNoticeSelect, |
| | |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'saleOrderId', |
| | | label: '销售订单编号', |
| | | component: markRaw(ErpSaleOrderSelect), |
| | | componentProps: { |
| | | disabled: isHeaderReadonly(formType), |
| | | placeholder: '请选择销售订单', |
| | | onChange: (item: any) => { |
| | | if (formApi) { |
| | | formApi.setFieldValue('salesOrderCode', item?.no ?? ''); |
| | | if (item?.customerId) { |
| | | formApi.setFieldValue('clientId', item.customerId); |
| | | } |
| | | } |
| | | }, |
| | | }, |
| | | rules: 'selectRequired', |
| | | dependencies: { |
| | | triggerFields: ['salesOrderCode'], |
| | | if: () => formType === 'create', |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'salesOrderCode', |
| | | label: '销售订单编号', |
| | | component: 'Input', |
| | | componentProps: { |
| | | disabled: isHeaderReadonly(formType), |
| | | placeholder: '请输入销售订单编号', |
| | | disabled: true, |
| | | placeholder: '销售订单编号', |
| | | }, |
| | | dependencies: { |
| | | triggerFields: [''], |
| | | if: () => formType !== 'create', |
| | | }, |
| | | }, |
| | | { |
| | |
| | | disabled: isHeaderReadonly(formType), |
| | | format: 'YYYY-MM-DD', |
| | | placeholder: '请选择出库日期', |
| | | valueFormat: 'x', |
| | | valueFormat: 'YYYY-MM-DD', |
| | | }, |
| | | rules: 'required', |
| | | }, |
| | | { |
| | | fieldName: 'clientId', |
| | | label: '客户', |
| | | component: markRaw(MdClientSelect), |
| | | component: markRaw(CrmCustomerSelect), |
| | | componentProps: { |
| | | disabled: isHeaderReadonly(formType), |
| | | placeholder: '请选择客户', |
| | |
| | | { |
| | | fieldName: 'clientId', |
| | | label: '客户', |
| | | component: markRaw(MdClientSelect), |
| | | component: markRaw(CrmCustomerSelect), |
| | | componentProps: { |
| | | placeholder: '请选择客户', |
| | | }, |
| | |
| | | minWidth: 120, |
| | | }, |
| | | { |
| | | field: 'itemModel', |
| | | title: '物料型号', |
| | | minWidth: 120, |
| | | }, |
| | | { |
| | | field: 'unitMeasureName', |
| | | title: '单位', |
| | | width: 80, |
| | | title: '主计量单位', |
| | | width: 100, |
| | | }, |
| | | { |
| | | field: 'enterUnitMeasureName', |
| | | title: '录入单位', |
| | | width: 90, |
| | | }, |
| | | { |
| | | field: 'enterQuantity', |
| | | title: '录入数量', |
| | | width: 100, |
| | | }, |
| | | { |
| | | field: 'quantity', |
| | |
| | | hasNotice: boolean, |
| | | formApi?: VbenFormApi, |
| | | ): VbenFormSchema[] { |
| | | const unitHandlers = useLineUnitHandlers(formApi); |
| | | return [ |
| | | { |
| | | fieldName: 'noticeId', |
| | |
| | | componentProps: { |
| | | // 选择发货通知单行后,自动回填物料、数量、批次、是否检验 |
| | | onChange: async (line?: MesWmSalesNoticeLineApi.SalesNoticeLine) => { |
| | | // 切换通知行等于切换产品,先重置型号与单位口径(会清空数量),再按通知行回填 |
| | | await unitHandlers.handleItemChange(line?.itemId); |
| | | await formApi?.setValues({ |
| | | batchCode: line?.batchCode, |
| | | itemId: line?.itemId, |
| | |
| | | { |
| | | fieldName: 'itemId', |
| | | label: '产品', |
| | | component: markRaw(MdItemSelect), |
| | | component: markRaw(MdmItemSelect), |
| | | componentProps: { |
| | | placeholder: '请选择产品', |
| | | // 切换产品后,重新记录物料主单位并清空型号、录入单位口径 |
| | | onChange: async (item?: MdmItemApi.Item) => { |
| | | await unitHandlers.handleItemChange(item?.id); |
| | | }, |
| | | }, |
| | | rules: 'selectRequired', |
| | | dependencies: { |
| | |
| | | }), |
| | | }, |
| | | }, |
| | | // 物料型号 / 录入单位 / 录入数量 / 出库数量(物料主单位口径) |
| | | ...buildItemUnitSchema(formApi), |
| | | { |
| | | fieldName: 'batchCode', |
| | | label: '批次号', |
| | |
| | | componentProps: { |
| | | placeholder: '请输入批次号', |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'quantity', |
| | | label: '出库数量', |
| | | component: 'InputNumber', |
| | | componentProps: { |
| | | class: '!w-full', |
| | | min: 0, |
| | | placeholder: '请输入出库数量', |
| | | precision: 2, |
| | | }, |
| | | rules: 'required', |
| | | }, |
| | | { |
| | | fieldName: 'oqcCheckFlag', |
| | |
| | | { |
| | | fieldName: 'itemId', |
| | | label: '物料', |
| | | component: markRaw(MdItemSelect), |
| | | component: markRaw(MdmItemSelect), |
| | | componentProps: { |
| | | disabled: true, |
| | | }, |