| | |
| | | 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 { MesWmReturnVendorApi } from '#/api/mes/wm/returnvendor'; |
| | | import type { MesWmReturnVendorDetailApi } from '#/api/mes/wm/returnvendor/detail'; |
| | |
| | | import { Button } from 'ant-design-vue'; |
| | | |
| | | import { generateAutoCode } from '#/api/mes/md/autocode/record'; |
| | | import { MdItemSelect } from '#/views/mes/md/item/components'; |
| | | import { MdmItemSelect } from '#/views/basicData/mdm/components'; |
| | | import { MdVendorSelect } from '#/views/mes/md/vendor/components'; |
| | | import { ErpPurchaseOrderSelect } from '#/views/erp/purchase/order/components'; |
| | | import { WmBatchSelect } from '#/views/wls/batch/components'; |
| | | import { WmMaterialStockSelect } from '#/views/wls/materialstock/components'; |
| | | import { |
| | | buildItemUnitSchema, |
| | | useLineUnitHandlers, |
| | | } from '#/views/wls/utils/item-unit-convert'; |
| | | import { |
| | | WmWarehouseAreaSelect, |
| | | WmWarehouseLocationSelect, |
| | |
| | | format: 'YYYY-MM-DD HH:mm:ss', |
| | | placeholder: '请选择退货日期', |
| | | showTime: true, |
| | | valueFormat: 'x', |
| | | valueFormat: 'YYYY-MM-DD HH:mm:ss', |
| | | }, |
| | | rules: 'required', |
| | | }, |
| | |
| | | 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', |
| | |
| | | vendorId?: number, |
| | | formApi?: VbenFormApi, |
| | | ): VbenFormSchema[] { |
| | | const unitHandlers = useLineUnitHandlers(formApi); |
| | | return [ |
| | | { |
| | | fieldName: 'itemId', |
| | | label: '产品物料', |
| | | component: markRaw(MdItemSelect), |
| | | component: markRaw(MdmItemSelect), |
| | | componentProps: { |
| | | placeholder: '请选择产品物料', |
| | | // 切换产品后,重新记录物料主单位并清空型号、录入单位口径 |
| | | onChange: async (item?: MdmItemApi.Item) => { |
| | | await unitHandlers.handleItemChange(item?.id); |
| | | }, |
| | | }, |
| | | rules: 'selectRequired', |
| | | }, |
| | | { |
| | | fieldName: 'quantity', |
| | | label: '退货数量', |
| | | component: 'InputNumber', |
| | | componentProps: { |
| | | class: '!w-full', |
| | | min: 0, |
| | | placeholder: '请输入退货数量', |
| | | precision: 2, |
| | | }, |
| | | rules: 'required', |
| | | }, |
| | | // 物料型号 / 录入单位 / 录入数量 / 退货数量(物料主单位口径) |
| | | ...buildItemUnitSchema(formApi, { quantityLabel: '退货数量' }), |
| | | { |
| | | fieldName: 'batchId', |
| | | label: '批次号', |
| | |
| | | } |
| | | |
| | | /** 拣货明细新增/修改的表单 */ |
| | | export function useDetailFormSchema(formApi?: VbenFormApi): VbenFormSchema[] { |
| | | export function useDetailFormSchema( |
| | | formApi?: VbenFormApi, |
| | | onStockChange?: (stock?: MesWmMaterialStockApi.MaterialStock) => void, |
| | | ): VbenFormSchema[] { |
| | | return [ |
| | | { |
| | | fieldName: 'quantityMax', |
| | |
| | | { |
| | | fieldName: 'itemId', |
| | | label: '物料', |
| | | component: markRaw(MdItemSelect), |
| | | component: markRaw(MdmItemSelect), |
| | | componentProps: { |
| | | disabled: true, |
| | | }, |
| | |
| | | componentProps: { |
| | | // 选择库存记录后,自动回填仓库/库区/库位/批次/数量 |
| | | onChange: async (stock?: MesWmMaterialStockApi.MaterialStock) => { |
| | | onStockChange?.(stock); |
| | | await formApi?.setValues({ |
| | | areaId: stock?.areaId, |
| | | batchCode: stock?.batchCode, |
| | | batchId: stock?.batchId, |
| | | locationId: stock?.locationId, |
| | | quantity: stock?.quantity, |
| | | quantityMax: stock?.quantity, |