Просмотр исходного кода

chore: 产成品报工单调整

xyh 2 лет назад
Родитель
Сommit
1f331b53ae

+ 17 - 12
packages/app/src/pages/product-report/context.ts

@@ -1,18 +1,23 @@
-import {
-  TableSearchContext,
-  createPageContext,
-  createSearchContext,
-  createTableSearchContext,
-} from '@hooks';
+import {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 contextState: OriginalListParams<GetNoticeListParams> = {
+  type: '',
+  wllbCode: '',
+  startTime: '',
+  endTime: '',
+  partType: '产成品' as const,
+  materialName: '',
+  companyNumber: '',
+  noticeCode: '',
+  noticeId: '',
+  wbs: '',
+  entryNumber: '',
+  productionCode: '',
+  moveType: '',
+  sourceType: '',
+};
 export const context = createTableSearchContext(contextState);
-export function contextStateSelector([{type, code, startTime, endTime}]: TableSearchContext<
-  typeof contextState
->): OriginalListParams<GetNoticeListParams> {
-  return {partType: '产成品', startTime, endTime, type, wllbCode: code, materialName: ''} as any;
-}

+ 63 - 39
packages/app/src/pages/product-report/filter/index.tsx

@@ -1,52 +1,76 @@
+import {FilterSelectorModal, FilterTool} from '@components';
 import {
-  FilterButtonGroup,
-  FilterDatePicker,
-  FilterField,
-  FilterFieldWrapper,
-  FilterSelect,
-} from '@components';
-import {useContextSection, useFilterField, useRangeDate, useTableSearchEvent} from '@hooks';
+  useContextSection,
+  useFilterDB,
+  useFilterField,
+  useRangeDate,
+  useTableSearchToolEvents,
+} from '@hooks';
 import {Card} from 'antd';
 import {FC} from 'react';
 import {context, searchContext} from '../context';
-
-const options = [
-  {label: '全部', value: ''},
-  {label: '未入库', value: '0'},
-  {label: '已入库', value: '1'},
-];
+import {fixedMap, sourceMap} from './state';
 
 const Filter: FC = function () {
   const [{dates, start, end}, onDatesChange] = useRangeDate();
-  const [{type, code}, onChange] = useFilterField({code: '', type: ''});
-  const {isSearching, refetch} = useContextSection(searchContext, state => state[0]);
-  const onSearch = useTableSearchEvent(context, {startTime: start, endTime: end, type, code});
+  const [fields, {onChange, resetState}] = useFilterField(
+    {
+      type: '',
+      wllbCode: '',
+      startTime: '',
+      endTime: '',
+      partType: '半成品' as const,
+      materialName: '',
+      companyNumber: '',
+      noticeCode: '',
+      noticeId: '',
+      wbs: '',
+      entryNumber: '',
+      productionCode: '',
+      moveType: '',
+      sourceType: '',
+    },
+    true,
+  );
+  const {isSearching} = useContextSection(searchContext, state => state[0]);
+  const [visible, {onSearch, onShowModal, onCloseModal, onReset}] = useTableSearchToolEvents(
+    context,
+    {...fields, startTime: start, endTime: end},
+    {
+      resetCallback() {
+        resetState();
+        onDatesChange([null, null]);
+      },
+    },
+  );
+  const [filterList, {set}] = useFilterDB();
 
   return (
-    <Card>
-      <FilterFieldWrapper onSearch={onSearch}>
-        <FilterField
-          name='semiReportCode'
-          label='物料编号'
-          value={code}
-          onChange={onChange('code')}
+    <>
+      <Card>
+        <FilterTool
+          filterData={filterList}
+          dates={dates}
+          fields={fields}
+          onSearch={onSearch}
+          onReset={onReset}
+          isSearching={isSearching}
+          onChange={onChange}
+          onDatesChange={onDatesChange}
+          onFilter={onShowModal}
+          sourceMap={sourceMap}
+          fixedMap={fixedMap}
         />
-        <FilterSelect
-          options={options}
-          name='semiReportType'
-          label='状态'
-          value={type}
-          onChange={onChange('type')}
-        />
-        <FilterDatePicker
-          name='rawMaterialDates'
-          label='报工时间'
-          value={dates}
-          onChange={onDatesChange}
-        />
-        <FilterButtonGroup isSearching={isSearching} onSearch={onSearch} onRefresh={refetch} />
-      </FilterFieldWrapper>
-    </Card>
+      </Card>
+
+      <FilterSelectorModal
+        visible={visible}
+        onClose={onCloseModal}
+        onConfirm={set}
+        source={filterList}
+        filtermap={sourceMap}
+      />
+    </>
   );
 };
 

+ 30 - 0
packages/app/src/pages/product-report/filter/state.ts

@@ -0,0 +1,30 @@
+import {FilterGroupMap, MapValue} from '@components';
+import {contextState} from '../context';
+
+export const sourceMap: FilterGroupMap<typeof contextState> = new Map([
+  ['1', {label: '报工时间', value: 'endTime', type: 'date'}],
+  ['2', {label: '分录号', value: 'entryNumber', type: 'field'}],
+  ['3', {label: '所属公司', value: 'companyNumber', type: 'keySelect', selectKey: '公司'}],
+  ['4', {label: '移动类型', value: 'moveType', type: 'field'}],
+  ['5', {label: '来源类型', value: 'sourceType', type: 'field'}],
+  [
+    '6',
+    {
+      label: '状态',
+      value: 'type',
+      type: 'select',
+      options: [
+        {label: '未入库', value: '0'},
+        {label: '已入库', value: '1'},
+      ],
+    },
+  ],
+]);
+
+export const fixedMap: MapValue<typeof contextState>[] = [
+  {label: '生产单号', value: 'productionCode', type: 'field'},
+  {label: '报工单ID', value: 'noticeId', type: 'field'},
+  {label: '报工单编号', value: 'noticeCode', type: 'field'},
+  {label: '物料名称', value: 'materialName', type: 'field'},
+  {label: '物料编号', value: 'wllbCode', type: 'field'},
+];

+ 20 - 9
packages/app/src/pages/product-report/table/hooks.tsx

@@ -1,26 +1,37 @@
 import {deleNotice} from '@apis';
 import {useSupertube, useTableDeleteEvent} from '@hooks';
 import {NoticeListData} from '@models';
-import {MIDDLE_TABLE_WIDTH, HUGE_TABLE_WIDTH, SMALL_TABLE_WIDTH, NORMAL_TABLE_WIDTH} from '@utils';
+import {
+  MIDDLE_TABLE_WIDTH,
+  HUGE_TABLE_WIDTH,
+  SMALL_TABLE_WIDTH,
+  NORMAL_TABLE_WIDTH,
+  LARGE_TABLE_WIDTH,
+} from '@utils';
 import {Button} from 'antd';
 import {ColumnsType} from 'antd/es/table';
 
 const columns: ColumnsType<NoticeListData> = [
-  {title: '报工单号', dataIndex: 'noticeId', key: 'noticeId', width: MIDDLE_TABLE_WIDTH},
-  {title: '物料名称', dataIndex: 'materialName', key: 'materialName', width: HUGE_TABLE_WIDTH},
-  {title: '物料编号', dataIndex: 'wllbCode', key: 'wllbCode', width: MIDDLE_TABLE_WIDTH},
-  {title: '数量', dataIndex: 'num', key: 'num', width: SMALL_TABLE_WIDTH},
   {
-    title: '生产批次',
+    title: '生产单号',
     dataIndex: 'productionCode',
-    key: 'productionCode',
+
     width: MIDDLE_TABLE_WIDTH,
   },
-  {title: '分录号', dataIndex: 'entryNumber', key: 'entryNumber', width: NORMAL_TABLE_WIDTH},
+  {title: '报工单ID', dataIndex: 'noticeId', width: MIDDLE_TABLE_WIDTH},
+  {title: '报工单编号', dataIndex: 'noticeCode', width: MIDDLE_TABLE_WIDTH},
+  {title: '物料名称', dataIndex: 'materialName', width: HUGE_TABLE_WIDTH},
+  {title: '物料编号', dataIndex: 'wllbCode', width: MIDDLE_TABLE_WIDTH},
+  {title: '数量', dataIndex: 'num', width: SMALL_TABLE_WIDTH, align: 'right'},
+  {title: '报工时间', dataIndex: 'noticeTime', width: NORMAL_TABLE_WIDTH},
+  {title: '分录号', dataIndex: 'entryNumber', width: NORMAL_TABLE_WIDTH},
+  {title: '所属公司', dataIndex: 'companyName', width: LARGE_TABLE_WIDTH},
+  {title: '移动类型', dataIndex: 'moveType', width: NORMAL_TABLE_WIDTH},
+  {title: '来源类型', dataIndex: 'sourceType', width: NORMAL_TABLE_WIDTH},
   {
     title: '状态',
     dataIndex: 'type',
-    key: 'type',
+
     render(_, {type}) {
       return type === '0' ? '未入库' : '已入库';
     },

+ 8 - 4
packages/app/src/pages/product-report/table/index.tsx

@@ -1,7 +1,7 @@
 import {FC} from 'react';
 import {Card} from 'antd';
 import {Table, TableTools} from '@components';
-import {context, contextStateSelector, pageContext, searchContext} from '../context';
+import {context, pageContext, searchContext} from '../context';
 
 import {getNoticeList} from '@apis';
 import {useContextSection, useQueryTableList, useSupertube} from '@hooks';
@@ -10,8 +10,8 @@ import {useBoolean} from 'ahooks';
 import AddModal from './modal';
 
 const TableList: FC = function () {
-  const params = useContextSection(context, contextStateSelector);
-  const [{count, data}, {refetch}] = useQueryTableList({
+  const params = useContextSection(context, state => state[0]);
+  const [{count, data, isFetching}, {refetch}] = useQueryTableList({
     queryFn: getNoticeList,
     params,
     pageContext,
@@ -24,7 +24,11 @@ const TableList: FC = function () {
   return (
     <>
       <Card className='table-wrapper'>
-        {isSuper && <TableTools onClick={setTrue} />}
+        <TableTools
+          onAdd={isSuper ? setTrue : void 0}
+          onRefresh={refetch}
+          isRefreshing={isFetching}
+        />
 
         <Table
           data-testid='semi_report_table'

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

@@ -1,24 +1,14 @@
-import {
-  FilterButtonGroup,
-  FilterDatePicker,
-  FilterField,
-  FilterFieldWrapper,
-  FilterSelectorModal,
-  FilterTool,
-} from '@components';
+import {FilterSelectorModal, FilterTool} from '@components';
 import {
   useContextSection,
   useFilterDB,
   useFilterField,
   useRangeDate,
-  useTableExportEvent,
-  useTableSearchEvent,
   useTableSearchToolEvents,
 } from '@hooks';
 import {Card} from 'antd';
-import {FC, useState} from 'react';
-import {context, pageContext, searchContext} from '../context';
-import {exportSemiManufacturesInStream} from '@apis';
+import {FC} from 'react';
+import {context, searchContext} from '../context';
 import {fixedMap, sourceMap} from './state';
 
 const Filter: FC = function () {