| | |
| | | |
| | | import { generateAutoCode } from '#/api/mes/md/autocode/record'; |
| | | import { getRangePickerDefaultProps } from '#/utils'; |
| | | import { |
| | | useLineUnitHandlers, |
| | | buildItemUnitSchema, |
| | | } from '#/views/wls/utils/item-unit-convert'; |
| | | import { WmMaterialStockSelect } from '#/views/wls/materialstock/components'; |
| | | import { |
| | | WmWarehouseAreaSelect, |
| | |
| | | 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', |
| | |
| | | |
| | | /** 出库单行新增/修改的表单 */ |
| | | export function useLineFormSchema(formApi?: VbenFormApi): VbenFormSchema[] { |
| | | const unitHandlers = useLineUnitHandlers(formApi); |
| | | return [ |
| | | { |
| | | fieldName: 'itemId', |
| | |
| | | componentProps: { |
| | | // 选择库存物资后,自动回填物料、批次号、仓库位置和最大可出库数量 |
| | | onChange: async (stock?: MesWmMaterialStockApi.MaterialStock) => { |
| | | // 切换库存物资等于切换物料,先清掉上一份型号与录入单位口径 |
| | | await unitHandlers.handleItemChange(stock?.itemId); |
| | | await formApi?.setValues({ |
| | | areaId: stock?.areaId, |
| | | batchCode: stock?.batchCode, |
| | | itemId: stock?.itemId, |
| | | locationId: stock?.locationId, |
| | | quantityMax: stock?.quantity, |
| | | warehouseId: stock?.warehouseId, |
| | |
| | | }), |
| | | }, |
| | | }, |
| | | { |
| | | fieldName: 'quantity', |
| | | label: '出库数量', |
| | | component: 'InputNumber', |
| | | componentProps: { |
| | | class: '!w-full', |
| | | min: 0.01, |
| | | placeholder: '请输入出库数量', |
| | | precision: 2, |
| | | }, |
| | | rules: 'required', |
| | | dependencies: { |
| | | triggerFields: ['quantityMax'], |
| | | componentProps: (values) => ({ |
| | | class: '!w-full', |
| | | max: values.quantityMax, |
| | | min: 0.01, |
| | | placeholder: '请输入出库数量', |
| | | precision: 2, |
| | | }), |
| | | }, |
| | | }, |
| | | // 物料型号 / 录入单位 / 录入数量 / 出库数量(主单位口径) |
| | | ...buildItemUnitSchema(formApi), |
| | | { |
| | | fieldName: 'batchCode', |
| | | label: '批次号', |