|
|
@@ -5,7 +5,7 @@ import {useMutation, useQuery} from '@tanstack/react-query';
|
|
|
import {message} from 'antd';
|
|
|
import {useEffect} from 'react';
|
|
|
import {useForm, useFormContext} from 'react-hook-form';
|
|
|
-import {object, string} from 'yup';
|
|
|
+import {number, object, string} from 'yup';
|
|
|
|
|
|
type FormState = {
|
|
|
/** 库位编号 */
|
|
|
@@ -18,6 +18,8 @@ type FormState = {
|
|
|
storageIsNotDisable: string
|
|
|
/** 所在仓库 */
|
|
|
storageWarehouseWhere: string
|
|
|
+ /** 库位容量 */
|
|
|
+ storageCapacity: number
|
|
|
};
|
|
|
|
|
|
const validate = object({
|
|
|
@@ -26,6 +28,8 @@ const validate = object({
|
|
|
storageLocationType: string().required('请输入库位类型'),
|
|
|
storageWarehouseWhere: string().required('请输入所在仓库'),
|
|
|
storageIsNotDisable: string().required('请选择状态'),
|
|
|
+ storageCapacity: number().typeError('请输入数字类型').min(0, '库位容量必须大于0')
|
|
|
+ .required('请输入库位容量'),
|
|
|
});
|
|
|
|
|
|
function useAdd(onClose: () => void, onFetch: () => void) {
|
|
|
@@ -73,6 +77,7 @@ export function useFormState(
|
|
|
storageLocationType: '',
|
|
|
storageWarehouseWhere: '',
|
|
|
storageIsNotDisable: '1',
|
|
|
+ storageCapacity: 0,
|
|
|
},
|
|
|
resolver: yupResolver(validate),
|
|
|
});
|
|
|
@@ -93,6 +98,7 @@ export function useFormState(
|
|
|
storageLocationType,
|
|
|
storageIsNotDisable,
|
|
|
storageWarehouseWhere,
|
|
|
+ storageCapacity,
|
|
|
}) {
|
|
|
const params: AddStorageParams = {
|
|
|
storageLocationName,
|
|
|
@@ -100,6 +106,7 @@ export function useFormState(
|
|
|
storageLocationType,
|
|
|
isNotDisable: storageIsNotDisable,
|
|
|
warehouseWhere: storageWarehouseWhere,
|
|
|
+ storageLocationCapacity: storageCapacity,
|
|
|
};
|
|
|
|
|
|
id.length
|
|
|
@@ -144,5 +151,6 @@ export function useFormInfoValue(id: string) {
|
|
|
setValue('storageLocationType', data?.storageLocationType ?? '');
|
|
|
setValue('storageIsNotDisable', data?.isNotDisable ?? '1');
|
|
|
setValue('storageWarehouseWhere', data?.warehouseWhere ?? '');
|
|
|
+ setValue('storageCapacity', Number(data?.storageLocationCapacity ?? 0));
|
|
|
}, [data, setValue]);
|
|
|
}
|