Pārlūkot izejas kodu

update: 重写gs错误信息

xyh 2 gadi atpakaļ
vecāks
revīzija
5cefad56f4

+ 19 - 8
packages/app/src/models/request/queryList.ts

@@ -160,17 +160,28 @@ export type GetDeleteLogListParams = {
 
 /** 获取GS接口错误日志 */
 export type GetGSErrorLogListParams = {
-  startTime: string;
-  endTime: string;
-  /** 路径 */
-  url: string;
+  /** 单据编号 */
+  documentCode: string;
+  /** gs单据编号 */
+  generateCode: string;
+  /** 数量 */
+  num: string;
   /** 错误信息 */
   errorInfo: string;
-  /** 内容 */
-  dataVal: string;
-  /** 请求类型 */
+  /** 物料编号 */
+  materialCode: string;
+  /** gs分录号 */
+  entryNumberGs: string;
+  /** 状态 */
+  transmissionType: string;
+  /** 单据id */
+  documentId: string;
+  /** 分录号 */
+  entryNumber: string;
+  startTime: string;
+  endTime: string;
+  /** 单据类型 */
   type: string;
-  transmissionType: '1',
 } & ListParams;
 
 /** 其他入库 */

+ 18 - 8
packages/app/src/models/response/queryList.ts

@@ -326,18 +326,28 @@ export type DeleteLogListData = {
 
 /** GS错误日志 */
 export type GSErrorListData = {
-  id: string;
-  /** 路径 */
-  url: string;
+  /** 单据编号 */
+  documentCode: string;
+  /** gs单据编号 */
+  generateCode: string;
+  /** 数量 */
+  num: string;
   /** 错误信息 */
   errorInfo: string;
-  /** 数据 */
-  dataVal: string;
+  /** 物料编号 */
+  materialCode: string;
+  /** gs分录号 */
+  entryNumberGs: string;
   /** 日期 */
   scrq: string;
-  /** 是否重传 1未重传 0重传 */
-  transmissionType: 0 | 1;
-  /** 请求类型 */
+  /** 状态 */
+  transmissionType: number;
+  /** 单据id */
+  documentId: string;
+  /** 分录号 */
+  entryNumber: string;
+  id: number;
+  /** 单据类型 */
   type: string;
 };
 

+ 18 - 4
packages/app/src/pages/gs-error-log/context.ts

@@ -8,12 +8,26 @@ import {GetGSErrorLogListParams, OriginalListParams} from '@models';
 export const pageContext = createPageContext();
 export const searchContext = createSearchContext();
 export const contextState: OriginalListParams<GetGSErrorLogListParams> = {
+  /** 单据编号 */
+  documentCode: '',
+  /** gs单据编号 */
+  generateCode: '',
+  /** 数量 */
+  num: '',
+  /** 错误信息 */
+  errorInfo: '',
+  /** 物料编号 */
+  materialCode: '',
+  /** gs分录号 */
+  entryNumberGs: '',
+  /** 状态 */
+  transmissionType: '1',
+  /** 单据id */
+  documentId: '',
+  /** 分录号 */
+  entryNumber: '',
   startTime: '',
   endTime: '',
-  url: '',
-  errorInfo: '',
-  dataVal: '',
   type: '',
-  transmissionType: '1' as const,
 };
 export const context = createTableSearchContext(contextState);

+ 31 - 48
packages/app/src/pages/gs-error-log/filter/index.tsx

@@ -2,17 +2,13 @@ import {
   useContextSection,
   useFilterField,
   useRangeDate,
+  useTableFilterState,
   useTableSearchToolEvents,
 } from '@hooks';
 import {FC} from 'react';
 import {context, contextState, searchContext} from '../context';
-import {Card} from 'antd';
-import {
-  FilterButtonGroup,
-  FilterDatePicker,
-  FilterField,
-  FilterFieldWrapper,
-} from '@components';
+import {FilterSelectorModal, FilterTool} from '@components';
+import {fixedMap, sourceMap} from './state';
 
 const Filter: FC = function() {
   const [fields, {onChange, resetState}] = useFilterField(
@@ -24,7 +20,10 @@ const Filter: FC = function() {
   const [{dates, start, end}, onDatesChange] = useRangeDate(null, null, {
     enableTime: true,
   });
-  const [, {onSearch, onReset}] = useTableSearchToolEvents(
+  const [
+    visible,
+    {onSearch, onReset, onShowModal, onCloseModal},
+  ] = useTableSearchToolEvents(
     context,
     {...fields, startTime: start, endTime: end},
     {
@@ -38,49 +37,33 @@ const Filter: FC = function() {
     searchContext,
     state => state[0].isSearching,
   );
+  const [filterList, set] = useTableFilterState(searchContext);
 
   return (
-    <Card>
-      <FilterFieldWrapper onSearch={onSearch} testId="error_log_filter">
-        <FilterField
-          label="请求地址"
-          value={fields.url}
-          onChange={onChange('url')}
-          name="url"
-        />
-        <FilterField
-          label="错误信息"
-          value={fields.errorInfo}
-          onChange={onChange('errorInfo')}
-          name="errorInfo"
-        />
-        <FilterField
-          label="请求内容"
-          value={fields.dataVal}
-          onChange={onChange('dataVal')}
-          name="dataVal"
-        />
-        <FilterField
-          value={fields.type}
-          onChange={onChange('type')}
-          label="请求类型"
-          name="type"
-        />
-        <FilterDatePicker
-          value={dates}
-          onChange={onDatesChange}
-          label="请求时间"
-          name="date"
-          enableTime
-        />
+    <>
+      <FilterTool
+        fields={fields}
+        onChange={onChange}
+        filterData={filterList}
+        onReset={onReset}
+        onSearch={onSearch}
+        isSearching={isSearching}
+        sourceMap={sourceMap}
+        fixedMap={fixedMap}
+        onFilter={onShowModal}
+        dates={dates}
+        onDatesChange={onDatesChange}
+        testId="gs_errro_filter"
+      />
 
-        <FilterButtonGroup
-          onSearch={onSearch}
-          isSearching={isSearching}
-          onReset={onReset}
-        />
-      </FilterFieldWrapper>
-    </Card>
+      <FilterSelectorModal
+        visible={visible}
+        onClose={onCloseModal}
+        onConfirm={set}
+        source={filterList}
+        filtermap={sourceMap}
+      />
+    </>
   );
 };
 

+ 62 - 0
packages/app/src/pages/gs-error-log/filter/state.ts

@@ -0,0 +1,62 @@
+import {FilterGroupMap, MapValue} from '@components';
+import {contextState} from '../context';
+
+export const fixedMap: MapValue<typeof contextState>[] = [
+  {label: '单据ID', type: 'field', value: 'documentId'},
+  {label: '单据号', type: 'field', value: 'documentCode'},
+  {label: 'GS单据号', type: 'field', value: 'generateCode'},
+  {label: '错误信息', type: 'field', value: 'errorInfo'},
+  {label: '日志时间', type: 'date', value: 'startTime', enableTime: true},
+  {
+    label: '状态',
+    type: 'select',
+    value: 'transmissionType',
+    options: [{label: '成功', value: '0'}, {label: '失败', value: '1'}],
+  },
+];
+
+export const sourceMap: FilterGroupMap<typeof contextState> = new Map([
+  [
+    '1',
+    {
+      label: '物料编号',
+      type: 'field',
+      value: 'materialCode',
+    },
+  ],
+  [
+    '2',
+    {
+      label: 'GS分录号',
+      type: 'field',
+      value: 'materialCode',
+    },
+  ],
+  [
+    '3',
+    {
+      label: '分录号',
+      type: 'field',
+      value: 'materialCode',
+    },
+  ],
+  [
+    '4',
+    {
+      label: '单据类型',
+      type: 'select',
+      value: 'type',
+      options: [
+        {label: '采购收货', value: '101'},
+        {label: '销售交货单', value: '201'},
+        {label: '生产领用', value: '207'},
+        {label: '其他收货', value: '109'},
+        {label: '其他发货', value: '209'},
+        {label: '补领料发货', value: 'Z32'},
+        {label: '非生产领用', value: 'Z05'},
+        {label: '生产收货', value: '104'},
+        {label: '移库单', value: '345'},
+      ],
+    },
+  ],
+]);

+ 0 - 78
packages/app/src/pages/gs-error-log/table/hooks.tsx

@@ -1,78 +0,0 @@
-import {retryErrorInterface} from '@apis';
-import {GSErrorListData} from '@models';
-import {useMutation} from '@tanstack/react-query';
-import {
-  NORMAL_TABLE_WIDTH,
-  HUGE_TABLE_WIDTH,
-  SMALL_TABLE_WIDTH,
-  MIDDLE_TABLE_WIDTH,
-} from '@utils';
-import {Button, message} from 'antd';
-import {ColumnsType} from 'antd/es/table';
-import {useState} from 'react';
-
-const columns: ColumnsType<GSErrorListData> = [
-  {title: '请求地址', dataIndex: 'url', width: NORMAL_TABLE_WIDTH},
-  {title: '错误信息', dataIndex: 'errorInfo', width: HUGE_TABLE_WIDTH},
-  {title: '请求内容', dataIndex: 'dataVal', width: HUGE_TABLE_WIDTH},
-  {title: '请求类型', dataIndex: 'type', width: SMALL_TABLE_WIDTH},
-  {title: '请求时间', dataIndex: 'scrq', width: MIDDLE_TABLE_WIDTH},
-];
-
-function useRetry(refetch: () => void) {
-  const [pendingId, setPendingId] = useState('');
-
-  const {mutate} = useMutation({
-    mutationFn: retryErrorInterface,
-    onSuccess({msg}) {
-      if (msg === '200') {
-        message.success('已重试');
-        refetch();
-      }
-    },
-    onSettled() {
-      setPendingId('');
-    },
-  });
-
-  function onRetry(data: GSErrorListData) {
-    return function() {
-      const {id} = data;
-      setPendingId(id);
-      mutate(data);
-    };
-  }
-
-  return [pendingId, onRetry] as const;
-}
-
-export function useColumns(fetch: () => void) {
-  const [retryId, onRetry] = useRetry(fetch);
-
-  const tableColumns: ColumnsType<GSErrorListData> = [
-    ...columns,
-    {
-      title: '操作',
-      width: SMALL_TABLE_WIDTH,
-      fixed: 'right',
-      dataIndex: 'id',
-      render(_, data) {
-        const {transmissionType, id} = data;
-
-        return (
-          <Button
-            type="text"
-            className="ant-text-btn-color-primary"
-            disabled={transmissionType === 0}
-            loading={retryId === id}
-            onClick={onRetry(data)}
-          >
-            {transmissionType === 0 ? '已重试' : '重试'}
-          </Button>
-        );
-      },
-    },
-  ];
-
-  return tableColumns;
-}

+ 36 - 6
packages/app/src/pages/gs-error-log/table/index.tsx

@@ -12,18 +12,48 @@ import {Table, TableTools} from '@components';
 import {ColumnsType} from 'antd/es/table';
 import {GSErrorListData} from '@models';
 import {
-  NORMAL_TABLE_WIDTH,
   HUGE_TABLE_WIDTH,
-  SMALL_TABLE_WIDTH,
   MIDDLE_TABLE_WIDTH,
+  NORMAL_TABLE_WIDTH,
+  SMALL_TABLE_WIDTH,
 } from '@utils';
 
 const columns: ColumnsType<GSErrorListData> = [
-  {title: '请求地址', dataIndex: 'url', width: NORMAL_TABLE_WIDTH},
+  {title: '单据ID', dataIndex: 'documentId', width: HUGE_TABLE_WIDTH},
+  {title: '单据号', dataIndex: 'documentCode', width: HUGE_TABLE_WIDTH},
+  {title: 'GS单据号', dataIndex: 'generateCode', width: HUGE_TABLE_WIDTH},
   {title: '错误信息', dataIndex: 'errorInfo', width: HUGE_TABLE_WIDTH},
-  {title: '请求内容', dataIndex: 'dataVal', width: HUGE_TABLE_WIDTH},
-  {title: '请求类型', dataIndex: 'type', width: SMALL_TABLE_WIDTH},
-  {title: '请求时间', dataIndex: 'scrq', width: MIDDLE_TABLE_WIDTH},
+  {title: '物料编号', dataIndex: 'materialCode', width: HUGE_TABLE_WIDTH},
+  {title: '数量', dataIndex: 'num', align: 'right', width: NORMAL_TABLE_WIDTH},
+  {title: 'GS分录号', dataIndex: 'entryNumberGs', width: HUGE_TABLE_WIDTH},
+  {title: '分录号', dataIndex: 'entryNumber', width: MIDDLE_TABLE_WIDTH},
+  {title: '日志时间', dataIndex: 'scrq', width: MIDDLE_TABLE_WIDTH},
+  {
+    title: '单据类型',
+    dataIndex: 'type',
+    width: NORMAL_TABLE_WIDTH,
+    render(_, {type}) {
+      switch (type) {
+        case '101': return '采购收货';
+        case '201': return '销售交货单';
+        case '207': return '生产领用';
+        case '109': return '其他收货';
+        case '209': return '其他发货';
+        case 'Z32': return '补领料发货';
+        case 'Z05': return '非生产领用';
+        case '104': return '生产收货';
+        case '345': return '移库单';
+      }
+    },
+  },
+  {
+    title: '状态',
+    dataIndex: 'transmissionType',
+    width: SMALL_TABLE_WIDTH,
+    render(_, {transmissionType}) {
+      return String(transmissionType) === '1' ? '失败' : '成功';
+    },
+  },
 ];
 
 const TableList: FC = function() {