Browse Source

ADD:完成bug single tree对接

wjj 4 years ago
parent
commit
603123f131

+ 0 - 1
src/components/GlobalHeader/RightContent.jsx

@@ -14,7 +14,6 @@ const ENVTagColor = {
 };
 
 const GlobalHeaderRight = (props) => {
-  console.log('right');
   const { theme, layout, dispatch, taskName } = props;
   const [idInfo, setIdInfo] = useState({});
   let className = styles.right;

+ 1 - 1
src/pages/bugs/components/BugDetailModal/index.less

@@ -9,7 +9,7 @@
     border-bottom: 1px solid #eee;
     font-size: 14px;
     .detailLabel {
-      width: 90px;
+      width: 80px;
       line-height: 30px;
       height: 30px;
       display: inline-block;

+ 92 - 0
src/pages/bugs/components/BugSingleList/index.jsx

@@ -0,0 +1,92 @@
+import { Pagination } from 'antd';
+import React, { useEffect, useState } from 'react';
+import { connect } from 'umi';
+import styles from './index.less';
+import { treeFilter } from 'enzyme/src/RSTTraversal';
+
+const BugSingleList = (props) => {
+  const {dispatch,commonId,bugTreeList,bugSingleList,type} = props;
+  const [start,setStart] = useState(0);
+  const [page,setPage] = useState('null');
+  const [currentItem,setCurrentItem] = useState([]);
+
+  const onPageChange = (num)=>{
+    console.log('page',num)
+  }
+
+  const handleSingleItemClick = (item)=>{
+    const currItem = bugSingleList.TreeRoot.filter(i=>i[0]===item[0]);
+    setCurrentItem(currItem[0]);
+  }
+
+  useEffect(()=>{
+    bugSingleList.TreeRoot && setCurrentItem(bugSingleList.TreeRoot[0])
+  },[bugSingleList])
+
+  useEffect(()=>{
+    if(JSON.stringify(currentItem)!=='[]'){
+      //获取bug详情信息用于展示
+      dispatch({
+        type: 'editReport/getBugDetail',
+        payload:{
+          id:currentItem[0]
+        }
+      }).then(res => {
+        console.log(res)
+        dispatch({
+          type: 'allBugs/saveBugItemDetail',
+          payload:{
+            ...res
+          }
+        })
+      })
+    }
+  },[currentItem])
+
+  useEffect(()=>{
+    dispatch({
+      type:'allBugs/getSingleList',
+      payload:{
+        case_take_id:`${commonId.caseId}-${commonId.examId}`,
+        start,
+        count:"10",
+        page
+      }
+    })
+  },[])
+
+  return (
+    <div>
+      <div className={styles.bugSingleList}>
+        {
+          bugSingleList&&bugSingleList.TreeRoot&&bugSingleList.TreeRoot.map((item,index)=>{
+            return (
+              <div key={item[0]}
+                className={`${styles.bugListItem} ${currentItem[0] === item[0] ? styles.bugListItemActive : ''}`}
+                onClick={()=>{handleSingleItemClick(item)}}>
+                <span className={styles.bugListItemNum}>
+                  Bug{index+1}:
+                </span>
+                <div className={styles.bugListItemInfo}>
+                  <div className={styles.bugListItemTitle}>
+                    {item[2]}
+                  </div>
+                </div>
+              </div>
+            )
+          })
+        }
+      </div>
+      <div className={styles.pagination}>
+        <Pagination showQuickJumpe defaultCurrent={2} total={bugSingleList.Count} onChange={onPageChange} />
+      </div>
+    </div>
+  );
+};
+
+export default connect(({ allBugs , editReport}) => ({
+  data: allBugs.step,
+  bugSingleList: allBugs.bugSingleList,
+  reportCommonInfo: editReport.reportCommonInfo,
+  commonId: editReport.commonId,
+}))(BugSingleList);

+ 33 - 0
src/pages/bugs/components/BugSingleList/index.less

@@ -0,0 +1,33 @@
+@import '~antd/es/style/themes/default.less';
+
+.bugSingleList {
+  .bugListItem {
+    padding: 10px 20px;
+    border: 1px dashed #1890ff;
+    border-bottom: none;
+    border-radius: 7px;
+    max-width: 350px;
+    display: flex;
+    height: 60px;
+    line-height: 40px;
+    .bugListItemNum {
+      font-weight: bold;
+      display: inline-block;
+      width: 50px;
+    }
+  }
+  .bugListItem:last-child{
+    border-bottom: 1px dashed #1890ff;
+  }
+  .bugListItem:hover {
+    background-color: #e6f7ff;
+  }
+  .bugListItemActive {
+    background-color: #e6f7ff;
+  }
+
+
+}
+.pagination{
+  margin-top: 10px;
+}

+ 6 - 5
src/pages/bugs/components/BugList/index.jsx → src/pages/bugs/components/BugTreeList/index.jsx

@@ -4,8 +4,8 @@ import { connect } from 'umi';
 import styles from './index.less';
 import { treeFilter } from 'enzyme/src/RSTTraversal';
 
-const BugList = (props) => {
-  const { data, dispatch,commonId,bugTreeList} = props;
+const BugTreeList = (props) => {
+  const {dispatch,commonId,bugTreeList,bugSingleList,type} = props;
   const [start,setStart] = useState(0);
   const [page,setPage] = useState('null');
   const [currentTreeItem,setCurrentTreeItem] = useState([]);
@@ -32,7 +32,6 @@ const BugList = (props) => {
           id:currentTreeItem[0]
         }
       }).then(res => {
-        console.log(res)
         dispatch({
           type: 'allBugs/saveBugItemDetail',
           payload:{
@@ -79,7 +78,9 @@ const BugList = (props) => {
           })
         }
       </div>
-      <Pagination showQuickJumper defaultCurrent={2} total={bugTreeList.Count} onChange={onPageChange} />
+      <div className={styles.pagination}>
+        <Pagination showQuickJumper defaultCurrent={2} total={bugTreeList.Count} onChange={onPageChange} />
+      </div>
     </div>
   );
 };
@@ -89,4 +90,4 @@ export default connect(({ allBugs , editReport}) => ({
   bugTreeList: allBugs.bugTreeList,
   reportCommonInfo: editReport.reportCommonInfo,
   commonId: editReport.commonId,
-}))(BugList);
+}))(BugTreeList);

+ 3 - 8
src/pages/bugs/components/BugList/index.less → src/pages/bugs/components/BugTreeList/index.less

@@ -13,14 +13,6 @@
       display: inline-block;
       width: 50px;
     }
-    .bugListItemInfo{
-      .bugListItemSummary {
-
-      }
-      .bugListItemTitle{
-
-      }
-    }
   }
   .bugListItem:last-child{
     border-bottom: 1px dashed #1890ff;
@@ -34,3 +26,6 @@
 
 
 }
+.pagination{
+  margin-top: 10px;
+}

+ 4 - 43
src/pages/bugs/index.jsx

@@ -4,7 +4,8 @@ import { PageContainer } from '@ant-design/pro-layout';
 import { connect } from 'umi';
 const { Option } = Select;
 
-import BugList from './components/BugList';
+import BugTreeList from './components/BugTreeList';
+import BugSingleList from './components/BugSingleList';
 import BugDetailModal from './components/BugDetailModal';
 
 import {
@@ -13,51 +14,11 @@ import {
 } from '@ant-design/icons';
 import styles from './style.less';
 
-const options = [
-  { label: '树状', value: 'tree' },
-  { label: '单一状', value: 'single' },
-];
-const options2 = [
-  {
-    value: 'zhejiang',
-    label: 'Zhejiang',
-    children: [
-      {
-        value: 'hangzhou',
-        label: 'Hangzhou',
-        children: [
-          {
-            value: 'xihu',
-            label: 'West Lake',
-          },
-        ],
-      },
-    ],
-  },
-  {
-    value: 'jiangsu',
-    label: 'Jiangsu',
-    children: [
-      {
-        value: 'nanjing',
-        label: 'Nanjing',
-        children: [
-          {
-            value: 'zhonghuamen',
-            label: 'Zhong Hua Men',
-          },
-        ],
-      },
-    ],
-  },
-]
-
 const AllBugs = (props) => {
   const {dispatch,commonId,reportCommonInfo,reportReview} = props;
   const [status, setStatus] = useState('tree');
 
   const onChange = e => {
-    console.log('radio checked', e.target.value);
     setStatus(e.target.value);
   };
 
@@ -119,7 +80,8 @@ const AllBugs = (props) => {
           </Row>
           <Row>
             <Col span={8}>
-              <BugList/>
+              {status === 'tree'? <BugTreeList /> : <BugSingleList/>}
+
             </Col>
             <Col span={8}>
               这里是树状图
@@ -138,6 +100,5 @@ const AllBugs = (props) => {
 export default connect(({ allBugs,editReport }) => ({
   commonId: editReport.commonId,
   reportCommonInfo: editReport.reportCommonInfo,
-  allBugList: allBugs.allBugList,
   reportReview: allBugs.reportReview,
 }))(AllBugs);

+ 17 - 2
src/pages/bugs/model.js

@@ -1,6 +1,7 @@
 import {
   getReportReview,
-  getTreeList
+  getTreeList,
+  getSingleList
 } from './service';
 
 const Model = {
@@ -8,6 +9,7 @@ const Model = {
   state: {
     reportReview:{},
     bugTreeList:[],
+    bugSingleList:[],
     bugItemDetail:{}
   },
   effects: {
@@ -30,6 +32,17 @@ const Model = {
         payload: res,
       });
     },
+
+    //todo:获取bug单一状列表
+    * getSingleList({ payload }, { call, put }) {
+      const {case_take_id,start,count,page} = payload;
+      let res = yield call(getSingleList, case_take_id,start,count,page);
+
+      yield put({
+        type: 'saveBugSingleList',
+        payload: res,
+      });
+    },
   },
   reducers: {
     saveReportReview(state, { payload }) {
@@ -38,8 +51,10 @@ const Model = {
     saveBugTreeList(state, { payload }) {
       return { ...state, bugTreeList: payload };
     },
+    saveBugSingleList(state, { payload }) {
+      return { ...state, bugSingleList: payload };
+    },
     saveBugItemDetail(state, { payload }) {
-      console.log(payload)
       return { ...state, bugItemDetail: payload };
     },
   }

+ 13 - 0
src/pages/bugs/service.js

@@ -23,3 +23,16 @@ export async function getTreeList(case_take_id,start,count,page) {
     }
   });
 }
+
+//todo:获取单一状列表
+export async function getSingleList(case_take_id,start,count,page) {
+  return request('/api/history/getSingleStu', {
+    method: 'get',
+    params: {
+      case_take_id,
+      start,
+      count,
+      page
+    }
+  });
+}