1234567891011121314151617181920212223242526272829303132333435 |
- import { tenderStore } from '@/store/mobx'
- import history from '@/utils/history'
- import { storage } from '@/utils/util'
- import { observer } from 'mobx-react'
- import React, { useEffect } from 'react'
- interface Authorization {
- type: 'contract' | 'safe' | 'quality'
- auth: 'access' | 'add' | 'delete'
- children: React.ReactNode
- }
- /** auth的格式化为:delete | add | access */
- const Authorization: React.FC<Authorization> = ({ type, auth, children }) => {
- useEffect(() => {
- if (tenderStore.bid) {
- tenderStore.saveTenderPermission(tenderStore.bid)
- }
- if (!tenderStore.tender.bidsectionId) {
- tenderStore.cloneTenderFromStorage()
- }
- }, [ ])
- const authPass = 1
- // 获取mobx存储的权限
- const permission = tenderStore.permission[type]
- if (permission[auth] === authPass) {
- return <>{children}</>
- }
- return null
- }
- export default observer(Authorization)
|