李志伟 il y a 3 ans
Parent
révision
0f67a0ddcb

+ 0
- 1
config/routes.js Voir le fichier

@@ -78,7 +78,6 @@ export default [
78 78
   {
79 79
     path: '/deleteLog',
80 80
     name: '删除日志',
81
-    access:'admin',
82 81
     icon: 'ProfileOutlined',
83 82
     component: '@/pages/deleteLog',    
84 83
   },

+ 16
- 3
src/pages/deleteLog/index.jsx Voir le fichier

@@ -1,11 +1,13 @@
1 1
 
2
-import React, { useRef } from 'react'
2
+import React, { useRef,useState,useEffect } from 'react'
3 3
 import moment from 'moment';
4
-import { DatePicker } from 'antd';
4
+import { useModel } from 'umi';
5
+import { DatePicker,Input } from 'antd';
5 6
 import { PageHeaderWrapper } from '@ant-design/pro-layout';
6 7
 import PageTable from '@/components/PageTable'
7 8
 import OrgSearch from '@/components/OrgSearch';
8 9
 import { getDeleteformList } from '@/services/work'
10
+import { getDetail } from '@/services/org';
9 11
 
10 12
 const { RangePicker } = DatePicker;
11 13
 
@@ -16,6 +18,9 @@ const formatterTime = (val) => {
16 18
 export default (props) => {
17 19
   const initDate = useRef(moment())
18 20
   const deleteDateRef = useRef(moment())
21
+  const { initialState } = useModel('@@initialState');
22
+  const [orgName,setOrgName]=useState('')
23
+
19 24
 
20 25
   const handleBeforSearch = (params) => {
21 26
     const { createDate, deleteDate, ...others } = params;
@@ -41,6 +46,13 @@ export default (props) => {
41 46
 
42 47
     return { ...others, start, end, deleteStart, deleteEnd };
43 48
   }
49
+  useEffect(()=>{
50
+    if (initialState.currentUser.orgId) {
51
+      getDetail(initialState.currentUser.orgId).then((res)=>{
52
+        setOrgName(res.orgName);
53
+      })
54
+    }
55
+  },[initialState.currentUser.orgId])
44 56
 
45 57
   const columns = [
46 58
     {
@@ -50,7 +62,8 @@ export default (props) => {
50 62
       search: true,
51 63
       hideInTable: true,
52 64
       renderFormItem: () => (
53
-        <OrgSearch placeholder='请输入企业名称' />
65
+        !initialState.currentUser.orgId?
66
+        <OrgSearch placeholder='请输入企业名称' />:<Input readOnly value={orgName} />
54 67
       ),
55 68
     },
56 69
     {

+ 7
- 11
src/pages/resumework/form/index.jsx Voir le fichier

@@ -18,8 +18,7 @@ export default (props) => {
18 18
   const initDate = useRef(moment())
19 19
   const actionRef = useRef();
20 20
   const { initialState } = useModel('@@initialState');
21
-  const isorg=useRef(false)
22
-  const [orgName,setOrgName]=useState()
21
+  const [orgName,setOrgName]=useState('')
23 22
 
24 23
   const handleBeforSearch = (params) => {
25 24
     const { createDate, ...others } = params;
@@ -33,7 +32,7 @@ export default (props) => {
33 32
       start = moment(createDate[0]).format('YYYY-MM-DD')
34 33
       end = moment(createDate[1]).format('YYYY-MM-DD')
35 34
     }
36
-    if (isorg.current) {
35
+    if (initialState.currentUser.orgId) {
37 36
       orgId=initialState.currentUser.orgId
38 37
       return { ...others, start, end,orgId };
39 38
     }
@@ -49,16 +48,13 @@ export default (props) => {
49 48
     })
50 49
   }
51 50
   useEffect(()=>{
52
-    if (initialState.roleAlias == 'org') {
53
-      isorg.current=true
51
+    if (initialState.currentUser.orgId) {
54 52
       getDetail(initialState.currentUser.orgId).then((res)=>{
55 53
         setOrgName(res.orgName);
56 54
       })
57
-    }else{
58
-      setOrgName('');
59 55
     }
60
-  },[initialState.currentUser.orgId, initialState.roleAlias])
61
-
56
+  },[initialState.currentUser.orgId])
57
+  
62 58
   const columns = [
63 59
     {
64 60
       title: '企业名称',
@@ -67,10 +63,10 @@ export default (props) => {
67 63
       search: true,
68 64
       hideInTable:true,
69 65
       renderFormItem: () => (
70
-        !isorg.current?
66
+        !initialState.currentUser.orgId?
71 67
         <OrgSearch placeholder='请输入企业名称' />:<Input readOnly value={orgName} />
72 68
       ),
73
-      formItemProps: !isorg.current?{
69
+      formItemProps: !initialState.currentUser.orgId?{
74 70
         rules: [          
75 71
           {
76 72
             required: true,

+ 0
- 16
src/utils/hooks/useFetchState.js Voir le fichier

@@ -1,16 +0,0 @@
1
-import { useCallback, useEffect, useRef, useState } from 'react';
2
-
3
-function useFetchState(...props) {
4
-  const focus = useRef();
5
-  const [state, setState] = useState(...props);
6
-  useEffect(() => {
7
-    focus.current = true;
8
-    return () => (focus.current = false);
9
-  }, []);
10
-  const setFetchState = useCallback((...params) => {
11
-    focus.current && setState(...params);
12
-  }, []);
13
-  return [state, setFetchState];
14
-}
15
-
16
-export default useFetchState;