Browse Source

chore: 增加报工单接口字段

xyh 2 years ago
parent
commit
c4f3a391c5

+ 3 - 1
packages/app/src/hooks/useTableSearch/index.ts

@@ -26,8 +26,10 @@ export function useTableSearchContextReducer<S extends InitStateType>(init: S) {
   return useReducer(reducer, initState());
 }
 
+export type TableSearchContext<S> = [S, Dispatch<TableSearchAction<S>>];
+
 export function createTableSearchContext<S extends InitStateType>(state: S) {
-  return createContext<[S, Dispatch<TableSearchAction<S>>]>([
+  return createContext<TableSearchContext<S>>([
     {...state},
     () => null,
   ]);

+ 2 - 4
packages/app/src/pages/semi-in-stream/context.ts

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

+ 2 - 4
packages/app/src/pages/semi-out-stream/context.ts

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

+ 12 - 1
packages/app/src/pages/semi-report/context.ts

@@ -1,7 +1,18 @@
-import {createPageContext, createSearchContext, createTableSearchContext} from '@hooks';
+import {
+  TableSearchContext,
+  createPageContext,
+  createSearchContext,
+  createTableSearchContext,
+} from '@hooks';
+import {GetNoticeListParams, OriginalListParams} from '@models';
 
 export const pageContext = createPageContext();
 export const searchContext = createSearchContext();
 
 export const contextState = {type: '', code: '', startTime: '', endTime: ''};
 export const context = createTableSearchContext(contextState);
+export function contextStateSelector(
+  [{type, code, startTime, endTime}]: TableSearchContext<typeof contextState>,
+): OriginalListParams<GetNoticeListParams> {
+  return {partType: '半成品', startTime, endTime, type, materialCode: code};
+}

+ 2 - 4
packages/app/src/pages/semi-report/table/hooks.tsx

@@ -1,5 +1,5 @@
 import {useContextSection, useQueryTableList} from '@hooks';
-import {context, pageContext, searchContext} from '../context';
+import {context, contextStateSelector, pageContext, searchContext} from '../context';
 import {getNoticeList} from '@apis';
 import {Button} from 'antd';
 import {ColumnsType} from 'antd/es/table';
@@ -10,9 +10,7 @@ import {useState} from 'react';
 export function useList() {
   const params = useContextSection(
     context,
-    function([{code, startTime, endTime, type}]) {
-      return {startTime, endTime, type, materialCode: code};
-    },
+    contextStateSelector,
   );
 
   return useQueryTableList({