Browse Source

feat: 增加其他出功能

xyh 2 years ago
parent
commit
2beb7d9132

+ 32 - 0
packages/app/src/apis/queryList.ts

@@ -21,6 +21,7 @@ import {
   GSErrorListData,
   GetOtherInParams,
   OtherInListData,
+  GetOtherOutParams,
 } from '@models';
 import {request} from './request';
 
@@ -304,3 +305,34 @@ export function getOtherIn(
     signal,
   });
 }
+
+/** 其他出库 */
+export function getOtherOut(
+  data: GetOtherOutParams,
+  signal?: AbortSignal,
+): BaseListResult<any> {
+  return request({
+    method: 'GET',
+    data,
+    url: `${BASE_URL}/getOtherShipments`,
+    signal,
+  });
+}
+
+/** 删除其他入库 */
+export function deleteOtherIn(id: string) {
+  return request({
+    method: 'DELETE',
+    data: {id},
+    url: '/warehousing/delOtherReceivingGoods',
+  });
+}
+
+/** 删除其他出库 */
+export function deleteOtherOut(id: string) {
+  return request({
+    method: 'DELETE',
+    data: {id},
+    url: '/warehousing/delOtherShipments',
+  });
+}

+ 21 - 0
packages/app/src/models/request/queryList.ts

@@ -183,4 +183,25 @@ export type GetOtherInParams = {
   /** 所属公司 */
   companyNumber: string;
   wbs: string;
+  /** 入库状态 0 出库完成 1 出库未完成 '' 全部 */
+  type: '' | '0' | '1';
+} & ListParams;
+
+/** 其他出库 */
+export type GetOtherOutParams = {
+  /** 出库单编号 */
+  askGoodsCode: string;
+  /** 物料编号 */
+  materialCode: string;
+  /** 物料名称 */
+  materialName: string;
+  startTime: string;
+  endTime: string;
+  /** 所属公司 */
+  companyNumber: string;
+  wbs: string;
+  /** 所属部门 */
+  departmentCode: string;
+  /** 出库状态 0 出库完成 1 出库未完成 '' 全部 */
+  type: '' | '0' | '1';
 } & ListParams;

+ 38 - 0
packages/app/src/models/response/queryList.ts

@@ -370,3 +370,41 @@ export type OtherInListData = {
   /**  物料编号 */
   materialCode: string;
 };
+
+/** 其他出库数据 */
+export type OtherOutListData = {
+  id: string;
+  /** 其他入库ID */
+  askGoodsId: string;
+  /** 其他入库编号 */
+  askGoodsCode: string;
+  /** 公司编号 */
+  companyNumber: string;
+  /** 通知时间 */
+  sqrq: Date;
+  /** 来源类型 */
+  sourceType: string;
+  /** 移动类型 */
+  moveType: string;
+  /** 分录号 */
+  entryNumber: string;
+  /** 物料id */
+  materialId: string;
+  wbs: string;
+  /** 计量单位 */
+  measurementId: string;
+  /** shuliang  */
+  num: string;
+  /** 出库数量 */
+  outNum: string;
+  /** 物料名称 */
+  materialName: string;
+  /** 公司名称 */
+  companyName: string;
+  /** 物料类别 */
+  partType: string;
+  /**  物料编号 */
+  materialCode: string;
+  /** 所属部门 */
+  department: string;
+};

+ 2 - 0
packages/app/src/pages/order-log/filter/index.tsx

@@ -22,6 +22,8 @@ const options = [
   {label: '报工单', value: '报工单'},
   {label: '交货单', value: '交货单'},
   {label: '移库单', value: '移库单'},
+  {label: '其他入库', value: '其他入库'},
+  {label: '其他出库', value: '其他出库'},
 ];
 
 const Filter: FC = function () {

+ 21 - 0
packages/app/src/pages/other-out/context.ts

@@ -0,0 +1,21 @@
+import {
+  createPageContext,
+  createSearchContext,
+  createTableSearchContext,
+} from '@hooks';
+import {GetOtherOutParams, OriginalListParams} from '@models';
+
+export const searchContext = createSearchContext();
+export const pageContext = createPageContext();
+export const contextState: OriginalListParams<GetOtherOutParams> = {
+  askGoodsCode: '',
+  materialCode: '',
+  materialName: '',
+  startTime: '',
+  endTime: '',
+  companyNumber: '',
+  wbs: '',
+  departmentCode: '',
+  type: '',
+};
+export const context = createTableSearchContext(contextState);

+ 66 - 0
packages/app/src/pages/other-out/filter/index.tsx

@@ -0,0 +1,66 @@
+import {
+  useContextSection,
+  useFilterDB,
+  useFilterField,
+  useRangeDate,
+  useTableSearchToolEvents,
+} from '@hooks';
+import {FC} from 'react';
+import {context, contextState, searchContext} from '../context';
+import {FilterSelectorModal, FilterTool} from '@components';
+import {fixedMap, sourceMap} from './state';
+
+const Filter: FC = function () {
+  const [fields, {onChange, resetState}] = useFilterField(
+    {
+      ...contextState,
+    },
+    true,
+  );
+  const [{dates, start, end}, onDatesChange] = useRangeDate();
+  const [visible, {onSearch, onReset, onShowModal, onCloseModal}] =
+    useTableSearchToolEvents(
+      context,
+      {...fields, startTime: start, endTime: end},
+      {
+        resetCallback() {
+          resetState();
+          onDatesChange([null, null]);
+        },
+      },
+    );
+  const isSearching = useContextSection(
+    searchContext,
+    state => state[0].isSearching,
+  );
+  const [filterList, {set}] = useFilterDB();
+
+  return (
+    <>
+      <FilterTool
+        fields={fields}
+        dates={dates}
+        onChange={onChange}
+        onDatesChange={onDatesChange}
+        onReset={onReset}
+        onSearch={onSearch}
+        onFilter={onShowModal}
+        filterData={filterList}
+        sourceMap={sourceMap}
+        fixedMap={fixedMap}
+        isSearching={isSearching}
+        testId='other_out_filter'
+      />
+
+      <FilterSelectorModal
+        visible={visible}
+        onClose={onCloseModal}
+        filtermap={sourceMap}
+        source={filterList}
+        onConfirm={set}
+      />
+    </>
+  );
+};
+
+export default Filter;

+ 43 - 0
packages/app/src/pages/other-out/filter/state.ts

@@ -0,0 +1,43 @@
+import {FilterGroupMap, MapValue} from '@components';
+import {contextState} from '../context';
+
+export const fixedMap: MapValue<typeof contextState>[] = [
+  {type: 'field', value: 'askGoodsCode', label: '出库单编号'},
+  {type: 'field', value: 'materialCode', label: '物料编号'},
+  {type: 'field', value: 'materialName', label: '物料名称'},
+];
+
+export const sourceMap: FilterGroupMap<typeof contextState> = new Map([
+  ['1', {type: 'date', label: '通知时间', value: 'startTime'}],
+  [
+    '2',
+    {
+      type: 'keySelect',
+      label: '所属公司',
+      selectKey: '公司',
+      value: 'startTime',
+    },
+  ],
+  ['3', {type: 'field', label: 'WBS编号', value: 'wbs'}],
+  [
+    '4',
+    {
+      type: 'keySelect',
+      selectKey: '部门字典',
+      label: '领用部门',
+      value: 'departmentCode',
+    },
+  ],
+  [
+    '5',
+    {
+      type: 'select',
+      label: '出库状态',
+      value: 'type',
+      options: [
+        {label: '已完成', value: '1'},
+        {label: '未完成', value: '0'},
+      ],
+    },
+  ],
+]);

+ 22 - 0
packages/app/src/pages/other-out/index.tsx

@@ -0,0 +1,22 @@
+import {PageProvider, SearchProvider, TableSearchProvider} from '@components';
+import {FC} from 'react';
+import {context, contextState, pageContext, searchContext} from './context';
+import Filter from './filter';
+import TableList from './table';
+
+const OtherOut: FC = function () {
+  return (
+    <TableSearchProvider context={context} state={contextState}>
+      <PageProvider context={pageContext}>
+        <SearchProvider context={searchContext}>
+          <section className='content-main'>
+            <Filter />
+            <TableList />
+          </section>
+        </SearchProvider>
+      </PageProvider>
+    </TableSearchProvider>
+  );
+};
+
+export default OtherOut;

+ 67 - 0
packages/app/src/pages/other-out/table/hooks.tsx

@@ -0,0 +1,67 @@
+import {deleteOtherOut} from '@apis';
+import {useSupertube, useTableDeleteEvent} from '@hooks';
+import {OtherOutListData} from '@models';
+import {
+  HUGE_TABLE_WIDTH,
+  LARGE_TABLE_WIDTH,
+  NORMAL_TABLE_WIDTH,
+  SMALL_TABLE_WIDTH,
+} from '@utils';
+import {Button} from 'antd';
+import {ColumnsType} from 'antd/es/table';
+
+const columns: ColumnsType<OtherOutListData> = [
+  {title: ' 出库单编号', dataIndex: 'askGoodsCode', width: LARGE_TABLE_WIDTH},
+  {title: '物料编号', dataIndex: 'materialCode', width: LARGE_TABLE_WIDTH},
+  {title: '物料名称', dataIndex: 'materialName', width: HUGE_TABLE_WIDTH},
+  {
+    title: '出库数量',
+    dataIndex: 'num',
+    width: SMALL_TABLE_WIDTH,
+    align: 'right',
+  },
+  {
+    title: '已出库数量',
+    dataIndex: 'outNum',
+    width: NORMAL_TABLE_WIDTH,
+    align: 'right',
+  },
+  {title: '所属公司', dataIndex: 'companyName', width: LARGE_TABLE_WIDTH},
+  {title: '公司编号', dataIndex: 'companyNumber', width: SMALL_TABLE_WIDTH},
+  {title: '领用部门', dataIndex: 'department', width: NORMAL_TABLE_WIDTH},
+  {title: '通知时间', dataIndex: 'sqrq', width: NORMAL_TABLE_WIDTH},
+  {title: 'WBS编号', dataIndex: 'wbs', width: NORMAL_TABLE_WIDTH},
+];
+
+export function useColumns(refetch: () => void) {
+  const isSuper = useSupertube();
+  const [pendingId, onDelete] = useTableDeleteEvent(deleteOtherOut, refetch, {
+    label: '其他出库',
+  });
+
+  const tableColumns: ColumnsType<OtherOutListData> = [
+    ...columns,
+    {
+      title: '操作',
+      dataIndex: 'id',
+      width: SMALL_TABLE_WIDTH,
+      fixed: 'right',
+      render(_, {id, askGoodsCode}) {
+        return (
+          <>
+            <Button
+              type='text'
+              danger
+              loading={pendingId === id}
+              onClick={onDelete(id, askGoodsCode)}
+            >
+              删除
+            </Button>
+          </>
+        );
+      },
+    },
+  ];
+
+  return isSuper ? tableColumns : columns;
+}

+ 35 - 0
packages/app/src/pages/other-out/table/index.tsx

@@ -0,0 +1,35 @@
+import {useContextSection, useQueryTableList} from '@hooks';
+import {FC} from 'react';
+import {context, pageContext, searchContext} from '../context';
+import {getOtherOut} from '@apis';
+import {useColumns} from './hooks';
+import {Table, TableTools} from '@components';
+import {Card} from 'antd';
+
+const TableList: FC = function () {
+  const params = useContextSection(context, state => state[0]);
+  const [{data, count, isFetching}, {refetch}] = useQueryTableList({
+    queryFn: getOtherOut,
+    pageContext,
+    searchContext,
+    params,
+  });
+  const columns = useColumns(refetch);
+
+  return (
+    <Card className='table-wrapper'>
+      <TableTools isRefreshing={isFetching} onRefresh={refetch} />
+
+      <Table
+        data={data}
+        columns={columns}
+        count={count}
+        pageContext={pageContext}
+        searchContext={searchContext}
+        data-testid='other_out_table'
+      />
+    </Card>
+  );
+};
+
+export default TableList;

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

@@ -37,6 +37,7 @@ import {
   INVENTORY_PATH,
   GS_ERROR_LOG_PATH,
   OTHER_IN_PATH,
+  OTHER_OUT_PATH,
 } from './name';
 import {
   Container,
@@ -74,6 +75,7 @@ import {
   Login,
   GSErrorLog,
   OtherIn,
+  OtherOut,
 } from './routes';
 import Main from '@pages/main';
 import Home from '@pages/home';
@@ -120,6 +122,7 @@ export const routes: RouteObject[] = [
       {path: INVENTORY_PATH, element: <Inventory />},
       {path: GS_ERROR_LOG_PATH, element: <GSErrorLog />},
       {path: OTHER_IN_PATH, element: <OtherIn />},
+      {path: OTHER_OUT_PATH, element: <OtherOut />},
     ],
   },
   {path: NO_PERMISSION_PATH, element: <NoPermision />},

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

@@ -97,3 +97,5 @@ export const INVENTORY_PATH = '/inventory';
 export const GS_ERROR_LOG_PATH = '/log/error';
 /** 其他入库 */
 export const OTHER_IN_PATH = '/other/in';
+/** 其他出库 */
+export const OTHER_OUT_PATH = '/other/out';

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

@@ -200,3 +200,6 @@ export const GSErrorLog = lazy(
 export const OtherIn = lazy(
   () => import(/* webpackChunkName: "otherIn" */ '@pages/other-in'),
 );
+export const OtherOut = lazy(
+  () => import(/* webpackChunkName: "otherOut" */ '@pages/other-out'),
+);