Kaynağa Gözat

库位管理增加库位容量

xyh 2 yıl önce
ebeveyn
işleme
204bd535a4

+ 2 - 0
cypress/e2e/storage.cy.ts

@@ -95,6 +95,7 @@ describe('库位管理', function() {
       cy.getTestId('field_storageLocationName').type('名称');
       cy.getTestId('field_storageLocationType').type('类型');
       cy.getTestId('field_storageWarehouseWhere').type('1号仓库');
+      cy.getTestId('field_storageCapacity').clear().type('5');
       selectClick('select_storageIsNotDisable', 1);
     });
   });
@@ -108,6 +109,7 @@ describe('库位管理', function() {
       cy.getTestId('field_storageLocationName').should('have.value', '1号库位');
       cy.getTestId('field_storageLocationType').should('have.value', '原材料库位');
       cy.getTestId('field_storageWarehouseWhere').should('have.value', '1号仓库');
+      cy.getTestId('field_storageCapacity').should('have.value', '8');
       validateSelect('select_storageIsNotDisable', '启用');
     });
   });

+ 1 - 0
cypress/fixtures/storage/info.json

@@ -11,6 +11,7 @@
         "storageLocationType": "原材料库位",
         "isNotDisable": "1",
         "createTime": "2023-02-04",
+        "storageLocationCapacity": "8",
         "page": 0,
         "limit": 0
       }

+ 2 - 0
packages/app/src/models/request/storage.ts

@@ -24,6 +24,8 @@ export type AddStorageParams = {
   isNotDisable: string
   /** 所在仓库 */
   warehouseWhere: string
+  /** 库位容量 */
+  storageLocationCapacity: number
 };
 
 /** 修改仓库 */

+ 3 - 1
packages/app/src/models/response/storage.ts

@@ -12,5 +12,7 @@ export type StorageListData = {
   /** 是否禁用 */
   isNotDisable: string,
   /** 创建时间 */
-  createTime: string
+  createTime: string,
+  /** 库位容量 */
+  storageLocationCapacity: string,
 };

+ 1 - 0
packages/app/src/pages/storage/table/hooks.tsx

@@ -88,6 +88,7 @@ export function useHandle(reftch: () => void) {
     {title: '库位名称', dataIndex: 'storageLocationName', key: 'storageLocationName'},
     {title: '所在仓库', dataIndex: 'warehouseWhere', key: 'warehouseWhere'},
     {title: '库位类型', dataIndex: 'storageLocationType', key: 'storageLocationType'},
+    {title: '库位容量', dataIndex: 'storageLocationCapacity', key: 'storageLocationCapacity'},
     {
       title: '是否禁用',
       dataIndex: 'isNotDisable',

+ 7 - 0
packages/app/src/pages/storage/table/modal/Info.tsx

@@ -44,6 +44,13 @@ const StoreModalInfo: FC<Props> = function({id, isLoading, onClose}) {
         label='所在仓库'
         control={control}
       />
+      <ModalField
+        name='storageCapacity'
+        width='300px'
+        label='库位容量'
+        type='number'
+        control={control}
+      />
       <ModalSelect
         name='storageIsNotDisable'
         width='300px'

+ 9 - 1
packages/app/src/pages/storage/table/modal/hooks.ts

@@ -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]);
 }