Sfoglia il codice sorgente

chore: 采购单和逾期采购单合并一个列表

xyh 2 anni fa
parent
commit
b79c0ce77b

+ 1 - 1
packages/app/src/pages/goods/table/hooks.tsx

@@ -65,7 +65,7 @@ export function useHandle() {
     {title: '物料库存', dataIndex: 'count', key: 'count', width: NORMAL_TABLE_WIDTH},
     {title: '物料类别', dataIndex: 'partType', key: 'partType', width: NORMAL_TABLE_WIDTH},
     {title: '物料类型', dataIndex: 'materialType', key: 'materialType', width: NORMAL_TABLE_WIDTH},
-    {title: '存储容量', dataIndex: 'size', key: 'size', width: NORMAL_TABLE_WIDTH},
+    {title: '存储容量', dataIndex: 'size', key: 'size', width: SMALL_TABLE_WIDTH},
     {title: '最大存储容量', dataIndex: 'maxNum', key: 'maxNum', width: SMALL_TABLE_WIDTH},
     {title: '最小存储容量', dataIndex: 'minNum', key: 'minNum', width: SMALL_TABLE_WIDTH},
     {

+ 13 - 1
packages/app/src/pages/purchase-order/context.ts

@@ -1,4 +1,10 @@
-import {createPageContext, createSearchContext, createTableSearchContext} from '@hooks';
+import {
+  TableSearchContext,
+  createPageContext,
+  createSearchContext,
+  createTableSearchContext,
+} from '@hooks';
+import {GetReceiveOrderListParams, OriginalListParams} from '@models';
 
 export const pageContext = createPageContext();
 export const searchContext = createSearchContext();
@@ -7,5 +13,11 @@ export const contextState = {
   startTime: '',
   endTime: '',
   orderCode: '',
+  type: '1' as '1' | '2',
 };
 export const context = createTableSearchContext(contextState);
+export function contextStateSelector(
+  [{startTime, endTime, orderCode}]: TableSearchContext<typeof contextState>,
+): OriginalListParams<GetReceiveOrderListParams> {
+  return {startTime, endTime, orderCode};
+}

+ 9 - 4
packages/app/src/pages/purchase-order/filter/hooks.ts

@@ -1,12 +1,17 @@
-import {useContextSection} from '@hooks';
-import {context, searchContext} from '../context';
+import {useContextSection, usePage} from '@hooks';
+import {context, pageContext, searchContext} from '../context';
 
-export function useSearch(startTime: string, endTime: string, code: string) {
+export function useSearch({
+  startTime, endTime, code, type,
+}: {startTime: string, endTime: string, code: string, type: '1' | '2'}) {
   const {isSearching, refetch} = useContextSection(searchContext, state => state[0]);
   const dispatch = useContextSection(context, state => state[1]);
+  const [,{onCurrentPageChange}] = usePage(pageContext);
 
   function onSearch() {
-    dispatch({type: 'SEARCH', payload: {startTime, endTime, orderCode: code}});
+    // 这里修改页码为了在切换请求方法时保证不出现问题
+    onCurrentPageChange(1);
+    dispatch({type: 'SEARCH', payload: {startTime, endTime, orderCode: code, type}});
   }
 
   return [{isSearching, refetch}, onSearch] as const;

+ 23 - 7
packages/app/src/pages/purchase-order/filter/index.tsx

@@ -1,26 +1,42 @@
-import {FilterButtonGroup, FilterDatePicker, FilterField} from '@components';
-import {useRangeDate} from '@hooks';
+import {FilterButtonGroup, FilterDatePicker, FilterField, FilterSelect} from '@components';
+import {useFilterField, useRangeDate} from '@hooks';
 import {Card, Row} from 'antd';
-import {FC, useState} from 'react';
+import {FC} from 'react';
 import {useSearch} from './hooks';
 
+const typeOptions = [
+  {label: '所有', value: '1'},
+  {label: '逾期', value: '2'},
+];
+
 const Filter: FC = function() {
   const [{dates, start, end}, onDatesChange] = useRangeDate();
-  const [code, onCodeChange] = useState('');
-  const [{isSearching, refetch}, onSearch] = useSearch(start, end, code);
+  const [{code, type}, onChange] = useFilterField<{type: '1' | '2', code: string}>({type: '1', code: ''});
+  const [{isSearching, refetch}, onSearch] = useSearch({
+    startTime: start,
+    endTime: end,
+    code,
+    type,
+  });
 
   return (
     <Card>
       <Row>
-        <FilterField name='purchaseCode' label='采购单号' value={code} onChange={onCodeChange} />
+        <FilterField name='purchaseCode' label='采购单号' value={code} onChange={onChange('code')} />
         <FilterDatePicker
           name='purchaseDate'
           label='到料时间'
           value={dates}
           onChange={onDatesChange}
         />
+        <FilterSelect
+          name='purchaseType'
+          label='订单类型'
+          value={type}
+          onChange={onChange('type')}
+          options={typeOptions}
+        />
         <FilterButtonGroup
-          offset={6}
           onRefresh={refetch}
           onSearch={onSearch}
           isSearching={isSearching}

+ 9 - 4
packages/app/src/pages/purchase-order/table/hooks.ts

@@ -1,13 +1,18 @@
 import {useContextSection, useQueryTableList} from '@hooks';
 import {context, pageContext, searchContext} from '../context';
-import {getReceiveOrderList} from '@apis';
+import {getReceiveOrderList, getTimeoutReceiveOrderList} from '@apis';
 
 export function useList() {
-  const params = useContextSection(context, state => state[0]);
+  const {
+    startTime,
+    endTime,
+    orderCode,
+    type,
+  } = useContextSection(context, state => state[0]);
 
   return useQueryTableList({
-    queryFn: getReceiveOrderList,
-    params,
+    queryFn: type === '1' ? getReceiveOrderList : getTimeoutReceiveOrderList,
+    params: {startTime, endTime, orderCode},
     pageContext,
     searchContext,
   });