index.tsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // 部门-资产分配
  2. import { Tabs } from 'antd';
  3. import { useIntl } from '@@/plugin-locale/localeExports';
  4. import Product from './product';
  5. import Device from '@/pages/system/Department/Assets/deivce';
  6. import Member from '@/pages/system/Department/Member';
  7. import { model } from '@formily/reactive';
  8. import { observer } from '@formily/react';
  9. // import { ExclamationCircleOutlined } from '@ant-design/icons';
  10. import { useEffect } from 'react';
  11. interface AssetsProps {
  12. parentId: string;
  13. }
  14. export enum ASSETS_TABS_ENUM {
  15. 'ProductCategory' = 'ProductCategory',
  16. 'Product' = 'Product',
  17. 'Device' = 'Device',
  18. 'User' = 'User',
  19. }
  20. export const AssetsModel = model<{
  21. tabsIndex: string;
  22. bindModal: boolean;
  23. parentId: string;
  24. params: any;
  25. }>({
  26. tabsIndex: ASSETS_TABS_ENUM.Product,
  27. bindModal: false,
  28. parentId: '',
  29. params: {},
  30. });
  31. const Assets = observer((props: AssetsProps) => {
  32. const intl = useIntl();
  33. // 资产类型
  34. const TabsArray = [
  35. // {
  36. // intlTitle: '1',
  37. // defaultMessage: '产品分类',
  38. // key: ASSETS_TABS_ENUM.ProductCategory,
  39. // components: ProductCategory,
  40. // },
  41. {
  42. intlTitle: '2',
  43. defaultMessage: '产品',
  44. key: ASSETS_TABS_ENUM.Product,
  45. components: Product,
  46. },
  47. {
  48. intlTitle: '3',
  49. defaultMessage: '设备',
  50. key: ASSETS_TABS_ENUM.Device,
  51. components: Device,
  52. },
  53. {
  54. intlTitle: '4',
  55. defaultMessage: '用户',
  56. key: ASSETS_TABS_ENUM.User,
  57. components: Member,
  58. },
  59. ];
  60. useEffect(() => {
  61. AssetsModel.parentId = props.parentId;
  62. }, [props.parentId]);
  63. return (
  64. <div style={{ position: 'relative', width: '100%' }}>
  65. {/* <div style={{ position: 'absolute', top: 12, left: 180 }}>
  66. <ExclamationCircleOutlined style={{ marginRight: 12 }} />
  67. 部门拥有的资产为所有类型资产的并集
  68. </div> */}
  69. <Tabs
  70. activeKey={AssetsModel.tabsIndex}
  71. onChange={(key) => {
  72. AssetsModel.tabsIndex = key;
  73. }}
  74. >
  75. {TabsArray.map((item) => (
  76. <Tabs.TabPane
  77. tab={intl.formatMessage({
  78. id: item.intlTitle,
  79. defaultMessage: item.defaultMessage,
  80. })}
  81. key={item.key}
  82. >
  83. <item.components parentId={props.parentId} />
  84. </Tabs.TabPane>
  85. ))}
  86. </Tabs>
  87. </div>
  88. );
  89. });
  90. export default Assets;