소스 검색

chore: 库存明细修改

xyh 2 년 전
부모
커밋
dcda5736a9

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

@@ -49,11 +49,15 @@ export function getReserveWarningList(
 }
 
 /** 库存查询 */
-export function getStockList(data: GetStockListParams): BaseListResult<StockListData> {
+export function getStockList(
+  data: GetStockListParams,
+  signal?: AbortSignal,
+): BaseListResult<StockListData> {
   return request({
     method: 'GET',
     url: `${BASE_URL}/storageLocation`,
     data,
+    signal,
   });
 }
 
@@ -216,3 +220,12 @@ export function exportWarning(data: GetReserveWarningListParams): any {
     url: `${BASE_URL}/reserveWarningsExport`,
   });
 }
+
+/** 导出储量预警 */
+export function exportStockList(data: GetStockListParams): any {
+  return request({
+    method: 'GET',
+    data,
+    url: `${BASE_URL}/exportStorageLocation`,
+  });
+}

+ 12 - 4
packages/app/src/models/request/queryList.ts

@@ -26,10 +26,18 @@ export type GetReserveWarningListParams = {
 
 /** 获取库存信息 */
 export type GetStockListParams = {
-  /** 库位code */
-  storageLocationCode: string;
-  /** 物料tldid */
-  materialId: string;
+  /** 库位名称 */
+  storageLocationName: string;
+  /** 物料编号 */
+  wllbCode: string;
+  /** 物料名称 */
+  materialName: string;
+  /** 供应商 */
+  supplierId: string;
+  /** 所属公司 */
+  companyCode: string;
+  /** wbs */
+  wbs: string;
 } & ListParams;
 
 export type GSInterfaceType =

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

@@ -66,6 +66,11 @@ export type StockListData = {
   code: string;
   /** 物料数量 */
   sum: number;
+  /** 所属公司 */
+  companyName: string;
+  /** 供应商 */
+  supplierName: string;
+  wbs: string;
 };
 
 /** GS接口信息 */

+ 8 - 17
packages/app/src/pages/stock/context.ts

@@ -1,24 +1,15 @@
-import {
-  TableSearchContext,
-  createPageContext,
-  createSearchContext,
-  createTableSearchContext,
-} from '@hooks';
+import {createPageContext, createSearchContext, createTableSearchContext} from '@hooks';
 import {GetStockListParams, OriginalListParams} from '@models';
 
 export const pageContext = createPageContext();
 export const searchContext = createSearchContext();
 
-export const contextState = {
-  materialId: '',
-  locationCode: '',
+export const contextState: OriginalListParams<GetStockListParams> = {
+  wllbCode: '',
+  materialName: '',
+  storageLocationName: '',
+  wbs: '',
+  companyCode: '',
+  supplierId: '',
 };
 export const context = createTableSearchContext(contextState);
-export function contextStateSelector([{materialId, locationCode}]: TableSearchContext<
-  typeof contextState
->): OriginalListParams<GetStockListParams> {
-  return {
-    materialId,
-    storageLocationCode: locationCode,
-  };
-}

+ 42 - 29
packages/app/src/pages/stock/filter/index.tsx

@@ -1,41 +1,54 @@
-import {FilterButtonGroup, FilterField, FilterFieldWrapper, FilterSelect} from '@components';
-import {useContextSection, useFilterField, useStorageOptions, useTableSearchEvent} from '@hooks';
+import {useContextSection, useFilterDB, useFilterField, useTableSearchToolEvents} from '@hooks';
 import {Card} from 'antd';
 import {FC} from 'react';
 import {context, searchContext} from '../context';
+import {FilterSelectorModal, FilterTool} from '@components';
+import {fixedMap, sourceMap} from './state';
 
 const Filter: FC = function () {
-  const [{material, location}, onChange] = useFilterField({material: '', location: ''});
-  const locationOptions = useStorageOptions(true);
-  const {isSearching, refetch} = useContextSection(searchContext, state => state[0]);
-  const onSearch = useTableSearchEvent(context, {materialId: material, locationCode: location});
+  const [fields, {onChange, resetState}] = useFilterField(
+    {
+      storageLocationName: '',
+      wllbCode: '',
+      materialName: '',
+      companyCode: '',
+      customerCode: '',
+      wbs: '',
+    },
+    true,
+  );
+  const {isSearching} = useContextSection(searchContext, state => state[0]);
+  const [visible, {onSearch, onReset, onShowModal, onCloseModal}] = useTableSearchToolEvents(
+    context,
+    fields,
+    {resetCallback: resetState},
+  );
+  const [filterList, {set}] = useFilterDB();
 
   return (
-    <Card>
-      <FilterFieldWrapper onSearch={onSearch}>
-        <FilterField
-          value={material}
-          label='物料编号'
-          onChange={onChange('material')}
-          name='materialCode'
-        />
-
-        <FilterSelect
-          options={locationOptions}
-          name='semiReportType'
-          label='库位'
-          value={location}
-          onChange={onChange('location')}
-        />
-
-        <FilterButtonGroup
-          isSearching={isSearching}
+    <>
+      <Card>
+        <FilterTool
+          fields={fields}
+          onChange={onChange}
+          filterData={filterList}
+          onReset={onReset}
           onSearch={onSearch}
-          onRefresh={refetch}
-          offset={6}
+          isSearching={isSearching}
+          sourceMap={sourceMap}
+          fixedMap={fixedMap}
+          onFilter={onShowModal}
         />
-      </FilterFieldWrapper>
-    </Card>
+      </Card>
+
+      <FilterSelectorModal
+        visible={visible}
+        onClose={onCloseModal}
+        onConfirm={set}
+        source={filterList}
+        filtermap={sourceMap}
+      />
+    </>
   );
 };
 

+ 14 - 0
packages/app/src/pages/stock/filter/state.ts

@@ -0,0 +1,14 @@
+import {FilterGroupMap, MapValue} from '@components';
+import {contextState} from '../context';
+
+export const fixedMap: MapValue<typeof contextState>[] = [
+  {label: '物料编号', type: 'field', value: 'wllbCode'},
+  {label: '物料名称', type: 'field', value: 'materialName'},
+  {label: '库位名称', type: 'field', value: 'storageLocationName'},
+];
+
+export const sourceMap: FilterGroupMap<typeof contextState> = new Map([
+  ['1', {label: '所属公司', type: 'keySelect', selectKey: '公司', value: 'companyCode'}],
+  ['2', {label: '供应商', type: 'keySelect', selectKey: '供应商/客户', value: 'supplierId'}],
+  ['3', {label: 'WBS编号', type: 'field', value: 'wbs'}],
+]);

+ 22 - 11
packages/app/src/pages/stock/table/index.tsx

@@ -2,36 +2,47 @@ import {Card} from 'antd';
 import {FC} from 'react';
 import {ColumnsType} from 'antd/es/table';
 import {StockListData} from '@models';
-import {Table} from '@components';
-import {context, contextStateSelector, pageContext, searchContext} from '../context';
-import {HUGE_TABLE_WIDTH, NORMAL_TABLE_WIDTH, SMALL_TABLE_WIDTH} from '@utils';
-import {getStockList} from '@apis';
-import {useContextSection, useQueryTableList} from '@hooks';
+import {Table, TableTools} from '@components';
+import {context, pageContext, searchContext} from '../context';
+import {HUGE_TABLE_WIDTH, LARGE_TABLE_WIDTH, NORMAL_TABLE_WIDTH, SMALL_TABLE_WIDTH} from '@utils';
+import {exportStockList, getStockList} from '@apis';
+import {useContextSection, useQueryTableList, useTableExportEvent} from '@hooks';
 
 const columns: ColumnsType<StockListData> = [
-  {title: '物料名称', dataIndex: 'name', key: 'name', width: HUGE_TABLE_WIDTH},
-  {title: '物料编号', dataIndex: 'code', key: 'code', width: NORMAL_TABLE_WIDTH},
-  {title: '数量', dataIndex: 'sum', key: 'sum', width: SMALL_TABLE_WIDTH},
+  {title: '物料编号', dataIndex: 'code', width: LARGE_TABLE_WIDTH},
+  {title: '物料名称', dataIndex: 'name', width: HUGE_TABLE_WIDTH},
+  {title: '数量', dataIndex: 'sum', width: SMALL_TABLE_WIDTH, align: 'right'},
   {
     title: '库位名称',
     dataIndex: 'storageLocationName',
-    key: 'storageLocationName',
     width: NORMAL_TABLE_WIDTH,
   },
+  {title: '所属公司', dataIndex: 'companyName', width: LARGE_TABLE_WIDTH},
+  {title: '供应商', dataIndex: 'supplierName', width: LARGE_TABLE_WIDTH},
+  {title: 'WBS编号', dataIndex: 'wbs', width: NORMAL_TABLE_WIDTH},
 ];
 
 const TableList: FC = function () {
-  const params = useContextSection(context, contextStateSelector);
+  const params = useContextSection(context, state => state[0]);
 
-  const [{data, count}] = useQueryTableList({
+  const [{data, count, isFetching}, {refetch}] = useQueryTableList({
     queryFn: getStockList,
     params,
     pageContext,
     searchContext,
   });
 
+  const [isExporting, onExport] = useTableExportEvent({pageContext, context, fn: exportStockList});
+
   return (
     <Card className='table-wrapper'>
+      <TableTools
+        onRefresh={refetch}
+        isRefreshing={isFetching}
+        isExporting={isExporting}
+        onExport={onExport}
+      />
+
       <Table
         data-testid='stock_table'
         data={data}