Jelajahi Sumber

fix: PermSelect在custom下staffIds默认为空数组

lanjianrong 5 tahun lalu
induk
melakukan
91845135ec

+ 3 - 2
src/pages/Customer/Company/components/PermSelect.tsx

@@ -24,7 +24,8 @@ const PermSelect: React.FC<PermSelectProps> = ({ dataType, onConfirm }) => {
   const { initialState: { permData } = { permData: {} } } = useModel('@@initialState')
   const { toggleModal, setModalProps } = useModal()
   const options = [...(permData[dataType] || [])]
-  const [defaultValue, defaultStaffIds] = getPermAuthCache(dataType)
+  const [defaultValue, defaultStaffIds, permAuthCache] = getPermAuthCache(dataType)
+
   const [state, setState] = useState({
     currKey: defaultValue,
     staffIds: defaultStaffIds,
@@ -37,7 +38,7 @@ const PermSelect: React.FC<PermSelectProps> = ({ dataType, onConfirm }) => {
         width: '60vw',
         modalRender: () => (
           <CustomPerm
-            defaultValues={state.staffIds}
+            defaultValues={state.staffIds || []}
             onConfirm={({ staffIds, dataPermission }) => {
               setState({ ...state, staffIds, currKey: e })
               onConfirm({ staffIds, dataPermission })

+ 1 - 3
src/pages/Product/Lock/Lockstore/index.jsx

@@ -107,11 +107,9 @@ const LockStore = ({ prodList = [], dispatch, shouldUpdate }) => {
   // }
   const { initialState: { permData } = { permData: {} } } = useModel('@@initialState')
   const [state, setState] = useState({
-    params: { dataPermission: 'oneself', staffIds: null },
     data: [],
     totalOld: 0, // 待接收锁总数
     totalNew: 0,
-    id: '',
     orderIds: []
   })
 
@@ -417,7 +415,7 @@ const LockStore = ({ prodList = [], dispatch, shouldUpdate }) => {
               placeholder={`在${
                 permData[PermDataTypeEunm.PRODUCT]?.find(
                   item => item.value === defaultPermAuthCache
-                )?.label || '自定义'
+                )?.label
               }下搜索`}
               onSearch={handleSearch}
             />

+ 3 - 3
src/utils/auth/index.ts

@@ -33,10 +33,10 @@ export function clearAuthCache(immediate = true) {
 }
 
 export function getPermAuthCache(dataType?: MainMenuKeyEnum) {
-  if (!dataType) return [null, null]
+  const permAuthCache = getAuthCache(PERMISSION_SELECT_KEY)
+  if (!dataType) return [null, null, permAuthCache]
   let defaultValue = 'oneself',
     defaultStaffIds = null
-  const permAuthCache = getAuthCache(PERMISSION_SELECT_KEY)
   if (permAuthCache && permAuthCache[dataType]) {
     if (isArray(permAuthCache[dataType])) {
       // 防止类型为custom但staffIds为空数组的情况
@@ -51,5 +51,5 @@ export function getPermAuthCache(dataType?: MainMenuKeyEnum) {
       defaultValue = permAuthCache[dataType]
     }
   }
-  return [defaultValue, defaultStaffIds]
+  return [defaultValue, defaultStaffIds, permAuthCache]
 }