Browse Source

ADD:新增用例后默认选中当前用例

wjj 4 years ago
parent
commit
ed444e2c8e

+ 1 - 1
src/pages/edit/components/BugGuideTree/index.jsx

@@ -174,7 +174,7 @@ const BugGuideTree = (props) => {
         initItemRecursionRecPage(jsonPath.children, page, style);
         myChart.setOption({ series: [{ data: [jsonPath] }] });
       }
-    }, 500);
+    }, 2000);
   };
 
   const setRecPage = (page) => {

+ 23 - 10
src/pages/edit/components/Step2/index.jsx

@@ -15,7 +15,6 @@ import { recurrent, severity, bug_categories } from './const';
 import { timeToString,getBase64 } from '../../utils';
 
 import BugGuideTree from '../BugGuideTree';
-import { instanceOf } from 'prop-types';
 
 const formItemLayout = {
   labelCol: {
@@ -117,9 +116,14 @@ const Step2 = (props) => {
             formData,
             report_id: reportCommonInfo.id,
           },
-        }).then((res) => {
+        }).then(({ res, testCaseList}) => {
           if (res && res.id) {
             message.success('添加成功!');
+            //添加成功后要把currCase指向新的
+            const currCase = testCaseList.filter(item=>
+              item.id === res.id
+            )
+            handleClickTestCase(currCase[0]);
           }
         });
       }
@@ -127,6 +131,15 @@ const Step2 = (props) => {
     });
   };
 
+  // useEffect(()=>{
+  //   const
+  //   const currCase = testCaseList.filter(item=>
+  //     item.id === res.id
+  //   )
+  //   console.log(currCase);
+  //   currentTestCaseRef.current = currCase;
+  // },[testCaseList])
+
   const handleAddBug = () => {
     addBugForm.validateFields().then((res) => {
       let formData = new FormData();
@@ -158,7 +171,6 @@ const Step2 = (props) => {
           useCase: currentTestCaseRef.current.id,
         },
       }).then(res => {
-
         setAddTestBugModal(false);
       });
     });
@@ -396,8 +408,8 @@ const Step2 = (props) => {
                             <div className={styles.testBugItemTitleBlock}>
                               <span className={styles.testBugItemTitle}>标题:</span>
                               <span className={styles.testBugItemTitleDetail}>{item.detail.title}</span>
-                              <Tag color="cyan">{recurrent[item.detail.recurrent]}</Tag>
-                              <Tag color="red">{severity[item.detail.severity]}</Tag>
+                              <Tag color="cyan">{recurrent[item.detail.recurrent -1]}</Tag>
+                              <Tag color="red">{severity[item.detail.severity -1]}</Tag>
                               <Tag color="geekblue">{item.detail.bug_category}</Tag>
                             </div>
                             <div className={styles.testBugItemTitleBlock}>
@@ -410,11 +422,12 @@ const Step2 = (props) => {
                             </div>
                           </div>
                         </Col>
-                        <Col span={12} className={styles.bugImgList}>
-                          <img src={require('../../assets/report1.jpeg')} alt='bug_img' />
-                          <img src={require('../../assets/report2.jpeg')} alt='bug_img' />
-                          <img src={require('../../assets/report3.jpeg')} alt='bug_img' />
-                        </Col>
+                        {item.detail.img_url ?
+                          <Col span={12} className={styles.bugImgList}>
+                            {item.detail.img_url.split(',').map(img=>{
+                              return <img src={img} alt='bug_img' key={img}/>
+                            })}
+                          </Col> : null}
                       </Row>
 
                     </div>

+ 7 - 3
src/pages/edit/model.js

@@ -131,14 +131,18 @@ const Model = {
       });
     },
     //todo:创建新用例
-    * createTestCase({ payload }, { call, put }) {
+    * createTestCase({ payload }, { call, put,select }) {
       let { formData, report_id } = payload;
       let res = yield call(createTestCase, formData);
-      yield put({
+      yield put.resolve({
         type: 'getTestCaseList',
         payload: { report_id },
       });
-      return res;
+      const testCaseList = yield select(state => {
+        return state.editReport.testCaseList;
+      })
+      console.log(testCaseList);
+      return {res,testCaseList};
     },
     //todo:更新用例
     * updateTestCase({ payload }, { call, put }) {