import React, { useEffect, useRef, useState } from 'react'; import { Form, Row, Col, Card, Modal, Input, Select, Upload, Button, message, Tag, Badge } from 'antd'; import { connect } from 'umi'; import styles from './index.less'; import { ForkOutlined, PlusOutlined, ExclamationCircleFilled, UploadOutlined, EditOutlined, EyeOutlined, } from '@ant-design/icons'; import * as echarts from 'echarts'; import { recurrent, severity, bug_categories } from './const'; import { timeToString } from '../../utils'; import BugGuideTree from '../BugGuideTree'; const formItemLayout = { labelCol: { span: 8, }, wrapperCol: { span: 19, }, }; const modalFormItemLayout = { labelCol: { span: 5, }, wrapperCol: { span: 19, }, }; const Step2 = (props) => { const [reportForm] = Form.useForm(); const [addCaseForm] = Form.useForm(); const [addBugForm] = Form.useForm(); const [editReportForm] = Form.useForm(); const { dispatch, reportCommonInfo, osType, testCaseList, caseBugList, categories, pathInfo, } = props; const [showTaskRecommendModal, setTaskRecommendModal] = useState(false); const [showAddTestCaseModal, setAddTestCaseModal] = useState(false); const [showAddBugModal, setAddTestBugModal] = useState(false); const [showEditReportModal, setEditReportModal] = useState(false); const currentTestCaseRef = useRef({}); const [isAddCaseStatus, setIsAddCaseStatus] = useState(true); // const [currActiveTestCase, setCurrActiveTestCase] = useState({}); const [page2List, setPage2List] = useState([]); const [page3List, setPage3List] = useState([]); const handleEditReportInfo = () => { editReportForm.validateFields().then((res)=> { let formData = new FormData(); formData.append('name', res.name); formData.append('report_id', reportCommonInfo.id); formData.append('worker_id', '2'); formData.append('case_take_id', '1718-1718'); formData.append('device_model', res.device_model); formData.append('device_brand', res.device_brand); formData.append('device_os', res.device_os); dispatch({ type: 'editReport/updateReportCommonDetail', payload: { formData } }) }) setEditReportModal(false) }; const handleAddOrEditTestCase = () => { addCaseForm.validateFields().then((res) => { let formData = new FormData(); // formData.append("id", values.reportName); formData.append('report_id', reportCommonInfo.id); formData.append('name', res.name); formData.append('front', res.front); formData.append('behind', res.behind); formData.append('description', res.description); if (!isAddCaseStatus) { //处理编辑用例 formData.append('id', currentTestCaseRef.current.id); dispatch({ type: 'editReport/updateTestCase', payload: { formData, report_id: reportCommonInfo.id, }, }).then((res) => { if (res && res.status === 200) { message.success('修改成功!'); } }); } else { //处理添加用例 dispatch({ type: 'editReport/createTestCase', payload: { formData, report_id: reportCommonInfo.id, }, }).then((res) => { if (res && res.id) { message.success('添加成功!'); } }); } setAddTestCaseModal(false); }); }; const handleAddBug = () => { addBugForm.validateFields().then((res) => { let formData = new FormData(); formData.append('report_id', reportCommonInfo.id); formData.append('title', res.title); formData.append('description', res.description); formData.append('bug_category', res.bug_category); formData.append('severity', res.severity); formData.append('recurrent', res.recurrent); formData.append('parent', null); formData.append('useCase', currentTestCaseRef.current.id); formData.append('case_id', '1718'); formData.append('case_take_id', '1718-1718'); formData.append('worker_id', '2'); formData.append('page', `${res.page1}-${res.page2}-${res.page3}`); //新建bug dispatch({ type: 'editReport/createCaseBug', payload: { formData, useCase: currentTestCaseRef.current.id, }, }).then(res => { setAddTestBugModal(false); }); }); }; const handleClickTestCase = (caseItem) => { // setCurrActiveTestCase(caseItem); currentTestCaseRef.current = caseItem; dispatch({ type: 'editReport/getCaseBugList', payload: caseItem.id, }); }; const handleEditTestCase = (item) => { setIsAddCaseStatus(false); currentTestCaseRef.current = item; addCaseForm.setFieldsValue(currentTestCaseRef.current); setAddTestCaseModal(true); }; const handleClickAddCase = () => { addCaseForm.resetFields(); setAddTestCaseModal(true); }; const handleClickAddBug = () => { //current目前只在点击edit cease的时候会有用 addBugForm.resetFields(); setAddTestBugModal(true); }; const handleClickRecommendBtn = () => { dispatch({ type: 'editReport/getPathInfo', payload: { case_take_id: '1718-1718', report_id: reportCommonInfo.id, }, }); dispatch({ type: 'editReport/getBugRecommendPath', payload: { case_take_id: '1718-1718', report_id: reportCommonInfo.id, }, }); dispatch({ type: 'editReport/getBugRecommendList', payload: { case_take_id: '1718-1718', report_id: reportCommonInfo.id, }, }); setTaskRecommendModal(true); }; const handleSelectPage1 = (val) => { let item = categories.find(x => x.item === val); setPage2List(item.children); }; const handleSelectPage2 = (val) => { let item = page2List.find(x => x.item === val); setPage3List(item.children); }; useEffect(() => { //判断是否已经有报告 dispatch({ type: 'editReport/getReportInfo', payload: { case_take_id: '1718-1718', worker_id: '2', }, }).then((res) => { // console.log(res) // console.log(reportCommonInfo) //有报告,获取对应信息。没有就直接转去了第一步 dispatch({ type: 'editReport/getTestCaseList', payload: { report_id: reportCommonInfo.id }, }).then((res) => { if (res && res.length) { currentTestCaseRef.current = res[0]; dispatch({ type: 'editReport/getCaseBugList', payload: currentTestCaseRef.current.id, }); } }); dispatch({ type: 'editReport/getCategories', payload: { examId: 1718 }, }); }); }, [dispatch, reportCommonInfo.id]); return (
{timeToString(reportCommonInfo.create_time_millis)} {reportCommonInfo.name} {reportCommonInfo.device_brand} {reportCommonInfo.device_model} {reportCommonInfo.device_os}
setEditReportModal(true)} />

测试用例列表

{testCaseList && testCaseList.length ? testCaseList.map((item) => { return (
{ handleClickTestCase(item); }}> {{`NO.${((item.id).substring((item.id.length) - 6)).toUpperCase()}`}} {/**/} {item.name} handleEditTestCase(item)} />
); }) :
快来创建你的第一个测试用例吧~
}

缺陷列表

{caseBugList && caseBugList.length ? caseBugList.map((item) => { return (
标题: {item.detail.title} {recurrent[item.detail.recurrent]} {severity[item.detail.severity]} {item.detail.bug_category}
路径: {item.detail.bug_page}
描述: {item.detail.description}
bug_img bug_img bug_img
); }) :
当前用例暂无提交记录,快去创建第一个BUG吧~
}
确定, ]} onCancel={() => { setAddTestCaseModal(false); }} > 为了评分准确,请勿提交重复测试用例
确定, ]} onCancel={() => { setAddTestBugModal(false); }} className={styles.bugForm} > 为了评分准确,请勿提交重复Bug
{/**/} {/* */} {/* */} {/* */} {/**/}
确定, ]} onCancel={() => { setEditReportModal(false); }}>
setTaskRecommendModal(false)} onCancel={() => { setTaskRecommendModal(false); } } className="addModal">
); }; export default connect(({ editReport, loading }) => ({ submitting: loading.effects['editReport/submitStepForm'], reportCommonInfo: editReport.reportCommonInfo, testCaseList: editReport.testCaseList, caseBugList: editReport.caseBugList, categories: editReport.categories, pathInfo: editReport.pathInfo, osType: editReport.osType, }))(Step2);