Browse Source

FIX:修复取消点赞的问题

wjj 4 years ago
parent
commit
f4c8ce8d6f

+ 6 - 5
src/pages/bugs/components/BugDetailModal/index.jsx

@@ -10,7 +10,7 @@ import {
 import { recurrent, severity, bug_categories } from '@/pages/edit/components/Step2/const';
 
 const BugItemDetail = (props) => {
-  const { bugItemDetail, dispatch } = props;
+  const { bugItemDetail, dispatch,reportCommonInfo } = props;
   const [detail, setDetail] = useState({});
   const [operator, setOperator] = useState(-1);
 
@@ -39,7 +39,7 @@ const BugItemDetail = (props) => {
         dispatch({
           type: 'editReport/goodForReport',
           payload: {
-            id: currDetail.id,//被点赞的报告的id
+            id: detail.id,//被点赞的报告的id
             report_id: reportCommonInfo.id,
             user_id: 2,
             action: 'like',
@@ -49,7 +49,7 @@ const BugItemDetail = (props) => {
         dispatch({
           type: 'editReport/badForReport',
           payload: {
-            id: currDetail.id,//被点赞的报告的id
+            id: detail.id,//被点赞的报告的id
             report_id: reportCommonInfo.id,
             user_id: 2,
             action: 'dislike',
@@ -64,7 +64,7 @@ const BugItemDetail = (props) => {
         dispatch({
           type: 'editReport/cancelGoodForReport',
           payload: {
-            id: currDetail.id,//被点赞的报告的id
+            id: detail.id,//被点赞的报告的id
             report_id: reportCommonInfo.id,
           },
         });
@@ -72,7 +72,7 @@ const BugItemDetail = (props) => {
         dispatch({
           type: 'editReport/cancelBadForReport',
           payload: {
-            id: currDetail.id,//被点赞的报告的id
+            id: detail.id,//被点赞的报告的id
             report_id: reportCommonInfo.id,
           },
         });
@@ -159,4 +159,5 @@ const BugItemDetail = (props) => {
 
 export default connect(({ allBugs, editReport }) => ({
   bugItemDetail: allBugs.bugItemDetail,
+  reportCommonInfo: editReport.reportCommonInfo,
 }))(BugItemDetail);

+ 2 - 3
src/pages/bugs/components/BugSingleList/index.jsx

@@ -5,8 +5,7 @@ import styles from './index.less';
 import { treeFilter } from 'enzyme/src/RSTTraversal';
 
 const BugSingleList = (props) => {
-  const {dispatch,commonId,bugTreeList,bugSingleList,type} = props;
-  const [page,setPage] = useState('null');
+  const {dispatch,commonId,bugTreeList,bugSingleList,page} = props;
   const [currPage,setCurrPage] = useState(1);
   const [currentItem,setCurrentItem] = useState([]);
 
@@ -56,7 +55,7 @@ const BugSingleList = (props) => {
 
   useEffect(()=>{
     getSingleBugList();
-  },[currPage])
+  },[currPage,page])
 
   return (
     <div>

+ 2 - 3
src/pages/bugs/components/BugTreeList/index.jsx

@@ -5,8 +5,7 @@ import styles from './index.less';
 import { treeFilter } from 'enzyme/src/RSTTraversal';
 
 const BugTreeList = (props) => {
-  const { dispatch, commonId, bugTreeList, bugSingleList, type } = props;
-  const [page, setPage] = useState('null');
+  const { dispatch, commonId, bugTreeList, bugSingleList, page } = props;
   const [currentTreeItem, setCurrentTreeItem] = useState([]);
   const [currPage, setCurrPage] = useState(1);
 
@@ -56,7 +55,7 @@ const BugTreeList = (props) => {
 
   useEffect(() => {
     getBugTreeList();
-  }, [currPage]);
+  }, [currPage,page]);
 
   return (
     <div>

+ 18 - 5
src/pages/bugs/index.jsx

@@ -23,15 +23,19 @@ const AllBugs = (props) => {
   const [page1,setPage1] = useState('')
   const [page2,setPage2] = useState('')
   const [page3,setPage3] = useState('')
+  const [page, setPage] = useState('null');
 
   const onChange = e => {
     setStatus(e.target.value);
+    setPage('null');
   };
 
   const handlePage1Change = (val) => {
-    setPage1(val)
-    let item = categories.find(x => x.item === val);
-    setPage2List(item.children);
+    if(val !== page1){
+      setPage1(val)
+      let item = categories.find(x => x.item === val);
+      setPage2List(item.children);
+    }
   };
 
   const handlePage2Change = (val) => {
@@ -43,6 +47,14 @@ const AllBugs = (props) => {
     setPage3(val)
   };
 
+  useEffect(()=>{
+    if(page1){
+      const newPage = `${page1}${page2?'-'+page2:''}${page3?'-'+page3:''}`
+      console.log(newPage);
+      setPage(newPage);
+    }
+  },[page1,page2,page3])
+
   const getReportReview = () => {
     dispatch({
       type: 'allBugs/getReportReview',
@@ -111,7 +123,8 @@ const AllBugs = (props) => {
                   })}
                 </Select>
                 <Select
-                        placeholder="请选择三级界面">
+                        placeholder="请选择三级界面"
+                onSelect={(val)=>{handlePage3Change(val)}}>
                   {page3List.map((item) => {
                     return <Select.Option value={item.item} key={item.item}>{item.item}</Select.Option>;
                   })}
@@ -127,7 +140,7 @@ const AllBugs = (props) => {
         </Row>
         <Row>
           <Col span={8}>
-            {status === 'tree' ? <BugTreeList /> : <BugSingleList />}
+            {status === 'tree' ? <BugTreeList page={page}/> : <BugSingleList page={page}/>}
 
           </Col>
           <Col span={8}>

+ 1 - 3
src/pages/edit/components/Step2/index.jsx

@@ -428,9 +428,7 @@ const Step2 = (props) => {
                       <Row gutter={10}>
                         <Col span={6}>
                           {<span
-                            className={styles.testCaseItemNo}>{`NO.${((item.id).substring((item.id.length) - 6)).toUpperCase()}`}</span>}
-                          {/*<Badge color="#2db7f5"*/}
-                          {/*       text={} />*/}
+                            className={styles.testCaseItemNo}>{`编号.${((item.id).substring((item.id.length) - 6)).toUpperCase()}`}</span>}
                         </Col>
                         <Col span={15}>
                           <span>{item.name}</span>