Browse Source

chore: 半成品报工单管理表格调整

xyh 2 years ago
parent
commit
ef06945c83

+ 31 - 1
packages/app/src/models/request/semiManufactures.ts

@@ -3,10 +3,40 @@ import {ListParams} from '.';
 /** 报工单 */
 export type GetNoticeListParams = {
   partType: '产成品' | '半成品';
+  /** 是否入库 */
   type: string;
   startTime: string;
   endTime: string;
-  materialCode: string;
+  /** 公司编号 */
+  companyNumber: string;
+  /** 分录号 */
+  entryNumber: string;
+  /**
+   * 物料编号
+   */
+  wllbCode: string;
+  /**
+   * 物料名称
+   */
+  materialName: string;
+  /**
+   * 报工单ID
+   */
+  noticeId: string;
+  /**
+   * 生产单号
+   */
+  productionCode: string;
+  /**
+   * wbs
+   */
+  wbs: string;
+  /** 移动类型 */
+  moveType: string;
+  /** 来源类型 */
+  sourceType: string;
+  /** 报工单编号 */
+  noticeCode: string;
 } & ListParams;
 
 /** 半成品入库 */

+ 11 - 1
packages/app/src/models/response/semiManufactures.ts

@@ -1,6 +1,8 @@
 /** 报工单数据 */
 export type NoticeListData = {
   /** 所属公司 */
+  companyName: string;
+  /** 所属公司编号 */
   companyNumber: string;
   /**
    * 分录号
@@ -31,7 +33,7 @@ export type NoticeListData = {
    */
   num: string;
   /**
-   * 生产批次
+   * 生产单号
    */
   productionCode: string;
   /**
@@ -52,6 +54,14 @@ export type NoticeListData = {
   wllbClass: string;
   /** 物料编号 */
   wllbCode: string;
+  /** 移动类型 */
+  moveType: string;
+  /** 来源类型 */
+  sourceType: string;
+  /** 报工时间 */
+  noticeTime: string;
+  /** 报工单编号 */
+  noticeCode: string;
 };
 
 /** 半成品入库流水 */

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

@@ -14,5 +14,5 @@ export const context = createTableSearchContext(contextState);
 export function contextStateSelector([{type, code, startTime, endTime}]: TableSearchContext<
   typeof contextState
 >): OriginalListParams<GetNoticeListParams> {
-  return {partType: '产成品', startTime, endTime, type, materialCode: code};
+  return {partType: '产成品', startTime, endTime, type, wllbCode: code, materialName: ''} as any;
 }

+ 17 - 12
packages/app/src/pages/semi-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: '半成品',
+  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, materialCode: code};
-}

+ 65 - 33
packages/app/src/pages/semi-report/filter/index.tsx

@@ -4,49 +4,81 @@ import {
   FilterField,
   FilterFieldWrapper,
   FilterSelect,
+  FilterSelectorModal,
+  FilterTool,
 } from '@components';
-import {useContextSection, useFilterField, useRangeDate, useTableSearchEvent} from '@hooks';
+import {
+  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, {type, code, startTime: start, endTime: end});
+  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/semi-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'},
+];

+ 15 - 9
packages/app/src/pages/semi-report/table/hooks.tsx

@@ -5,6 +5,7 @@ import {NoticeListData} from '@models';
 import {
   DOUBLE_BTN_WIDTH,
   HUGE_TABLE_WIDTH,
+  LARGE_TABLE_WIDTH,
   MIDDLE_TABLE_WIDTH,
   NORMAL_TABLE_WIDTH,
   SMALL_TABLE_WIDTH,
@@ -12,21 +13,26 @@ import {
 import {useSupertube, useTableDeleteEvent, useTableModalEvent} from '@hooks';
 
 const tableColumns: 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' ? '未入库' : '已入库';
     },
@@ -44,7 +50,7 @@ export function useHandle(refetch: () => void) {
     {
       title: '操作',
       dataIndex: 'id',
-      key: 'id',
+
       width: isSuper ? DOUBLE_BTN_WIDTH : SMALL_TABLE_WIDTH,
       fixed: 'right',
       render(_, {id, type}) {

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

@@ -2,7 +2,7 @@ import {FC} from 'react';
 import {useHandle} from './hooks';
 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';
 import {useBoolean} from 'ahooks';
@@ -10,7 +10,7 @@ import AddModal from './modal';
 import PutInModal from './put-in-modal';
 
 const TableList: FC = function () {
-  const params = useContextSection(context, contextStateSelector);
+  const params = useContextSection(context, state => state[0]);
   const [{data, count, isFetching}, {refetch}] = useQueryTableList({
     queryFn: getNoticeList,
     params,