Procházet zdrojové kódy

feat: 半成品入库流水

xyh před 2 roky
rodič
revize
bd32b4f8bd

+ 3 - 1
packages/app/src/apis/request.ts

@@ -13,11 +13,13 @@ const http = axios.create({
   timeout: 5000,
 });
 
+const exportUrlList = ['productExcel', 'getRemovalHalfProductExcel'];
 const exportReg = /export/i;
 
 http.interceptors.request.use(function(config) {
   if (config?.url) {
-    const isExport = exportReg.test(config.url);
+    const isExport = exportReg.test(config.url)
+    || exportUrlList.some(val => config.url ? config.url.includes(val) : false);
     isExport && (config.responseType = 'blob');
   }
 

+ 8 - 5
packages/app/src/apis/stream.ts

@@ -7,6 +7,7 @@ import {
   GetWarehousingFlowingListParams,
   NoticeListData,
   RawMaterialOutStreamListData,
+  SemiInStreamListData,
   SemiManufacturesAddParams,
   SemiManufacturesOutParams,
   WarehousingListData,
@@ -98,10 +99,10 @@ export function semiManufacturesOut(data: SemiManufacturesOutParams): BaseResult
 /** 半成品入库流水单 */
 export function getSemiManufacturesInStream(
   data: GetWarehousingFlowingListParams,
-): BaseListResult<any> {
+): BaseListResult<SemiInStreamListData> {
   return request({
     method: 'GET',
-    url: `${BASE_URL}/getNotice`,
+    url: `${BASE_URL}/getProduct`,
     data,
   });
 }
@@ -114,6 +115,7 @@ export function exportSemiManufacturesInStream(
     method: 'GET',
     url: `${BASE_URL}/productExcel`,
     data,
+    skipError: true,
   });
 }
 
@@ -123,7 +125,7 @@ export function getSemiManufacturesDrawList(
 ): BaseListResult<any> {
   return request({
     method: 'GET',
-    url: 'askGoods/getGoodsHalf',
+    url: '/askGoods/getGoodsHalf',
     data,
   });
 }
@@ -134,7 +136,7 @@ export function getSemiManufacturesDrawStream(
 ): BaseListResult<any> {
   return request({
     method: 'GET',
-    url: 'askGoods/getRemovalHalfProduct',
+    url: '/askGoods/getRemovalHalfProduct',
     data,
   });
 }
@@ -145,7 +147,8 @@ export function exportSemiManufacturesDrawStream(
 ): any {
   return request({
     method: 'GET',
-    url: 'askGoods/getRemovalHalfProductExcel',
+    url: '/askGoods/getRemovalHalfProductExcel',
     data,
+    skipError: true,
   });
 }

+ 15 - 0
packages/app/src/models/response/stream.ts

@@ -169,3 +169,18 @@ export type NoticeListData = {
   */
   wllbClass: string;
 };
+
+/** 半成品入库流水 */
+export type SemiInStreamListData = {
+  id: string;
+  /** 物料名称 */
+  materialName: string;
+  /** 入库数量 */
+  warehousingNum: string;
+  /** 入库人 */
+  userName: string;
+  /** 生产时间 */
+  producBatch: string;
+  /** 入库时间 */
+  scrq: string;
+};

+ 14 - 1
packages/app/src/pages/semi-in-stream/context.ts

@@ -1,4 +1,11 @@
-import {createPageContext, createSearchContext, createTableSearchContext} from '@hooks';
+import {
+  TableSearchAction,
+  createPageContext,
+  createSearchContext,
+  createTableSearchContext,
+} from '@hooks';
+import {GetWarehousingFlowingListParams, OriginalListParams} from '@models';
+import {Dispatch} from 'react';
 
 export const pageContext = createPageContext();
 export const searchContext = createSearchContext();
@@ -9,3 +16,9 @@ export const contextState = {
   endTime: '',
 };
 export const context = createTableSearchContext(contextState);
+type ContextState = typeof contextState;
+export function contextStateSelector(
+  [{startTime, endTime, code}]: [ContextState, Dispatch<TableSearchAction<ContextState>>],
+): OriginalListParams<GetWarehousingFlowingListParams> {
+  return {startTime, endTime, wllbCode: code};
+}

+ 33 - 0
packages/app/src/pages/semi-in-stream/filter/hooks.ts

@@ -0,0 +1,33 @@
+import {useContextSection, useExportFile, usePage, useTableSearchState} from '@hooks';
+import {context, contextStateSelector, pageContext, searchContext} from '../context';
+import {exportSemiManufacturesInStream} from '@apis';
+
+export function useSearch(code: string, startTime: string, endTime: string) {
+  const [isSearching] = useTableSearchState(searchContext);
+  const dispatch = useContextSection(context, state => state[1]);
+
+  function onSearch() {
+    dispatch({type: 'SEARCH', payload: {startTime, endTime, code}});
+  }
+
+  return [isSearching, onSearch] as const;
+}
+
+export function useExport() {
+  const params = useContextSection(
+    context,
+    contextStateSelector,
+  );
+  const [isExporting, mutate] = useExportFile(exportSemiManufacturesInStream);
+  const [{page, pageSize}] = usePage(pageContext);
+
+  function onExport() {
+    mutate({
+      page: String(page),
+      limit: String(pageSize),
+      ...params,
+    });
+  }
+
+  return [isExporting, onExport] as const;
+}

+ 26 - 3
packages/app/src/pages/semi-in-stream/filter/index.tsx

@@ -1,8 +1,31 @@
-import css from './index.module.css';
-import {FC} from 'react';
+import {FilterButtonGroup, FilterDatePicker, FilterField} from '@components';
+import {useRangeDate} from '@hooks';
+import {Card, Row} from 'antd';
+import {FC, useState} from 'react';
+import {useExport, useSearch} from './hooks';
 
 const Filter: FC = function() {
-  return <></>;
+  const [code, onCodeChange] = useState('');
+  const [{dates, start, end}, onDatesChange] = useRangeDate();
+  const [isSearching, onSearch] = useSearch(code, start, end);
+  const [isExporting, onExport] = useExport();
+
+  return (
+    <Card>
+      <Row>
+        <FilterField name='semiInCode' label='物料编号' value={code} onChange={onCodeChange} />
+        <FilterDatePicker name='semiInDates' label='入库时间' value={dates} onChange={onDatesChange} />
+
+        <FilterButtonGroup
+          offset={6}
+          isSearching={isSearching}
+          onSearch={onSearch}
+          isExporting={isExporting}
+          onExport={onExport}
+        />
+      </Row>
+    </Card>
+  );
 };
 
 export default Filter;

+ 6 - 1
packages/app/src/pages/semi-in-stream/index.tsx

@@ -1,13 +1,18 @@
 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 SemiInStream: FC = function() {
   return (
     <TableSearchProvider context={context} state={contextState}>
       <PageProvider context={pageContext}>
         <SearchProvider context={searchContext}>
-          <section className='content-main' />
+          <section className='content-main'>
+            <Filter />
+            <TableList />
+          </section>
         </SearchProvider>
       </PageProvider>
     </TableSearchProvider>

+ 14 - 0
packages/app/src/pages/semi-in-stream/table/hooks.ts

@@ -0,0 +1,14 @@
+import {useContextSection, useQueryTableList} from '@hooks';
+import {context, contextStateSelector, pageContext, searchContext} from '../context';
+import {getSemiManufacturesInStream} from '@apis';
+
+export function useList() {
+  const params = useContextSection(context, contextStateSelector);
+
+  return useQueryTableList({
+    queryFn: getSemiManufacturesInStream,
+    params,
+    pageContext,
+    searchContext,
+  });
+}

+ 33 - 0
packages/app/src/pages/semi-in-stream/table/index.tsx

@@ -0,0 +1,33 @@
+import {Card} from 'antd';
+import {FC} from 'react';
+import {useList} from './hooks';
+import {Table} from '@components';
+import {ColumnsType} from 'antd/es/table';
+import {SemiInStreamListData} from '@models';
+import {pageContext, searchContext} from '../context';
+
+const columns: ColumnsType<SemiInStreamListData> = [
+  {title: '物料名称', dataIndex: 'materialName', key: 'materialName'},
+  {title: '生产时间', dataIndex: 'producBatch', key: 'producBatch'},
+  {title: '数量', dataIndex: 'warehousingNum', key: 'warehousingNum'},
+  {title: '用户名称', dataIndex: 'userName', key: 'userName'},
+  {title: '入库时间', dataIndex: 'scrq', key: 'scrq'},
+];
+
+const TableList: FC = function() {
+  const [{data, count}] = useList();
+  return (
+    <Card className='table-wrapper'>
+      <Table
+        columns={columns}
+        data={data}
+        count={count}
+        pageContext={pageContext}
+        searchContext={searchContext}
+        data-testid='semi_in_stream_table'
+      />
+    </Card>
+  );
+};
+
+export default TableList;