index.tsx 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. }>({
  25. tabsIndex: ASSETS_TABS_ENUM.Product,
  26. bindModal: false,
  27. parentId: '',
  28. });
  29. const Assets = observer((props: AssetsProps) => {
  30. const intl = useIntl();
  31. // 资产类型
  32. const TabsArray = [
  33. // {
  34. // intlTitle: '1',
  35. // defaultMessage: '产品分类',
  36. // key: ASSETS_TABS_ENUM.ProductCategory,
  37. // components: ProductCategory,
  38. // },
  39. {
  40. intlTitle: '2',
  41. defaultMessage: '产品',
  42. key: ASSETS_TABS_ENUM.Product,
  43. components: Product,
  44. },
  45. {
  46. intlTitle: '3',
  47. defaultMessage: '设备',
  48. key: ASSETS_TABS_ENUM.Device,
  49. components: Device,
  50. },
  51. {
  52. intlTitle: '4',
  53. defaultMessage: '用户',
  54. key: ASSETS_TABS_ENUM.User,
  55. components: Member,
  56. },
  57. ];
  58. useEffect(() => {
  59. AssetsModel.parentId = props.parentId;
  60. }, [props.parentId]);
  61. return (
  62. <div style={{ position: 'relative', width: '100%' }}>
  63. <div style={{ position: 'absolute', top: 12, left: 180 }}>
  64. <ExclamationCircleOutlined style={{ marginRight: 12 }} />
  65. 部门拥有的资产为所有类型资产的并集
  66. </div>
  67. <Tabs
  68. activeKey={AssetsModel.tabsIndex}
  69. onChange={(key) => {
  70. AssetsModel.tabsIndex = key;
  71. }}
  72. >
  73. {TabsArray.map((item) => (
  74. <Tabs.TabPane
  75. tab={intl.formatMessage({
  76. id: item.intlTitle,
  77. defaultMessage: item.defaultMessage,
  78. })}
  79. key={item.key}
  80. >
  81. <item.components parentId={props.parentId} />
  82. </Tabs.TabPane>
  83. ))}
  84. </Tabs>
  85. </div>
  86. );
  87. });
  88. export default Assets;