zhengyiming
4 天以前 245791c6de54b269dc22f38b0f6c5d160bf9c641
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import * as operateHistoryServices from '@/services/api/OperateHistory';
import { OrderInputType } from '@bole-core/core';
import { useTable } from '@bole-core/components';
import { MaybeRef } from 'vue';
import { OperateHistoryTypeEnum } from '@/constants';
 
export enum OperateType {
  /**
   * 审核
   */
  Audit = 1,
  /**
   * 入账
   */
  Account = 2,
  /**
   * 上传发票
   */
  Invoice = 3,
}
 
export const OperateTypeText = {
  [OperateType.Audit]: '审核',
  [OperateType.Account]: '入账',
  [OperateType.Invoice]: '上传发票',
};
 
export type UseTableLogListOptions = {
  relationId: MaybeRef<string>;
  operateType?: MaybeRef<number>;
};
 
export function useTableLogList({ relationId, operateType }: UseTableLogListOptions) {
  const BaseState = {
    loading: true,
  };
 
  const state = reactive({ ...BaseState });
 
  const { getDataSource: getList, proTableProps } = useTable(
    async ({ pageIndex, pageSize }) => {
      try {
        let params: API.GetOperateHistoryInput = {
          pageModel: {
            rows: pageSize,
            page: pageIndex,
            orderInput: [{ property: 'creationTime', order: OrderInputType.Desc }],
          },
          relationId: unref(relationId),
        };
        const _operateType = unref(operateType);
        if (_operateType) {
          params.operateName = OperateTypeText[_operateType];
        }
        let res = await operateHistoryServices.getOperateHistoryByRelationId(params, {
          showLoading: !state.loading,
        });
        return res;
      } catch (error) {}
    },
    {
      queryKey: ['operateHistoryServices/getOperateHistoryByRelationId'],
      columnsRenderProps: {
        creationTime: {
          type: 'date',
          format: 'YYYY-MM-DD HH:mm:ss',
        },
      },
    }
  );
 
  const OperateHistoryTableColumns: API.CustomModuleColumnDto[] = [
    { id: '1', enCode: 'creatorName', name: '操作人' },
    { id: '2', enCode: 'creationTime', name: '操作时间', width: 180 },
    { id: '3', enCode: 'operateName', name: '操作' },
    { id: '4', enCode: 'operateContent', name: '操作内容' },
  ];
 
  return {
    state,
    getList,
    proTableProps,
    OperateHistoryTableColumns,
  };
}
 
export type UseTableLogListByTypeOptions = {
  relationId: MaybeRef<string>;
  operateHistoryType?: MaybeRef<OperateHistoryTypeEnum>;
};
 
export function useTableLogListByType({
  relationId,
  operateHistoryType,
}: UseTableLogListByTypeOptions) {
  const BaseState = {
    loading: true,
  };
 
  const state = reactive({ ...BaseState });
 
  const { getDataSource: getList, proTableProps } = useTable(
    async ({ pageIndex, pageSize }) => {
      try {
        let params: API.QueryOperateHistoryByTypeInput = {
          pageModel: {
            rows: pageSize,
            page: pageIndex,
            orderInput: [{ property: 'creationTime', order: OrderInputType.Desc }],
          },
          typeId: unref(relationId),
          operateHistoryType: unref(operateHistoryType),
        };
 
        let res = await operateHistoryServices.getOperateHistoryByType(params, {
          showLoading: !state.loading,
        });
        return res;
      } catch (error) {}
    },
    {
      queryKey: ['operateHistoryServices/getOperateHistoryByRelationId'],
      columnsRenderProps: {
        creationTime: {
          type: 'date',
          format: 'YYYY-MM-DD HH:mm:ss',
        },
      },
    }
  );
 
  const OperateHistoryTableColumns: API.CustomModuleColumnDto[] = [
    { id: '1', enCode: 'creatorName', name: '操作人' },
    { id: '2', enCode: 'creationTime', name: '操作时间', width: 180 },
    { id: '3', enCode: 'operateName', name: '操作' },
    { id: '4', enCode: 'operateContent', name: '操作内容' },
  ];
 
  return {
    state,
    getList,
    proTableProps,
    OperateHistoryTableColumns,
  };
}