傅行帆 5 vuotta sitten
vanhempi
commit
53ba7b1dd4

+ 3
- 3
src/components/SelectButton/NewTypeSelect.jsx Näytä tiedosto

@@ -23,20 +23,20 @@ const NewsTypeSelect = (props) => {
23 23
   const [ data, setData ] = useState([])
24 24
   const [ value, setValue ] = useState('')
25 25
   const preProps = usePrevious(props)
26
-
26
+  
27 27
   if ((!preProps || !preProps.value) && props.value && !value) {
28 28
     setValue(props.value)
29 29
   }
30 30
 
31 31
   useEffect(() => {
32 32
     getNewsTypeList();
33
-  },[])
33
+  },[props.buildingId])
34 34
 
35 35
   const getNewsTypeList = (e) => {
36 36
     request({
37 37
         url: '/api/admin/taNewsType',
38 38
         method: 'GET',
39
-        params: {pageNum: 1,pageSize: 999},
39
+        params: {pageNum: 1,pageSize: 999,buildingId: props.buildingId},
40 40
         action: 'admin.taNewsType.get',
41 41
     }).then((data) => {
42 42
         setData(data.records)

+ 11
- 2
src/pages/news/list/editNewsList.jsx Näytä tiedosto

@@ -30,6 +30,7 @@ const { TextArea } = Input;
30 30
   const [ tab, changeTab ] = useState('basic')
31 31
   const newsId = props.location.query.newsId
32 32
   const [ dynamicData, setDynamicData ] = useState({})
33
+  
33 34
   if(newsId){
34 35
     useEffect(() => {
35 36
       getDynamicData(newsId);
@@ -46,6 +47,8 @@ const { TextArea } = Input;
46 47
     }
47 48
   }
48 49
 
50
+  
51
+
49 52
   const cancelPage = () =>{
50 53
     router.push({
51 54
       pathname: '/news/list/NewsList',
@@ -53,11 +56,17 @@ const { TextArea } = Input;
53 56
   }
54 57
 
55 58
   const Basic = (props) => {
59
+    const [ changeBuildingId, setChangeBuildingIdData ] = useState('')
60
+    
61
+    const handleBuildingChange = (e) => {
62
+      console.log(e)
63
+      setChangeBuildingIdData(e)
64
+    }
56 65
     const fields = [
57 66
       {
58 67
         label: '意向项目',
59 68
         name: 'buildingId',
60
-        render: <BuildSelect />,
69
+        render: <BuildSelect onChange={(e => handleBuildingChange(e))}/>,
61 70
         value: dynamicData.buildingId,
62 71
         rules: [
63 72
           {required: true, message: '请选择所属项目'},
@@ -85,7 +94,7 @@ const { TextArea } = Input;
85 94
       {
86 95
         label: '资讯类型',
87 96
         name: 'newsTypeId',
88
-        render: <NewsTypeSelect />,
97
+        render: <NewsTypeSelect buildingId={changeBuildingId || dynamicData.buildingId}/>,
89 98
         value: dynamicData.newsTypeId,
90 99
         rules: [
91 100
           {required: true, message: '请选择资讯类型'},