index.tsx 941 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { tenderStore } from '@/store/mobx'
  2. import history from '@/utils/history'
  3. import { storage } from '@/utils/util'
  4. import { observer } from 'mobx-react'
  5. import React, { useEffect } from 'react'
  6. interface Authorization {
  7. type: 'contract' | 'safe' | 'quality'
  8. auth: 'access' | 'add' | 'delete'
  9. children: React.ReactNode
  10. }
  11. /** auth的格式化为:delete | add | access */
  12. const Authorization: React.FC<Authorization> = ({ type, auth, children }) => {
  13. useEffect(() => {
  14. if (tenderStore.bid) {
  15. tenderStore.saveTenderPermission(tenderStore.bid)
  16. }
  17. if (!tenderStore.tender.bidsectionId) {
  18. tenderStore.cloneTenderFromStorage()
  19. }
  20. }, [ ])
  21. const authPass = 1
  22. // 获取mobx存储的权限
  23. const permission = tenderStore.permission[type]
  24. if (permission[auth] === authPass) {
  25. return <>{children}</>
  26. }
  27. return null
  28. }
  29. export default observer(Authorization)