Browse Source

feat: 增加订单删除日志

xyh 2 years ago
parent
commit
8fc4120839

+ 11 - 0
packages/app/src/apis/queryList.ts

@@ -15,6 +15,8 @@ import {
   GetRelocationOrderListParams,
   RelocationOrderListData,
   BaseResult,
+  GetDeleteLogListParams,
+  DeleteLogListData,
 } from '@models';
 import {request} from './request';
 
@@ -183,3 +185,12 @@ export function exportRelocationOrderList(
     skipError: true,
   });
 }
+
+/** 获取单据删除日志 */
+export function getDeleteLogList(data: GetDeleteLogListParams): BaseListResult<DeleteLogListData> {
+  return request({
+    method: 'GET',
+    url: `${BASE_URL}/getLogData`,
+    data,
+  });
+}

+ 1 - 1
packages/app/src/components/filter-field/Select.tsx

@@ -1,4 +1,4 @@
-import {Col, Row, Select as SelectOri} from 'antd';
+import {Col, Select as SelectOri} from 'antd';
 import css from './index.module.css';
 import {FC} from 'react';
 import {filterOptions} from '@utils';

+ 4 - 4
packages/app/src/components/table-search-provider/index.tsx

@@ -1,5 +1,5 @@
 import {TableSearchAction, useTableSearchContextReducer} from '@hooks';
-import {Dispatch, FC, ReactNode} from 'react';
+import {Dispatch, ReactElement, ReactNode} from 'react';
 import {Context} from 'use-context-selector';
 
 type Props<T> = {
@@ -8,15 +8,15 @@ type Props<T> = {
   children: ReactNode;
 };
 
-const TableSearchProvider: FC<Props<any>> = function <T extends Record<string, unknown>>({
+function TableSearchProvider<T extends Record<string, unknown>>({
   context,
   state,
   children,
-}: Props<T>) {
+}: Props<T>): ReactElement {
   const {Provider} = context;
   const value = useTableSearchContextReducer(state);
 
   return <Provider value={value}>{children}</Provider>;
-};
+}
 
 export default TableSearchProvider;

+ 3 - 3
packages/app/src/components/table/index.tsx

@@ -2,7 +2,7 @@ import {Table as OriTable} from 'antd';
 import {ColumnsType} from 'antd/es/table';
 import {createPageContext, createSearchContext, usePage, useTableSearchState} from '@hooks';
 import {PAGE_SIZE_LIST, calcColumnsWidth} from '@utils';
-import {FC} from 'react';
+import {ReactElement} from 'react';
 
 type Props<T> = {
   testId?: string;
@@ -16,7 +16,7 @@ type Props<T> = {
   pageSizeList?: string[];
 };
 
-const Table: FC<Props<any>> = function <T extends Record<string, any>>(props: Props<T>) {
+function Table<T extends Record<string, any>>(props: Props<T>): ReactElement {
   const {
     columns,
     data,
@@ -51,6 +51,6 @@ const Table: FC<Props<any>> = function <T extends Record<string, any>>(props: Pr
       bordered
     />
   );
-};
+}
 
 export default Table;

+ 3 - 3
packages/app/src/hooks/use-filter-field/index.tsx

@@ -1,13 +1,13 @@
-import {useState} from 'react';
+import {useCallback, useState} from 'react';
 
 export function useFilterField<T extends Record<string, string | number>>(init: T) {
   const [fields, setFields] = useState<T>(init);
 
-  function onChange(key: keyof T) {
+  const onChange = useCallback(function (key: keyof T) {
     return function (value: string | number) {
       setFields(prev => ({...prev, [key]: value}));
     };
-  }
+  }, []);
 
   return [fields, onChange] as const;
 }

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

@@ -64,3 +64,15 @@ export type GetRelocationOrderListParams = {
   warehouseTransferCode: string;
 } & BaseOrderListParams &
   ListParams;
+
+/** 获取单据删除日志 */
+export type GetDeleteLogListParams = {
+  /** 单据类型 */
+  documentType: string;
+  /** 开始时间 */
+  startTime: string;
+  /** 结束时间 */
+  endTime: string;
+  /** 内容模糊查询 */
+  data: string;
+} & ListParams;

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

@@ -239,3 +239,18 @@ export type RelocationOrderListData = {
    */
   wbs: string;
 };
+
+/** 单据删除日志 */
+export type DeleteLogListData = {
+  id: string;
+  /** 用户id */
+  userId: string;
+  /** 删除日期 */
+  scrq: string;
+  /** 删除数据 */
+  data: string;
+  /** 0删除 1修改 */
+  type: '0' | '1';
+  /** 单据类型 */
+  documentType: string;
+};

+ 4 - 4
packages/app/src/pages/gs-interface-log/filter/index.tsx

@@ -1,6 +1,6 @@
-import {FilterButtonGroup, FilterSelect} from '@components';
+import {FilterButtonGroup, FilterFieldWrapper, FilterSelect} from '@components';
 import {useContextSection, useFilterField, useTableSearchEvent} from '@hooks';
-import {Card, Row} from 'antd';
+import {Card} from 'antd';
 import {FC} from 'react';
 import {context, searchContext} from '../context';
 import {GSInterfaceType} from '@models';
@@ -29,7 +29,7 @@ const Filter: FC = function () {
 
   return (
     <Card>
-      <Row>
+      <FilterFieldWrapper>
         <FilterSelect
           name='dictionaryName'
           label='接口名称'
@@ -45,7 +45,7 @@ const Filter: FC = function () {
           onRefresh={refetch}
           offset={12}
         />
-      </Row>
+      </FilterFieldWrapper>
     </Card>
   );
 };

+ 12 - 0
packages/app/src/pages/order-log/context.ts

@@ -0,0 +1,12 @@
+import {createPageContext, createSearchContext, createTableSearchContext} from '@hooks';
+import {GetDeleteLogListParams, OriginalListParams} from '@models';
+
+export const pageContext = createPageContext();
+export const searchContext = createSearchContext();
+export const contextState: OriginalListParams<GetDeleteLogListParams> = {
+  startTime: '',
+  endTime: '',
+  documentType: '',
+  data: '',
+};
+export const context = createTableSearchContext(contextState);

+ 52 - 0
packages/app/src/pages/order-log/filter/index.tsx

@@ -0,0 +1,52 @@
+import {
+  FilterButtonGroup,
+  FilterDatePicker,
+  FilterField,
+  FilterFieldWrapper,
+  FilterSelect,
+} from '@components';
+import {useContextSection, useFilterField, useRangeDate, useTableSearchEvent} from '@hooks';
+import {Card} from 'antd';
+import {FC} from 'react';
+import {context, searchContext} from '../context';
+
+const Filter: FC = function () {
+  const [{dates, start, end}, onDatesChange] = useRangeDate();
+  const [{documentType, data}, onChange] = useFilterField({documentType: '', data: ''});
+  const onSearch = useTableSearchEvent(context, {
+    startTime: start,
+    endTime: end,
+    documentType,
+    data,
+  });
+  const {isSearching, refetch} = useContextSection(searchContext, state => state[0]);
+
+  return (
+    <Card>
+      <FilterFieldWrapper>
+        <FilterField
+          name='orderLogData'
+          label='单据内容'
+          value={data}
+          onChange={onChange('data')}
+        />
+        <FilterSelect
+          name='orderLogType'
+          label='单据类型'
+          value={documentType}
+          onChange={onChange('documentType')}
+          options={[]}
+        />
+        <FilterDatePicker
+          label='操作时间'
+          value={dates}
+          name='orderLogDate'
+          onChange={onDatesChange}
+        />
+        <FilterButtonGroup onSearch={onSearch} isSearching={isSearching} onRefresh={refetch} />
+      </FilterFieldWrapper>
+    </Card>
+  );
+};
+
+export default Filter;

+ 22 - 0
packages/app/src/pages/order-log/index.tsx

@@ -0,0 +1,22 @@
+import {PageProvider, SearchProvider, TableSearchProvider} from '@components';
+import {FC} from 'react';
+import {context, contextState, pageContext, searchContext} from './context';
+import Filter from './filter';
+import TableList from './table';
+
+const OrderLog: FC = function () {
+  return (
+    <TableSearchProvider context={context} state={contextState}>
+      <PageProvider context={pageContext}>
+        <SearchProvider context={searchContext}>
+          <section className='content-main'>
+            <Filter />
+            <TableList />
+          </section>
+        </SearchProvider>
+      </PageProvider>
+    </TableSearchProvider>
+  );
+};
+
+export default OrderLog;

+ 40 - 0
packages/app/src/pages/order-log/table/index.tsx

@@ -0,0 +1,40 @@
+import {getDeleteLogList} from '@apis';
+import {useContextSection, useQueryTableList} from '@hooks';
+import {DeleteLogListData} from '@models';
+import {MAXIMAL_TABLE_WIDTH, MIDDLE_TABLE_WIDTH, NORMAL_TABLE_WIDTH} from '@utils';
+import {Card} from 'antd';
+import {ColumnsType} from 'antd/es/table';
+import {FC} from 'react';
+import {context, pageContext, searchContext} from '../context';
+import {Table} from '@components';
+
+const columns: ColumnsType<DeleteLogListData> = [
+  {title: '用户名称', dataIndex: 'useId', width: NORMAL_TABLE_WIDTH},
+  {title: '单据类型', dataIndex: 'documentType', width: NORMAL_TABLE_WIDTH},
+  {title: '删除数据', dataIndex: 'data', width: MAXIMAL_TABLE_WIDTH},
+  {title: '删除时间', dataIndex: 'data', width: MIDDLE_TABLE_WIDTH},
+];
+
+const TableList: FC = function () {
+  const params = useContextSection(context, state => state[0]);
+  const [{data, count}] = useQueryTableList({
+    queryFn: getDeleteLogList,
+    params,
+    pageContext,
+    searchContext,
+  });
+
+  return (
+    <Card className='table-wrapper'>
+      <Table
+        pageContext={pageContext}
+        searchContext={searchContext}
+        columns={columns}
+        data={data}
+        count={count}
+      />
+    </Card>
+  );
+};
+
+export default TableList;