index.jsx 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886
  1. import React, { useEffect, useRef, useState } from 'react';
  2. import { Form, Row, Col, Card, Modal, Input, Select, Upload, Button, message, Tag, Tooltip, Image } from 'antd';
  3. import { connect } from 'umi';
  4. import styles from './index.less';
  5. import {
  6. ForkOutlined,
  7. PlusOutlined,
  8. ExclamationCircleFilled,
  9. UploadOutlined,
  10. EditOutlined,
  11. EyeOutlined,
  12. ShareAltOutlined,
  13. LeftOutlined,
  14. RightOutlined,
  15. } from '@ant-design/icons';
  16. const { Search } = Input;
  17. import * as echarts from 'echarts';
  18. import { recurrent, severity, bug_categories } from './const';
  19. import { timeToString, getBase64 } from '@/utils/common';
  20. import BugGuideTree from '../BugGuideTree';
  21. const formItemLayout = {
  22. labelCol: {
  23. span: 8,
  24. },
  25. wrapperCol: {
  26. span: 19,
  27. },
  28. };
  29. const modalFormItemLayout = {
  30. labelCol: {
  31. span: 5,
  32. },
  33. wrapperCol: {
  34. span: 19,
  35. },
  36. };
  37. const uploadButton = (
  38. <div>
  39. <PlusOutlined />
  40. <div style={{ marginTop: 8 }}>点击上传</div>
  41. </div>
  42. );
  43. const Step2 = (props) => {
  44. const [reportForm] = Form.useForm();
  45. const [addCaseForm] = Form.useForm();
  46. const [addBugForm] = Form.useForm();
  47. const [editReportForm] = Form.useForm();
  48. const {
  49. dispatch, reportCommonInfo, osType,collaborative_type,
  50. testCaseList, caseBugList, categories, pathInfo,commonId
  51. } = props;
  52. const [showTaskRecommendModal, setTaskRecommendModal] = useState(false);
  53. const [showAddTestCaseModal, setAddTestCaseModal] = useState(false);
  54. const [showAddBugModal, setAddTestBugModal] = useState(false);
  55. const [showEditReportModal, setEditReportModal] = useState(false);
  56. const currentTestCaseRef = useRef({});
  57. const [currBugDetail,setCurrBugDetail] = useState({});
  58. const [isAddCaseStatus, setIsAddCaseStatus] = useState(true);
  59. // const [currActiveTestCase, setCurrActiveTestCase] = useState({});
  60. //上传图片廊需要的字段
  61. const [fileList, setFileList] = useState([]);
  62. const [previewTitle, setPreviewTitle] = useState('');
  63. const [previewImage, setPreviewImage] = useState('');
  64. const [previewVisible, setPreviewVisible] = useState(false);
  65. const [page2List, setPage2List] = useState([]);
  66. const [page3List, setPage3List] = useState([]);
  67. const [bugList, setBugList] = useState([]);
  68. const forkStatus = useRef(false);
  69. const currForkId = useRef('');
  70. const forkInput = useRef('');
  71. const handleEditReportInfo = () => {
  72. editReportForm.validateFields().then((res) => {
  73. let formData = new FormData();
  74. formData.append('name', res.name);
  75. formData.append('report_id', reportCommonInfo.id);
  76. formData.append('worker_id', commonId.userId);
  77. formData.append('case_take_id', commonId.case_take_id);
  78. formData.append('device_model', res.device_model);
  79. formData.append('device_brand', res.device_brand);
  80. formData.append('device_os', res.device_os);
  81. dispatch({
  82. type: 'editReport/updateReportCommonDetail',
  83. payload: { formData },
  84. });
  85. });
  86. setEditReportModal(false);
  87. };
  88. const handleAddOrEditTestCase = () => {
  89. addCaseForm.validateFields().then((res) => {
  90. let formData = new FormData();
  91. // formData.append("id", values.reportName);
  92. formData.append('report_id', reportCommonInfo.id);
  93. formData.append('name', res.name);
  94. formData.append('front', res.front);
  95. formData.append('behind', res.behind);
  96. formData.append('description', res.description);
  97. if (!isAddCaseStatus) {
  98. //处理编辑用例
  99. formData.append('id', currentTestCaseRef.current.id);
  100. dispatch({
  101. type: 'editReport/updateTestCase',
  102. payload: {
  103. formData,
  104. report_id: reportCommonInfo.id,
  105. },
  106. }).then((res) => {
  107. if (res && res.status === 200) {
  108. message.success('修改成功!');
  109. }
  110. });
  111. } else {
  112. //处理添加用例
  113. dispatch({
  114. type: 'editReport/createTestCase',
  115. payload: {
  116. formData,
  117. report_id: reportCommonInfo.id,
  118. },
  119. }).then(({ res, testCaseList }) => {
  120. if (res && res.id) {
  121. message.success('添加成功!');
  122. //添加成功后要把currCase指向新的
  123. const currCase = testCaseList.filter(item =>
  124. item.id === res.id,
  125. );
  126. handleClickTestCase(currCase[0]);
  127. }
  128. });
  129. }
  130. setAddTestCaseModal(false);
  131. });
  132. };
  133. const handleAddBug = () => {
  134. addBugForm.validateFields().then((res) => {
  135. let formData = new FormData();
  136. formData.append('report_id', reportCommonInfo.id);
  137. formData.append('title', res.title);
  138. formData.append('description', res.description);
  139. formData.append('bug_category', res.bug_category);
  140. formData.append('severity', res.severity);
  141. formData.append('recurrent', res.recurrent);
  142. formData.append('parent', forkStatus.current?currForkId.current+'-2':null);
  143. formData.append('useCase', currentTestCaseRef.current.id);
  144. formData.append('case_id', commonId.caseId);
  145. formData.append('case_take_id', commonId.case_take_id);
  146. formData.append('worker_id', commonId.userId);
  147. formData.append('page', `${res.page1}-${res.page2}-${res.page3}`);
  148. if (fileList.length) {
  149. let str = '';
  150. fileList.map(item => {
  151. str += (item.response + ',');
  152. });
  153. str = str.substring(0, str.length - 1);
  154. formData.append('img_url', str);
  155. }
  156. //新建bug
  157. dispatch({
  158. type: 'editReport/createCaseBug',
  159. payload: {
  160. formData,
  161. useCase: currentTestCaseRef.current.id,
  162. },
  163. }).then(res => {
  164. setAddTestBugModal(false);
  165. });
  166. });
  167. };
  168. const handleClickTestCase = (caseItem) => {
  169. // setCurrActiveTestCase(caseItem);
  170. currentTestCaseRef.current = caseItem;
  171. dispatch({
  172. type: 'editReport/getCaseBugList',
  173. payload: caseItem.id,
  174. });
  175. };
  176. const handleEditTestCase = (item) => {
  177. setIsAddCaseStatus(false);
  178. currentTestCaseRef.current = item;
  179. addCaseForm.setFieldsValue(currentTestCaseRef.current);
  180. setAddTestCaseModal(true);
  181. };
  182. const handleClickAddCase = () => {
  183. addCaseForm.resetFields();
  184. setAddTestCaseModal(true);
  185. };
  186. const handleClickAddBug = () => {
  187. //current目前只在点击edit cease的时候会有用
  188. addBugForm.resetFields();
  189. forkInput.current.state.value = '';
  190. setAddTestBugModal(true);
  191. };
  192. const handleClickRecommendBtn = () => {
  193. dispatch({
  194. type: 'editReport/getPathInfo',
  195. payload: {
  196. case_take_id: commonId.case_take_id,
  197. report_id: reportCommonInfo.id,
  198. },
  199. });
  200. dispatch({
  201. type: 'editReport/getBugRecommendPath',
  202. payload: {
  203. case_take_id: commonId.case_take_id,
  204. report_id: reportCommonInfo.id,
  205. },
  206. });
  207. dispatch({
  208. type: 'editReport/getBugRecommendList',
  209. payload: {
  210. case_take_id: commonId.case_take_id,
  211. report_id: reportCommonInfo.id,
  212. },
  213. });
  214. setTaskRecommendModal(true);
  215. };
  216. const handleSelectPage1 = (val) => {
  217. if (val !== page1) {
  218. addBugForm.setFieldsValue({page1:val,page2:'',page3:''})
  219. let item = categories.find(x => x.item === val);
  220. setPage2List(item.children);
  221. }
  222. };
  223. const handleSelectPage2 = (val) => {
  224. if (val !== page2) {
  225. addBugForm.setFieldsValue({page2:val,page3:''})
  226. let item = page2List.find(x => x.item === val);
  227. setPage3List(item.children);
  228. }
  229. };
  230. // const handlePage3Change = val => {
  231. // // setPage3(val);
  232. // };
  233. const handlePreview = async file => {
  234. if (!file.url && !file.preview) {
  235. file.preview = await getBase64(file.originFileObj);
  236. }
  237. setPreviewImage(file.url || file.preview);
  238. setPreviewVisible(true);
  239. setPreviewTitle(file.name || file.url.substring(file.url.lastIndexOf('/') + 1));
  240. };
  241. const handleCancel = () => setPreviewVisible(false);
  242. const handleChange = ({ fileList }) => {
  243. setFileList(fileList);
  244. };
  245. const handleChangeImgToLeft = (item) => {
  246. item.left--;
  247. item.right--;
  248. item['imgArr'] = item['originArr'].slice(item['left'], item['right']);
  249. let newList = [...bugList];
  250. let index = newList.findIndex(i => i.id === item.id);
  251. newList.splice(index, 1, item);
  252. setBugList(newList);
  253. };
  254. const handleChangeImgToRight = (item) => {
  255. item.left++;
  256. item.right++;
  257. item['imgArr'] = item['originArr'].slice(item['left'], item['right']);
  258. let newList = [...bugList];
  259. let index = newList.findIndex(i => i.id === item.id);
  260. newList.splice(index, 1, item);
  261. setBugList(newList);
  262. };
  263. const searchBugToFork = value =>{
  264. forkStatus.current = true;
  265. currForkId.current = value;
  266. dispatch({
  267. type: 'editReport/getBugDetail',
  268. payload: { id: value},
  269. }).then(res=>{
  270. setCurrBugDetail(res.detail);
  271. const {bug_page, bug_category, severity, recurrent} = res.detail;
  272. const pages = bug_page.split("-");
  273. const page1 = pages[0];
  274. const page2 = pages[1];
  275. const page3 = pages[2];
  276. dispatch({
  277. type: 'editReport/forkReport',
  278. payload: {
  279. page1, page2, page3, bug_category, severity, recurrent
  280. },
  281. })
  282. })
  283. }
  284. const handleInitThreePages = ()=>{
  285. let detail = { ...currBugDetail };
  286. detail['recurrent'] = recurrent[currBugDetail.recurrent];
  287. detail['severity'] = severity[currBugDetail.severity];
  288. if(JSON.stringify(detail)!=='{}') {
  289. let pages = detail.bug_page.split("-");
  290. detail.page1 = pages[0];
  291. detail.page2 = pages[1];
  292. detail.page3 = pages[2];
  293. if (page2List && page2List.length) {
  294. handleSelectPage2(pages[1]);
  295. console.log(detail)
  296. addBugForm.setFieldsValue(detail)
  297. console.log(addBugForm.getFieldsValue())
  298. }else{
  299. handleSelectPage1(pages[0]);
  300. }
  301. }
  302. }
  303. useEffect(()=>{
  304. handleInitThreePages();
  305. },[currBugDetail,page2List])
  306. useEffect(() => {
  307. //能到第二步,说明是有报告信息的
  308. //有报告,获取对应信息。没有就直接转去了第一步
  309. dispatch({
  310. type: 'editReport/getTestCaseList',
  311. payload: { report_id: reportCommonInfo.id },
  312. }).then((res) => {
  313. if (res && res.length && commonId) {
  314. currentTestCaseRef.current = res[0];
  315. dispatch({
  316. type: 'editReport/getCaseBugList',
  317. payload: currentTestCaseRef.current.id,
  318. });
  319. }
  320. });
  321. dispatch({
  322. type: 'editReport/getCategories',
  323. payload: { examId: commonId.examId },
  324. });
  325. }, [reportCommonInfo,commonId.userId,commonId.examId,commonId.case_take_id]);
  326. useEffect(() => {
  327. let bugs = caseBugList.map(item => item.detail);
  328. bugs.map(item => {
  329. item['originArr'] = item.img_url ? item.img_url.split(',') : [];
  330. if (item['originArr'].length >= 3) {
  331. //通过更改左右的标记值来更改显示的图片
  332. item['left'] = 0;
  333. item['right'] = 3;
  334. item['imgArr'] = item['originArr'].slice(item['left'], item['right']);
  335. } else if (item['originArr'].length > 0 && item['originArr'].length < 3) {
  336. item['imgArr'] = item['originArr'];
  337. item['left'] = 0;
  338. item['right'] = item['originArr'].length;
  339. }
  340. });
  341. setBugList(bugs);
  342. }, [caseBugList]);
  343. return (
  344. <div id="main">
  345. <Row gutter={10} className={styles.reportInfoContainer}>
  346. <Col span={23}>
  347. <Form
  348. {...formItemLayout}
  349. form={reportForm}
  350. className={styles.stepForm}
  351. hideRequiredMark
  352. >
  353. <Row gutter={10}>
  354. <Col span={5}>
  355. <Form.Item label="创建日期" rules={[{ required: true, message: '请输入报告名称' }]}>
  356. {timeToString(reportCommonInfo.create_time_millis)}
  357. </Form.Item>
  358. </Col>
  359. <Col span={5}>
  360. <Form.Item label="报告名称" rules={[{ required: true, message: '请输入报告名称' }]}>
  361. {reportCommonInfo.name}
  362. </Form.Item>
  363. </Col>
  364. <Col span={5}>
  365. <Form.Item label="设备名称" required>
  366. {reportCommonInfo.device_brand}
  367. </Form.Item>
  368. </Col>
  369. <Col span={5}>
  370. <Form.Item label="设备品牌" required>
  371. {reportCommonInfo.device_model}
  372. </Form.Item>
  373. </Col>
  374. <Col span={4}>
  375. <Form.Item label="操作系统" required>
  376. {reportCommonInfo.device_os}
  377. </Form.Item>
  378. </Col>
  379. </Row>
  380. </Form>
  381. </Col>
  382. <Col span={1}>
  383. <EditOutlined className={styles.editReportInfoIcon}
  384. onClick={() => setEditReportModal(true)}
  385. />
  386. </Col>
  387. </Row>
  388. <Card>
  389. <div className={styles.reportContainer}>
  390. <Row gutter={10}>
  391. <Col span={8}>
  392. <div gutter={10} className={styles.testCaseTitle}>
  393. <h3>测试用例列表</h3>
  394. <Button size="small" type="primary"
  395. onClick={() => {
  396. handleClickAddCase();
  397. }}>
  398. <PlusOutlined className={styles.addIcon} />
  399. 用例
  400. </Button>
  401. </div>
  402. <div className={styles.testCaseList}>
  403. {testCaseList && testCaseList.length ? testCaseList.map((item) => {
  404. return (
  405. <div
  406. className={`${styles.testCaseItem} ${currentTestCaseRef.current.id === item.id ? styles.activeCase : ''}`}
  407. key={item.id}
  408. onClick={() => {
  409. handleClickTestCase(item);
  410. }}>
  411. <Row gutter={10}>
  412. <Col span={6}>
  413. {<span
  414. className={`${styles.testCaseItemNo} ${styles.testCaseItemTitle}`}>{`编号.${((item.id).substring((item.id.length) - 6)).toUpperCase()}`}</span>}
  415. </Col>
  416. <Col span={15} className={styles.testCaseItemTitle}>
  417. <Tooltip title={item.name}>
  418. {item.name}
  419. </Tooltip>
  420. </Col>
  421. <Col span={3}>
  422. <EditOutlined className={styles.editTestBug}
  423. onClick={() => handleEditTestCase(item)} />
  424. </Col>
  425. </Row>
  426. </div>);
  427. }) : <div>快来创建你的第一个测试用例吧~</div>}
  428. </div>
  429. </Col>
  430. <Col span={16}>
  431. <div gutter={10} className={styles.testBugTitle}>
  432. <h3>缺陷列表</h3>
  433. <div>
  434. <Button size="small" type="primary"
  435. disabled={JSON.stringify(currentTestCaseRef.current) === '{}'}
  436. onClick={() => handleClickAddBug()}>
  437. <PlusOutlined className={styles.addIcon} />
  438. 缺陷
  439. </Button>
  440. {
  441. collaborative_type === '0' ?
  442. <Button size="small"
  443. className={styles.recommendBtn}
  444. disabled={JSON.stringify(currentTestCaseRef.current) === '{}'}
  445. onClick={() => handleClickRecommendBtn()}>
  446. <ShareAltOutlined className={styles.addIcon}/>
  447. 推荐
  448. </Button> : null
  449. }
  450. </div>
  451. </div>
  452. <div className={styles.testBugList}>
  453. {bugList && bugList.length ? bugList.map((item) => {
  454. return (
  455. <div className={styles.testBugItem} key={item.id}>
  456. <Row gutter={10}>
  457. <Col span={12}>
  458. <div>
  459. <div className={styles.testBugItemTitleBlock}>
  460. <Tooltip title={item.title}>
  461. <span className={styles.testBugItemTitleDetail}>标题:{item.title}</span>
  462. </Tooltip>
  463. </div>
  464. <div className={styles.testBugItemTitleBlock}>
  465. <span className={styles.testBugItemTitle}>特征:</span>
  466. <Tag color="cyan">{recurrent[item.recurrent - 1]}</Tag>
  467. <Tag color="red">{severity[item.severity - 1]}</Tag>
  468. <Tag color="geekblue">{item.bug_category}</Tag>
  469. </div>
  470. <div className={styles.testBugItemTitleBlock}>
  471. <span className={styles.testBugItemTitle}>标识:</span>
  472. {item.id}
  473. </div>
  474. <div className={styles.testBugItemTitleBlock}>
  475. <span className={styles.testBugItemTitle}>路径:</span>
  476. {item.bug_page}
  477. </div>
  478. <div className={styles.testBugItemTitleBlock}>
  479. <Tooltip title={item.description}>
  480. <span className={styles.testBugItemDesc}>描述:{item.description}</span>
  481. </Tooltip>
  482. </div>
  483. </div>
  484. </Col>
  485. {
  486. item.img_url ? (
  487. <Col span={12} className={styles.bugImgList}>
  488. {item.left > 0 ? <LeftOutlined
  489. onClick={() => {
  490. handleChangeImgToLeft(item);
  491. }} /> : <div className={styles.switchImgBtn}></div>}
  492. {item.imgArr.map(img => {
  493. return <Image src={img} key={img} />;
  494. })}
  495. {item.right < (item.originArr.length - 1) ? <RightOutlined onClick={() => {
  496. handleChangeImgToRight(item);
  497. }} /> : <div className={styles.switchImgBtn}></div>}
  498. </Col>)
  499. : null}
  500. </Row>
  501. </div>
  502. );
  503. }) : <div>当前用例暂无提交记录,快去创建第一个BUG吧~</div>}
  504. </div>
  505. </Col>
  506. </Row>
  507. </div>
  508. </Card>
  509. <Modal title={isAddCaseStatus ? '添加测试用例' : '编辑测试用例'} width={720}
  510. visible={showAddTestCaseModal}
  511. forceRender={true}
  512. className="addModal"
  513. footer={[
  514. <Button key='submit' type="primary" htmlType="submit" onClick={handleAddOrEditTestCase}>确定</Button>,
  515. <Button key='cancel' htmlType="button" style={{ marginLeft: '10px' }}
  516. onClick={() => {
  517. setAddTestCaseModal(false);
  518. }}>取消</Button>]}
  519. onCancel={() => {
  520. setAddTestCaseModal(false);
  521. }}
  522. >
  523. <ExclamationCircleFilled className={styles.addModalInfo} />为了评分准确,请勿提交重复测试用例
  524. <Form
  525. {...modalFormItemLayout}
  526. form={addCaseForm}
  527. layout="horizontal"
  528. className={styles.stepForm}
  529. >
  530. <Form.Item
  531. label="用例名称"
  532. name="name"
  533. rules={[
  534. {
  535. required: true,
  536. message: '请输入用例名称!',
  537. },
  538. ]}
  539. >
  540. <Input />
  541. </Form.Item>
  542. <Form.Item
  543. label="前置条件"
  544. name="front"
  545. rules={[
  546. {
  547. required: true,
  548. message: '请输入前置条件!',
  549. },
  550. ]}
  551. >
  552. <Input.TextArea autoSize={{ minRows: 3, maxRows: 999 }} />
  553. </Form.Item>
  554. <Form.Item
  555. label="测试步骤"
  556. name="behind"
  557. rules={[
  558. {
  559. required: true,
  560. message: '请输入测试步骤!',
  561. },
  562. ]}
  563. >
  564. <Input.TextArea autoSize={{ minRows: 3, maxRows: 999 }} />
  565. </Form.Item>
  566. <Form.Item
  567. label="预期结果"
  568. name="description"
  569. rules={[
  570. {
  571. required: true,
  572. message: '请输入预期结果!',
  573. },
  574. ]}
  575. >
  576. <Input.TextArea autoSize={{ minRows: 3, maxRows: 999 }} />
  577. </Form.Item>
  578. </Form>
  579. </Modal>
  580. <Modal visible={showAddBugModal} width={720}
  581. forceRender={true}
  582. title={[
  583. <span className={styles.modalTitle} key="title">添加用例缺陷</span>,
  584. <Search
  585. placeholder="输入Bug标识进行fork"
  586. allowClear
  587. enterButton="fork"
  588. onSearch={searchBugToFork}
  589. className={styles.forkBtn}
  590. key="search"
  591. ref={forkInput}
  592. />
  593. ]}
  594. footer={[
  595. <Button key='submit' type="primary" htmlType="submit" onClick={handleAddBug}>确定</Button>,
  596. <Button key='cancel' htmlType="button" style={{ marginLeft: '10px' }}
  597. onClick={() => {
  598. setAddTestBugModal(false);
  599. forkInput.current.state.value = '';
  600. }}>取消</Button>]}s
  601. onCancel={() => {
  602. setAddTestBugModal(false);
  603. }}
  604. className={styles.bugForm}
  605. >
  606. <ExclamationCircleFilled className={styles.addModalInfo} />为了评分准确,请勿提交重复缺陷Bug
  607. <Form
  608. form={addBugForm}
  609. {...modalFormItemLayout}
  610. layout="horizontal"
  611. className={styles.stepForm}
  612. >
  613. <Form.Item
  614. label="缺陷标题"
  615. name="title"
  616. rules={[
  617. {
  618. required: true,
  619. message: '请输入测试标题!',
  620. },
  621. ]}
  622. >
  623. <Input.TextArea autoSize={{ minRows: 1, maxRows: 999 }} />
  624. </Form.Item>
  625. <Form.Item
  626. label="缺陷描述"
  627. name="description"
  628. rules={[
  629. {
  630. required: true,
  631. message: '请输入题目描述!',
  632. },
  633. ]}
  634. >
  635. <Input.TextArea autoSize={{ minRows: 2, maxRows: 999 }} />
  636. </Form.Item>
  637. <Form.Item
  638. label="三级页面"
  639. required={true}
  640. >
  641. <Row gutter={5} className={styles.pageSelect}>
  642. <Col span={8}>
  643. <Form.Item
  644. name="page1"
  645. rules={[
  646. {
  647. required: true,
  648. message: '请输入一级页面',
  649. },
  650. ]}
  651. >
  652. <Select value={addBugForm.getFieldValue('page1')} onSelect={(val) => {
  653. handleSelectPage1(val);
  654. }}>
  655. {categories.map((item) => {
  656. return <Select.Option value={item.item} key={item.item}>{item.item}
  657. </Select.Option>;
  658. })}
  659. </Select>
  660. </Form.Item>
  661. </Col>
  662. <Col span={8}>
  663. <Form.Item
  664. name="page2"
  665. rules={[
  666. {
  667. required: true,
  668. message: '请输入二级页面',
  669. },
  670. ]}
  671. >
  672. <Select value={addBugForm.getFieldValue('page2')}
  673. disabled={!page2List.length&& !addBugForm.getFieldValue('page2')}
  674. onSelect={(val) => {
  675. handleSelectPage2(val);
  676. }}>
  677. {page2List.map((item) => {
  678. return <Select.Option value={item.item} key={item.item}>{item.item}</Select.Option>;
  679. })}
  680. </Select>
  681. </Form.Item>
  682. </Col>
  683. <Col span={8}>
  684. <Form.Item
  685. name="page3"
  686. rules={[
  687. {
  688. required: true,
  689. message: '请输入三级页面',
  690. },
  691. ]}
  692. >
  693. <Select value={addBugForm.getFieldValue('page3')} disabled={!page3List.length&& !addBugForm.getFieldValue('page3')}>
  694. {page3List.map((item) => {
  695. return <Select.Option value={item.item} key={item.item}>{item.item}</Select.Option>;
  696. })}
  697. </Select>
  698. </Form.Item>
  699. </Col>
  700. </Row>
  701. </Form.Item>
  702. <Form.Item
  703. label="漏洞分类"
  704. name="bug_category"
  705. rules={[
  706. {
  707. required: true,
  708. message: '请选择漏洞分类!',
  709. },
  710. ]}
  711. >
  712. <Select>
  713. {bug_categories.map((item) => {
  714. return <Select.Option value={item} key={item}>{item}</Select.Option>;
  715. })}
  716. </Select>
  717. </Form.Item>
  718. <Form.Item
  719. label="严重等级"
  720. name="severity"
  721. rules={[
  722. {
  723. required: true,
  724. message: '请选择严重等级!',
  725. },
  726. ]}
  727. >
  728. <Select>
  729. {severity.map((item) => {
  730. return <Select.Option value={item} key={item}>{item}</Select.Option>;
  731. })}
  732. </Select>
  733. </Form.Item>
  734. <Form.Item
  735. label="复现程度"
  736. name="recurrent"
  737. rules={[
  738. {
  739. required: true,
  740. message: '请选择复现程度!',
  741. },
  742. ]}
  743. >
  744. <Select>
  745. {recurrent.map((item) => {
  746. return <Select.Option value={item} key={item}>{item}</Select.Option>;
  747. })}
  748. </Select>
  749. </Form.Item>
  750. <Form.Item
  751. label="上传截图"
  752. name="testName"
  753. >
  754. <Upload
  755. action='/Bug/api/upload/image'
  756. data={file => ({ // data里存放的是接口的请求参数
  757. file,
  758. caseId: currentTestCaseRef.current.id,
  759. work_id: '2',
  760. })}
  761. listType="picture-card"
  762. fileList={fileList}
  763. onPreview={handlePreview}
  764. onChange={handleChange}
  765. >
  766. {uploadButton}
  767. </Upload>
  768. <Modal
  769. visible={previewVisible}
  770. title={previewTitle}
  771. footer={null}
  772. onCancel={() => handleCancel()}
  773. >
  774. <img alt="example" style={{ width: '100%' }} src={previewImage} />
  775. </Modal>
  776. </Form.Item>
  777. </Form>
  778. </Modal>
  779. <Modal title="修改报告基础信息" visible={showEditReportModal}
  780. footer={[
  781. <Button key='submit' type="primary" htmlType="submit"
  782. onClick={handleEditReportInfo}>确定</Button>,
  783. <Button key='cancel' htmlType="button" style={{ marginLeft: '10px' }}
  784. onClick={() => {
  785. setEditReportModal(false);
  786. }}>取消</Button>]}
  787. onCancel={() => {
  788. setEditReportModal(false);
  789. }}>
  790. <div>
  791. <Form
  792. {...modalFormItemLayout}
  793. form={editReportForm}
  794. layout="horizontal"
  795. initialValues={reportCommonInfo}
  796. >
  797. <Form.Item label="报告名称" name="name" rules={[{ required: true, message: '请输入报告名称' }]}>
  798. <Input placeholder="请输入报告名称" />
  799. </Form.Item>
  800. <Form.Item label="设备名称" name="device_model" rules={[{ required: true, message: '请输入设备品牌' }]}>
  801. <Input placeholder="请输入设备名称" />
  802. </Form.Item>
  803. <Form.Item label="设备品牌" name="device_brand" rules={[{ required: true, message: '请输入设备品牌' }]}>
  804. <Input placeholder="请输入设备品牌" />
  805. </Form.Item>
  806. <Form.Item label="操作系统" name="device_os" rules={[{ required: true, message: '请输入操作系统' }]}>
  807. <Select placeholder="请选择操作系统">
  808. {osType.map((option) => {
  809. return <Select.Option value={option} key={option}>{option}</Select.Option>;
  810. })}
  811. </Select>
  812. </Form.Item>
  813. </Form>
  814. </div>
  815. </Modal>
  816. <Modal title="任务推荐"
  817. visible={showTaskRecommendModal}
  818. destroyOnClose width={1000}
  819. onOk={() => setTaskRecommendModal(false)}
  820. onCancel={() => {
  821. setTaskRecommendModal(false);
  822. }
  823. }
  824. className={styles.recommendModal}>
  825. <div>
  826. <BugGuideTree />
  827. </div>
  828. </Modal>
  829. </div>
  830. );
  831. };
  832. export default connect(({ editReport, loading ,report}) => ({
  833. submitting: loading.effects['editReport/submitStepForm'],
  834. reportCommonInfo: editReport.reportCommonInfo,
  835. testCaseList: editReport.testCaseList,
  836. caseBugList: editReport.caseBugList,
  837. categories: editReport.categories,
  838. pathInfo: editReport.pathInfo,
  839. osType: editReport.osType,
  840. commonId: editReport.commonId,
  841. collaborative_type: report.collaborative_type,
  842. }))(Step2);