瀏覽代碼

chore: 物料储量预警调整

xyh 2 年之前
父節點
當前提交
a9cd7789e6

+ 12 - 1
packages/app/src/apis/queryList.ts

@@ -38,11 +38,13 @@ export function getDeadProductsList(
 /** 物料储量预警查询 */
 export function getReserveWarningList(
   data: GetReserveWarningListParams,
+  signal?: AbortSignal,
 ): BaseListResult<ReserveWarningListData> {
   return request({
     method: 'GET',
-    url: `${BASE_URL}/reserveWarning`,
+    url: `${BASE_URL}/reserveWarnings`,
     data,
+    signal,
   });
 }
 
@@ -205,3 +207,12 @@ export function exportDeadproduct(data: GetDeadProductsListParams): any {
     url: `${BASE_URL}/dullGoodsExport`,
   });
 }
+
+/** 导出储量预警 */
+export function exportWarning(data: GetReserveWarningListParams): any {
+  return request({
+    method: 'GET',
+    data,
+    url: `${BASE_URL}/reserveWarningsExport`,
+  });
+}

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

@@ -20,6 +20,8 @@ export type GetDeadProductsListParams = {
 export type GetReserveWarningListParams = {
   /** 物料编号 */
   wllbCode: string;
+  /** 物料名称 */
+  materialName: string;
 } & ListParams;
 
 /** 获取库存信息 */

+ 4 - 13
packages/app/src/pages/reserves/context.ts

@@ -1,20 +1,11 @@
-import {
-  TableSearchContext,
-  createPageContext,
-  createSearchContext,
-  createTableSearchContext,
-} from '@hooks';
+import {createPageContext, createSearchContext, createTableSearchContext} from '@hooks';
 import {GetReserveWarningListParams, OriginalListParams} from '@models';
 
 export const pageContext = createPageContext();
 export const searchContext = createSearchContext();
 
-export const contextState = {
-  code: '',
+export const contextState: OriginalListParams<GetReserveWarningListParams> = {
+  wllbCode: '',
+  materialName: '',
 };
 export const context = createTableSearchContext(contextState);
-export function contextStateSelector([{code}]: TableSearchContext<
-  typeof contextState
->): OriginalListParams<GetReserveWarningListParams> {
-  return {wllbCode: code};
-}

+ 25 - 11
packages/app/src/pages/reserves/filter/index.tsx

@@ -1,24 +1,38 @@
 import {FilterButtonGroup, FilterField, FilterFieldWrapper} from '@components';
-import {useContextSection, useTableSearchEvent} from '@hooks';
+import {useContextSection, useFilterField, useTableSearchToolEvents} from '@hooks';
 import {Card} from 'antd';
-import {FC, useState} from 'react';
+import {FC} from 'react';
 import {context, searchContext} from '../context';
 
 const Filter: FC = function () {
-  const [code, onChange] = useState('');
-  const {isSearching, refetch} = useContextSection(searchContext, state => state[0]);
-  const onSearch = useTableSearchEvent(context, {code});
+  const {isSearching} = useContextSection(searchContext, state => state[0]);
+  const [fields, {onChange, resetState}] = useFilterField(
+    {
+      wllbCode: '',
+      materialName: '',
+    },
+    true,
+  );
+  const [, {onSearch, onReset}] = useTableSearchToolEvents(context, fields, {
+    resetCallback: resetState,
+  });
 
   return (
     <Card>
       <FilterFieldWrapper onSearch={onSearch}>
-        <FilterField value={code} label='物料编号' onChange={onChange} name='materialCode' />
-        <FilterButtonGroup
-          offset={12}
-          onSearch={onSearch}
-          isSearching={isSearching}
-          onRefresh={refetch}
+        <FilterField
+          value={fields.wllbCode}
+          label='物料编号'
+          onChange={onChange('wllbCode')}
+          name='wllbCode'
+        />
+        <FilterField
+          value={fields.materialName}
+          label='物料名称'
+          onChange={onChange('materialName')}
+          name='materialName'
         />
+        <FilterButtonGroup onSearch={onSearch} isSearching={isSearching} onReset={onReset} />
       </FilterFieldWrapper>
     </Card>
   );

+ 19 - 10
packages/app/src/pages/reserves/table/index.tsx

@@ -2,31 +2,40 @@ import {FC} from 'react';
 import {ColumnsType} from 'antd/es/table';
 import {ReserveWarningListData} from '@models';
 import {Card} from 'antd';
-import {Table} from '@components';
-import {context, contextStateSelector, pageContext, searchContext} from '../context';
+import {Table, TableTools} from '@components';
+import {context, pageContext, searchContext} from '../context';
 import {HUGE_TABLE_WIDTH, NORMAL_TABLE_WIDTH, SMALL_TABLE_WIDTH} from '@utils';
-import {getReserveWarningList} from '@apis';
-import {useContextSection, useQueryTableList} from '@hooks';
+import {exportWarning, getReserveWarningList} from '@apis';
+import {useContextSection, useQueryTableList, useTableExportEvent} from '@hooks';
 
 const columns: ColumnsType<ReserveWarningListData> = [
-  {title: '物料名称', dataIndex: 'materialName', key: 'materialName', width: HUGE_TABLE_WIDTH},
   {title: '物料编号', dataIndex: 'wllbCode', key: 'wllbCode', width: NORMAL_TABLE_WIDTH},
-  {title: '数量', dataIndex: 'amount', key: 'amount', width: SMALL_TABLE_WIDTH},
-  {title: '最小数量', dataIndex: 'minNum', key: 'minNum', width: SMALL_TABLE_WIDTH},
-  {title: '最大数量', dataIndex: 'maxNum', key: 'maxNum', width: SMALL_TABLE_WIDTH},
+  {title: '物料名称', dataIndex: 'materialName', key: 'materialName', width: HUGE_TABLE_WIDTH},
+  {title: '数量', dataIndex: 'amount', key: 'amount', width: SMALL_TABLE_WIDTH, align: 'right'},
+  {title: '最小数量', dataIndex: 'minNum', key: 'minNum', width: SMALL_TABLE_WIDTH, align: 'right'},
+  {title: '最大数量', dataIndex: 'maxNum', key: 'maxNum', width: SMALL_TABLE_WIDTH, align: 'right'},
 ];
 
 const TableList: FC = function () {
-  const params = useContextSection(context, contextStateSelector);
-  const [{data, count}] = useQueryTableList({
+  const params = useContextSection(context, state => state[0]);
+  const [{data, count, isFetching}, {refetch}] = useQueryTableList({
     queryFn: getReserveWarningList,
     params,
     pageContext,
     searchContext,
   });
 
+  const [isExporting, onExport] = useTableExportEvent({pageContext, context, fn: exportWarning});
+
   return (
     <Card className='table-wrapper'>
+      <TableTools
+        onRefresh={refetch}
+        isRefreshing={isFetching}
+        onExport={onExport}
+        isExporting={isExporting}
+      />
+
       <Table
         data={data}
         count={count}