Browse Source

modify: 半成品领料可以领取多次

xyh 2 năm trước cách đây
mục cha
commit
9a7467a0be

+ 50 - 9
packages/app/src/pages/semi-draw/table/hooks.tsx

@@ -13,17 +13,49 @@ import {
 import {useSupertube, useTableDeleteEvent, useTableModalEvent} from '@hooks';
 
 const tableColumns: ColumnsType<SemiDrawListData> = [
-  {title: '要货单编号', dataIndex: 'askGoodsId', key: 'askGoodsId', width: MIDDLE_TABLE_WIDTH},
+  {
+    title: '要货单编号',
+    dataIndex: 'askGoodsId',
+    key: 'askGoodsId',
+    width: MIDDLE_TABLE_WIDTH,
+  },
   {
     title: '生产订单号',
     dataIndex: 'productionCode',
     key: 'productionCode',
     width: MIDDLE_TABLE_WIDTH,
   },
-  {title: '物料编号', dataIndex: 'materialCode', key: 'materialCode', width: LARGE_TABLE_WIDTH},
-  {title: '物料名称', dataIndex: 'materialName', key: 'materialName', width: HUGE_TABLE_WIDTH},
-  {title: '数量', dataIndex: 'num', key: 'num', width: SMALL_TABLE_WIDTH, align: 'right'},
-  {title: '要料部门', dataIndex: 'department', key: 'department', width: NORMAL_TABLE_WIDTH},
+  {
+    title: '物料编号',
+    dataIndex: 'materialCode',
+    key: 'materialCode',
+    width: LARGE_TABLE_WIDTH,
+  },
+  {
+    title: '物料名称',
+    dataIndex: 'materialName',
+    key: 'materialName',
+    width: HUGE_TABLE_WIDTH,
+  },
+  {
+    title: '需求数量',
+    dataIndex: 'num',
+    key: 'num',
+    width: SMALL_TABLE_WIDTH,
+    align: 'right',
+  },
+  {
+    title: '出库数量',
+    dataIndex: 'outNum',
+    width: SMALL_TABLE_WIDTH,
+    align: 'right',
+  },
+  {
+    title: '要料部门',
+    dataIndex: 'department',
+    key: 'department',
+    width: NORMAL_TABLE_WIDTH,
+  },
   {title: '所属公司', dataIndex: 'companyName', width: HUGE_TABLE_WIDTH},
   {title: '分录号', dataIndex: 'entryNumber', width: NORMAL_TABLE_WIDTH},
   {title: '移动类型', dataIndex: 'moveType', width: NORMAL_TABLE_WIDTH},
@@ -42,9 +74,13 @@ const tableColumns: ColumnsType<SemiDrawListData> = [
 ];
 
 export function useHandle(refetch: () => void) {
-  const [deleteId, onDelete] = useTableDeleteEvent(delProductionRequisition, refetch, {
-    label: '半成品领料单',
-  });
+  const [deleteId, onDelete] = useTableDeleteEvent(
+    delProductionRequisition,
+    refetch,
+    {
+      label: '半成品领料单',
+    },
+  );
   const [{visible, editId: putOutId}, {onClose, onEdit}] = useTableModalEvent();
 
   const isSuper = useSupertube();
@@ -68,7 +104,12 @@ export function useHandle(refetch: () => void) {
               {type === '0' ? '出库' : '已出库'}
             </Button>
             {isSuper && (
-              <Button type='text' danger loading={deleteId === id} onClick={onDelete(id)}>
+              <Button
+                type='text'
+                danger
+                loading={deleteId === id}
+                onClick={onDelete(id)}
+              >
                 删除
               </Button>
             )}

+ 23 - 11
packages/app/src/pages/semi-draw/table/put-out-modal/hooks.ts

@@ -6,7 +6,7 @@ import {useMutation, useQueryClient} from '@tanstack/react-query';
 import {message} from 'antd';
 import {useEffect, useMemo} from 'react';
 import {useForm} from 'react-hook-form';
-import {object, string} from 'yup';
+import {number, object, string} from 'yup';
 import {useStore} from 'zustand';
 
 type FormState = {
@@ -14,11 +14,17 @@ type FormState = {
   warehouse: string;
   /** 库位id */
   location: string;
+  /** 出库数量 */
+  outNum: number;
 };
 
 const validate = object({
   warehouse: string().required('请选择仓库'),
   location: string().required('请选择库位'),
+  outNum: number()
+    .typeError('请输入数字')
+    .required('请输入出库数量')
+    .min(1, '出库数量不能小于1个'),
 });
 
 function useData(id: string) {
@@ -26,9 +32,12 @@ function useData(id: string) {
 
   return useMemo(
     function () {
-      const data = client.getQueryData<SemiDrawListData[]>([getSemiManufacturesDrawList.name], {
-        exact: false,
-      });
+      const data = client.getQueryData<SemiDrawListData[]>(
+        [getSemiManufacturesDrawList.name],
+        {
+          exact: false,
+        },
+      );
       if (!data) return void 0;
 
       return data.find(val => val.id === id);
@@ -48,10 +57,12 @@ export function useFormState({
   onClose: () => void;
   onFetch: () => void;
 }) {
-  const {control, handleSubmit, reset, clearErrors, watch} = useForm<FormState>({
-    resolver: yupResolver(validate),
-    defaultValues: {warehouse: '', location: ''},
-  });
+  const {control, handleSubmit, reset, clearErrors, watch} = useForm<FormState>(
+    {
+      resolver: yupResolver(validate),
+      defaultValues: {warehouse: '', outNum: 0, location: ''},
+    },
+  );
 
   useEffect(
     function () {
@@ -78,15 +89,16 @@ export function useFormState({
 
   const userId = useStore(userStore, state => String(state.id));
 
-  const onSubmit = handleSubmit(function ({location}) {
+  const onSubmit = handleSubmit(function ({location, outNum}) {
     if (!data) return message.error('未获取到领料单信息');
-    const {companyNumber, wbs, materialId, askGoodsId, num, materialCode} = data;
+
+    const {companyNumber, wbs, materialId, askGoodsId, materialCode} = data;
 
     mutate({
       companyNumber,
       wbs,
       materialId,
-      warehousingNum: num,
+      warehousingNum: String(outNum),
       askGoodsId,
       wllbCode: materialCode,
       storageLocationCode: location,

+ 15 - 3
packages/app/src/pages/semi-draw/table/put-out-modal/index.tsx

@@ -1,4 +1,4 @@
-import {Modal, ModalSelect} from '@components';
+import {Modal, ModalField, ModalSelect} from '@components';
 import {FC, useMemo} from 'react';
 import {useFormState} from './hooks';
 import {useDictionaryOptions, useStorageOptions} from '@hooks';
@@ -12,7 +12,8 @@ type Props = {
 
 const PutOutModal: FC<Props> = function (props) {
   const [{control, isLoading}, {onSubmit, watch}] = useFormState(props);
-  const {data: warehouse, isFetching: isWarehoseFetching} = useDictionaryOptions('仓库');
+  const {data: warehouse, isFetching: isWarehoseFetching} =
+    useDictionaryOptions('仓库');
   const warehouseOptions = useMemo(
     function () {
       return warehouse.filter(val => val?.type === '1');
@@ -29,7 +30,18 @@ const PutOutModal: FC<Props> = function (props) {
   );
 
   return (
-    <Modal {...props} title='选择库位信息' onSubmit={onSubmit} isLoading={isLoading}>
+    <Modal
+      {...props}
+      title='选择库位信息'
+      onSubmit={onSubmit}
+      isLoading={isLoading}
+    >
+      <ModalField
+        label='出库数量'
+        type='number'
+        name='outNum'
+        control={control}
+      />
       <ModalSelect
         data={warehouseOptions}
         control={control}