Browse Source

chore: 销售表格调整

xyh 2 years ago
parent
commit
8f7286a84d

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

@@ -139,11 +139,15 @@ export function delUnProductionRequisition(id: string): BaseResult {
 }
 
 /** 查询销售单 */
-export function getSellOrderList(data: GetSellOrderListParams): BaseListResult<SellOrderListData> {
+export function getSellOrderList(
+  data: GetSellOrderListParams,
+  signal?: AbortSignal,
+): BaseListResult<SellOrderListData> {
   return request({
     method: 'GET',
     url: `${BASE_URL}/getDelivery`,
     data,
+    signal,
   });
 }
 

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

@@ -91,6 +91,20 @@ export type GetProductionRequisitionListParams = {
 export type GetSellOrderListParams = {
   /** 销售单id */
   deliveryId: string;
+  /** wbs编号 */
+  wbs: string;
+  /** 客户 */
+  customerCode: string;
+  /** 所属公司 */
+  companyNumber: string;
+  /** 来源类型 */
+  sourceType: string;
+  /** 移动类型 */
+  moveType: string;
+  /** 交货类型 */
+  deliveryType: string;
+  /** 分录号 */
+  entryNumber: string;
 } & BaseOrderListParams &
   ListParams;
 

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

@@ -191,6 +191,18 @@ export type SellOrderListData = {
    * WBS
    */
   wbs: string;
+  /** 客户 */
+  customerName: string;
+  /** 公司名称 */
+  companyName: string;
+  /** 分录号 */
+  entryNumber: string;
+  /** 来源类型 */
+  sourceType: string;
+  /** 移动类型 */
+  moveType: string;
+  /** 订单类型 */
+  deliveryType: string;
 };
 
 /** 移库单数据 */

+ 3 - 9
packages/app/src/pages/pda-menu/table/modal/Info.tsx

@@ -12,15 +12,9 @@ const Info: FC<Props> = function ({id}) {
 
   return (
     <>
-      <ModalField name='menuID' width='300px' label='菜单id' control={control} />
-      <ModalField name='menuName' width='300px' label='菜单名称' control={control} />
-      <ModalField
-        name='menuOrderBy'
-        width='300px'
-        label='菜单排序'
-        control={control}
-        type='number'
-      />
+      <ModalField name='menuID' label='菜单ID' control={control} />
+      <ModalField name='menuName' label='菜单名称' control={control} />
+      <ModalField name='menuOrderBy' label='菜单排序' control={control} type='number' />
     </>
   );
 };

+ 7 - 0
packages/app/src/pages/sell-order/context.ts

@@ -9,5 +9,12 @@ export const contextState: OriginalListParams<GetSellOrderListParams> = {
   materialName: '',
   startTime: '',
   endTime: '',
+  wbs: '',
+  customerCode: '',
+  companyNumber: '',
+  sourceType: '',
+  moveType: '',
+  deliveryType: '',
+  entryNumber: '',
 };
 export const context = createTableSearchContext(contextState);

+ 52 - 48
packages/app/src/pages/sell-order/filter/index.tsx

@@ -1,69 +1,73 @@
-import {FilterButtonGroup, FilterDatePicker, FilterField, FilterFieldWrapper} from '@components';
 import {
   useContextSection,
+  useFilterDB,
   useFilterField,
-  useTableExportEvent,
-  useTableSearchEvent,
   useRangeDate,
+  useTableSearchToolEvents,
 } from '@hooks';
 import {Card} from 'antd';
 import {FC} from 'react';
 import {searchContext, context, pageContext} from '../context';
 import {exportSellOrderList} from '@apis';
+import {FilterSelectorModal, FilterTool} from '@components';
+import {fixedMap, sourceMap} from './state';
 
 const Filter: FC = function () {
-  const [fields, onChange] = useFilterField({
-    deliveryId: '',
-    materialCode: '',
-    materialName: '',
-  });
-  const {materialCode, materialName, deliveryId} = fields;
+  const [fields, {onChange, resetState}] = useFilterField(
+    {
+      deliveryId: '',
+      materialCode: '',
+      materialName: '',
+      wbs: '',
+      customerCode: '',
+      companyNumber: '',
+      sourceType: '',
+      moveType: '',
+      deliveryType: '',
+      entryNumber: '',
+    },
+    true,
+  );
   const [{dates, start, end}, onDatesChange] = useRangeDate();
-  const {isSearching, refetch} = useContextSection(searchContext, state => state[0]);
-  const onSearch = useTableSearchEvent(context, {...fields, startTime: start, endTime: end});
-  const [isExporting, onExport] = useTableExportEvent({
-    fn: exportSellOrderList,
+  const {isSearching} = useContextSection(searchContext, state => state[0]);
+  const [visible, {onSearch, onReset, onShowModal, onCloseModal}] = useTableSearchToolEvents(
     context,
-    pageContext,
-  });
+    {...fields, startTime: start, endTime: end},
+    {
+      resetCallback() {
+        resetState();
+        onDatesChange([null, null]);
+      },
+    },
+  );
+  const [filterList, {set}] = useFilterDB();
 
   return (
-    <Card>
-      <FilterFieldWrapper onSearch={onSearch}>
-        <FilterField
-          name='sellOrder'
-          label='销售单号'
-          value={deliveryId}
-          onChange={onChange('deliveryId')}
-        />
-        <FilterField
-          name='materialName'
-          label='物料名称'
-          value={materialName}
-          onChange={onChange('materialName')}
-        />
-        <FilterField
-          name='materialCode'
-          label='物料编号'
-          value={materialCode}
-          onChange={onChange('materialCode')}
-        />
-
-        <FilterDatePicker
-          name='askGoodsDates'
-          label='单据日期'
-          value={dates}
-          onChange={onDatesChange}
-        />
-        <FilterButtonGroup
+    <>
+      <Card>
+        <FilterTool
+          fields={fields}
+          dates={dates}
+          onChange={onChange}
           onSearch={onSearch}
-          onRefresh={refetch}
+          onDatesChange={onDatesChange}
+          onFilter={onShowModal}
+          sourceMap={sourceMap}
+          fixedMap={fixedMap}
           isSearching={isSearching}
-          onExport={onExport}
-          isExporting={isExporting}
+          onReset={onReset}
+          filterData={filterList}
         />
-      </FilterFieldWrapper>
-    </Card>
+      </Card>
+
+      <FilterSelectorModal
+        visible={visible}
+        onClose={onCloseModal}
+        source={filterList}
+        onConfirm={set}
+        filtermap={sourceMap}
+      />
+    </>
   );
 };
 

+ 19 - 0
packages/app/src/pages/sell-order/filter/state.ts

@@ -0,0 +1,19 @@
+import {FilterGroupMap, MapValue} from '@components';
+import {contextState} from '../context';
+
+export const fixedMap: MapValue<typeof contextState>[] = [
+  {label: '销售单号', type: 'field', value: 'deliveryId'},
+  {label: '物料编号', type: 'field', value: 'materialCode'},
+  {label: '物料名称', type: 'field', value: 'materialName'},
+];
+
+export const sourceMap: FilterGroupMap<typeof contextState> = new Map([
+  ['1', {label: '客户名称', type: 'keySelect', selectKey: '供应商/客户', value: 'customerCode'}],
+  ['2', {label: '所属公司', type: 'keySelect', selectKey: '公司', value: 'companyNumber'}],
+  ['3', {label: '销售日期', type: 'date', value: 'startTime'}],
+  ['4', {label: 'WBS编号', type: 'field', value: 'wbs'}],
+  ['5', {label: '来源类型', type: 'field', value: 'sourceType'}],
+  ['6', {label: '移动类型', type: 'field', value: 'moveType'}],
+  ['7', {label: '交货类型', type: 'field', value: 'deliveryType'}],
+  ['8', {label: '分录号', type: 'field', value: 'entryNumber'}],
+]);

+ 48 - 16
packages/app/src/pages/sell-order/table/hooks.tsx

@@ -1,6 +1,12 @@
 import {ColumnsType} from 'antd/es/table';
 import {SellOrderListData} from '@models';
-import {HUGE_TABLE_WIDTH, MIDDLE_TABLE_WIDTH, NORMAL_TABLE_WIDTH, SMALL_TABLE_WIDTH} from '@utils';
+import {
+  HUGE_TABLE_WIDTH,
+  LARGE_TABLE_WIDTH,
+  MIDDLE_TABLE_WIDTH,
+  NORMAL_TABLE_WIDTH,
+  SMALL_TABLE_WIDTH,
+} from '@utils';
 import {useSupertube, useTableDeleteEvent} from '@hooks';
 import {deleSellOrder} from '@apis';
 import {Button} from 'antd';
@@ -12,12 +18,6 @@ const columns: ColumnsType<SellOrderListData> = [
     key: 'deliveryId',
     width: MIDDLE_TABLE_WIDTH,
   },
-  {
-    title: '物料名称',
-    dataIndex: 'materialName',
-    key: 'materialName',
-    width: HUGE_TABLE_WIDTH,
-  },
   {
     title: '物料编号',
     dataIndex: 'materialCode',
@@ -25,10 +25,10 @@ const columns: ColumnsType<SellOrderListData> = [
     width: MIDDLE_TABLE_WIDTH,
   },
   {
-    title: 'WBS编号',
-    dataIndex: 'wbs',
-    key: 'wbs',
-    width: NORMAL_TABLE_WIDTH,
+    title: '物料名称',
+    dataIndex: 'materialName',
+    key: 'materialName',
+    width: HUGE_TABLE_WIDTH,
   },
   {
     title: '交货数量',
@@ -49,17 +49,49 @@ const columns: ColumnsType<SellOrderListData> = [
     width: SMALL_TABLE_WIDTH,
   },
   {
-    title: '公司编号',
-    dataIndex: 'companyNumber',
-    key: 'companyNumber',
-    width: SMALL_TABLE_WIDTH,
+    title: '客户名称',
+    dataIndex: 'customerName',
+    key: 'customerName',
+    width: LARGE_TABLE_WIDTH,
+  },
+  {
+    title: '所属公司',
+    dataIndex: 'companyName',
+    key: 'companyName',
+    width: LARGE_TABLE_WIDTH,
   },
   {
-    title: '单据日期',
+    title: '销售日期',
     dataIndex: 'billsTime',
     key: 'billsTime',
     width: NORMAL_TABLE_WIDTH,
   },
+  {
+    title: 'WBS编号',
+    dataIndex: 'wbs',
+    key: 'wbs',
+    width: NORMAL_TABLE_WIDTH,
+  },
+  {
+    title: '来源类型',
+    dataIndex: 'sourceType',
+    width: NORMAL_TABLE_WIDTH,
+  },
+  {
+    title: '移动类型',
+    dataIndex: 'moveType',
+    width: NORMAL_TABLE_WIDTH,
+  },
+  {
+    title: '交货类型',
+    dataIndex: 'deliveryType',
+    width: NORMAL_TABLE_WIDTH,
+  },
+  {
+    title: '分录号',
+    dataIndex: 'entryNumber',
+    width: NORMAL_TABLE_WIDTH,
+  },
 ];
 
 export function useColumns(refetch: () => void) {

+ 16 - 4
packages/app/src/pages/sell-order/table/index.tsx

@@ -1,7 +1,7 @@
-import {useContextSection, useQueryTableList, useSupertube} from '@hooks';
+import {useContextSection, useQueryTableList, useSupertube, useTableExportEvent} from '@hooks';
 import {FC} from 'react';
 import {context, pageContext, searchContext} from '../context';
-import {getSellOrderList} from '@apis';
+import {exportSellOrderList, getSellOrderList} from '@apis';
 import {Card} from 'antd';
 
 import {Table, TableTools} from '@components';
@@ -11,7 +11,7 @@ import AddModal from './modal';
 
 const TableList: FC = function () {
   const params = useContextSection(context, state => state[0]);
-  const [{data, count}, {refetch}] = useQueryTableList({
+  const [{data, count, isFetching}, {refetch}] = useQueryTableList({
     queryFn: getSellOrderList,
     params,
     pageContext,
@@ -20,11 +20,23 @@ const TableList: FC = function () {
   const columns = useColumns(refetch);
   const [visible, {setTrue, setFalse}] = useBoolean();
   const isSuper = useSupertube();
+  const [isExporting, onExport] = useTableExportEvent({
+    fn: exportSellOrderList,
+    context,
+    pageContext,
+  });
 
   return (
     <>
       <Card className='table-wrapper'>
-        {isSuper && <TableTools onClick={setTrue} />}
+        <TableTools
+          onAdd={isSuper ? setTrue : void 0}
+          isRefreshing={isFetching}
+          onRefresh={refetch}
+          isExporting={isExporting}
+          onExport={onExport}
+        />
+
         <Table
           columns={columns}
           pageContext={pageContext}