store.ts
1.97 KB
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
import { useState } from 'react';
import * as api from './api';
import { getShopApi, getUnitCompanyListApi } from '@/common/api';
import usePagination from '@/hooks/usePagination';
import useInitail from "@/hooks/useInitail";
export interface BreadcrumbItem {
key?: string
name?: string
}
export default function useStore() {
const [currentItem, setCurrentItem] = useState<StanderList.ListVO>({});
// 面包屑列表
const [breadcrumbs, setBreadcrumbs] = useState<BreadcrumbItem[]>([{ name: '列表', key: 'list' }]);
// 当前面包屑
const [currentBreadcrumb, setCurrentBreadcrumb] = useState<BreadcrumbItem>({ name: '列表', key: 'list' });
//渠道
const { data } = useInitail(getUnitCompanyListApi, [], { types: '80' });
const { data: unitItem } = useInitail(api.getUnitItem, [], {});
const { data: shopList } = useInitail(getShopApi, [], {});
const { list: postList, loading: postLoading } = usePagination(api.getPostList, {});
const { list, setParams, paginationConfig, innerParams, loading, setLoading } = usePagination(api.getListApi, { status: 1 });
const [isPart, setIsPart] = useState<boolean>(false);
/**是否可编辑 */
const [editDisabled, setEditDisabled] = useState<boolean>(false);
const typeName = [
{ name: '固定资产', type: 1 },
{ name: '低值品', type: 2 },
{ name: '易耗品', type: 3 },
];
const dataType = [
{ name: '天', id: 1 },
{ name: '月', id: 3 },
];
const MenuItems = [
{ label: '物品维度', key: '1' },
{ label: '门店维度', key: '2' },
{ label: '岗位维度', key: '3' },
];
return {
data,
shopList,
postList,
unitItem,
postLoading,
breadcrumbs,
setBreadcrumbs,
currentBreadcrumb,
setCurrentBreadcrumb,
typeName,
dataType,
currentItem,
setCurrentItem,
list,
innerParams,
setParams,
paginationConfig,
loading,
setLoading,
isPart,
setIsPart,
MenuItems,
editDisabled,
setEditDisabled
};
}