wjj vor 4 Jahren
Ursprung
Commit
0ccfe23e02
1 geänderte Dateien mit 10 neuen und 13 gelöschten Zeilen
  1. 10 13
      src/pages/edit/components/Step2/index.jsx

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

@@ -22,6 +22,7 @@ const formItemLayout = {
 
 const Step2 = (props) => {
   const [form] = Form.useForm();
+  const [addCaseForm] = Form.useForm();
   const { data, dispatch, submitting, reportCommonInfo, testCaseList } = props;
   // console.log(reportCommonInfo,props)
   const [showTaskRecommendModal, setTaskRecommendModal] = useState(false);
@@ -35,10 +36,10 @@ const Step2 = (props) => {
     return null;
   }
 
-  const { validateFields, getFieldsValue } = form;
+  const { validateFields, getFieldsValue } = addCaseForm;
 
   const handleAddTestCase = () => {
-    form.validateFields().then((res) => {
+    addCaseForm.validateFields().then((res) => {
       let formData = new FormData();
       // formData.append("id", values.reportName);
       formData.append('report_id', reportCommonInfo.id);
@@ -62,17 +63,14 @@ const Step2 = (props) => {
   };
 
   const handleEditTestCase = (item) => {
-    //setCurrTestCase(item);
     currentTestCaseRef.current = item;
-    //console.log(currTestCase)
+    addCaseForm.setFieldsValue(currentTestCaseRef.current)
     setAddTestCaseModal(true);
   };
 
   const handleClickAddCase = ()=>{
-   // setCurrTestCase({});
     currentTestCaseRef.current = {};
-    addCaseform.resetFields();
-    //console.log(currTestCase)
+    addCaseForm.resetFields();
     setAddTestCaseModal(true);
   }
 
@@ -226,8 +224,8 @@ const Step2 = (props) => {
         </div>
       </Card>
       <Modal title="添加测试用例" width={720}
-             forceRender={ true }
              visible={showAddTestCaseModal}
+             forceRender={true}
              className="addModal"
              footer={[
                <Button key='submit' type="primary" htmlType="submit" onClick={handleAddTestCase}>添加</Button>,
@@ -240,8 +238,7 @@ const Step2 = (props) => {
         <ExclamationCircleFilled className={styles.addModalInfo} />为了评分准确,请勿提交重复测试用例
         <Form
           {...formItemLayout}
-          addCaseform={form}
-          initialValues={currentTestCaseRef.current}
+          form={addCaseForm}
           layout="horizontal"
           className={styles.stepForm}
         >
@@ -267,7 +264,7 @@ const Step2 = (props) => {
               },
             ]}
           >
-            <Input.TextArea autoSize={{ minRows: 3, maxRows: Infinity }}/>
+            <Input.TextArea autoSize={{ minRows: 3, maxRows: 999 }}/>
           </Form.Item>
           <Form.Item
             label="测试步骤"
@@ -279,7 +276,7 @@ const Step2 = (props) => {
               },
             ]}
           >
-            <Input.TextArea autoSize={{ minRows: 3, maxRows: Infinity }}/>
+            <Input.TextArea autoSize={{ minRows: 3, maxRows: 999 }}/>
           </Form.Item>
           <Form.Item
             label="预期结果"
@@ -291,7 +288,7 @@ const Step2 = (props) => {
               },
             ]}
           >
-            <Input.TextArea autoSize={{ minRows: 3, maxRows: Infinity }}/>
+            <Input.TextArea autoSize={{ minRows: 3, maxRows: 999 }}/>
           </Form.Item>
         </Form>
       </Modal>