Browse Source

chore: 物料增加是否推荐库位

xyh 2 years ago
parent
commit
c983c0611e

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

@@ -25,4 +25,6 @@ export type EditDictionaryParams = {
    * 物料大小
    */
   size: string;
+  /** 是否推荐库位 */
+  isRecommend: string;
 };

+ 2 - 0
packages/app/src/models/response/dictionary.ts

@@ -17,4 +17,6 @@ export type DictionaryData = {
   size: string | null;
   tldId: string;
   type: string | null;
+  /** 是否推荐库位 */
+  isRecommend: '1' | '0';
 };

+ 8 - 0
packages/app/src/pages/goods/table/hooks.tsx

@@ -54,6 +54,14 @@ export function useHandle() {
         return isNotDisable === '1' ? '是' : '否';
       },
     },
+    {
+      title: '是否推荐库位',
+      dataIndex: 'isRecommend',
+      key: 'isRecommend',
+      render(_, {isRecommend}) {
+        return isRecommend === '1' ? '是' : '否';
+      },
+    },
     {
       title: '操作',
       dataIndex: 'tldId',

+ 6 - 0
packages/app/src/pages/goods/table/modal/Info.tsx

@@ -35,6 +35,12 @@ const Info: FC<Props> = function({id}) {
         control={control}
         data={options}
       />
+      <ModalSelect
+        label='推荐库位'
+        name='goodsRecommend'
+        control={control}
+        data={options}
+      />
     </>
   );
 };

+ 6 - 2
packages/app/src/pages/goods/table/modal/hooks.ts

@@ -11,6 +11,7 @@ type FormState = {
   goodsType: string,
   goodsSize: number,
   goodsMixin: string,
+  goodsRecommend: string,
 };
 
 const validate = object({
@@ -18,6 +19,7 @@ const validate = object({
   goodsSize: number().typeError('请输入数字')
     .min(1, '不能小于1个').required('请输入物料存储容量'),
   goodsMixin: string().required('请选择是否混合存储'),
+  goodsRecommend: string().required('请选择是否推荐库位'),
 });
 
 export function useFormState(
@@ -25,7 +27,7 @@ export function useFormState(
   {onClose: () => void, onFetch: () => void, visible: boolean, id: string},
 ) {
   const formInstance = useForm<FormState>({
-    defaultValues: {goodsType: '', goodsSize: 1, goodsMixin: ''},
+    defaultValues: {goodsType: '', goodsSize: 1, goodsMixin: '', goodsRecommend: ''},
     resolver: yupResolver(validate),
   });
 
@@ -46,12 +48,13 @@ export function useFormState(
     },
   });
 
-  const onSubmit = handleSubmit(function({goodsMixin, goodsSize, goodsType}) {
+  const onSubmit = handleSubmit(function({goodsMixin, goodsSize, goodsType, goodsRecommend}) {
     mutate({
       isNotDisable: goodsMixin,
       size: String(goodsSize),
       id,
       materialType: goodsType,
+      isRecommend: goodsRecommend,
     });
   });
 
@@ -76,5 +79,6 @@ export function useWatchId(id: string) {
     setValue('goodsType', data?.wllbClass ?? '');
     setValue('goodsSize', Number(data?.size ?? '1'));
     setValue('goodsMixin', data?.isNotDisable ?? '');
+    setValue('goodsRecommend', data?.isRecommend ?? '');
   }, [data, setValue]);
 }