Blame view

src/pages/pms/storage/partShop/store.ts 1.99 KB
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
1
2
3
4
  import useInitail from '@/hooks/useInitail';
  import usePagination from '@/hooks/usePagination';
  import * as api from './api';
  import { useState, useEffect } from 'react';
9fe058df   baiyun   库存库房查询
5
  import { getStoragePage } from '@/pages/pms/storage/StorageManage/api';
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  
  let bodyEl = document.body;
  let top = 0;
  // 当蒙层出现,固定body,不让其跟着蒙层滚动,蒙层消失,恢复其原来的位置
  function stopBodyScroll(isFixed: boolean) {
    if (isFixed) {
      top = window.scrollY;
      bodyEl.style.position = 'fixed';
      bodyEl.style.top = -top + 'px';
    } else {
      bodyEl.style.position = '';
      bodyEl.style.top = '';
      window.scrollTo(0, top);
    }
  }
  
  export default function useStore() {
dfc8ef65   jiangwei   样式调整
23
    const pagination = usePagination<PmsStoragePartShop.Item>(api.getPartShopPageApi, { orderBy: 18, isAsc: false });
9fe058df   baiyun   库存库房查询
24
    const { list: storages } = usePagination<PartStorageSpace.PageVO>(getStoragePage, {pageSize: 1000});
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
25
26
    const { data: shops } = useInitail<PmsStoragePartShop.Option[], {}>(api.getShopApi, [], {});
    const [visible, setVisible] = useState(false);
cf4f0fe5   baiyun   释放库存
27
    const [confirmLoading, setConfirmLoading] = useState(false);
630dfca7   baiyun   优化导入库存和废弃代码删除
28
    const [importVisible, setImportVisible] = useState(false);
cf4f0fe5   baiyun   释放库存
29
    const [releaseVisible, setReleaseVisible] = useState(false);
630dfca7   baiyun   优化导入库存和废弃代码删除
30
    const [override, setOverride] = useState(false);
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
31
    const [item, setItem] = useState<PmsStoragePartShop.Item>({});
b412162f   jiangwei   服务站配件调整
32
33
    const [fw] = useState(location.href.includes('fw'));
    const [fwS] = useState(location.href.includes('fwStock'));
58a9b20c   jiangwei   服务站配件新增功能、工单缺件bug
34
35
    const [isprice, setIsprice] = useState<boolean>(false);
    const [isadd, setIsadd] = useState<boolean>(false);
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
36
37
38
39
40
41
42
43
44
45
46
  
    useEffect(() => {
      if (visible) stopBodyScroll(true);
      else stopBodyScroll(false);
    }, [visible]);
  
    return {
      ...pagination,
      shops,
      visible,
      setVisible,
cf4f0fe5   baiyun   释放库存
47
48
49
50
      releaseVisible,
      setReleaseVisible,
      confirmLoading,
      setConfirmLoading,
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
51
      item,
630dfca7   baiyun   优化导入库存和废弃代码删除
52
53
54
      setItem,
      importVisible,
      setImportVisible,
9fe058df   baiyun   库存库房查询
55
      storages,
630dfca7   baiyun   优化导入库存和废弃代码删除
56
      override,
750fc9fb   baiyun   服务站配件权限管理
57
      setOverride,
58a9b20c   jiangwei   服务站配件新增功能、工单缺件bug
58
      fw,
b412162f   jiangwei   服务站配件调整
59
      fwS,
58a9b20c   jiangwei   服务站配件新增功能、工单缺件bug
60
61
62
63
      isprice,
      setIsprice,
      isadd,
      setIsadd
630dfca7   baiyun   优化导入库存和废弃代码删除
64
    };
cc26d1fc   张志伟   🎉 重新构建项目,解决项目过大的问题
65
  }