Browse Source

chore: 移除旧版其他入其他出

xyh 2 years ago
parent
commit
99300924c2

+ 0 - 115
packages/app/src/pages/stock-in/hooks.ts

@@ -1,115 +0,0 @@
-import {otherIn, otherInGetStockInfo} from '@apis';
-import {yupResolver} from '@hookform/resolvers/yup';
-import {GetOtherInGetStockInfoParams, OtherStockInParams} from '@models';
-import {userStore} from '@stores';
-import {useMutation} from '@tanstack/react-query';
-import {message} from 'antd';
-import {FormEvent} from 'react';
-import {useForm} from 'react-hook-form';
-import {number, object, string} from 'yup';
-
-type FormState = {
-  /** 物料编号 */
-  materialCode: string;
-  /** 所属公司 */
-  accountSleeve: string;
-  /** wbs */
-  wbs: string;
-  /** 数量 */
-  num: number;
-  /** 库位信息 */
-  storageLocationCode: string;
-  /** 仓库信息 */
-  warehouse: string;
-};
-
-async function submitQuery(
-  params: GetOtherInGetStockInfoParams & {amount: string},
-) {
-  const data = await otherInGetStockInfo(params);
-  if (data.msg === '200') {
-    /**
-     * 获取库存信息
-     * 如果有库存使用第一个库存入库
-     * 如果没有库存传入库位信息进行新增入库
-     */
-    const {department} = userStore.getState();
-    const inParams: OtherStockInParams = {
-      ...params,
-      departmentId: department,
-      id: data.list.length > 0 ? data.list[0].id : null,
-      producDate: '',
-    };
-
-    const result = await otherIn(inParams);
-
-    return result;
-  }
-
-  return data;
-}
-
-const validate = object({
-  materialCode: string().required('请输入物料编号'),
-  accountSleeve: string().required('请选择公司'),
-  wbs: string().required('请输入WBS编号'),
-  num: number()
-    .typeError('请输入数字')
-    .required('请输入数量')
-    .min(1, '数量不能小于1个'),
-  storageLocationCode: string().required('请选择入库库位'),
-  warehouse: string().required('请选择入库仓库'),
-});
-
-export function useFormState() {
-  const {control, clearErrors, reset, handleSubmit, watch} = useForm<FormState>(
-    {
-      resolver: yupResolver(validate),
-      defaultValues: {
-        materialCode: '',
-        accountSleeve: '',
-        wbs: '',
-        num: 1,
-        storageLocationCode: '',
-        warehouse: '',
-      },
-    },
-  );
-
-  const {isLoading, mutate} = useMutation({
-    mutationFn: submitQuery,
-    onSuccess({msg}) {
-      if (msg === '200') {
-        message.success('入库成功');
-        clearErrors();
-        reset();
-      }
-    },
-  });
-
-  const onSubmit = handleSubmit(function ({
-    wbs,
-    storageLocationCode,
-    materialCode,
-    accountSleeve,
-    num,
-  }) {
-    mutate({
-      wllbCode: materialCode,
-      accountSleeve,
-      wbs,
-      storageLocationCode,
-      amount: String(num),
-    });
-  });
-
-  function onReset(e: FormEvent) {
-    e.preventDefault();
-    reset();
-  }
-
-  return [
-    {control, isLoading},
-    {onSubmit, watch, onReset},
-  ] as const;
-}

+ 0 - 4
packages/app/src/pages/stock-in/index.module.css

@@ -1,4 +0,0 @@
-.form {
-  max-width: 600px;
-  margin: 0 auto;
-}

+ 0 - 94
packages/app/src/pages/stock-in/index.tsx

@@ -1,94 +0,0 @@
-import {Button, Card, Space} from 'antd';
-import {FC, useMemo} from 'react';
-import css from './index.module.css';
-import {useFormState} from './hooks';
-import {FormField, FormSelect} from '@components';
-import {
-  useDictionaryWidthCode,
-  useMaterialOptions,
-  useStorageOptions,
-} from '@hooks';
-
-const StockIn: FC = function () {
-  const [{control, isLoading}, {onSubmit, watch, onReset}] = useFormState();
-  const {data: materialOptions, isFetching} = useMaterialOptions();
-  const [{data: corporationOptions, isFetching: isCorporationFetching}] =
-    useDictionaryWidthCode('公司', {
-      enabled: true,
-      findValue: state => state.code,
-    });
-  const [{data: warehouseOptions, isFetching: isWarehouseFetching}] =
-    useDictionaryWidthCode('仓库', {enabled: true});
-  const halfWarehouseOptions = useMemo(
-    function () {
-      return warehouseOptions.filter(val => val.type === '1');
-    },
-    [warehouseOptions],
-  );
-  const warehouseId = watch('warehouse');
-  const {data: locationOptions, isFetching: isLocationFetching} =
-    useStorageOptions(false, state => state.storageLocationCode, {
-      id: warehouseId,
-    });
-
-  return (
-    <section className='content-main ant-card-title-reset'>
-      <Card title='半成品其他入库'>
-        <form className={css.form} onSubmit={onSubmit} onReset={onReset}>
-          <Space direction='vertical' className='width-full'>
-            <FormSelect
-              loading={isFetching}
-              options={materialOptions}
-              control={control}
-              label='入库物料'
-              name='materialCode'
-              showSearch
-              placeholder='请输入物料编号'
-            />
-            <FormSelect
-              loading={isWarehouseFetching}
-              options={halfWarehouseOptions}
-              control={control}
-              label='所属仓库'
-              name='warehouse'
-              showSearch
-            />
-            <FormSelect
-              loading={isLocationFetching}
-              options={locationOptions}
-              control={control}
-              label='所属库位'
-              name='storageLocationCode'
-              showSearch
-            />
-            <FormSelect
-              loading={isCorporationFetching}
-              options={corporationOptions}
-              control={control}
-              label='所属公司'
-              name='accountSleeve'
-            />
-            <FormField control={control} name='wbs' label='WBS编号' />
-            <FormField
-              control={control}
-              name='num'
-              label='入库数量'
-              type='number'
-            />
-
-            <Space className='width-full' style={{justifyContent: 'flex-end'}}>
-              <Button htmlType='reset' disabled={isLoading}>
-                重置
-              </Button>
-              <Button htmlType='submit' type='primary' loading={isLoading}>
-                确认入库
-              </Button>
-            </Space>
-          </Space>
-        </form>
-      </Card>
-    </section>
-  );
-};
-
-export default StockIn;

+ 0 - 86
packages/app/src/pages/stock-out/hooks.ts

@@ -1,86 +0,0 @@
-import {otherOut} from '@apis';
-import {yupResolver} from '@hookform/resolvers/yup';
-import {userStore} from '@stores';
-import {useMutation} from '@tanstack/react-query';
-import {message} from 'antd';
-import {FormEvent} from 'react';
-import {useForm} from 'react-hook-form';
-import {number, object, string} from 'yup';
-import {useStore} from 'zustand';
-
-type FormState = {
-  wllbCode: string;
-  storageLocationCode: string;
-  num: number;
-  wbs: string;
-  accountSleeve: string;
-  warehouse: string;
-};
-
-const validate = object({
-  wllbCode: string().required('请输入物料编号'),
-  warehouse: string().required('请选择出库仓库'),
-  storageLocationCode: string().required('请选择出库库位'),
-  wbs: string().required('请输入wbs编号'),
-  accountSleeve: string().required('请选择所属公司'),
-  num: number().typeError('请输入出库数量').min(1, '出库数量不能小于1个'),
-});
-
-export function useFormState() {
-  const {control, reset, handleSubmit, clearErrors, watch} = useForm<FormState>(
-    {
-      resolver: yupResolver(validate),
-      defaultValues: {
-        wllbCode: '',
-        storageLocationCode: '',
-        num: 1,
-        warehouse: '',
-        wbs: '',
-        accountSleeve: '',
-      },
-    },
-  );
-
-  function onReset(e: FormEvent) {
-    e.preventDefault();
-    reset();
-  }
-
-  const {mutate, isLoading} = useMutation({
-    mutationFn: otherOut,
-    onSuccess({msg}) {
-      if (msg === '200') {
-        reset();
-        clearErrors();
-        message.success('出库成功');
-      }
-    },
-  });
-
-  const {userId, department} = useStore(userStore, state => ({
-    userId: String(state.id),
-    department: state.department,
-  }));
-  const onSubmit = handleSubmit(function ({
-    wllbCode,
-    storageLocationCode,
-    num,
-    wbs,
-    accountSleeve,
-  }) {
-    mutate({
-      userId,
-      department,
-      wllbCode,
-      storageLocationCode,
-      num: String(num),
-      wbs,
-      accountSleeve,
-    });
-  });
-
-  return [
-    {isLoading, control},
-    {onSubmit, onReset, watch},
-  ] as const;
-}

+ 0 - 4
packages/app/src/pages/stock-out/index.module.css

@@ -1,4 +0,0 @@
-.form {
-  max-width: 600px;
-  margin: 0 auto;
-}

+ 0 - 93
packages/app/src/pages/stock-out/index.tsx

@@ -1,93 +0,0 @@
-import {Button, Card, Space} from 'antd';
-import {FC, useMemo} from 'react';
-import css from './index.module.css';
-import {FormField, FormSelect} from '@components';
-import {useFormState} from './hooks';
-import {
-  useDictionaryWidthCode,
-  useMaterialOptions,
-  useStorageOptions,
-} from '@hooks';
-
-const OtherStockOut: FC = function () {
-  const [{control, isLoading}, {onSubmit, onReset, watch}] = useFormState();
-  const {data: materialOptions, isFetching} = useMaterialOptions();
-  const [{data: warehouseOptions, isFetching: isWarehouseFetching}] =
-    useDictionaryWidthCode('仓库', {enabled: true});
-  const halfWarehouseOptions = useMemo(
-    function () {
-      return warehouseOptions.filter(val => val.type === '1');
-    },
-    [warehouseOptions],
-  );
-  const warehouseId = watch('warehouse');
-  const {data: locationOptions, isFetching: isLocationFetching} =
-    useStorageOptions(false, state => state.storageLocationCode, {
-      id: warehouseId,
-    });
-  const [{data: corporationOptions, isFetching: isCorporationFetching}] =
-    useDictionaryWidthCode('公司', {
-      enabled: true,
-      findValue: state => state.code,
-    });
-
-  return (
-    <section className='content-main ant-card-title-reset'>
-      <Card title='半成品其他出库'>
-        <form className={css.form} onSubmit={onSubmit} onReset={onReset}>
-          <Space direction='vertical' className='width-full'>
-            <FormSelect
-              loading={isFetching}
-              options={materialOptions}
-              control={control}
-              label='出库物料'
-              name='wllbCode'
-              showSearch
-              placeholder='请输入物料编号'
-            />
-            <FormSelect
-              loading={isWarehouseFetching}
-              options={halfWarehouseOptions}
-              control={control}
-              label='所属仓库'
-              name='warehouse'
-              showSearch
-            />
-            <FormSelect
-              loading={isLocationFetching}
-              options={locationOptions}
-              control={control}
-              label='所属库位'
-              name='storageLocationCode'
-              showSearch
-            />{' '}
-            <FormSelect
-              loading={isCorporationFetching}
-              options={corporationOptions}
-              control={control}
-              label='所属公司'
-              name='accountSleeve'
-            />
-            <FormField control={control} name='wbs' label='WBS编号' />
-            <FormField
-              control={control}
-              name='num'
-              label='出库数量'
-              type='number'
-            />
-            <Space className='width-full' style={{justifyContent: 'flex-end'}}>
-              <Button htmlType='reset' disabled={isLoading}>
-                重置
-              </Button>
-              <Button htmlType='submit' type='primary' loading={isLoading}>
-                确认出库
-              </Button>
-            </Space>
-          </Space>
-        </form>
-      </Card>
-    </section>
-  );
-};
-
-export default OtherStockOut;

+ 0 - 6
packages/app/src/routes/index.tsx

@@ -36,8 +36,6 @@ import {
   ORDER_LOG_PATH,
   INVENTORY_PATH,
   GS_ERROR_LOG_PATH,
-  PUT_IN_STORAGE,
-  PUT_OUT_STORAGE,
 } from './name';
 import {
   Container,
@@ -74,8 +72,6 @@ import {
   Inventory,
   Login,
   GSErrorLog,
-  PutInStorageWithOther,
-  PutOutStorageWithOther,
 } from './routes';
 import Main from '@pages/main';
 import Home from '@pages/home';
@@ -121,8 +117,6 @@ export const routes: RouteObject[] = [
       {path: ORDER_LOG_PATH, element: <OrderDeleteLog />},
       {path: INVENTORY_PATH, element: <Inventory />},
       {path: GS_ERROR_LOG_PATH, element: <GSErrorLog />},
-      {path: PUT_IN_STORAGE, element: <PutInStorageWithOther />},
-      {path: PUT_OUT_STORAGE, element: <PutOutStorageWithOther />},
     ],
   },
   {path: NO_PERMISSION_PATH, element: <NoPermision />},

+ 0 - 4
packages/app/src/routes/name.ts

@@ -95,7 +95,3 @@ export const ORDER_LOG_PATH = '/log/order';
 export const INVENTORY_PATH = '/inventory';
 /** gs错误日志 */
 export const GS_ERROR_LOG_PATH = '/log/error';
-/** 半成品其他入库 */
-export const PUT_IN_STORAGE = '/putin/other';
-/** 半成品其他出库 */
-export const PUT_OUT_STORAGE = '/putout/other';

+ 0 - 8
packages/app/src/routes/routes.tsx

@@ -197,11 +197,3 @@ export const Inventory = lazy(
 export const GSErrorLog = lazy(
   () => import(/* webpackChunkName: "gsErrorLog" */ '@pages/gs-error-log'),
 );
-export const PutInStorageWithOther = lazy(
-  () =>
-    import(/* webpackChunkName: "putInStorageWithOther" */ '@pages/stock-in'),
-);
-export const PutOutStorageWithOther = lazy(
-  () =>
-    import(/* webpackChunkName: "putOutStorageWithOther" */ '@pages/stock-out'),
-);